-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C API for BLS signature
aggregate_verify
& batch_verify
(incl par…
…allel) (#381) * fix up BLS sig `batch_verify` for C API We had a leftover generic and the `messages` were passed not as an openArray as required * [bls] fix `update` for `View` messages The previous code recursed into itself instead of the main `update` above * [bls] fix up batch_verify_parallel C API signature, convert openArray * [lib] build bls_signature_parallel into libconstantine * [C] add C API header for aggregate_verify, batch_verify * [examples] add example for batch_verify C API * [examples] extend README for C API on how to compile (and run) * [C] add C API header for batch_verify_parallel, add to `constantine.h` * [examples] extend example to use parallel batch_verify version * [examples] use clang, fix typo * update naming ByteView -> ctt_span following C++20 naming * [C] fix name of `aggregate_verify` by adding prefix * [example] use `sysrand` to fill secureRandomBytes array
- Loading branch information
Showing
9 changed files
with
216 additions
and
14 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 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
64 changes: 64 additions & 0 deletions
64
include/constantine/protocols/ethereum_bls_signatures_parallel.h
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,64 @@ | ||
/** 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. | ||
*/ | ||
#ifndef __CTT_H_ETHEREUM_BLS_SIGNATURES_PARALLEL__ | ||
#define __CTT_H_ETHEREUM_BLS_SIGNATURES_PARALLEL__ | ||
|
||
#include "constantine/core/datatypes.h" | ||
#include "constantine/core/threadpool.h" | ||
#include "constantine/protocols/ethereum_bls_signatures.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// Ethereum BLS signatures parallel interface | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Verify that all (pubkey, message, signature) triplets are valid | ||
* returns `true` if all signatures are valid, `false` if at least one is invalid. | ||
* | ||
* For message domain separation purpose, the tag is `BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_` | ||
* | ||
* Input: | ||
* - Public keys initialized by one of the key derivation or deserialization procedure. | ||
* Or validated via validate_pubkey | ||
* - Messages as an anonymous struct of `(data = byte*, length = size_t)` pairs | ||
* (the `View` type on the Nim side uses `int` for the length field, which depends on the | ||
* system) | ||
* - Signatures initialized by one of the key derivation or deserialization procedure. | ||
* Or validated via validate_signature | ||
* - `len`: number of elements in `pubkey`, `messages`, `sig` arrays | ||
* | ||
* In particular, the public keys and signature are assumed to be on curve subgroup checked. | ||
* | ||
* To avoid splitting zeros and rogue keys attack: | ||
* 1. Cryptographically-secure random bytes must be provided. | ||
* 2. Augmentation or Proof of possessions must used for each public keys. | ||
* | ||
* The secureRandomBytes will serve as input not under the attacker control to foil potential splitting zeros inputs. | ||
* The scheme assumes that the attacker cannot | ||
* resubmit 2^64 times forged (publickey, message, signature) triplets | ||
* against the same `secureRandomBytes` | ||
*/ | ||
ctt_eth_bls_status ctt_eth_bls_batch_verify_parallel( | ||
const ctt_threadpool* tp, | ||
const ctt_eth_bls_pubkey pubkey[], | ||
const ctt_span messages[], | ||
const ctt_eth_bls_signature sig[], | ||
ptrdiff_t len, | ||
const byte secure_random_bytes[32] | ||
) __attribute__((warn_unused_result)); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // __CTT_H_ETHEREUM_BLS_SIGNATURES_PARALLEL__ |