Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rust/src/host_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub trait HostFunctionsProvider {
/// The SHA-512 hash algorithm
fn sha2_512(message: &[u8]) -> [u8; 64];

/// The SHA-512 hash algorithm with its output truncated to 256 bits.
fn sha2_512_truncated(message: &[u8]) -> [u8; 32];
/// The SHA2-512/256 hash algorithm.
fn sha2_512_256(message: &[u8]) -> [u8; 32];

/// The Keccak-256 hash function.
fn keccak_256(message: &[u8]) -> [u8; 32];
Expand Down Expand Up @@ -51,7 +51,7 @@ pub mod host_functions_impl {
buf
}

fn sha2_512_truncated(message: &[u8]) -> [u8; 32] {
fn sha2_512_256(message: &[u8]) -> [u8; 32] {
let digest = Sha512_256::digest(message);
let mut buf = [0u8; 32];
buf.copy_from_slice(&digest);
Expand Down
2 changes: 1 addition & 1 deletion rust/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) fn do_hash<H: HostFunctionsProvider>(hash: HashOp, data: &[u8]) -> Ha
HashOp::Keccak256 => Hash::from(H::keccak_256(data)),
HashOp::Ripemd160 => Hash::from(H::ripemd160(data)),
HashOp::Bitcoin => Hash::from(H::ripemd160(&H::sha2_256(data)[..])),
HashOp::Sha512256 => Hash::from(H::sha2_512_truncated(data)),
HashOp::Sha512256 => Hash::from(H::sha2_512_256(data)),
HashOp::Blake2b512 => Hash::from(H::blake2b_512(data)),
HashOp::Blake2s256 => Hash::from(H::blake2s_256(data)),
HashOp::Blake3 => Hash::from(H::blake3(data)),
Expand Down