pub struct Scheme<P: PublicKey, V: Variant> { /* private fields */ }Expand description
BLS12-381 multi-signature implementation of the Scheme trait.
Implementations§
Source§impl<P: PublicKey, V: Variant> Scheme<P, V>
impl<P: PublicKey, V: Variant> Scheme<P, V>
Sourcepub fn new(
participants: OrderedAssociated<P, V::Public>,
private_key: Private,
) -> Self
pub fn new( participants: OrderedAssociated<P, V::Public>, private_key: Private, ) -> Self
Creates a new scheme instance with the provided key material.
Participants have both an identity key and a consensus key. The identity key is used for committee ordering and indexing, while the consensus key is used for signing and verification.
If the provided private key does not match any consensus key in the committee, the instance will act as a verifier (unable to generate signatures).
Sourcepub fn verifier(participants: OrderedAssociated<P, V::Public>) -> Self
pub fn verifier(participants: OrderedAssociated<P, V::Public>) -> Self
Builds a verifier that can authenticate votes and certificates.
Participants have both an identity key and a consensus key. The identity key is used for committee ordering and indexing, while the consensus key is used for verification.
Trait Implementations§
Source§impl<P: PublicKey, V: Variant + Send + Sync> Scheme for Scheme<P, V>
impl<P: PublicKey, V: Variant + Send + Sync> Scheme for Scheme<P, V>
Source§type PublicKey = P
type PublicKey = P
Public key type for participant identity used to order and index the committee.
Source§type Certificate = Certificate<V>
type Certificate = Certificate<V>
Quorum certificate recovered from a set of votes.
Source§fn me(&self) -> Option<u32>
fn me(&self) -> Option<u32>
Returns the index of “self” in the participant set, if available.
Returns
None if the scheme is a verifier-only instance.Source§fn participants(&self) -> &Ordered<Self::PublicKey>
fn participants(&self) -> &Ordered<Self::PublicKey>
Returns the ordered set of participant public identity keys managed by the scheme.
Source§fn sign_vote<D: Digest>(
&self,
namespace: &[u8],
context: VoteContext<'_, D>,
) -> Option<Vote<Self>>
fn sign_vote<D: Digest>( &self, namespace: &[u8], context: VoteContext<'_, D>, ) -> Option<Vote<Self>>
Signs a vote for the given context using the supplied namespace for domain separation.
Returns
None if the scheme cannot sign (e.g. it’s a verifier-only instance).Source§fn verify_vote<D: Digest>(
&self,
namespace: &[u8],
context: VoteContext<'_, D>,
vote: &Vote<Self>,
) -> bool
fn verify_vote<D: Digest>( &self, namespace: &[u8], context: VoteContext<'_, D>, vote: &Vote<Self>, ) -> bool
Verifies a single vote against the participant material managed by the scheme.
Source§fn verify_votes<R, D, I>(
&self,
_rng: &mut R,
namespace: &[u8],
context: VoteContext<'_, D>,
votes: I,
) -> VoteVerification<Self>
fn verify_votes<R, D, I>( &self, _rng: &mut R, namespace: &[u8], context: VoteContext<'_, D>, votes: I, ) -> VoteVerification<Self>
Batch-verifies votes and separates valid messages from the voter indices that failed
verification. Read more
Source§fn assemble_certificate<I>(&self, votes: I) -> Option<Self::Certificate>where
I: IntoIterator<Item = Vote<Self>>,
fn assemble_certificate<I>(&self, votes: I) -> Option<Self::Certificate>where
I: IntoIterator<Item = Vote<Self>>,
Aggregates a quorum of votes into a certificate, returning
None if the quorum is not met. Read moreSource§fn verify_certificate<R: Rng + CryptoRng, D: Digest>(
&self,
_rng: &mut R,
namespace: &[u8],
context: VoteContext<'_, D>,
certificate: &Self::Certificate,
) -> bool
fn verify_certificate<R: Rng + CryptoRng, D: Digest>( &self, _rng: &mut R, namespace: &[u8], context: VoteContext<'_, D>, certificate: &Self::Certificate, ) -> bool
Verifies a certificate that was recovered or received from the network.
Source§fn seed(&self, _: Round, _: &Self::Certificate) -> Option<Self::Seed>
fn seed(&self, _: Round, _: &Self::Certificate) -> Option<Self::Seed>
Extracts randomness seed, if provided by the scheme, derived from the certificate
for the given round.
Source§fn is_attributable(&self) -> bool
fn is_attributable(&self) -> bool
Returns whether per-validator fault evidence can be safely exposed. Read more
Source§fn certificate_codec_config(&self) -> <Self::Certificate as Read>::Cfg
fn certificate_codec_config(&self) -> <Self::Certificate as Read>::Cfg
Encoding configuration for bounded-size certificate decoding used in network payloads.
Source§fn certificate_codec_config_unbounded() -> <Self::Certificate as Read>::Cfg
fn certificate_codec_config_unbounded() -> <Self::Certificate as Read>::Cfg
Encoding configuration that allows unbounded certificate decoding. Read more
Source§fn verify_certificates<'a, R, D, I>(
&self,
rng: &mut R,
namespace: &[u8],
certificates: I,
) -> boolwhere
R: Rng + CryptoRng,
D: Digest,
I: Iterator<Item = (VoteContext<'a, D>, &'a Self::Certificate)>,
fn verify_certificates<'a, R, D, I>(
&self,
rng: &mut R,
namespace: &[u8],
certificates: I,
) -> boolwhere
R: Rng + CryptoRng,
D: Digest,
I: Iterator<Item = (VoteContext<'a, D>, &'a Self::Certificate)>,
Verifies a stream of certificates, returning
false at the first failure.Auto Trait Implementations§
impl<P, V> Freeze for Scheme<P, V>
impl<P, V> RefUnwindSafe for Scheme<P, V>
impl<P, V> Send for Scheme<P, V>
impl<P, V> Sync for Scheme<P, V>
impl<P, V> Unpin for Scheme<P, V>
impl<P, V> UnwindSafe for Scheme<P, V>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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