Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pallet-cosmwasm::crypto::do_secp256k1_verify() fails for signatures with recovery ID 1 #4500

Closed
conr2d opened this issue Jul 13, 2024 · 3 comments
Labels

Comments

@conr2d
Copy link

conr2d commented Jul 13, 2024

Description

The current implementation of do_secp256k1_verify() adds a dummy byte 0x00 to the end of the secp256k1 signature to convert a 64-byte signature to a 65-byte Substrate ECDSA signature.

For verifying a secp256k1 signature, the recovery ID is not needed when the public key is known. However, sp_io::crypto::ecdsa_verify_prehashed() internally recovers a public key from the signature, so it doesn't work as expected.

conr2d@49efc1a

In the attached example, the newly added test secp256k1_recover_pubkey_recovers() shows the given signature is valid, but it causes secp256k1_verify_verifies() to fail.

Possible Solutions

  • Submit a PR to polkadot-sdk to change the behavior of sp_io::crypto::ecdsa_verify_prehashed().
  • Add a new host function for secp256k1 signature verification.

If you would like, I can submit a pull request to resolve this issue.

@conr2d
Copy link
Author

conr2d commented Aug 2, 2024

This issue is related to paritytech/polkadot-sdk#5217.

Copy link

github-actions bot commented Sep 4, 2024

stale-issue

@github-actions github-actions bot added the Stale label Sep 4, 2024
Copy link

github-actions bot commented Sep 8, 2024

close-issue

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant