Struct diem_types::validator_verifier::ValidatorVerifier [−][src]
pub struct ValidatorVerifier { /* fields omitted */ }
Expand description
Supports validation of signatures for known authors with individual voting powers. This struct can be used for all signature verification operations including block and network signature verification, respectively.
Implementations
pub fn new(
address_to_validator_info: BTreeMap<AccountAddress, ValidatorConsensusInfo>
) -> Self
pub fn new(
address_to_validator_info: BTreeMap<AccountAddress, ValidatorConsensusInfo>
) -> Self
Initialize with a map of account address to validator info and set quorum size to
default (2f + 1
) or zero if address_to_validator_info
is empty.
Helper method to initialize with a single author and public key with quorum voting power 1.
pub fn verify<T: Serialize + CryptoHash>(
&self,
author: AccountAddress,
message: &T,
signature: &Ed25519Signature
) -> Result<(), VerifyError>
pub fn verify<T: Serialize + CryptoHash>(
&self,
author: AccountAddress,
message: &T,
signature: &Ed25519Signature
) -> Result<(), VerifyError>
Verify the correctness of a signature of a message by a known author.
pub fn verify_aggregated_struct_signature<T: CryptoHash + Serialize>(
&self,
message: &T,
aggregated_signature: &BTreeMap<AccountAddress, Ed25519Signature>
) -> Result<(), VerifyError>
pub fn verify_aggregated_struct_signature<T: CryptoHash + Serialize>(
&self,
message: &T,
aggregated_signature: &BTreeMap<AccountAddress, Ed25519Signature>
) -> Result<(), VerifyError>
This function will successfully return when at least quorum_size signatures of known authors are successfully verified. Also, an aggregated signature is considered invalid if any of the attached signatures is invalid or it does not correspond to a known author. The latter is to prevent malicious users from adding arbitrary content to the signature payload that would go unnoticed.
pub fn batch_verify_aggregated_signatures<T: CryptoHash + Serialize>(
&self,
message: &T,
aggregated_signature: &BTreeMap<AccountAddress, Ed25519Signature>
) -> Result<(), VerifyError>
pub fn batch_verify_aggregated_signatures<T: CryptoHash + Serialize>(
&self,
message: &T,
aggregated_signature: &BTreeMap<AccountAddress, Ed25519Signature>
) -> Result<(), VerifyError>
This function will try batch signature verification and falls back to normal iterated verification if batching fails.
pub fn check_voting_power<'a>(
&self,
authors: impl Iterator<Item = &'a AccountAddress>
) -> Result<(), VerifyError>
pub fn check_voting_power<'a>(
&self,
authors: impl Iterator<Item = &'a AccountAddress>
) -> Result<(), VerifyError>
Ensure there is at least quorum_voting_power in the provided signatures and there are only known authors. According to the threshold verification policy, invalid public keys are not allowed.
Returns the public key for this address.
Returns the voting power for this address.
Returns an ordered list of account addresses as an Iterator
.
Returns quorum voting power.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for ValidatorVerifier
impl Send for ValidatorVerifier
impl Sync for ValidatorVerifier
impl Unpin for ValidatorVerifier
impl UnwindSafe for ValidatorVerifier
Blanket Implementations
Mutably borrows from an owned value. Read more
Generates a hash used only for tests.