pub trait AggregateAuthenticator: Display + Serialize + DeserializeOwned + Send + Sync + 'static + Clone {
    type Sig: Authenticator<PubKey = Self::PubKey>;
    type PubKey: VerifyingKey<Sig = Self::Sig>;
    type PrivKey: SigningKey<Sig = Self::Sig>;

    // Required methods
    fn aggregate<'a, K, I>(signatures: I) -> Result<Self, FastCryptoError>
       where K: Borrow<Self::Sig> + 'a,
             I: IntoIterator<Item = &'a K>;
    fn add_signature(
        &mut self,
        signature: Self::Sig
    ) -> Result<(), FastCryptoError>;
    fn add_aggregate(&mut self, signature: Self) -> Result<(), FastCryptoError>;
    fn verify(
        &self,
        pks: &[<Self::Sig as Authenticator>::PubKey],
        message: &[u8]
    ) -> Result<(), FastCryptoError>;
    fn verify_different_msg(
        &self,
        pks: &[<Self::Sig as Authenticator>::PubKey],
        messages: &[&[u8]]
    ) -> Result<(), FastCryptoError>;
    fn batch_verify<'a>(
        sigs: &[&Self],
        pks: Vec<impl ExactSizeIterator<Item = &'a Self::PubKey>>,
        messages: &[&[u8]]
    ) -> Result<(), FastCryptoError>;
}
Expand description

Trait impl’d by aggregated signatures in asymmetric cryptography.

The trait bounds are implemented to allow the aggregation of multiple signatures, and to verify it against multiple, unaggregated public keys. For signature schemes where aggregation is not possible, a trivial implementation is provided.

Required Associated Types§

type Sig: Authenticator<PubKey = Self::PubKey>

type PubKey: VerifyingKey<Sig = Self::Sig>

type PrivKey: SigningKey<Sig = Self::Sig>

Required Methods§

fn aggregate<'a, K, I>(signatures: I) -> Result<Self, FastCryptoError>
where K: Borrow<Self::Sig> + 'a, I: IntoIterator<Item = &'a K>,

Combine signatures into a single aggregated signature.

fn add_signature(&mut self, signature: Self::Sig) -> Result<(), FastCryptoError>

fn add_aggregate(&mut self, signature: Self) -> Result<(), FastCryptoError>

fn verify( &self, pks: &[<Self::Sig as Authenticator>::PubKey], message: &[u8] ) -> Result<(), FastCryptoError>

Verify this aggregate signature assuming that all signatures are over the same message.

§Example
use fastcrypto::{traits::{AggregateAuthenticator, KeyPair, Signer, VerifyingKey}};
use rand::thread_rng;
use fastcrypto::bls12381::min_sig::{BLS12381AggregateSignature, BLS12381KeyPair};

let message: &[u8] = b"Hello, world!";
let kp1 = BLS12381KeyPair::generate(&mut thread_rng());
let signature1 = kp1.sign(message);
let kp2 = BLS12381KeyPair::generate(&mut thread_rng());
let signature2 = kp2.sign(message);

let aggregated_signature = BLS12381AggregateSignature::aggregate(vec!(&signature1, &signature2)).unwrap();
let public_keys = &[kp1.public().clone(), kp2.public().clone()];
assert!(aggregated_signature.verify(public_keys, message).is_ok());

fn verify_different_msg( &self, pks: &[<Self::Sig as Authenticator>::PubKey], messages: &[&[u8]] ) -> Result<(), FastCryptoError>

Verify this aggregate signature where the signatures are over different messages.

§Example
use fastcrypto::{traits::{AggregateAuthenticator, KeyPair, Signer, VerifyingKey}};
use rand::thread_rng;
use fastcrypto::bls12381::min_sig::{BLS12381AggregateSignature, BLS12381KeyPair};

let message1: &[u8] = b"Hello, world!";
let kp1 = BLS12381KeyPair::generate(&mut thread_rng());
let signature1 = kp1.sign(message1);
let message2: &[u8] = b"Hello, world!!!";
let kp2 = BLS12381KeyPair::generate(&mut thread_rng());
let signature2 = kp2.sign(message2);

let aggregated_signature = BLS12381AggregateSignature::aggregate(vec!(&signature1, &signature2)).unwrap();
let messages = [message1, message2];
let public_keys = [kp1.public().clone(), kp2.public().clone()];
assert!(aggregated_signature.verify_different_msg(&public_keys, &messages).is_ok());

fn batch_verify<'a>( sigs: &[&Self], pks: Vec<impl ExactSizeIterator<Item = &'a Self::PubKey>>, messages: &[&[u8]] ) -> Result<(), FastCryptoError>

Verify a batch of aggregate signatures, each consisting of a number of signatures over the same message.

§Example
use fastcrypto::{traits::{AggregateAuthenticator, KeyPair, Signer, VerifyingKey}};
use rand::thread_rng;
use fastcrypto::bls12381::min_sig::{BLS12381AggregateSignature, BLS12381KeyPair};

let message1: &[u8] = b"Hello, world!";
let kp1 = BLS12381KeyPair::generate(&mut thread_rng());
let signature1 = kp1.sign(message1);
let aggregated_signature1 = BLS12381AggregateSignature::aggregate(vec!(&signature1)).unwrap();
let message2: &[u8] = b"1234";
let kp2 = BLS12381KeyPair::generate(&mut thread_rng());
let signature2 = kp2.sign(message2);
let aggregated_signature2 = BLS12381AggregateSignature::aggregate(vec!(&signature2)).unwrap();

let aggregated_signatures = [&aggregated_signature1, &aggregated_signature2];
let messages = [message1, message2];
let pks1 = [kp1.public().clone()];
let pks2 = [kp2.public().clone()];
let public_keys = vec!(pks1.iter(), pks2.iter());
assert!(BLS12381AggregateSignature::batch_verify(&aggregated_signatures, public_keys, &messages).is_ok());

Object Safety§

This trait is not object safe.

Implementors§

§

impl AggregateAuthenticator for BLS12381AggregateSignature

§

type Sig = BLS12381Signature

§

type PubKey = BLS12381PublicKey

§

type PrivKey = BLS12381PrivateKey

§

impl AggregateAuthenticator for BLS12381AggregateSignature

§

type Sig = BLS12381Signature

§

type PubKey = BLS12381PublicKey

§

type PrivKey = BLS12381PrivateKey