I'm trying to add ECDSA signature verification to my contract.
However, using the example ECDSA from 3 years ago doesn't seem to work anymore. There are tons of errors I'm getting but this is one of the errors:
error: too many arguments to function call, expected 2, have 5 auto n = eosio::recover_key(&digest, (char *)&sig, sizeof(sig), pub, 34);
I checked the API and it does say that there should be 5 parameters but the compiler seems to be only expecting 2. Any suggestions?
My contract code (referenced):
`///@abi action
void ecrecover(std::string data, const signature &sig)
{
std::string tmp;
checksum256 digest;
sha256(&data[0], data.size(), &digest);
char pub[34]; // public key without checksum
auto n = recover_key(&digest, (char *)&sig, sizeof(sig), pub, 34);
assert(n == 34);
std::string pubhex = to_hex(pub, sizeof(pub)).substr(2); // remove leading '00'
tmp = hex_to_string(pubhex.c_str());
strcpy(pub, tmp.c_str());
checksum160 chksm;
ripemd160(pub, 33, &chksm);
tmp = hex_to_string(pubhex + to_hex(&chksm, 20).substr(0,8)); // append checksum
unsigned char encoded[37 * 137 / 100];
base58encode(tmp, 37, encoded);
tmp = "EOS" + std::string(reinterpret_cast<char*>(encoded));
assert(tmp.length() == 53);
print(tmp);
}
///@abi action
void ecverify(std::string data, const signature &sig, const public_key &pk)
{
checksum256 digest;
sha256(&data[0], data.size(), &digest);
assert_recover_key(&digest, (const char *)&sig, sizeof(sig), (const char *)&pk, sizeof(pk));
print("VALID");
}`