tellor-io / layer

tellor chain - a cosmos sdk chain for reporting and validating arbitrary data
https://www.tellor.io
8 stars 3 forks source link

Cosmos signature matching for hardhat tests #163

Closed themandalore closed 1 month ago

themandalore commented 1 month ago

Maybe this: https://hackmd.io/@0xGhastly/H1GlUwiZh

tkernell commented 1 month ago

And to document the issue, we have a problem with manual hardhat testing of the bridge functionality. On the cosmos side, we use keyring.Sign method for signing bridge messages. This method automatically sha256 hashes a message before signing. On the ethereum side, the ethers.js/web3.js signing methods tend to sign with sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))). This has created a mismatch when running manual bridge tests.

tkernell commented 1 month ago

Here is another possible method to try:

https://github.com/pubkey/eth-crypto?tab=readme-ov-file#sign

tkernell commented 1 month ago

or this, used by ethers.js:

https://www.npmjs.com/package/elliptic

tkernell commented 1 month ago

I found a solution in old ethers.js, and this is fixed in the tests. Closing this issue