-
Notifications
You must be signed in to change notification settings - Fork 70
Add secp256k1 verify and pubKey recovery function #583
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
Open
heliuchuan
wants to merge
13
commits into
main
Choose a base branch
from
addsecpverify
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+331
−4
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
72b8470
Add secp256k1 verify and pubKey recovery function
heliuchuan 1b78a57
update CL
heliuchuan 06eb4d9
add docstring
heliuchuan 5352d99
add docstring
heliuchuan 86f7da1
update
heliuchuan 54e8857
update
heliuchuan 1ba4cbd
fix cycle
heliuchuan 9143ef1
add whitespace
heliuchuan 3cb75c3
run fmt
heliuchuan 21ee3c2
change bcsBytes to toUint8Array
heliuchuan a9c0320
address comments
heliuchuan 130dff2
use anypubkey static func
heliuchuan 88c9d23
fix lint
heliuchuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add secp256k1 verify and pubKey recovery function
commit 72b8470b9332ba454e328d2b0c6b446e769c760e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we accept
AnySignature
if we only verify forSecp256k1Account
? why isSecp256k1Signature
is not part ofAnySignature
? Also, why do we acceptHexInput
as a signature? dont we want to make sure the function accepts a valid signature?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, public key recovery should be in the signature to return. I don't think it belongs at the account level given you can't recover the private key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Secp256k1Account does not exist. SingleKeyAccount exists which returns AnySignature when it signs something. You can get the inner Secp256k1Signature via signature.signature, but you would still have to type check it into Secp256k1Signature. Having the function handle it seems better DevX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gregnazario not sure what you are suggesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and HexInput is again for convenience. The function will check signature validity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also would expect this function to be in a different place than
Account
.I think
Secp256k1PublicKey.fromMessageAndSignature
makes total sense (fromSignedMessage
could be even more concise).Ideally that's all the devs would need, and they could do the following:
now.. how can we make this even easier / more concise?
Secp256k1PublicKey
toAnyPublicKey
is a bit annoying, maybe we can have the constructor there instead:AnyPublicKey.fromSecp256k1SignedMessage({ message, signature })
verifyAuthenticationKey({ authKey, accountAddress })
which could live in theapi
to avoid dependency cyclesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really hate the
AnyPublicKey
name ughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the problem is you need to look up the auth key with the address, and only via the auth key can you figure out which public key is correct. If a recovery is provided 2 public keys would be returned.
I'm down for AnyPublicKey.fromSecp256k1SignedMessage({ message, signature }) though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I re-evaluated it and did similar here aptos-labs/aptos-go-sdk#108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, gotcha makes sense