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 signer_index(&self) -> Option<Participant>
pub fn signer_index(&self) -> Option<Participant>
Returns the index this instance signs at, or None if it cannot sign.
Sourcepub fn sign<S>(
&self,
subject: impl Subject<Namespace = N>,
) -> Option<Attestation<S>>where
S: Scheme<Signature = Ed25519Signature>,
pub fn sign<S>(
&self,
subject: impl Subject<Namespace = N>,
) -> Option<Attestation<S>>where
S: Scheme<Signature = Ed25519Signature>,
Signs a subject and returns the signer index and signature.
Sourcepub fn verify_attestation<S>(
&self,
subject: impl Subject<Namespace = N>,
attestation: &Attestation<S>,
) -> boolwhere
S: Scheme<Signature = Ed25519Signature>,
pub fn verify_attestation<S>(
&self,
subject: impl Subject<Namespace = N>,
attestation: &Attestation<S>,
) -> boolwhere
S: Scheme<Signature = Ed25519Signature>,
Verifies a single attestation from a signer.
Sourcepub fn verify_attestations<S, R, I>(
&self,
rng: &mut R,
subject: impl Subject<Namespace = N>,
attestations: I,
strategy: &impl Strategy,
) -> Verification<S>where
S: Scheme<Signature = Ed25519Signature>,
R: CryptoRng,
I: IntoIterator<Item = Attestation<S>>,
pub fn verify_attestations<S, R, I>(
&self,
rng: &mut R,
subject: impl Subject<Namespace = N>,
attestations: I,
strategy: &impl Strategy,
) -> Verification<S>where
S: Scheme<Signature = Ed25519Signature>,
R: CryptoRng,
I: IntoIterator<Item = Attestation<S>>,
Batch-verifies attestations and returns verified attestations and invalid signers.
Sourcepub fn assemble<S, I>(
&self,
attestations: NonEmpty<I>,
) -> Result<Certificate, AssemblyError>
pub fn assemble<S, I>( &self, attestations: NonEmpty<I>, ) -> Result<Certificate, AssemblyError>
Assembles a certificate from a non-empty collection of attestations.
Sourcepub fn verify_certificate<S, R>(
&self,
rng: &mut R,
subject: impl Subject<Namespace = N>,
certificate: &Certificate,
strategy: &impl Strategy,
) -> bool
pub fn verify_certificate<S, R>( &self, rng: &mut R, subject: impl Subject<Namespace = N>, certificate: &Certificate, strategy: &impl Strategy, ) -> bool
Verifies a certificate using batch verification.
Sourcepub fn verify_certificates<'a, S, R, T, I>(
&self,
rng: &mut R,
certificates: NonEmpty<I>,
strategy: &impl Strategy,
) -> bool
pub fn verify_certificates<'a, S, R, T, I>( &self, rng: &mut R, certificates: NonEmpty<I>, strategy: &impl Strategy, ) -> bool
Verifies multiple certificates in a batch.
pub const fn is_attributable() -> bool
pub const fn is_batchable() -> bool
Sourcepub fn max_certificate_size(participants: u32) -> usize
pub fn max_certificate_size(participants: u32) -> usize
Returns an upper bound on the encoded certificate size for at most participants
participants.