Add explict check for points-on-curve in p256_verify bouncycastle implementation#9146
Merged
garyschulte merged 3 commits intobesu-eth:mainfrom Sep 10, 2025
Conversation
bshastry
reviewed
Sep 3, 2025
evm/src/main/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContract.java
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContract.java
Show resolved
Hide resolved
evm/src/test/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContractTest.java
Outdated
Show resolved
Hide resolved
evm/src/test/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContractTest.java
Outdated
Show resolved
Hide resolved
7650604 to
0062cec
Compare
macfarla
reviewed
Sep 7, 2025
evm/src/test/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContractTest.java
Show resolved
Hide resolved
8338d90 to
6d606c7
Compare
daniellehrner
approved these changes
Sep 10, 2025
evm/src/main/java/org/hyperledger/besu/evm/precompile/P256VerifyPrecompiledContract.java
Show resolved
Hide resolved
…-castle implementation of p256Verify Signed-off-by: garyschulte <garyschulte@gmail.com>
…thm cases for public key not on curve. Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
6d606c7 to
c0786bf
Compare
georgereuben
pushed a commit
to georgereuben/besu
that referenced
this pull request
Sep 16, 2025
…lementation (besu-eth#9146) * add explict check and test coverage for points-on-curve in the bouncy-castle implementation of p256Verify * update tests for r' exceeding N and exercising native SignatureAlgorithm cases for public key not on curve. Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: georgereuben <reubengeorge101@gmail.com>
jflo
pushed a commit
to jflo/besu
that referenced
this pull request
Oct 13, 2025
…lementation (besu-eth#9146) * add explict check and test coverage for points-on-curve in the bouncy-castle implementation of p256Verify * update tests for r' exceeding N and exercising native SignatureAlgorithm cases for public key not on curve. Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: jflo <justin+github@florentine.us>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR description
Address case where the pure java p256Verify implementation was not explicitly checking the public-key input is on-curve prior to verifying the signature. This code path is not part of mainnet ethereum, but some specific configurations of besu on a dev net could have triggered this exception:
Which would have caused these specifically configured instances of besu to
refuse to import or create a block with such an invalid public keyrely on exceptional logic to attribute the precompile result as invalid, rather than proactively checking the public key is valid.Thx @0xMushow for probing about point-validity in the besu implementation of eip-7951.
Fixed Issue(s)
adds point-on-curve check in the pure java bouncy castle implementation, and adds unit tests to assert the behavior across pure java and native implementation.
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests