-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ready for review - Pending fix of upstream vectors] Update BLS signa…
…ture scheme to draft standard (#36) * Rework the readme * Prepare transitioning to the new IETF API * Delete obsolete README, add Cipher suite ID (BLS_SIG_BLS12381G2-SHA256-SSWU-RO-_NUL_) * Stash BLS keygen implementation * Implement CoreSign, CoreVerify and signature aggregation * Implement CoreAggregateVerify * Implement message signing/verification, proof-of-possession generation/verification, aggregate verification/fast aggregate verification * add aggregate verify. Enforce proper usage of proofs at the API level for signature validation * Implement key pair generator * Move old test vectors, add Eth2 v0.10.0 test vectors * Fix paths for the moved old test suite * Add the spec overload that don't enforce proof-of-possessions usage. Needed for test vectors * Prevent non constant-time comparison of secret-key (and comparison altogether) * Add IO + fix types/API issues * IO: include to allow accessing private fields * Add (failing) signing test vectors * Add hex dumps - the hex dumps are the same! (but comparison fails for unknown reason) * Fix sign test by exporting an `==` proc * Factor out common part of the tests * Properly handle tampered signature in the test vector * Add signature aggregation tests * Add fast aggregate verify test (failing to wrong test - ethereum/consensus-specs#1618) * Switch coreAggregateVerify to a streaming API to accomodate AoS SoA and interleaving proofs of possessions * Add AggregateVerify test for both SoA and AoS API * Comment out internal tests, skip buggy upstream test, add to nimble * don't export init/update * Add yaml testing dependency to CI * Use NimYAML fork (flyx/NimYAML#77) * YAML fix was not fully applied * NimYAML update lost in the rebase/force push * Hopefully fix NimYAML build issues * same NimYAML fix on POSIX
- Loading branch information
Showing
76 changed files
with
1,119 additions
and
214 deletions.
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
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
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
# Nim-BLSCurve | ||
# Copyright (c) 2018 Status Research & Development GmbH | ||
# Licensed under either of | ||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) | ||
# * MIT license ([LICENSE-MIT](LICENSE-MIT)) | ||
# at your option. | ||
# This file may not be copied, modified, or distributed except according to | ||
# those terms. | ||
|
||
# Implementation of IO routines to serialize to and from | ||
# the types defined in | ||
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-00#section-5.5 | ||
# - https://github.com/cfrg/draft-irtf-cfrg-bls-signature | ||
|
||
# This file should be included to have access to private fields | ||
# It is kept separated as it does not fall under the IETF BLS specification | ||
|
||
func fromHex*[T: SecretKey|PublicKey|Signature|ProofOfPossession]( | ||
obj: var T, | ||
hexStr: string | ||
): bool {.inline.} = | ||
## Initialize a BLS signature scheme object from | ||
## its hex raw bytes representation. | ||
## Returns true on asuccess and false otherwise | ||
when obj is SecretKey: | ||
result = obj.intVal.fromHex(hexStr) | ||
else: | ||
result = obj.point.fromHex(hexStr) | ||
|
||
func fromBytes*[T: SecretKey|PublicKey|Signature|ProofOfPossession]( | ||
obj: var T, | ||
raw: openarray[byte] | ||
): bool {.inline.} = | ||
## Initialize a BLS signature scheme object from | ||
## its raw bytes representation. | ||
## Returns true on success and false otherwise | ||
when obj is SecretKey: | ||
result = obj.intVal.fromBytes(hexStr) | ||
else: | ||
result = obj.point.fromBytes(hexStr) | ||
|
||
func toHex*(obj: SecretKey|PublicKey|Signature|ProofOfPossession): string = | ||
## Return the hex representation of a BLS signature scheme object | ||
## Signature and Proof-of-posessions are serialized in compressed form | ||
when obj is SecretKey: | ||
result = obj.intVal.toHex() | ||
else: | ||
result = obj.point.toHex() |
Oops, something went wrong.