commonware_consensus/aggregation/
scheme.rs

1//! Signing scheme implementations for `aggregation`.
2//!
3//! This module provides protocol-specific wrappers around the generic signing schemes
4//! in [`commonware_cryptography::certificate`]. Each wrapper binds the scheme's subject type to
5//! [`Item`], which represents the data being aggregated and signed.
6//!
7//! # Available Schemes
8//!
9//! - [`ed25519`]: Attributable signatures with individual verification. HSM-friendly,
10//!   no trusted setup required.
11//! - [`bls12381_multisig`]: Attributable signatures with aggregated verification.
12//!   Compact certificates while preserving attribution.
13//! - [`bls12381_threshold`]: Non-attributable threshold signatures. Constant-size
14//!   certificates regardless of committee size.
15
16use super::types::Item;
17use commonware_cryptography::{certificate, Digest};
18
19/// Marker trait for signing schemes compatible with `aggregation`.
20///
21/// This trait binds a [`certificate::Scheme`] to the [`Item`] subject type used
22/// by the aggregation protocol. It is automatically implemented for any scheme
23/// whose subject type matches `&'a Item<D>`.
24pub trait Scheme<D: Digest>: for<'a> certificate::Scheme<Subject<'a, D> = &'a Item<D>> {}
25
26impl<D: Digest, S> Scheme<D> for S where S: for<'a> certificate::Scheme<Subject<'a, D> = &'a Item<D>>
27{}
28
29pub mod bls12381_multisig {
30    //! BLS12-381 multi-signature implementation of the
31    //! [`Scheme`](commonware_cryptography::certificate::Scheme) trait for `aggregation`.
32    //!
33    //! This scheme is attributable: certificates are compact while still preserving
34    //! per-validator attribution.
35
36    use super::Item;
37    use commonware_cryptography::impl_certificate_bls12381_multisig;
38
39    impl_certificate_bls12381_multisig!(&'a Item<D>);
40}
41
42pub mod bls12381_threshold {
43    //! BLS12-381 threshold implementation of the [`Scheme`](commonware_cryptography::certificate::Scheme)
44    //! trait for `aggregation`.
45    //!
46    //! This scheme is non-attributable: partial signatures should not be exposed as
47    //! third-party evidence.
48
49    use super::Item;
50    use commonware_cryptography::impl_certificate_bls12381_threshold;
51
52    impl_certificate_bls12381_threshold!(&'a Item<D>);
53}
54
55pub mod ed25519 {
56    //! Ed25519 implementation of the [`Scheme`](commonware_cryptography::certificate::Scheme) trait
57    //! for `aggregation`.
58    //!
59    //! This scheme is attributable: individual signatures can be safely exposed as
60    //! evidence of liveness or faults.
61
62    use super::Item;
63    use commonware_cryptography::impl_certificate_ed25519;
64
65    impl_certificate_ed25519!(&'a Item<D>);
66}