Module primitives

Module primitives 

Source
Expand description

Operations over the BLS12-381 scalar field.

§Acknowledgements

The following crates were used as a reference when implementing this crate. If code is very similar to the reference, it is accompanied by a comment and link.

§Example

use commonware_cryptography::bls12381::{
    primitives::{ops::{partial_sign_message, partial_verify_message, threshold_signature_recover, verify_message}, poly::public, variant::MinSig},
    dkg::ops::{generate_shares},
};
use rand::rngs::OsRng;

// Configure threshold
let (n, t) = (5, 4);

// Generate commitment and shares
let (commitment, shares) = generate_shares::<_, MinSig>(&mut OsRng, None, n, t);

// Generate partial signatures from shares
let namespace = Some(&b"demo"[..]);
let message = b"hello world";
let partials: Vec<_> = shares.iter().map(|s| partial_sign_message::<MinSig>(s, namespace, message)).collect();

// Verify partial signatures
for p in &partials {
    partial_verify_message::<MinSig>(&commitment, namespace, message, p).expect("signature should be valid");
}

// Aggregate partial signatures
let threshold_sig = threshold_signature_recover::<MinSig, _>(t, &partials).unwrap();

// Verify threshold signature
let threshold_pub = public::<MinSig>(&commitment);
verify_message::<MinSig>(&threshold_pub, namespace, message, &threshold_sig).expect("signature should be valid");

Modules§

group
Group operations over the BLS12-381 scalar field.
ops
Digital signatures over the BLS12-381 curve using G1 as the Public Key (48 bytes) and G2 as the Signature (96 bytes).
poly
Polynomial operations over the BLS12-381 scalar field.
variant
Different variants of the BLS signature scheme.

Enums§

Error
Errors that can occur when working with BLS12-381 primitives.