-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add ECDSA over secp256k1 signatures and verification #490
Merged
+1,123
−91
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
f43a97c
[zoo] add generator for secp256k1
Vindaar 6434eba
[ECDSA] add initial ECDSA signing / verifying implementation
Vindaar e8540b6
[ecdsa] fix imports
Vindaar 41d502d
[ecdsa] export Secp256k1 as `C` for convenience
Vindaar 2760af4
[ecdsa] export `toDER` proc
Vindaar 9f31c38
[ecdsa] use `isZero` instead of old zero comparison
Vindaar 5862d43
[ecdsa] rename private key generator & add private -> public key
Vindaar 4fd34e2
[tests] add test cases for ECDSA signature verification
Vindaar a4ca057
[ecdsa] handle some `.noinit.` cases
Vindaar 22bd57b
[ecdsa] turn `toBytes`, `arrayWith` into in-place procedures
Vindaar 4e17514
[ecdsa] clean up comment about Fp -> Fr conversion
Vindaar 46d8f92
[ecdsa] replace toPemPrivateKey/PublicKey by in-place array variants
Vindaar 7164f07
[ecdsa] replace `toDER` by non allocating variant
Vindaar 890b185
[ecdsa] replace out-of-place arithmetic by in-place
Vindaar 50de116
[ecdsa] move ECDSA implementation to ~signatures~ directory
Vindaar 931044d
[ecdsa] remove dependence on explicit SHA256 hash function
Vindaar fe8a8aa
[ecdsa] make DERSignature generic under curve by having static size
Vindaar bec1536
[ecdsa] turn more procs generic over curve and hash function
Vindaar 34442fa
[ecdsa] replace sign/verify API by one matching BLS signatures
Vindaar 06f7a5f
[ecdsa] remove global curve & generator constants
Vindaar ad16403
[ecdsa] correctly handle truncation of digests > Fr BigInts
Vindaar e9174e6
create file for common signature ops, `derivePubkey` for ECDSA & BLS
Vindaar 4d72a6b
create file specifically for ECDSA over secp256k1
Vindaar a8ecd59
[ecdsa] add `fromDER` to split DER encoded signature back into r, s a…
Vindaar 828189c
[tests] add OpenSSL wrapper intended for test cases
Vindaar 722fa37
[tests] first step towards OpenSSL tests
Vindaar 64130a1
[tests] fully avoid JSON intermediary files for ECDSA tests
Vindaar e9387e8
[tests] rename file back to test case name, add DERSigSize tests
Vindaar 0d24f6a
[tests] also test our DER encoder
Vindaar 5229551
[tests] extend OpenSSL wrapper for required functionality
Vindaar 1d05da4
[tests] move openssl wrapper to root of tests to share between tests
Vindaar c0b3806
[tests] add test case to verify PEM file writer
Vindaar 87bc887
[ecdsa] clean up and fix PEM file writers
Vindaar 8000567
[tests] [bench] use shared OpenSSL wrapper where appropriate
Vindaar 04ce1c8
[codecs] move serialization logic to ecdsa secp256k1 submodule
Vindaar 0c5195f
[codecs] move DER signature serialization to codecs_ecdsa submodule
Vindaar 89688ba
[ecdsa] adjust ECDSA secp256k1 API & test cases
Vindaar 5011fe3
[ecdsa] add mini docstring for `verify`
Vindaar fa5a5eb
[codecs] clean up imports in `codecs_ecdsa.nim`
Vindaar 2f6a897
[ecdsa] clean up imports of `ecdsa_secp256k1.nim`
Vindaar 2693aec
[ecdsa] do not export `raw` field in ecdsa_secp256k1
Vindaar 1b44a8f
[CI] fix CI failures by including OpenSSL wrapper instead of import
Vindaar c2c39af
[bench] disable OpenSSL bench for sha256 on windows
Vindaar fa9e0ab
[nimble] add ECDSA signature test to nimble task
Vindaar 4cac2ec
[ecdsa] replace brainfart using pointer size for bits in byte
Vindaar 30285ff
[ecdsa] fix final related brainfart :)
Vindaar 901597e
[tests] when the brainfart infects the test cases too! 🤯
Vindaar 6c09fe1
replace DERSig* by DerSig*
Vindaar 0bbc839
replace `toPemFile` by simply `toPem`
Vindaar 20057e0
rename `common_signature_ops` to `ecc_sig_ops`
Vindaar 9642ca6
[tests] disable ECDSA test for Windows
Vindaar 2fd2bb2
[ecdsa] avoid awkward arrayWith declaration & call
Vindaar 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
create file for common signature ops,
derivePubkey
for ECDSA & BLS
Also cleans up the imports of the ECDSA file and adds the copyright header
commit e9174e60a118520158373279174a235349c5df3a
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Constantine | ||
# Copyright (c) 2018-2019 Status Research & Development GmbH | ||
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy | ||
# Licensed and distributed under either of | ||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). | ||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). | ||
# at your option. This file may not be copied, modified, or distributed except according to those terms. | ||
|
||
import | ||
constantine/math/[ec_shortweierstrass], | ||
constantine/named/zoo_generators, | ||
constantine/named/algebras | ||
|
||
func derivePubkey*[Pubkey, SecKey](pubkey: var Pubkey, seckey: SecKey) = | ||
## Generates the public key associated with the input secret key. | ||
## | ||
## The secret key MUST be in range (0, curve order) | ||
## 0 is INVALID | ||
const Group = Pubkey.G | ||
type Field = Pubkey.F | ||
const EC = Field.Name | ||
|
||
var pk {.noInit.}: EC_ShortW_Jac[Field, Group] | ||
pk.setGenerator() | ||
pk.scalarMul(seckey) | ||
pubkey.affine(pk) |
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
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.
I'm pretty sure lattices don't derive public keys the same way ;).
Probably better to rename the file
ecc_sig_ops.nim
or something.