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§
sourcefn hash_blake2b(&self, data: &[u8]) -> [u8; 32]
fn hash_blake2b(&self, data: &[u8]) -> [u8; 32]
Hashes input data using blake2b with 256 bit output.
sourcefn hash(&self, hasher: SupportedHashes, data: &[u8]) -> Vec<u8> ⓘ
fn hash(&self, hasher: SupportedHashes, data: &[u8]) -> Vec<u8> ⓘ
Hashes input data using a supported hash function.
sourcefn hash_64(&self, hasher: SupportedHashes, data: &[u8]) -> ([u8; 64], usize)
fn hash_64(&self, hasher: SupportedHashes, data: &[u8]) -> ([u8; 64], usize)
Hashes input into a 64 byte buffer
sourcefn compute_unsealed_sector_cid(
&self,
proof_type: RegisteredSealProof,
pieces: &[PieceInfo],
) -> Result<Cid, Error>
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.
sourcefn verify_signature(
&self,
signature: &Signature,
signer: &Address,
plaintext: &[u8],
) -> Result<(), Error>
fn verify_signature( &self, signature: &Signature, signer: &Address, plaintext: &[u8], ) -> Result<(), Error>
Verifies that a signature is valid for an address and plaintext.
fn recover_secp_public_key( &self, hash: &[u8; 32], signature: &[u8; 65], ) -> Result<[u8; 65], Error>
sourcefn verify_post(&self, verify_info: &WindowPoStVerifyInfo) -> Result<(), Error>
fn verify_post(&self, verify_info: &WindowPoStVerifyInfo) -> Result<(), Error>
Verifies a window proof of spacetime.
sourcefn verify_consensus_fault(
&self,
h1: &[u8],
h2: &[u8],
extra: &[u8],
) -> Result<Option<ConsensusFault>, Error>
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.