Browse Source

Update digest requirement from 0.7 to 0.8 (#141)

* Update `digest` and `blake2` requirement from 0.7 to 0.8

Updates the requirements on [digest](https://github.com/RustCrypto/traits) to permit the latest version.
- [Release notes](https://github.com/RustCrypto/traits/releases)
- [Commits](https://github.com/RustCrypto/traits/compare/digest_v0.7.2...digest-v0.8.1)

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
master
dependabot-preview[bot] 4 years ago
committed by GitHub
parent
commit
9ca5a94f2e
5 changed files with 20 additions and 17 deletions
  1. +3
    -3
      .hooks/pre-commit
  2. +2
    -2
      cp-benches/Cargo.toml
  3. +2
    -2
      crypto-primitives/Cargo.toml
  4. +6
    -6
      crypto-primitives/src/prf/blake2s/constraints.rs
  5. +7
    -4
      crypto-primitives/src/prf/blake2s/mod.rs

+ 3
- 3
.hooks/pre-commit

@ -4,7 +4,7 @@ rustfmt --version &>/dev/null
if [ $? != 0 ]; then
printf "[pre_commit] \033[0;31merror\033[0m: \"rustfmt\" not available. \n"
printf "[pre_commit] \033[0;31merror\033[0m: rustfmt can be installed via - \n"
printf "[pre_commit] $ rustup component add rustfmt-preview \n"
printf "[pre_commit] $ rustup component add rustfmt \n"
exit 1
fi
@ -13,7 +13,7 @@ problem_files=()
# collect ill-formatted files
for file in $(git diff --name-only --cached); do
if [ ${file: -3} == ".rs" ]; then
rustfmt --check $file &>/dev/null
rustfmt +nightly --check $file &>/dev/null
if [ $? != 0 ]; then
problem_files+=($file)
fi
@ -33,4 +33,4 @@ else
done
fi
exit 0
exit 0

+ 2
- 2
cp-benches/Cargo.toml

@ -22,8 +22,8 @@ edition = "2018"
################################# Dependencies ################################
[dev-dependencies]
algebra = { path = "../algebra", default-features = false }
blake2 = { version = "0.7", default-features = false }
algebra = { path = "../algebra", default-features = false, features = [ "edwards_bls12" ] }
blake2 = { version = "0.8", default-features = false }
criterion = "0.3.1"
crypto-primitives = { path = "../crypto-primitives" }
rand = { version = "0.7" }

+ 2
- 2
crypto-primitives/Cargo.toml

@ -25,8 +25,8 @@ edition = "2018"
algebra-core = { path = "../algebra-core", default-features = false }
bench-utils = { path = "../bench-utils" }
blake2 = { version = "0.7", default-features = false }
digest = "0.7"
blake2 = { version = "0.8", default-features = false }
digest = "0.8"
ff-fft = { path = "../ff-fft", default-features = false }
gm17 = { path = "../gm17", optional = true, default-features = false }

+ 6
- 6
crypto-primitives/src/prf/blake2s/constraints.rs

@ -530,12 +530,11 @@ impl PRFGadget for Blake2sGadget
#[cfg(test)]
mod test {
use algebra::jubjub::Fq as Fr;
use digest::{FixedOutput, Input};
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use crate::prf::blake2s::{constraints::blake2s_gadget, Blake2s as B2SPRF};
use blake2::Blake2s;
use blake2::VarBlake2s;
use r1cs_core::ConstraintSystem;
use super::Blake2sGadget;
@ -634,13 +633,15 @@ mod test {
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
for input_len in (0..32).chain((32..256).filter(|a| a % 8 == 0)) {
let mut h = Blake2s::new_keyed(&[], 32);
use digest::*;
let mut h = VarBlake2s::new_keyed(&[], 32);
let data: Vec<u8> = (0..input_len).map(|_| rng.gen()).collect();
h.process(&data);
h.input(&data);
let hash_result = h.fixed_result();
let mut hash_result = Vec::with_capacity(h.output_size());
h.variable_result(|res| hash_result.extend_from_slice(res));
let mut cs = TestConstraintSystem::<Fr>::new();
@ -663,7 +664,6 @@ mod test {
assert!(cs.is_satisfied());
let mut s = hash_result
.as_ref()
.iter()
.flat_map(|&byte| (0..8).map(move |i| (byte >> i) & 1u8 == 1u8));

+ 7
- 4
crypto-primitives/src/prf/blake2s/mod.rs

@ -1,5 +1,5 @@
use alloc::vec::Vec;
use blake2::Blake2s as b2s;
use blake2::{Blake2s as B2s, VarBlake2s};
use digest::Digest;
use super::PRF;
@ -18,7 +18,7 @@ impl PRF for Blake2s {
fn evaluate(seed: &Self::Seed, input: &Self::Input) -> Result<Self::Output, CryptoError> {
let eval_time = start_timer!(|| "Blake2s::Eval");
let mut h = b2s::new();
let mut h = B2s::new();
h.input(seed.as_ref());
h.input(input.as_ref());
let mut result = [0u8; 32];
@ -80,10 +80,13 @@ impl Blake2sWithParameterBlock {
}
pub fn evaluate(&self, input: &[u8]) -> Vec<u8> {
use digest::*;
let eval_time = start_timer!(|| "Blake2sWithParameterBlock::Eval");
let mut h = b2s::with_parameter_block(&self.parameters());
let mut h = VarBlake2s::with_parameter_block(&self.parameters());
h.input(input.as_ref());
end_timer!(eval_time);
h.result().to_vec()
let mut buf = Vec::with_capacity(h.output_size());
h.variable_result(|res| buf.extend_from_slice(res));
buf
}
}

Loading…
Cancel
Save