-
Notifications
You must be signed in to change notification settings - Fork 488
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
EIP7212 / PIP27 #1069
Merged
Merged
EIP7212 / PIP27 #1069
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9956fdf
crypto/secp2561r1: add secp256r1 curve verifiers
ulerdogan cdb9609
core/vm: implement secp256r1 verifier precompiled
ulerdogan 56f1933
params: add new precompiled gas price
ulerdogan ae2d3da
core/vm, params: rename precompiled to p256verify
ulerdogan 83a20d3
core/vm: simplify the return values format
ulerdogan fc057aa
crypto/secp25r1: fix reverse malleability issue
ulerdogan 40e6de0
core/vm: fix testdata non-malleable for p256Verify
ulerdogan b5559e3
core/vm: update the eip number
ulerdogan 0d115db
core, crypto/secp256r1: fix error reverts tx error
ulerdogan d64d8e7
crypto/secp256r1: refactor by simplfying return
ulerdogan 2bbf30f
core/vm: force the input length of p256verify
ulerdogan ab2f20e
crypto/secp256r1: reject the reference pubKey coordinates
ulerdogan 738107b
crypto/secp256r1: remove malleability check due to spec
ulerdogan 05a19f2
fix test, add napoli block
anshalshukla a0b925b
merge develop
anshalshukla 1e5211c
add test cases
anshalshukla 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
There are no files selected for viewing
This file contains 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[ | ||
{ | ||
"Input": "4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4da73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac36dbcd03009df8c59286b162af3bd7fcc0450c9aa81be5d10d312af6c66b1d604aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff37618b065f9832de4ca6ca971a7a1adc826d0f7c00181a5fb2ddf79ae00b4e10e", | ||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001", | ||
"Gas": 3450, | ||
"Name": "CallP256Verify", | ||
"NoBenchmark": false | ||
}, | ||
{ | ||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9414de3726ee4d237b410c1d85ebcb05553dc578561d9f7942b7250795beb9b9027b657067322fc00ab35263fde0acabf998cd9fcf1282df9555f85dba7bdbbe2dc90f74c9e210bc3e0c60aeaa03729c9e6acde4a048ee58fd2e466c1e7b0374e606b8c22ad2985df7d792ff344f03ce94a079da801006b13640bc5af7932a7b9", | ||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001", | ||
"Gas": 3450, | ||
"Name": "CallP256Verify", | ||
"NoBenchmark": false | ||
}, | ||
{ | ||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9b35d6a4f7f6fc5620c97d4287696f5174b3d37fa537b74b5fc26997ba79c725d62fe5e5fe6da76eec924e822c5ef853ede6c17069a9e9133a38f87d61599f68e7d5f3c812a255436846ee84a262b79ec4d0783afccf2433deabdca9ecf62bef5ff24e90988c7f139d378549c3a8bc6c94e6a1c911c1e02e6f48ed65aaf3d296e", | ||
"Expected": "0000000000000000000000000000000000000000000000000000000000000001", | ||
"Gas": 3450, | ||
"Name": "CallP256Verify", | ||
"NoBenchmark": false | ||
}, | ||
{ | ||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9c29c3df6ce3431b6f030b1b68b1589508ad9d1a149830489c638653aa4b08af93f6e86a9a7643403b6f5c593410d9f7234a8cd27309bce90447073ce17476850615ff147863bc8652be1e369444f90bbc5f9df05a26362e609f73ab1f1839fe3cd34fd2ae672c110671d49115825fc56b5148321aabe5ba39f2b46f71149cff9", | ||
"Expected": "", | ||
"Gas": 3450, | ||
"Name": "CallP256Verify", | ||
"NoBenchmark": false | ||
}, | ||
{ | ||
"Input": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9", | ||
"Expected": "", | ||
"Gas": 3450, | ||
"Name": "CallP256Verify", | ||
"NoBenchmark": false | ||
} | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package secp256r1 | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
"crypto/elliptic" | ||
"math/big" | ||
) | ||
|
||
// Generates approptiate public key format from given coordinates | ||
func newPublicKey(x, y *big.Int) *ecdsa.PublicKey { | ||
// Check if the given coordinates are valid | ||
if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) { | ||
return nil | ||
} | ||
|
||
// Check if the given coordinates are the reference point (infinity) | ||
if x.Sign() == 0 && y.Sign() == 0 { | ||
return nil | ||
} | ||
|
||
return &ecdsa.PublicKey{ | ||
Curve: elliptic.P256(), | ||
X: x, | ||
Y: y, | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package secp256r1 | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
"math/big" | ||
) | ||
|
||
// Verifies the given signature (r, s) for the given hash and public key (x, y). | ||
func Verify(hash []byte, r, s, x, y *big.Int) bool { | ||
// Create the public key format | ||
publicKey := newPublicKey(x, y) | ||
|
||
// Check if they are invalid public key coordinates | ||
if publicKey == nil { | ||
return false | ||
} | ||
|
||
// Verify the signature with the public key, | ||
// then return true if it's valid, false otherwise | ||
return ecdsa.Verify(publicKey, hash, r, s) | ||
} |
This file contains 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 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
Oops, something went wrong.
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.
kzgPointEvaluation
should probably not be here because it's part of EIP-4844 and EIP-4844 was excluded from the Napoli hardfork.