0

so I'm trying to use the recovery_key function linked here: https://developers.eos.io/manuals/eosio.cdt/latest/group__crypto/?query=recover_key&page=1#function-recover_key

Whenever I do use it though, it's always producing a compilation error, I think it's not showing the right API docs for the current version, I'm using eosio.cdt v1.8.0

My code:

    void ecrecover(std::string data, const eosio::signature &sig)
{
    eosio::checksum256 digest;
    eosio::sha256(&data[0], data.size(), &digest);
    uint8_t pub[34];
    auto res = eosio::recover_key(&digest, (char *)&sig, sizeof(sig), (char*)pub, 34);
    printhex(pub, sizeof(pub));
}

Then the error looks like this

/mnt/d/work/eos/contracts/prototypecontract/prototype/prototype.cpp:41:46: error: too many arguments to function call, expected 2, have 3
        eosio::sha256(&data[0], data.size(), &digest);
        ~~~~~~~~~~~~~                        ^~~~~~~
/usr/opt/eosio.cdt/1.8.0/bin/../include/eosiolib/core/eosio/crypto.hpp:287:4: note: 'sha256' declared here
   eosio::checksum256 sha256( const char* data, uint32_t length );
   ^
/mnt/d/work/eos/contracts/prototypecontract/prototype/prototype.cpp:43:62: error: too many arguments to function call, expected 2, have 5
        auto res = eosio::recover_key(&digest, (char *)&sig, sizeof(sig), (char*)pub, 34);
                   ~~~~~~~~~~~~~~~~~~                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/opt/eosio.cdt/1.8.0/bin/../include/eosiolib/core/eosio/crypto.hpp:328:4: note: 'recover_key' declared here
   eosio::public_key recover_key( const eosio::checksum256& digest, const eosio::signature& sig );
   ^
/mnt/d/work/eos/contracts/prototypecontract/prototype/prototype.cpp:44:9: error: use of undeclared identifier 'printhex'; did you mean 'eosio::printhex'?
        printhex(pub, sizeof(pub));
        ^~~~~~~~
        eosio::printhex
/usr/opt/eosio.cdt/1.8.0/bin/../include/eosiolib/contracts/eosio/../../core/eosio/print.hpp:77:16: note: 'eosio::printhex' declared here
   inline void printhex( const void* ptr, uint32_t size) {
               ^
Warning, empty ricardian clause file
Warning, empty ricardian clause file
Warning, action <claim> does not have a ricardian contract
Warning, action <noop> does not have a ricardian contract
3 errors generated.
Error while processing /mnt/d/work/eos/contracts/prototypecontract/prototype/prototype.cpp.
abigen error
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.