pub struct Generic<P: PublicKey, V: Variant, N: Namespace> {
pub participants: BiMap<P, V::Public>,
pub signer: Option<(Participant, Private)>,
pub namespace: N,
}Expand description
Generic BLS12-381 multi-signature implementation.
This struct contains the core cryptographic operations without protocol-specific context types. It can be reused across different protocols (simplex, aggregation, etc.) by wrapping it with protocol-specific trait implementations via the macro.
Fields§
§participants: BiMap<P, V::Public>Participants in the committee.
signer: Option<(Participant, Private)>Key used for generating signatures.
namespace: NPre-computed namespace(s) for this subject type.
Implementations§
Source§impl<P: PublicKey, V: Variant, N: Namespace> Generic<P, V, N>
impl<P: PublicKey, V: Variant, N: Namespace> Generic<P, V, N>
Sourcepub fn signer(
namespace: &[u8],
participants: BiMap<P, V::Public>,
private_key: Private,
) -> Option<Self>
pub fn signer( namespace: &[u8], participants: BiMap<P, V::Public>, private_key: Private, ) -> Option<Self>
Creates a new scheme instance with the provided key material.
Participants have both an identity key and a signing key. The identity key is used for participant set ordering and indexing, while the signing key is used for signing and verification.
Returns None if the provided private key does not match any signing key
in the participant set.
Sourcepub fn verifier(namespace: &[u8], participants: BiMap<P, V::Public>) -> Self
pub fn verifier(namespace: &[u8], participants: BiMap<P, V::Public>) -> Self
Builds a verifier that can authenticate signatures and certificates.
Participants have both an identity key and a signing key. The identity key is used for participant set ordering and indexing, while the signing key is used for verification.
Sourcepub const fn participants(&self) -> &Set<P>
pub const fn participants(&self) -> &Set<P>
Returns the ordered set of identity keys.
Sourcepub fn me(&self) -> Option<Participant>
pub fn me(&self) -> Option<Participant>
Returns the index of “self” in the participant set, if available.
Sourcepub fn sign<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
) -> Option<Attestation<S>>
pub fn sign<'a, S, D>( &self, subject: S::Subject<'a, D>, ) -> Option<Attestation<S>>
Signs a subject and returns the attestation.
Sourcepub fn verify_attestation<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
attestation: &Attestation<S>,
) -> bool
pub fn verify_attestation<'a, S, D>( &self, subject: S::Subject<'a, D>, attestation: &Attestation<S>, ) -> bool
Verifies a single attestation from a signer.
Sourcepub fn verify_attestations<'a, S, R, D, I, T>(
&self,
rng: &mut R,
subject: S::Subject<'a, D>,
attestations: I,
strategy: &T,
) -> Verification<S>where
S: Scheme<Signature = V::Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
D: Digest,
I: IntoIterator<Item = Attestation<S>>,
T: Strategy,
pub fn verify_attestations<'a, S, R, D, I, T>(
&self,
rng: &mut R,
subject: S::Subject<'a, D>,
attestations: I,
strategy: &T,
) -> Verification<S>where
S: Scheme<Signature = V::Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
D: Digest,
I: IntoIterator<Item = Attestation<S>>,
T: Strategy,
Batch-verifies attestations and returns verified attestations and invalid signers.
Sourcepub fn assemble<S, I, M>(&self, attestations: I) -> Option<Certificate<V>>
pub fn assemble<S, I, M>(&self, attestations: I) -> Option<Certificate<V>>
Assembles a certificate from a collection of attestations.
Sourcepub fn verify_certificate<'a, S, R, D, M>(
&self,
_rng: &mut R,
subject: S::Subject<'a, D>,
certificate: &Certificate<V>,
) -> bool
pub fn verify_certificate<'a, S, R, D, M>( &self, _rng: &mut R, subject: S::Subject<'a, D>, certificate: &Certificate<V>, ) -> bool
Verifies a certificate.
Sourcepub fn verify_certificates<'a, S, R, D, I, M>(
&self,
rng: &mut R,
certificates: I,
) -> boolwhere
S: Scheme,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
D: Digest,
I: Iterator<Item = (S::Subject<'a, D>, &'a Certificate<V>)>,
M: Faults,
pub fn verify_certificates<'a, S, R, D, I, M>(
&self,
rng: &mut R,
certificates: I,
) -> boolwhere
S: Scheme,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
D: Digest,
I: Iterator<Item = (S::Subject<'a, D>, &'a Certificate<V>)>,
M: Faults,
Verifies multiple certificates (no batch optimization for BLS multisig).
pub const fn is_attributable() -> bool
pub const fn is_batchable() -> bool
pub const fn certificate_codec_config(&self) -> <Certificate<V> as Read>::Cfg
pub const fn certificate_codec_config_unbounded() -> <Certificate<V> as Read>::Cfg
Trait Implementations§
Auto Trait Implementations§
impl<P, V, N> Freeze for Generic<P, V, N>where
N: Freeze,
impl<P, V, N> RefUnwindSafe for Generic<P, V, N>
impl<P, V, N> Send for Generic<P, V, N>
impl<P, V, N> Sync for Generic<P, V, N>
impl<P, V, N> Unpin for Generic<P, V, N>
impl<P, V, N> UnwindSafe for Generic<P, V, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more