Trait forest_filecoin::shim::fvm_latest::kernel::prelude::CryptoOps

source ·
pub trait CryptoOps {
    // Required methods
    fn verify_signature(
        &self,
        sig_type: SignatureType,
        signature: &[u8],
        signer: &Address,
        plaintext: &[u8],
    ) -> Result<bool, ExecutionError>;
    fn verify_bls_aggregate(
        &self,
        aggregate_sig: &[u8; 96],
        pub_keys: &[[u8; 48]],
        plaintexts_concat: &[u8],
        plaintext_lens: &[u32],
    ) -> Result<bool, ExecutionError>;
    fn recover_secp_public_key(
        &self,
        hash: &[u8; 32],
        signature: &[u8; 65],
    ) -> Result<[u8; 65], ExecutionError>;
    fn hash(
        &self,
        code: u64,
        data: &[u8],
    ) -> Result<Multihash<64>, ExecutionError>;
}
Expand description

Cryptographic primitives provided by the kernel.

Required Methods§

source

fn verify_signature( &self, sig_type: SignatureType, signature: &[u8], signer: &Address, plaintext: &[u8], ) -> Result<bool, ExecutionError>

Verifies that a signature is valid for an address and plaintext.

source

fn verify_bls_aggregate( &self, aggregate_sig: &[u8; 96], pub_keys: &[[u8; 48]], plaintexts_concat: &[u8], plaintext_lens: &[u32], ) -> Result<bool, ExecutionError>

Verifies a BLS aggregate signature. In the case where there is one signer/signed plaintext, this is equivalent to verifying a non-aggregated BLS signature.

Returns:

  • Ok(true) on a valid signature.
  • Ok(false) on an invalid signature or if the signature or public keys’ bytes represent an invalid curve point.
  • Err(IllegalArgument) if pub_keys.len() != plaintexts.len().
source

fn recover_secp_public_key( &self, hash: &[u8; 32], signature: &[u8; 65], ) -> Result<[u8; 65], ExecutionError>

Given a message hash and its signature, recovers the public key of the signer.

source

fn hash(&self, code: u64, data: &[u8]) -> Result<Multihash<64>, ExecutionError>

Hashes input data_in using with the specified hash function, writing the output to digest_out, returning the size of the digest written to digest_out. If digest_out is to small to fit the entire digest, it will be truncated. If too large, the leftover space will not be overwritten.

Implementors§