Trait fil_actors_shared::v14::vm_api::Primitives

source ·
pub trait Primitives {
    // Required methods
    fn hash_blake2b(&self, data: &[u8]) -> [u8; 32];
    fn hash(&self, hasher: SupportedHashes, data: &[u8]) -> Vec<u8> ;
    fn hash_64(&self, hasher: SupportedHashes, data: &[u8]) -> ([u8; 64], usize);
    fn compute_unsealed_sector_cid(
        &self,
        proof_type: RegisteredSealProof,
        pieces: &[PieceInfo],
    ) -> Result<Cid, Error>;
    fn verify_signature(
        &self,
        signature: &Signature,
        signer: &Address,
        plaintext: &[u8],
    ) -> Result<(), Error>;
    fn recover_secp_public_key(
        &self,
        hash: &[u8; 32],
        signature: &[u8; 65],
    ) -> Result<[u8; 65], Error>;
    fn verify_post(
        &self,
        verify_info: &WindowPoStVerifyInfo,
    ) -> Result<(), Error>;
    fn verify_consensus_fault(
        &self,
        h1: &[u8],
        h2: &[u8],
        extra: &[u8],
    ) -> Result<Option<ConsensusFault>, Error>;
    fn batch_verify_seals(&self, batch: &[SealVerifyInfo]) -> Result<Vec<bool>>;
    fn verify_aggregate_seals(
        &self,
        aggregate: &AggregateSealVerifyProofAndInfos,
    ) -> Result<(), Error>;
    fn verify_replica_update(
        &self,
        replica: &ReplicaUpdateInfo,
    ) -> Result<(), Error>;
}
Expand description

Pure functions implemented as primitives by the runtime.

Required Methods§

source

fn hash_blake2b(&self, data: &[u8]) -> [u8; 32]

Hashes input data using blake2b with 256 bit output.

source

fn hash(&self, hasher: SupportedHashes, data: &[u8]) -> Vec<u8>

Hashes input data using a supported hash function.

source

fn hash_64(&self, hasher: SupportedHashes, data: &[u8]) -> ([u8; 64], usize)

Hashes input into a 64 byte buffer

source

fn compute_unsealed_sector_cid( &self, proof_type: RegisteredSealProof, pieces: &[PieceInfo], ) -> Result<Cid, Error>

Computes an unsealed sector CID (CommD) from its constituent piece CIDs (CommPs) and sizes.

source

fn verify_signature( &self, signature: &Signature, signer: &Address, plaintext: &[u8], ) -> Result<(), Error>

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

source

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

source

fn verify_post(&self, verify_info: &WindowPoStVerifyInfo) -> Result<(), Error>

Verifies a window proof of spacetime.

source

fn verify_consensus_fault( &self, h1: &[u8], h2: &[u8], extra: &[u8], ) -> Result<Option<ConsensusFault>, Error>

Verifies that two block headers provide proof of a consensus fault:

  • both headers mined by the same actor
  • headers are different
  • first header is of the same or lower epoch as the second
  • at least one of the headers appears in the current chain at or after epoch earliest
  • the headers provide evidence of a fault (see the spec for the different fault types).

The parameters are all serialized block headers. The third “extra” parameter is consulted only for the “parent grinding fault”, in which case it must be the sibling of h1 (same parent tipset) and one of the blocks in the parent of h2 (i.e. h2’s grandparent). Returns nil and an error if the headers don’t prove a fault.

source

fn batch_verify_seals(&self, batch: &[SealVerifyInfo]) -> Result<Vec<bool>>

source

fn verify_aggregate_seals( &self, aggregate: &AggregateSealVerifyProofAndInfos, ) -> Result<(), Error>

source

fn verify_replica_update( &self, replica: &ReplicaUpdateInfo, ) -> Result<(), Error>

Implementors§