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§

source

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.

source

type QcVerifierParams: Serialize + for<'a> Deserialize<'a>

Public parameters for validating the QC E.g: verifying keys, stake table commitment

source

type MessageLength: ArrayLength<A::MessageUnit>

Allows to fix the size of the message at compilation time.

source

type Qc

Type of the actual quorum certificate object

source

type QuorumSize

Type of the quorum size (e.g. number of votes or accumulated weight of signatures)

Required Methods§

source

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 QC
  • signers - a bool vector indicating the list of verification keys corresponding to the set of partial signatures
  • sigs - 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.

source

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 QC
  • message - message to check the aggregated signature against
  • qc - quorum certificate
  • returns - 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.

source

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§

source

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 signature
  • message - message to be signed
  • sk - user signing key
  • returns - a “simple” signature
§Errors

Should return error if the underlying signature scheme fail to sign.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<A> QuorumCertificateScheme<A> for BitVectorQc<A>
where A: AggregateableSignatureSchemes + Serialize + for<'a> Deserialize<'a>, A::VerificationKey: SignatureKey,

source§

type QcProverParams = QcParams<<A as SignatureScheme>::VerificationKey, <A as SignatureScheme>::PublicParameter>

source§

type QcVerifierParams = QcParams<<A as SignatureScheme>::VerificationKey, <A as SignatureScheme>::PublicParameter>

source§

type Qc = (<A as SignatureScheme>::Signature, BitVec)

source§

type MessageLength = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

source§

type QuorumSize = U256