pub trait SignatureKey:
Send
+ Sync
+ Clone
+ Sized
+ Debug
+ Hash
+ Serialize
+ for<'a> Deserialize<'a>
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Display
+ ToFieldsLightClientCompat
+ for<'a> TryFrom<&'a TaggedBase64>
+ Into<TaggedBase64> {
type PrivateKey: PrivateSignatureKey;
type StakeTableEntry: StakeTableEntryType<Self> + Send + Sync + Sized + Clone + Debug + Hash + Eq + Serialize + for<'a> Deserialize<'a>;
type QcParams<'a>: Send + Sync + Sized + Clone + Debug + Hash;
type PureAssembledSignatureType: Send + Sync + Sized + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a> + Into<TaggedBase64> + for<'a> TryFrom<&'a TaggedBase64>;
type QcType: Send + Sync + Sized + 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: U256) -> Self::StakeTableEntry;
fn public_key(entry: &Self::StakeTableEntry) -> Self;
fn public_parameter(
stake_entries: &[Self::StakeTableEntry],
threshold: U256,
) -> Self::QcParams<'_>;
fn check(
real_qc_pp: &Self::QcParams<'_>,
data: &[u8],
qc: &Self::QcType,
) -> Result<(), SignatureError>;
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§
Sourcetype PrivateKey: PrivateSignatureKey
type PrivateKey: PrivateSignatureKey
The private key type for this signature algorithm
Sourcetype StakeTableEntry: StakeTableEntryType<Self> + Send + Sync + Sized + Clone + Debug + Hash + Eq + Serialize + for<'a> Deserialize<'a>
type StakeTableEntry: StakeTableEntryType<Self> + Send + Sync + Sized + Clone + Debug + Hash + Eq + Serialize + for<'a> Deserialize<'a>
The type of the entry that contain both public key and stake value
Sourcetype QcParams<'a>: Send + Sync + Sized + Clone + Debug + Hash
type QcParams<'a>: Send + Sync + Sized + Clone + Debug + Hash
The type of the quorum certificate parameters used for assembled signature
Sourcetype PureAssembledSignatureType: Send + Sync + Sized + Clone + Debug + Hash + PartialEq + Eq + Serialize + for<'a> Deserialize<'a> + Into<TaggedBase64> + for<'a> TryFrom<&'a TaggedBase64>
type PureAssembledSignatureType: Send + Sync + Sized + 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
Required Methods§
Sourcefn validate(
&self,
signature: &Self::PureAssembledSignatureType,
data: &[u8],
) -> bool
fn validate( &self, signature: &Self::PureAssembledSignatureType, data: &[u8], ) -> bool
Validate a signature
Sourcefn sign(
private_key: &Self::PrivateKey,
data: &[u8],
) -> Result<Self::PureAssembledSignatureType, Self::SignError>
fn sign( private_key: &Self::PrivateKey, data: &[u8], ) -> Result<Self::PureAssembledSignatureType, Self::SignError>
Sourcefn from_private(private_key: &Self::PrivateKey) -> Self
fn from_private(private_key: &Self::PrivateKey) -> Self
Produce a public key from a private key
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self, SerializationError>
fn from_bytes(bytes: &[u8]) -> Result<Self, SerializationError>
Sourcefn generated_from_seed_indexed(
seed: [u8; 32],
index: u64,
) -> (Self, Self::PrivateKey)
fn generated_from_seed_indexed( seed: [u8; 32], index: u64, ) -> (Self, Self::PrivateKey)
Generate a new key pair
Sourcefn stake_table_entry(&self, stake: U256) -> Self::StakeTableEntry
fn stake_table_entry(&self, stake: U256) -> Self::StakeTableEntry
get the stake table entry from the public key and stake value
Sourcefn public_key(entry: &Self::StakeTableEntry) -> Self
fn public_key(entry: &Self::StakeTableEntry) -> Self
only get the public key from the stake table entry
Sourcefn public_parameter(
stake_entries: &[Self::StakeTableEntry],
threshold: U256,
) -> Self::QcParams<'_>
fn public_parameter( stake_entries: &[Self::StakeTableEntry], threshold: U256, ) -> Self::QcParams<'_>
get the public parameter for the assembled signature checking
Sourcefn check(
real_qc_pp: &Self::QcParams<'_>,
data: &[u8],
qc: &Self::QcType,
) -> Result<(), SignatureError>
fn check( real_qc_pp: &Self::QcParams<'_>, data: &[u8], qc: &Self::QcType, ) -> Result<(), SignatureError>
check the quorum certificate for the assembled signature, returning Ok(())
if it is valid.
§Errors
Returns an error if the signature key fails to validate
Sourcefn sig_proof(
signature: &Self::QcType,
) -> (Self::PureAssembledSignatureType, BitVec)
fn sig_proof( signature: &Self::QcType, ) -> (Self::PureAssembledSignatureType, BitVec)
get the assembled signature and the BitVec
separately from the assembled signature
Sourcefn assemble(
real_qc_pp: &Self::QcParams<'_>,
signers: &BitSlice,
sigs: &[Self::PureAssembledSignatureType],
) -> Self::QcType
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
Sourcefn genesis_proposer_pk() -> Self
fn genesis_proposer_pk() -> Self
generates the genesis public key. Meant to be dummy/filler
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.