-
Notifications
You must be signed in to change notification settings - Fork 136
secp256r1 precompile #3382
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
Merged
Merged
secp256r1 precompile #3382
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e171145
secp256r1 impl
advaita-saha 0cae682
remove unwanted stuff
advaita-saha ab95690
fix double hashing
advaita-saha d481c60
remove commented code
advaita-saha b88979f
add complete test suite
advaita-saha bb1bfad
improve performance
advaita-saha cf05a0d
Merge branch 'master' into eip-7951
advaita-saha e4fd912
fix gas calculation
advaita-saha 8a3970b
fix unwanted ECC Points
advaita-saha abee849
few more fixes
advaita-saha 70e0955
fix weird EIP, no error but consume gas
advaita-saha a738006
Merge branch 'master' into eip-7951
advaita-saha 32ababd
cleanup
advaita-saha d7bdac1
some more unwanted code cleanup
advaita-saha 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Nimbus | ||
# Copyright (c) 2018-2025 Status Research & Development GmbH | ||
# Licensed under either of | ||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or | ||
# http://www.apache.org/licenses/LICENSE-2.0) | ||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or | ||
# http://opensource.org/licenses/MIT) | ||
# at your option. This file may not be copied, modified, or distributed except | ||
# according to those terms. | ||
|
||
import | ||
libp2p/crypto/ecnist, | ||
bearssl/[ec, hash] | ||
|
||
proc isInfinityByte*(data: openArray[byte]): bool = | ||
## Check if all values in ``data`` are zero. | ||
for b in data: | ||
if b != 0: | ||
return false | ||
return true | ||
|
||
proc verifyRaw*[T: byte | char]( | ||
sig: EcSignature, message: openArray[T], pubkey: ecnist.EcPublicKey | ||
): bool {.inline.} = | ||
## Verify ECDSA signature ``sig`` using public key ``pubkey`` and data | ||
## ``message``. | ||
## | ||
## Return ``true`` if message verification succeeded, ``false`` if | ||
## verification failed. | ||
doAssert((not isNil(sig)) and (not isNil(pubkey))) | ||
var hc: HashCompatContext | ||
var hash: array[32, byte] | ||
var impl = ecGetDefault() | ||
if pubkey.key.curve in EcSupportedCurvesCint: | ||
let res = ecdsaI31VrfyRaw( | ||
impl, | ||
addr message[0], | ||
uint(len(message)), | ||
unsafeAddr pubkey.key, | ||
addr sig.buffer[0], | ||
uint(len(sig.buffer)), | ||
) | ||
# Clear context with initial value | ||
result = (res == 1) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.