Skip to content

Add secp256k1_recover_pubkey API #765

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

Closed
webmaster128 opened this issue Feb 4, 2021 · 1 comment · Fixed by #790
Closed

Add secp256k1_recover_pubkey API #765

webmaster128 opened this issue Feb 4, 2021 · 1 comment · Fixed by #790

Comments

@webmaster128
Copy link
Member

webmaster128 commented Feb 4, 2021

ECDSA used with secp256k1 has an algorithm for recovering the public key of a signer from the message and the signature. This is important for systems like Ethereum, where public keys are not necessarily available directly.

We want an API call from the contract into the host as follows:

Name: secp256k1_recover_pubkey

Inputs:

  1. message_hash: [u8; 32] the same as in verify
  2. signature in the same format as verify
  3. v: u8 recovery parameter must be one of 0, 1, 2, 3. This is part of signatures in Ethereum (r, s, v) but not Cosmos (r, s)

Output: The public key in the format expected by verify.

Other APIs that implement the same functionality for inspiration:

Test vectors:


For Ethereum signatures the verification flow is the following:

  1. pubkey = secp256k1_recover_pubkey(message_hash, signature, v)
  2. secp256k1_verify(message_hash, signature, pubkey)

which later can be wrapped contract side to a combined verification call if desired.

@ethanfrey
Copy link
Member

Nice design, I agree with can replace #753

@mergify mergify bot closed this as completed in #790 Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants