Trait hotshot_types::traits::qc::QuorumCertificateScheme
source · pub trait QuorumCertificateScheme<A: AggregateableSignatureSchemes + Serialize + for<'a> Deserialize<'a>> {
type QcProverParams: Serialize + for<'a> Deserialize<'a>;
type QcVerifierParams: Serialize + for<'a> Deserialize<'a>;
type MessageLength: ArrayLength<A::MessageUnit>;
type Qc;
type QuorumSize;
// Required methods
fn assemble(
qc_pp: &Self::QcProverParams,
signers: &BitSlice,
sigs: &[A::Signature],
) -> Result<Self::Qc, SignatureError>;
fn check(
qc_vp: &Self::QcVerifierParams,
message: &GenericArray<A::MessageUnit, Self::MessageLength>,
qc: &Self::Qc,
) -> Result<Self::QuorumSize, SignatureError>;
fn trace(
qc_vp: &Self::QcVerifierParams,
message: &GenericArray<A::MessageUnit, Self::MessageLength>,
qc: &Self::Qc,
) -> Result<Vec<A::VerificationKey>, SignatureError>;
// Provided method
fn sign<R: CryptoRng + RngCore, M: AsRef<[A::MessageUnit]>>(
pp: &A::PublicParameter,
sk: &A::SigningKey,
msg: M,
prng: &mut R,
) -> Result<A::Signature, SignatureError> { ... }
}
Expand description
Trait for validating a QC built from different signatures on the same message
Required Associated Types§
sourcetype QcProverParams: Serialize + for<'a> Deserialize<'a>
type QcProverParams: Serialize + for<'a> Deserialize<'a>
Public parameters for generating the QC E.g: snark proving/verifying keys, list of (or pointer to) public keys stored in the smart contract.
sourcetype QcVerifierParams: Serialize + for<'a> Deserialize<'a>
type QcVerifierParams: Serialize + for<'a> Deserialize<'a>
Public parameters for validating the QC E.g: verifying keys, stake table commitment
sourcetype MessageLength: ArrayLength<A::MessageUnit>
type MessageLength: ArrayLength<A::MessageUnit>
Allows to fix the size of the message at compilation time.
sourcetype QuorumSize
type QuorumSize
Type of the quorum size (e.g. number of votes or accumulated weight of signatures)
Required Methods§
sourcefn assemble(
qc_pp: &Self::QcProverParams,
signers: &BitSlice,
sigs: &[A::Signature],
) -> Result<Self::Qc, SignatureError>
fn assemble( qc_pp: &Self::QcProverParams, signers: &BitSlice, sigs: &[A::Signature], ) -> Result<Self::Qc, SignatureError>
Computes an aggregated signature from a set of partial signatures and the verification keys involved
qc_pp
- public parameters for generating the QCsigners
- a bool vector indicating the list of verification keys corresponding to the set of partial signaturessigs
- partial signatures on the same message
§Errors
Will return error if some of the partial signatures provided are invalid or the number of partial signatures / verifications keys are different.
sourcefn check(
qc_vp: &Self::QcVerifierParams,
message: &GenericArray<A::MessageUnit, Self::MessageLength>,
qc: &Self::Qc,
) -> Result<Self::QuorumSize, SignatureError>
fn check( qc_vp: &Self::QcVerifierParams, message: &GenericArray<A::MessageUnit, Self::MessageLength>, qc: &Self::Qc, ) -> Result<Self::QuorumSize, SignatureError>
Checks an aggregated signature over some message provided as input
qc_vp
- public parameters for validating the QCmessage
- message to check the aggregated signature againstqc
- quorum certificatereturns
- the quorum size if the qc is valid, an error otherwise.
§Errors
Return error if the QC is invalid, either because accumulated weight didn’t exceed threshold, or some partial signatures are invalid.
sourcefn trace(
qc_vp: &Self::QcVerifierParams,
message: &GenericArray<A::MessageUnit, Self::MessageLength>,
qc: &Self::Qc,
) -> Result<Vec<A::VerificationKey>, SignatureError>
fn trace( qc_vp: &Self::QcVerifierParams, message: &GenericArray<A::MessageUnit, Self::MessageLength>, qc: &Self::Qc, ) -> Result<Vec<A::VerificationKey>, SignatureError>
Trace the list of signers given a qc.
§Errors
Return error if the inputs mismatch (e.g. wrong verifier parameter or original message).
Provided Methods§
sourcefn sign<R: CryptoRng + RngCore, M: AsRef<[A::MessageUnit]>>(
pp: &A::PublicParameter,
sk: &A::SigningKey,
msg: M,
prng: &mut R,
) -> Result<A::Signature, SignatureError>
fn sign<R: CryptoRng + RngCore, M: AsRef<[A::MessageUnit]>>( pp: &A::PublicParameter, sk: &A::SigningKey, msg: M, prng: &mut R, ) -> Result<A::Signature, SignatureError>
Produces a partial signature on a message with a single user signing key NOTE: the original message (vote) should be prefixed with the hash of the stake table.
agg_sig_pp
- public parameters for aggregate signaturemessage
- message to be signedsk
- user signing keyreturns
- a “simple” signature
§Errors
Should return error if the underlying signature scheme fail to sign.