pub struct Generic<P: PublicKey, N: Namespace> {
pub participants: BiMap<P, PublicKey>,
pub signer: Option<(Participant, PrivateKey)>,
pub namespace: N,
}Expand description
Generic Secp256r1 signing scheme implementation parameterized by identity type.
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, PublicKey>Participants in the committee.
signer: Option<(Participant, PrivateKey)>Key used for generating signatures.
namespace: NPre-computed namespace(s) for this subject type.
Implementations§
Source§impl<P: PublicKey, N: Namespace> Generic<P, N>
impl<P: PublicKey, N: Namespace> Generic<P, N>
Sourcepub fn signer(
namespace: &[u8],
participants: BiMap<P, PublicKey>,
private_key: PrivateKey,
) -> Option<Self>
pub fn signer( namespace: &[u8], participants: BiMap<P, PublicKey>, private_key: PrivateKey, ) -> 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, PublicKey>) -> Self
pub fn verifier(namespace: &[u8], participants: BiMap<P, PublicKey>) -> 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>>where
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
D: Digest,
pub fn sign<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
) -> Option<Attestation<S>>where
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
D: Digest,
Signs a subject and returns the attestation.
Sourcepub fn verify_attestation<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
attestation: &Attestation<S>,
) -> boolwhere
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
D: Digest,
pub fn verify_attestation<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
attestation: &Attestation<S>,
) -> boolwhere
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
D: Digest,
Verifies a single attestation from a signer.
Sourcepub fn verify_attestations<'a, S, R, D, I>(
&self,
_rng: &mut R,
subject: S::Subject<'a, D>,
attestations: I,
) -> Verification<S>where
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: Rng + CryptoRng,
D: Digest,
I: IntoIterator<Item = Attestation<S>>,
pub fn verify_attestations<'a, S, R, D, I>(
&self,
_rng: &mut R,
subject: S::Subject<'a, D>,
attestations: I,
) -> Verification<S>where
S: Scheme<Signature = Secp256r1Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: Rng + CryptoRng,
D: Digest,
I: IntoIterator<Item = Attestation<S>>,
Verifies attestations one-by-one and returns verified attestations and invalid signers.
Sourcepub fn assemble<S, I, M>(&self, attestations: I) -> Option<Certificate>
pub fn assemble<S, I, M>(&self, attestations: I) -> Option<Certificate>
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,
) -> bool
pub fn verify_certificate<'a, S, R, D, M>( &self, _rng: &mut R, subject: S::Subject<'a, D>, certificate: &Certificate, ) -> bool
Verifies a certificate by checking each signature individually.
pub const fn is_attributable() -> bool
pub const fn is_batchable() -> bool
pub const fn certificate_codec_config(&self) -> <Certificate as Read>::Cfg
pub const fn certificate_codec_config_unbounded() -> <Certificate as Read>::Cfg
Trait Implementations§
Auto Trait Implementations§
impl<P, N> Freeze for Generic<P, N>where
N: Freeze,
impl<P, N> RefUnwindSafe for Generic<P, N>where
N: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, N> Send for Generic<P, N>
impl<P, N> Sync for Generic<P, N>
impl<P, N> Unpin for Generic<P, N>
impl<P, N> UnwindSafe for Generic<P, N>where
N: UnwindSafe,
P: UnwindSafe,
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