mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-07 14:54:10 +00:00
Switch to using the blake2-rfc crate instead.
This commit is contained in:
parent
2e846844e7
commit
058801bdfc
@ -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"
|
||||
|
||||
|
@ -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<u8> = (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::<Bls12>::new();
|
||||
|
||||
|
@ -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<E: Engine>(
|
||||
|
||||
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<E: Engine>(
|
||||
|
||||
coeff.into_repr().write_be(&mut buf[9..]).unwrap();
|
||||
|
||||
h.process(&buf);
|
||||
h.update(&buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,14 +230,14 @@ impl<E: Engine> TestConstraintSystem<E> {
|
||||
}
|
||||
|
||||
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<E: Engine> TestConstraintSystem<E> {
|
||||
}
|
||||
|
||||
let mut s = String::new();
|
||||
for b in h.fixed_result().as_ref() {
|
||||
for b in h.finalize().as_ref() {
|
||||
s += &format!("{:02x}", b);
|
||||
}
|
||||
|
||||
|
@ -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<E: JubjubEngine>(
|
||||
// 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
|
||||
|
@ -1,6 +1,6 @@
|
||||
extern crate pairing;
|
||||
extern crate bellman;
|
||||
extern crate blake2;
|
||||
extern crate blake2_rfc;
|
||||
extern crate digest;
|
||||
extern crate rand;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user