From 1da255e5131f84ff8e8e991e4a70f1c802ba5a70 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 8 Dec 2023 15:16:41 +0000 Subject: [PATCH] Add hash blake2b512 --- examples/hash-bench.js | 1 + src/host_functions/hash.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/hash-bench.js b/examples/hash-bench.js index a7b962a..b5a071c 100644 --- a/examples/hash-bench.js +++ b/examples/hash-bench.js @@ -13,3 +13,4 @@ bench("sha256", iterations); bench("keccak256", iterations); bench("blake2b128", iterations); bench("blake2b256", iterations); +bench("blake2b512", iterations); diff --git a/src/host_functions/hash.rs b/src/host_functions/hash.rs index f27cad9..003defd 100644 --- a/src/host_functions/hash.rs +++ b/src/host_functions/hash.rs @@ -1,7 +1,7 @@ use super::Result; use anyhow::bail; use blake2::{ - digest::typenum::{U16, U32}, + digest::typenum::{U16, U32, U64}, Blake2b, Digest, }; use js::AsBytes; @@ -24,6 +24,7 @@ fn hash(algorithm: js::JsString, message: AsBytes>) -> Result do_hash::(message.0), "blake2b128" => do_hash::>(message.0), "blake2b256" => do_hash::>(message.0), + "blake2b512" => do_hash::>(message.0), _ => bail!("Unsupported hash algorithm: {}", algorithm.as_str()), }; Ok(hash.into())