web-examples icon indicating copy to clipboard operation
web-examples copied to clipboard

bug: Cosmos signDirect signature validation fails

Open amiryadid-fb opened this issue 2 years ago • 0 comments

Summary: When calling signDirect action after connecting to CosmosHub, the example fails to validate the signature returned due to checking the wrong field.

Description: According to WalletConnect Cosmos RPC reference after signing the payload, the response should have a signature property containing both a pub_key property and an additional signature field which contains the actual signature string that should be validated. When returning such response the example dApp tries to validate the signature returned and fails to do so, throwing a match is not a function error, which originates from cosmjs function fromBase64 used internally during the verification process.

image

From further inspection I believe this error is a result of trying to verify the initial signature field (containing the pub_key & signature object) instead of the actual signature string sent inside it (as match is a method on String type).

image

Steps to reproduce:

  1. When connecting, choose 'Cosmos Hub'
  2. Click cosmos_signDirect
  3. Sign the message in the wallet

Expected Result: The signature will be verified with no errors thrown in the console.

Actual Result: The verification fails instantly and a match is not a function error is thrown in the console tab

amiryadid-fb avatar Aug 08 '23 11:08 amiryadid-fb