MCPcopy Index your code
hub / github.com/celo-org/celo-bls-snark-rs

github.com/celo-org/celo-bls-snark-rs @v0.1.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.4 ↗ · + Follow
299 symbols 687 edges 47 files 115 documented · 38%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

celo-bls-snark-rs

Implements SNARK-friendly BLS signatures over BLS12-377 and SW6.

Using the code

Rust Crates

All Rust crates live under the crates/ directory. You can import them in your code via git paths, until they get published on crates.io.

Quick start

The following commands assume your current directory is the root of this repository.

The simple_signature program shows how to generate keys, sign and aggregate signatures.

To run it with debug logging enabled, execute:

RUST_LOG=debug cargo run --example simple_signature -- -m hello

Building

To build the project, you should use a recent stable Rust version. We test with 1.36.

# Build
cargo build (--release)
# Test. 
# Consider running tests in release mode, as some of 
# the cryptographic operations are slow in debug mode.
cargo test (--release)

Construction

We work over the BLS12-377 curve from [BCGMMW18].

Secret keys are elements of the scalar field Fr.

We would like to minimize the computation required for signing, since we would also like to achieve hardware wallet compatibility. Therefore, public keys are in G2 and signatures are in G1.

For most signatures - to hash a message to G1, we use the try-and-increment method coupled with Blake2Xs.

For signatures that we would like to verify in SNARKs - to hash a message to G1, we use the try-and-increment method coupled with a composite hash. The composite hash is composed of a Bowe-Hopwood hash over $E_{Ed/CP}$ from [BCGMMW18] and Blake2s.

We perform cofactor muliplication in G1 directly.

License

celo-bls-snark-rs is licensed under either of the following licenses, at your discretion.

Apache License Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) Unless you explicitly state otherwise, any contribution submitted for inclusion in celo-bls-snark-rs by you shall be dual licensed as above (as defined in the Apache v2 License), without any additional terms or conditions.

References

[BDN18] Boneh, D., Drijvers, M., & Neven, G. (2018, December). Compact multi-signatures for smaller blockchains. In International Conference on the Theory and Application of Cryptology and Information Security (pp. 435-464). Springer, Cham.

[BLS01] Boneh, D., Lynn, B., & Shacham, H. (2001, December). Short signatures from the Weil pairing. In International Conference on the Theory and Application of Cryptology and Information Security (pp. 514-532). Springer, Berlin, Heidelberg.

[BCGMMW18] Bowe, S., Chiesa, A., Green, M., Miers, I., Mishra, P., & Wu, H. (2018). Zexe: Enabling decentralized private computation. IACR ePrint, 962.

[pairings] Costello, C. . Pairings for beginners.

[BP17] Budroni, A., & Pintore, F. (2017). Efficient hash maps to G2 on BLS curves. Cryptology ePrint Archive, Report 2017/419.

[RY07] Ristenpart, T., & Yilek, S. (2007, May). The power of proofs-of-possession: Securing multiparty signatures against rogue-key attacks. In Annual International Conference on the Theory and Applications of Cryptographic Techniques (pp. 228-245). Springer, Berlin, Heidelberg.

Extension points exported contracts — how you extend this code

Hasher (Interface)
A hasher groups together collision resistant (CRH) and extendable output (XOF) functions in order to produce a hash of t [2 …
crates/bls-crypto/src/hashers/mod.rs
HashToCurve (Interface)
Trait for hashing arbitrary data to a group element on an elliptic curve [1 implementers]
crates/bls-crypto/src/hash_to_curve/mod.rs

Core symbols most depended-on inside this repo

as_ref
called by 17
crates/bls-crypto/src/bls/secret.rs
serialize
called by 17
crates/bls-crypto/src/bls/public.rs
to_public
called by 14
crates/bls-crypto/src/bls/secret.rs
verify
called by 13
crates/bls-crypto/src/bls/public.rs
bytes_to_bits
called by 11
crates/bls-gadgets/src/utils.rs
to_bits
called by 11
crates/epoch-snark/src/gadgets/epoch_data.rs
deserialize
called by 10
crates/bls-snark-sys/src/serialization.rs
sign
called by 10
crates/bls-crypto/src/bls/secret.rs

Shape

Function 170
Method 94
Class 30
Enum 3
Interface 2

Languages

Rust100%

Modules by API surface

crates/bls-crypto/src/hash_to_curve/try_and_increment.rs18 symbols
crates/bls-crypto/src/bls/signature.rs16 symbols
crates/bls-snark-sys/src/serialization.rs15 symbols
crates/bls-gadgets/src/bls.rs14 symbols
crates/bls-crypto/src/hashers/composite.rs14 symbols
crates/bls-snark-sys/src/snark/epoch_block.rs13 symbols
crates/bls-gadgets/src/bitmap.rs13 symbols
crates/bls-crypto/src/bls/cache.rs13 symbols
crates/epoch-snark/src/gadgets/epoch_data.rs12 symbols
crates/epoch-snark/src/epoch_block.rs12 symbols
crates/bls-snark-sys/src/signatures.rs12 symbols
crates/bls-gadgets/src/y_to_bit.rs12 symbols

For agents

$ claude mcp add celo-bls-snark-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page