Skip to content

Commit

Permalink
switch to blake2_simd
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf committed Sep 24, 2019
1 parent 79cba2e commit 4cbc045
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
12 changes: 8 additions & 4 deletions src/node_data.rs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
}

Expand Down

0 comments on commit 4cbc045

Please sign in to comment.