-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/warlock-labs/alt-bn128-bls …
…into mike/dkg-tests
- Loading branch information
Showing
19 changed files
with
503 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# sylow | ||
![Logo](./sylow.png) | ||
|
||
[![License](https://img.shields.io/crates/l/sylow)](https://choosealicense.com/licenses/mit/) | ||
[![Crates.io](https://img.shields.io/crates/v/sylow)](https://crates.io/crates/sylow) | ||
[![Docs](https://img.shields.io/crates/v/sylow?color=blue&label=docs)](https://docs.rs/sylow/) | ||
![CI](https://github.com/warlock-labs/sylow/actions/workflows/CI.yml/badge.svg) | ||
|
||
sylow is a Rust library implementing the BLS (Boneh-Lynn-Shacham) signature scheme using the alt-bn128 (BN254) elliptic curve. It provides threshold signing capabilities and associated utilities, initially developed for use in the Warlock Chaos product. | ||
Sylow (*ˈsyːlɔv*) is a Rust library providing functionality for signature generation and verification using | ||
the alt-bn128 (BN 254) elliptic curve, initially developed for use in the Warlock Chaos product. It provides a | ||
general finite field implementation, and extends it for usage into groups on the relevant elliptic curves of alt-bn128. | ||
|
||
## Features | ||
|
||
- Implementation of BLS signatures on the alt-bn128 (BN254) curve | ||
- Support for threshold signatures | ||
- Efficient pairing operations leveraging the alt-bn128 curve's properties | ||
- Utilities for key generation, signing, and verification | ||
- Compatibility with Ethereum's precompiled contracts for alt-bn128 operations | ||
|
@@ -45,9 +45,10 @@ For more examples and usage details, see the [API documentation](https://docs.rs | |
|
||
## Core Concepts | ||
|
||
- **BLS Signatures**: A signature scheme allowing for signature aggregation and threshold signing. | ||
- **Finite fields**: These serve as the backbone of modern cryptography, allowing for secure signature schemes. | ||
- **alt-bn128 (BN254) Curve**: An elliptic curve with efficient pairing operations, widely used in zkSNARKs and supported by Ethereum precompiles. | ||
- **Threshold Signatures**: A cryptographic primitive allowing a subset of parties to collaboratively sign messages. | ||
- **Optimal ate pairing**: A cryptographic primitive allowing for efficient computation to verify the validity of a | ||
cryptographic signature. | ||
|
||
## Performance | ||
|
||
|
@@ -57,11 +58,9 @@ The alt-bn128 curve is chosen for its efficiency and widespread support, particu | |
|
||
The following features and improvements are planned for future releases: | ||
|
||
- [ ] Basic BLS signature implementation | ||
- [ ] Key generation utilities | ||
- [ ] Signature aggregation | ||
- [ ] Threshold signature scheme | ||
- [ ] Optimizations for common operations | ||
- [x] Basic signature implementation | ||
- [x] Key generation utilities | ||
- [x] Optimizations for common operations | ||
- [ ] Extended test suite and benchmarks | ||
- [ ] Support for serialization formats used in blockchain contexts | ||
|
||
|
@@ -75,6 +74,10 @@ This project is licensed under the [MIT License](https://choosealicense.com/lice | |
|
||
## Contact | ||
|
||
This project is maintained by: | ||
- Tristan Britt [[email protected]](mailto:[email protected]) | ||
- 0xAlcibiades [[email protected]](mailto:[email protected]) | ||
|
||
Warlock Labs - [https://github.com/warlock-labs](https://github.com/warlock-labs) | ||
|
||
Project Link: [https://github.com/warlock-labs/sylow](https://github.com/warlock-labs/sylow) |
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,28 @@ | ||
//! This example shows how to leverage the batch computation of the Miller loops, or otherwise | ||
//! reuse the same G2 element in the pairing in repeated verifications. | ||
use crypto_bigint::rand_core::OsRng; | ||
use subtle::ConstantTimeEq; | ||
use sylow::{ | ||
pairing, FieldExtensionTrait, Fp, Fr, G1Affine, G1Projective, G2Projective, GroupTrait, | ||
}; | ||
|
||
fn main() { | ||
// First, let's generate a shared secret ... | ||
let private_key = Fp::new(Fr::rand(&mut OsRng).value()); | ||
// ... and a public key from it, at which we evaluate the coefficients of the Miller loops | ||
let pubkey = (G2Projective::generator() * private_key).precompute(); | ||
// Now, imagine we have 10 signatures we wish to verify. | ||
let hashed_msgs: Vec<G1Affine> = (0..10).map(|_| G1Affine::rand(&mut OsRng)).collect(); | ||
|
||
let signatures: Vec<G1Projective> = hashed_msgs | ||
.iter() | ||
.map(|x| G1Projective::from(x) * private_key) | ||
.collect(); | ||
// We can evaluate each of them individually using the precomputed coefficients ... | ||
for (sig, msg) in signatures.iter().zip(hashed_msgs.iter()) { | ||
let lhs = pairing(sig, &G2Projective::generator()); | ||
let rhs = pubkey.miller_loop(msg).final_exponentiation(); | ||
assert!(bool::from(lhs.ct_eq(&rhs))); | ||
} | ||
println!("All signatures are valid!"); | ||
} |
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
Oops, something went wrong.