-
Notifications
You must be signed in to change notification settings - Fork 572
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
feat(optimism): Add secp256r1 precompile for Fjord #1436
Conversation
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.
Left few comments
feb8f4c
to
9c04e78
Compare
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.
lgtm!
53a54e2
to
f880ab8
Compare
// Can fail only if the input is not exact length. | ||
let signature = Signature::from_slice(sig).unwrap(); | ||
// Can fail if the input is not valid, so we have to propagate the error. | ||
let public_key = VerifyingKey::from_sec1_bytes(&uncompressed_pk).ok()?; |
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.
Have checked this part of the spec:
Note that many implementations use (0, 0) as the reference point at infinity, which is not on the curve and should therefore be rejected.
I have feed the VerifyingKey::from_sec1_bytes
with pk = [0;64]
and it fails to get key, this is expected behaviour, just wanting to note it.
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.
Thanks, added a test case for this
* feat(optimism): Add secp256r1 precompile for Fjord (bluealloy#1436) * feat(optimism): Add secp256r1 precompile for Fjord * Fix docs * Fix nostd build * Load fjord precompiles via optimism handler register * Remove outdated fjord() precompile spec constructor * Document the secp256r1 feature * Address feedback * Handle invalid signatures * Update crates/precompile/src/secp256r1.rs * Update crates/precompile/src/secp256r1.rs * Blank return on failed signature verification * Add test case for invalid (zero) pubkey --------- Co-authored-by: rakita <rakita@users.noreply.github.com> * feat: add Haber spec to opBNB --------- Co-authored-by: Brian Bland <brian.t.bland@gmail.com> Co-authored-by: rakita <rakita@users.noreply.github.com>
secp256r1::P256VERIFY
precompile from the alphanet implementationP256Verify
to the chain precompiles post-fjord via the Optimism handle registerNote: Introduces new optional dependency on the
p256
crate