diff --git a/Cargo.toml b/Cargo.toml index 637341706..ff2a2f8db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,4 @@ quickcheck = "0.8" derive_more = "0.15" bigint = "4" byteorder = "1" -blake2 = { package = "blake2-rfc", git = "https://github.com/gtank/blake2-rfc.git", rev = "7a5b5fc99ae483a0043db7547fb79a6fa44b88a9" } +blake2 = { package = "blake2b_simd", version = "0.5" } diff --git a/src/node_data.rs b/src/node_data.rs index dcc8ded09..0adc0f2f6 100644 --- a/src/node_data.rs +++ b/src/node_data.rs @@ -1,6 +1,6 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt, ByteOrder}; use bigint::U256; -use blake2::blake2b::Blake2b; +use blake2::Params as Blake2Params; pub const MAX_NODE_DATA_SIZE: usize = 32 + 4 + 4 + 4 + 4 + 32 + 32 + 32 + 9 + 9 + 9; // 171 @@ -23,10 +23,14 @@ pub struct NodeData { } fn blake2b_personal(personalization: &[u8], input: &[u8]) -> [u8; 32] { - let mut hasher = Blake2b::with_params(32, &[], &[], personalization); - hasher.update(input); + let hash_result = Blake2Params::new() + .hash_length(32) + .personal(personalization) + .to_state() + .update(input) + .finalize(); let mut result = [0u8; 32]; - result.copy_from_slice(hasher.finalize().as_bytes()); + result.copy_from_slice(hash_result.as_bytes()); result }