From 657f45882c530c97b8fc0d2b0e3c4bc82296a765 Mon Sep 17 00:00:00 2001 From: Jeff Burdges Date: Tue, 19 Mar 2019 01:49:57 +0100 Subject: [PATCH] No need for Shak128 hre, but let's try to eliminate Sha2 --- vdf/src/proof_pietrzak.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vdf/src/proof_pietrzak.rs b/vdf/src/proof_pietrzak.rs index 786cecb..e5ab7c7 100644 --- a/vdf/src/proof_pietrzak.rs +++ b/vdf/src/proof_pietrzak.rs @@ -136,20 +136,21 @@ where for<'a, 'b> &'a T: std::ops::Mul<&'b T, Output = T>, for<'a, 'b> &'a T::BigNum: std::ops::Mul<&'b T::BigNum, Output = T::BigNum>, { - use sha2::{digest::FixedOutput, Digest, Sha256}; + use sha3::{digest::{Input, ExtendableOutput, XofReader}, Shake128}; let size = (int_size_bits + 16) >> 4; let mut v = Vec::with_capacity(size * 2); for _ in 0..size * 2 { v.push(0) } - let mut hasher = Sha256::new(); + let mut h = Shake128::default(); for i in &[&x, &y, &sqrt_mu] { i.serialize(&mut v).expect(super::INCORRECT_BUFFER_SIZE); - hasher.input(&v); + h.input(&v); } - let res = hasher.fixed_result(); - T::unsigned_deserialize_bignum(&res[..16]) + let mut res = [0u8; 16]; + h.xof_result().read(&mut res); + T::unsigned_deserialize_bignum(&res[..]) } fn create_proof_of_time_pietrzak(