-
Notifications
You must be signed in to change notification settings - Fork 198
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
k256 disrepency in secp256k1 key recover #988
Comments
More details please? |
Just updated, clicked publish by accident |
Were you expecting an error or for it to recover a key? Does the signature verify? |
It was recovering previously, i switched versions in original post, just run it again: |
The issue appears to be the signature is not low-S normalized, which was previously allowed due to a bug in the signature verification logic. If you try the low-S normalized version of the same signature, it works:
|
Closing as by design |
To clarify, is this low-S as in If the former, ACK. If the latter, I don't believe ECDSA has that requirement and it's an additional canonicity rule added by select systems. I don't see why recovery should globally enforce that rule. I'd ask where this design change was discussed so I can gain better insight into the decision causing it. |
@kayabaNerve it's specifically that Note that this was the behavior of previous versions of It was further highlighted in the NCC audit here: https://research.nccgroup.com/2023/08/30/public-report-entropy-rust-cryptography-review/ |
@tarcieri I see, thank you for the shift response! if we normalize the S I am assuming that we need to flip the |
Yes, see here for an example: https://github.com/RustCrypto/elliptic-curves/blob/5c829a4/k256/src/ecdsa.rs#L193 I'm curious about the provenience of these signatures. I would not expect them to verify in an EVM context. |
Sigs are from tests, so probably they are testing edge cases for EVM precompile contract (ecrecover). |
EVM ecrecover allows non-low-s. It's only a sometimes-used OpenZeppelin library which doesn't (ignoring sporadic custom impls of low-s-checks). |
This k256 version breaks revm, as documented in RustCrypto/elliptic-curves#988, which breaks foundry. While I would instead wait to bump revm, foundry nightly (the only supported version per the provided GH action) is broken and I'd rather correct it ASAP.
* Revert k256 bump This k256 version breaks revm, as documented in RustCrypto/elliptic-curves#988, which breaks foundry. While I would instead wait to bump revm, foundry nightly (the only supported version per the provided GH action) is broken and I'd rather correct it ASAP. * Lock to 0.13.1 in anvil/Cargo.toml
There is disrepency between 0.13.1 and 0.13.2 with a recovery of following signature.
sig:
73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75feeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c454901
msg:
0x18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c
Previously it was throwing error:
Relavnt code path: https://github.com/bluealloy/revm/blob/aa5667764890bc554ea6392ea1e84e3e1991be6d/crates/precompile/src/secp256k1.rs#L20-L24
But in
0.13.2
it is returning:Not related but eth test error is: static_CallEcrecover0_completeReturnValue.json
The text was updated successfully, but these errors were encountered: