Trait HostFunctionsProvider
pub trait HostFunctionsProvider {
// Required methods
fn sha2_256(message: &[u8]) -> [u8; 32];
fn sha2_512(message: &[u8]) -> [u8; 64];
fn sha2_512_truncated(message: &[u8]) -> [u8; 32];
fn keccak_256(message: &[u8]) -> [u8; 32];
fn ripemd160(message: &[u8]) -> [u8; 20];
fn blake2b_512(message: &[u8]) -> [u8; 64];
fn blake2s_256(message: &[u8]) -> [u8; 32];
fn blake3(message: &[u8]) -> [u8; 32];
}
Expand description
If this is to be executed in a blockchain context, then we need to delegate these hashing functions to a native implementation through host function calls. This trait provides that interface.
Required Methods§
fn sha2_512_truncated(message: &[u8]) -> [u8; 32]
fn sha2_512_truncated(message: &[u8]) -> [u8; 32]
The SHA-512 hash algorithm with its output truncated to 256 bits.
fn keccak_256(message: &[u8]) -> [u8; 32]
fn keccak_256(message: &[u8]) -> [u8; 32]
The Keccak-256 hash function.
fn blake2b_512(message: &[u8]) -> [u8; 64]
fn blake2b_512(message: &[u8]) -> [u8; 64]
BLAKE2b-512 hash function.
fn blake2s_256(message: &[u8]) -> [u8; 32]
fn blake2s_256(message: &[u8]) -> [u8; 32]
BLAKE2s-256 hash function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.