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

Provide Utility for Verifying Signatures #611

Closed
keefertaylor opened this issue Feb 11, 2021 · 4 comments · Fixed by #1133
Closed

Provide Utility for Verifying Signatures #611

keefertaylor opened this issue Feb 11, 2021 · 4 comments · Fixed by #1133
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@keefertaylor
Copy link

It would be useful to have an API that could verify signatures of payloads. Specifically, it would take:

  1. A message
  2. A public key (edpk...)
  3. A signature (edsig...)

And would return a boolean indicating if the signature matches.

As a bonus, it could also support tz2/tz3 signature schemes (sppk/spsig, p2pk,p2sig, IIRC)

@Innkst Innkst added this to the v8.1 milestone Mar 3, 2021
@Innkst Innkst added the enhancement New feature or request label Mar 4, 2021
@Innkst Innkst modified the milestones: v8.1, v8.2 Mar 16, 2021
@jevonearth
Copy link
Collaborator

We have an implementation of verify here: https://github.com/ecadlabs/taquito/blob/master/packages/taquito-remote-signer/src/taquito-remote-signer.ts#L155

We will extract this, and probably promote this to a new API in the @taquito/utils package.

@tolmekian1453
Copy link

tolmekian1453 commented Oct 28, 2021

Here's a self-contained sig validation JS gist based on the above, meant for letting users prove that they own a wallet address. It ensures the public key matches the wallet address, though you could just ask for the public key alone. I also threw in validateSignature in the beginning to pre-screen malformed sigs: https://gist.github.com/tolmekian1453/9f5ac6648a1468efdf1fc159c1ed4e18

Alternatively, is there any way to get the public key of an address you don't control? It's not easy for end users to get their public key because, for some reason, Temple wallet doesn't display it anywhere. Easiest way I know of is using Beacon's built-in code editor at https://docs.walletbeacon.io/guides/sign-payload and adding in console.log("pubKey", (await dAppClient.getActiveAccount()).publicKey). I know you can't reverse the hash, but I'm just wondering if the blockchain stores the public keys somewhere.

@gwendall
Copy link

gwendall commented Oct 28, 2021

Utilities around verifying ownership of an address are necessary indeed. Thanks for the gist @tolmekian1453. Would you mind sharing how you built your signature? I am trying to implement a "login with wallet" mechanism but fail to validate the signature - I get a Failed to validate signature Error: outlen must be at least 16, was given undefined error.

Here is a gist of how I generate my signature, which is based on the taquito docs on signature (https://tezostaquito.io/docs/signing/#generating-a-signature-with-beacon-sdk).

https://gist.github.com/gwendall/f1434318986bda590ddac7962d21ba19

I then pass it to my server, re-create the bytes from the user nonce and use your verify function. Any idea what I'm doing wrong ?

@gwendall
Copy link

gwendall commented Nov 3, 2021

@tolmekian1453 @jevonearth Here is a small repro, any idea what I'm doing wrong ?

https://github.com/gwendall/sign-test

roxaneletourneau added a commit that referenced this issue Nov 9, 2021
* Provide Utility for Verifying Signatures #611
@ac10n ac10n moved this to Done in Taquito Dev Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants