pub enum Generic<P: PublicKey, V: Variant, N: Namespace> {
Signer {
participants: Set<P>,
polynomial: Sharing<V>,
share: Share,
namespace: N,
},
Verifier {
participants: Set<P>,
polynomial: Sharing<V>,
namespace: N,
},
CertificateVerifier {
identity: V::Public,
namespace: N,
},
}Expand description
Generic BLS12-381 threshold signature implementation.
This enum 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.
A node can play one of the following roles: a signer (with its share), a verifier (with evaluated public polynomial), or an external verifier that only checks recovered certificates.
Variants§
Signer
Fields
Local share used to generate partial signatures.
namespace: NPre-computed namespace(s) for this subject type.
Verifier
Fields
namespace: NPre-computed namespace(s) for this subject type.
CertificateVerifier
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: Set<P>,
polynomial: Sharing<V>,
share: Share,
) -> Option<Self>
pub fn signer( namespace: &[u8], participants: Set<P>, polynomial: Sharing<V>, share: Share, ) -> Option<Self>
Constructs a signer instance with a private share and evaluated public polynomial.
The participant identity keys are used for committee ordering and indexing. The polynomial can be evaluated to obtain public verification keys for partial signatures produced by committee members.
Returns None if the share’s public key does not match any participant.
namespace- base namespace for domain separationparticipants- ordered set of participant identity keyspolynomial- public polynomial for threshold verificationshare- local threshold share for signing
Sourcepub fn verifier(
namespace: &[u8],
participants: Set<P>,
polynomial: Sharing<V>,
) -> Self
pub fn verifier( namespace: &[u8], participants: Set<P>, polynomial: Sharing<V>, ) -> Self
Produces a verifier that can authenticate signatures but does not hold signing state.
The participant identity keys are used for committee ordering and indexing. The polynomial can be evaluated to obtain public verification keys for partial signatures produced by committee members.
namespace- base namespace for domain separationparticipants- ordered set of participant identity keyspolynomial- public polynomial for threshold verification
Sourcepub fn certificate_verifier(namespace: &[u8], identity: V::Public) -> Self
pub fn certificate_verifier(namespace: &[u8], identity: V::Public) -> Self
Creates a verifier that only checks recovered certificates.
This lightweight verifier can authenticate recovered threshold certificates but cannot verify individual signatures or partial signatures.
namespace- base namespace for domain separationidentity- public identity of the committee (constant across reshares)
Sourcepub fn participants(&self) -> &Set<P>
pub fn participants(&self) -> &Set<P>
Returns the ordered set of participant public identity keys in the committee.
Sourcepub fn identity(&self) -> &V::Public
pub fn identity(&self) -> &V::Public
Returns the public identity of the committee (constant across reshares).
Returns the local share if this instance can generate partial signatures.
Sourcepub const fn me(&self) -> Option<Participant>
pub const 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, T, M>(
&self,
attestations: I,
strategy: &T,
) -> Option<V::Signature>where
S: Scheme<Signature = V::Signature>,
I: IntoIterator<Item = Attestation<S>>,
T: Strategy,
M: Faults,
pub fn assemble<S, I, T, M>(
&self,
attestations: I,
strategy: &T,
) -> Option<V::Signature>where
S: Scheme<Signature = V::Signature>,
I: IntoIterator<Item = Attestation<S>>,
T: Strategy,
M: Faults,
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: &V::Signature,
) -> bool
pub fn verify_certificate<'a, S, R, D, M>( &self, _rng: &mut R, subject: S::Subject<'a, D>, certificate: &V::Signature, ) -> bool
Verifies a certificate.
Sourcepub fn verify_certificates<'a, S, R, D, I, T, M>(
&self,
rng: &mut R,
certificates: I,
strategy: &T,
) -> bool
pub fn verify_certificates<'a, S, R, D, I, T, M>( &self, rng: &mut R, certificates: I, strategy: &T, ) -> bool
Verifies multiple certificates in a batch.
pub const fn is_attributable() -> bool
pub const fn is_batchable() -> bool
pub const fn certificate_codec_config(&self)
pub const fn certificate_codec_config_unbounded()
Trait Implementations§
Auto Trait Implementations§
impl<P, V, N> Freeze for Generic<P, V, N>
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