pub struct Generic<N: Namespace> {
pub participants: Set<PublicKey>,
pub signer: Option<(Participant, PrivateKey)>,
pub namespace: N,
}Expand description
Generic Ed25519 signing scheme 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: Set<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<N: Namespace> Generic<N>
impl<N: Namespace> Generic<N>
Sourcepub fn signer(
namespace: &[u8],
participants: Set<PublicKey>,
private_key: PrivateKey,
) -> Option<Self>
pub fn signer( namespace: &[u8], participants: Set<PublicKey>, private_key: PrivateKey, ) -> Option<Self>
Creates a new generic Ed25519 scheme instance.
Sourcepub fn verifier(namespace: &[u8], participants: Set<PublicKey>) -> Self
pub fn verifier(namespace: &[u8], participants: Set<PublicKey>) -> Self
Builds a verifier that can authenticate signatures without generating them.
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 = Ed25519Signature>,
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 = Ed25519Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
D: Digest,
Signs a subject and returns the signer index and signature.
Sourcepub fn verify_attestation<'a, S, D>(
&self,
subject: S::Subject<'a, D>,
attestation: &Attestation<S>,
) -> boolwhere
S: Scheme<Signature = Ed25519Signature>,
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 = Ed25519Signature>,
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 = Ed25519Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
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 = Ed25519Signature>,
S::Subject<'a, D>: Subject<Namespace = N>,
R: CryptoRngCore,
D: Digest,
I: IntoIterator<Item = Attestation<S>>,
Batch-verifies attestations 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 using batch verification.
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)>,
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)>,
M: Faults,
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) -> <Certificate as Read>::Cfg
pub const fn certificate_codec_config_unbounded() -> <Certificate as Read>::Cfg
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for Generic<N>where
N: Freeze,
impl<N> RefUnwindSafe for Generic<N>where
N: RefUnwindSafe,
impl<N> Send for Generic<N>
impl<N> Sync for Generic<N>
impl<N> Unpin for Generic<N>where
N: Unpin,
impl<N> UnwindSafe for Generic<N>where
N: 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