Expand description
Safe Rust bindings for the BICYCL cryptographic library.
BICYCL implements class-group-based cryptographic schemes including:
- Paillier homomorphic encryption
- Joye-Libert homomorphic encryption
- CL_HSMqk / CL_HSM2k class-group encryption with homomorphic properties
- ECDSA signatures
- Two-party ECDSA threshold signing (2-of-2)
- Threshold ECDSA (t-of-n)
- CL DLog proofs
§Build
Requires CMake, GMP, and OpenSSL development headers at build time.
§Thread safety
All types implement Send (can be moved between threads) but not
Sync (cannot be shared via &T across threads). This is safe because
BICYCL does not use thread-local storage; each object is a self-contained
heap allocation. The !Sync constraint prevents concurrent access to
Context’s error buffer and RandGen’s PRNG state.
In practice: you can store keys, ciphertexts, and even Context in
structs that are moved between threads (e.g., async tasks), but you must
not share a &Context across threads simultaneously.
§License
This crate is licensed under GPL-3.0-or-later. Any crate or binary that depends on it inherits the GPL-3.0 copyleft obligation.
§Quick start
use bicycl_rs::{Context, Error};
fn main() -> Result<(), Error> {
let ctx = Context::new()?;
let mut rng = ctx.randgen_from_seed_decimal("12345")?;
let paillier = ctx.paillier(512)?;
let (sk, pk) = paillier.keygen(&ctx, &mut rng)?;
let ct = paillier.encrypt_decimal(&ctx, &pk, &mut rng, "42")?;
let plain = paillier.decrypt_decimal(&ctx, &pk, &sk, &ct)?;
assert_eq!(plain, "42");
Ok(())
}Modules§
- cl_dlog
- State markers for
ClDlogSession. - threshold
- State markers for
ThresholdEcdsaSession. - two_
party - State markers for
TwoPartyEcdsaSession.
Structs§
- ClDlog
Message - A serializable message container used to exchange statements and proofs between prover and verifier in the CL DLog protocol.
- ClDlog
Session - A session for the interactive CL DLog (discrete logarithm) proof protocol.
- ClHsm2k
- A CL_HSM2k class-group encryption scheme with additive homomorphism over
Z/2^k. - ClHsm2k
Ciphertext - A CL_HSM2k ciphertext.
- ClHsm2k
Public Key - A CL_HSM2k public key. Safe to share.
- ClHsm2k
Secret Key - A CL_HSM2k secret key. Keep this private.
- ClHsmqk
- A CL_HSMqk class-group encryption scheme with additive homomorphism over
Z/q^k. - ClHsmqk
Ciphertext - A CL_HSMqk ciphertext.
- ClHsmqk
Public Key - A CL_HSMqk public key. Safe to share.
- ClHsmqk
Secret Key - A CL_HSMqk secret key. Keep this private.
- Class
Group - An imaginary quadratic class group defined by its discriminant.
- Context
- The central BICYCL library context.
- Ecdsa
- An ECDSA signature scheme instance.
- Ecdsa
Public Key - An ECDSA public (verification) key. Safe to share.
- Ecdsa
Secret Key - An ECDSA secret (signing) key. Keep this private.
- Ecdsa
Signature - An ECDSA signature
(r, s). - Joye
Libert - A Joye-Libert homomorphic encryption scheme instance.
- Joye
Libert Ciphertext - A Joye-Libert ciphertext.
- Joye
Libert Public Key - A Joye-Libert public key. Safe to share.
- Joye
Libert Secret Key - A Joye-Libert secret key. Keep this private.
- Paillier
- A Paillier homomorphic encryption scheme instance.
- Paillier
Ciphertext - A Paillier ciphertext.
- Paillier
Public Key - A Paillier public key. Safe to share.
- Paillier
Secret Key - A Paillier secret key. Keep this private.
- Qfi
- A Quadratic Form element in a class group.
- RandGen
- A deterministic pseudo-random number generator seeded from a decimal value.
- Threshold
Ecdsa Session - A stateful session for the threshold (t-of-n) ECDSA signing protocol.
- TwoParty
Ecdsa Session - A stateful session for the interactive two-party (2-of-2) ECDSA signing protocol.
Enums§
- Error
- All errors that can be returned by this crate.
Functions§
- abi_
version - Returns the ABI version of the linked
bicycl_capiC library. - version
- Returns the human-readable version string of the linked
bicycl_capilibrary. - zeroize
- Overwrites the given byte buffer with zeros using a memory-safe barrier.