pub trait Crypto: Send {
fn hash(&self, msg: Bytes) -> Hash;
fn sign(&self, hash: Hash) -> Result<Signature, Box<dyn Error + Send>>;
fn aggregate_signatures(
&self,
signatures: Vec<Signature>,
voters: Vec<Address>
) -> Result<Signature, Box<dyn Error + Send>>;
fn verify_signature(
&self,
signature: Signature,
hash: Hash,
voter: Address
) -> Result<(), Box<dyn Error + Send>>;
fn verify_aggregated_signature(
&self,
aggregate_signature: Signature,
msg_hash: Hash,
voters: Vec<Address>
) -> Result<(), Box<dyn Error + Send>>;
}
Expand description
Trait for some crypto methods.
Required Methods
Sign to the given hash by private key and return the signature if success.
Aggregate the given signatures into an aggregated signature according to the given bitmap.
Verify a signature and return the recovered address.