3

So I'm trying to find a way to sign a message with a certain private key, and then to be able to recover it's corresponding public key/address on both Ethereum and EOS. The thing is I'm having some trouble understanding how signatures are constructed in EOS. How are EOS's signatures different than Ethereum's other than:

  1. being base58 encoded, rather than a hexadecimal.
  2. being prefixed with 'SIG_K1_'

So far I've tried recovering public keys using Ethereum's ecrecover function, and using this piece of code on EOS:

ACTION DaVerifier::ecverify(std::string data, const capi_signature &sig)
{
    capi_checksum256 digest;
    sha256(&data[0], data.size(), &digest);
    uint8_t pub[34];
    auto res = recover_key(&digest, (char *)&sig, sizeof(sig), (char*)pub, 34);
    printhex(pub, sizeof(pub));
}

Any help?

1 Answer 1

2

In EOS a signature consists of the 'SIG' prefix, follwing the part that defines which curve algorithm was used (R1 or K1), follwing the SHA256 hash encoded with base58.

Take a look at https://github.com/EOSIO/eosjs-ecc, it contains all the neccessary cryptographic functions you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.