We rely on the k256 and ecdsa Rust crypto libraries for signing and hashing. These libraries have a default hash function (digest) based on the curve you are using. We are using the Secp256k1 curve as you can see here:
k256::ecdsa
pub type VerifyingKey = ecdsa_core::VerifyingKey<Secp256k1>
So calling methods on our VerifyingKey will, by default, select a sha2 hash that corresponds to the Secp256k1 curve. This is not what we want. We need messages hashed and verified with keccak256 hash.
The easiest way to implement this seem to use the *_digest variant of the methods.
Task
Change default uses of sha2 to use our digest instead.
Note: The code to compute signature assumes the message has already been hashed. So this does not need to change.
Problem
We rely on the
k256
andecdsa
Rust crypto libraries for signing and hashing. These libraries have a default hash function (digest) based on the curve you are using. We are using theSecp256k1
curve as you can see here:So calling methods on our
VerifyingKey
will, by default, select a sha2 hash that corresponds to theSecp256k1
curve. This is not what we want. We need messages hashed and verified withkeccak256
hash.The easiest way to implement this seem to use the
*_digest
variant of the methods.Task