diff --git a/Cargo.toml b/Cargo.toml index cdb161b..c20cb10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ features = ["expose-arith"] [dependencies] rand = "0.4" -blake2 = "0.7" +blake2-rfc = "0.2.18" digest = "0.7" bellman = "0.0.9" diff --git a/src/circuit/blake2s.rs b/src/circuit/blake2s.rs index 855a8c6..c46b243 100644 --- a/src/circuit/blake2s.rs +++ b/src/circuit/blake2s.rs @@ -313,8 +313,7 @@ mod test { use ::circuit::test::TestConstraintSystem; use super::blake2s; use bellman::{ConstraintSystem}; - use blake2::{Blake2s}; - use digest::{FixedOutput, Input}; + use blake2_rfc::blake2s::Blake2s; #[test] fn test_blake2s_constraints() { @@ -357,13 +356,13 @@ mod test { for input_len in (0..32).chain((32..256).filter(|a| a % 8 == 0)) { - let mut h = Blake2s::new_keyed(&[], 32); + let mut h = Blake2s::new(32); let data: Vec = (0..input_len).map(|_| rng.gen()).collect(); - h.process(&data); + h.update(&data); - let hash_result = h.fixed_result(); + let hash_result = h.finalize(); let mut cs = TestConstraintSystem::::new(); diff --git a/src/circuit/test/mod.rs b/src/circuit/test/mod.rs index e7f7515..01fda4a 100644 --- a/src/circuit/test/mod.rs +++ b/src/circuit/test/mod.rs @@ -16,12 +16,12 @@ use bellman::{ use std::collections::HashMap; use std::fmt::Write; -use blake2::{Blake2s}; -use digest::{FixedOutput, Input}; use byteorder::{BigEndian, ByteOrder}; use std::cmp::Ordering; use std::collections::BTreeMap; +use blake2_rfc::blake2s::Blake2s; + #[derive(Debug)] enum NamedObject { Constraint(usize), @@ -107,7 +107,7 @@ fn hash_lc( let mut buf = [0u8; 9 + 32]; BigEndian::write_u64(&mut buf[0..8], map.len() as u64); - h.process(&buf[0..8]); + h.update(&buf[0..8]); for (var, coeff) in map { match var.0.get_unchecked() { @@ -123,7 +123,7 @@ fn hash_lc( coeff.into_repr().write_be(&mut buf[9..]).unwrap(); - h.process(&buf); + h.update(&buf); } } @@ -230,14 +230,14 @@ impl TestConstraintSystem { } pub fn hash(&self) -> String { - let mut h = Blake2s::new_keyed(&[], 32); + let mut h = Blake2s::new(32); { let mut buf = [0u8; 24]; BigEndian::write_u64(&mut buf[0..8], self.inputs.len() as u64); BigEndian::write_u64(&mut buf[8..16], self.aux.len() as u64); BigEndian::write_u64(&mut buf[16..24], self.constraints.len() as u64); - h.process(&buf); + h.update(&buf); } for constraint in &self.constraints { @@ -247,7 +247,7 @@ impl TestConstraintSystem { } let mut s = String::new(); - for b in h.fixed_result().as_ref() { + for b in h.finalize().as_ref() { s += &format!("{:02x}", b); } diff --git a/src/group_hash.rs b/src/group_hash.rs index 01824c8..04faecb 100644 --- a/src/group_hash.rs +++ b/src/group_hash.rs @@ -1,7 +1,6 @@ use jubjub::*; use pairing::*; -use blake2::{Blake2s}; -use digest::{FixedOutput, Input}; +use blake2_rfc::blake2s::Blake2s; /// Produces an (x, y) pair (Montgomery) for a /// random point in the Jubjub curve. The point @@ -15,9 +14,9 @@ pub fn group_hash( // Check to see that scalar field is 255 bits assert!(E::Fr::NUM_BITS == 255); - let mut h = Blake2s::new_keyed(&[], 32); - h.process(tag); - let mut h = h.fixed_result().to_vec(); + let mut h = Blake2s::new(32); + h.update(tag); + let mut h = h.finalize().as_ref().to_vec(); assert!(h.len() == 32); // Take first/unset first bit of hash diff --git a/src/lib.rs b/src/lib.rs index 4a08bf9..8501bde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ extern crate pairing; extern crate bellman; -extern crate blake2; +extern crate blake2_rfc; extern crate digest; extern crate rand;