Trait hotshot::types::SignatureKey

source ·
pub trait SignatureKey:
    Sized
    + Send
    + Sync
    + Clone
    + Debug
    + Hash
    + Serialize
    + for<'a> Deserialize<'a>
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Display
    + for<'a> TryFrom<&'a TaggedBase64>
    + Into<TaggedBase64> {
    type PrivateKey: PrivateSignatureKey;
    type StakeTableEntry: StakeTableEntryType<Self> + Send + Sync + Clone + Debug + Hash + Eq + Serialize + for<'a> Deserialize<'a>;
    type QcParams: Send + Sync + Clone + Debug + Hash;
    type PureAssembledSignatureType: Send + Sync + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a> + Into<TaggedBase64> + for<'a> TryFrom<&'a TaggedBase64>;
    type QcType: Send + Sync + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a>;
    type SignError: Error + Send + Sync;

Show 13 methods // Required methods fn validate( &self, signature: &Self::PureAssembledSignatureType, data: &[u8], ) -> bool; fn sign( private_key: &Self::PrivateKey, data: &[u8], ) -> Result<Self::PureAssembledSignatureType, Self::SignError>; fn from_private(private_key: &Self::PrivateKey) -> Self; fn to_bytes(&self) -> Vec<u8> ; fn from_bytes(bytes: &[u8]) -> Result<Self, SerializationError>; fn generated_from_seed_indexed( seed: [u8; 32], index: u64, ) -> (Self, Self::PrivateKey); fn stake_table_entry(&self, stake: u64) -> Self::StakeTableEntry; fn public_key(entry: &Self::StakeTableEntry) -> Self; fn public_parameter( stake_entries: Vec<Self::StakeTableEntry>, threshold: U256, ) -> Self::QcParams; fn check( real_qc_pp: &Self::QcParams, data: &[u8], qc: &Self::QcType, ) -> bool; fn sig_proof( signature: &Self::QcType, ) -> (Self::PureAssembledSignatureType, BitVec); fn assemble( real_qc_pp: &Self::QcParams, signers: &BitSlice, sigs: &[Self::PureAssembledSignatureType], ) -> Self::QcType; fn genesis_proposer_pk() -> Self;
}
Expand description

Trait for abstracting public key signatures Self is the public key type

Required Associated Types§

source

type PrivateKey: PrivateSignatureKey

The private key type for this signature algorithm

source

type StakeTableEntry: StakeTableEntryType<Self> + Send + Sync + Clone + Debug + Hash + Eq + Serialize + for<'a> Deserialize<'a>

The type of the entry that contain both public key and stake value

source

type QcParams: Send + Sync + Clone + Debug + Hash

The type of the quorum certificate parameters used for assembled signature

source

type PureAssembledSignatureType: Send + Sync + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a> + Into<TaggedBase64> + for<'a> TryFrom<&'a TaggedBase64>

The type of the assembled signature, without BitVec

source

type QcType: Send + Sync + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a>

The type of the assembled qc: assembled signature + BitVec

source

type SignError: Error + Send + Sync

Type of error that can occur when signing data

Required Methods§

source

fn validate( &self, signature: &Self::PureAssembledSignatureType, data: &[u8], ) -> bool

Validate a signature

source

fn sign( private_key: &Self::PrivateKey, data: &[u8], ) -> Result<Self::PureAssembledSignatureType, Self::SignError>

Produce a signature

§Errors

If unable to sign the data with the key

source

fn from_private(private_key: &Self::PrivateKey) -> Self

Produce a public key from a private key

source

fn to_bytes(&self) -> Vec<u8>

Serialize a public key to bytes

source

fn from_bytes(bytes: &[u8]) -> Result<Self, SerializationError>

Deserialize a public key from bytes

§Errors

Will return Err if deserialization fails

source

fn generated_from_seed_indexed( seed: [u8; 32], index: u64, ) -> (Self, Self::PrivateKey)

Generate a new key pair

source

fn stake_table_entry(&self, stake: u64) -> Self::StakeTableEntry

get the stake table entry from the public key and stake value

source

fn public_key(entry: &Self::StakeTableEntry) -> Self

only get the public key from the stake table entry

source

fn public_parameter( stake_entries: Vec<Self::StakeTableEntry>, threshold: U256, ) -> Self::QcParams

get the public parameter for the assembled signature checking

source

fn check(real_qc_pp: &Self::QcParams, data: &[u8], qc: &Self::QcType) -> bool

check the quorum certificate for the assembled signature

source

fn sig_proof( signature: &Self::QcType, ) -> (Self::PureAssembledSignatureType, BitVec)

get the assembled signature and the BitVec separately from the assembled signature

source

fn assemble( real_qc_pp: &Self::QcParams, signers: &BitSlice, sigs: &[Self::PureAssembledSignatureType], ) -> Self::QcType

assemble the signature from the partial signature and the indication of signers in BitVec

source

fn genesis_proposer_pk() -> Self

generates the genesis public key. Meant to be dummy/filler

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SignatureKey for VerKey

source§

type PrivateKey = SignKey

source§

type StakeTableEntry = StakeTableEntry<VerKey>

source§

type QcParams = QcParams<VerKey, <BLSOverBN254CurveSignatureScheme as SignatureScheme>::PublicParameter>

source§

type PureAssembledSignatureType = <BLSOverBN254CurveSignatureScheme as SignatureScheme>::Signature

source§

type QcType = (<VerKey as SignatureKey>::PureAssembledSignatureType, BitVec)

source§

type SignError = SignatureError

source§

fn validate( &self, signature: &<VerKey as SignatureKey>::PureAssembledSignatureType, data: &[u8], ) -> bool

source§

fn sign( sk: &<VerKey as SignatureKey>::PrivateKey, data: &[u8], ) -> Result<<VerKey as SignatureKey>::PureAssembledSignatureType, <VerKey as SignatureKey>::SignError>

source§

fn from_private(private_key: &<VerKey as SignatureKey>::PrivateKey) -> VerKey

source§

fn to_bytes(&self) -> Vec<u8>

source§

fn from_bytes(bytes: &[u8]) -> Result<VerKey, SerializationError>

source§

fn generated_from_seed_indexed( seed: [u8; 32], index: u64, ) -> (VerKey, <VerKey as SignatureKey>::PrivateKey)

source§

fn stake_table_entry( &self, stake: u64, ) -> <VerKey as SignatureKey>::StakeTableEntry

source§

fn public_key(entry: &<VerKey as SignatureKey>::StakeTableEntry) -> VerKey

source§

fn public_parameter( stake_entries: Vec<<VerKey as SignatureKey>::StakeTableEntry>, threshold: U256, ) -> <VerKey as SignatureKey>::QcParams

source§

fn check( real_qc_pp: &<VerKey as SignatureKey>::QcParams, data: &[u8], qc: &<VerKey as SignatureKey>::QcType, ) -> bool

source§

fn sig_proof( signature: &<VerKey as SignatureKey>::QcType, ) -> (<VerKey as SignatureKey>::PureAssembledSignatureType, BitVec)

source§

fn assemble( real_qc_pp: &<VerKey as SignatureKey>::QcParams, signers: &BitSlice, sigs: &[<VerKey as SignatureKey>::PureAssembledSignatureType], ) -> <VerKey as SignatureKey>::QcType

source§

fn genesis_proposer_pk() -> VerKey

Implementors§