From 5a1e34546d7a666a6e690b8fce648b60d97b5579 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Tue, 26 Nov 2019 15:05:48 -0800 Subject: [PATCH 1/3] Update rand_core, curve25519-dalek, merlin versions. --- Cargo.toml | 10 +++++----- tests/range_proof.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a81e8e6a..438b163b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,24 +12,24 @@ keywords = ["cryptography", "crypto", "ristretto", "zero-knowledge", "bulletproo description = "A pure-Rust implementation of Bulletproofs using Ristretto" [dependencies] -curve25519-dalek = { version = "^1.2.3", default-features = false, features = ["u64_backend", "nightly", "serde", "alloc"] } +curve25519-dalek = { version = "2", default-features = false, features = ["u64_backend", "nightly", "serde", "alloc"] } subtle = { version = "2", default-features = false } sha3 = { version = "0.8", default-features = false } digest = { version = "0.8", default-features = false } -rand_core = { version = "0.4", default-features = false, features = ["alloc"] } -rand = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.5", default-features = false, features = ["alloc"] } +rand = { version = "0.7", default-features = false, optional = true } byteorder = { version = "1", default-features = false } serde = { version = "1", default-features = false, features = ["alloc"] } serde_derive = { version = "1", default-features = false } failure = { version = "0.1", default-features = false, features = ["derive"] } -merlin = { version = "1.2", default-features = false } +merlin = { version = "2", default-features = false } clear_on_drop = { version = "0.2", default-features = false, features = ["nightly"] } [dev-dependencies] hex = "0.3" criterion = "0.2" bincode = "1" -rand_chacha = "0.1" +rand_chacha = "0.2" [features] default = ["std", "avx2_backend"] diff --git a/tests/range_proof.rs b/tests/range_proof.rs index 339440f3..3e60d7ad 100644 --- a/tests/range_proof.rs +++ b/tests/range_proof.rs @@ -1,5 +1,5 @@ -extern crate rand; -use rand::SeedableRng; +extern crate rand_core; +use rand_core::SeedableRng; extern crate rand_chacha; use rand_chacha::ChaChaRng; From af6d51e6bdb175885f5dd4aac5c256d6dde29f08 Mon Sep 17 00:00:00 2001 From: Oleg Andreev Date: Thu, 12 Dec 2019 21:44:23 +0100 Subject: [PATCH 2/3] fix benchmarks --- Cargo.toml | 2 +- benches/r1cs.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 438b163b..5a655aae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ clear_on_drop = { version = "0.2", default-features = false, features = ["nightl [dev-dependencies] hex = "0.3" -criterion = "0.2" +criterion = "0.3" bincode = "1" rand_chacha = "0.2" diff --git a/benches/r1cs.rs b/benches/r1cs.rs index c4dade19..67dc2d8a 100644 --- a/benches/r1cs.rs +++ b/benches/r1cs.rs @@ -23,7 +23,8 @@ use bulletproofs::{BulletproofGens, PedersenGens}; use curve25519_dalek::ristretto::CompressedRistretto; use curve25519_dalek::scalar::Scalar; use merlin::Transcript; -use rand::{thread_rng, Rng}; +use rand::{Rng}; +use rand::seq::SliceRandom; // Shuffle gadget (documented in markdown file) @@ -177,7 +178,7 @@ fn bench_kshuffle_prove(c: &mut Criterion) { .map(|_| Scalar::from(rng.gen_range(min, max))) .collect(); let mut output = input.clone(); - rand::thread_rng().shuffle(&mut output); + output.shuffle(&mut rand::thread_rng()); // Make kshuffle proof b.iter(|| { @@ -219,7 +220,7 @@ fn bench_kshuffle_verify(c: &mut Criterion) { .map(|_| Scalar::from(rng.gen_range(min, max))) .collect(); let mut output = input.clone(); - rand::thread_rng().shuffle(&mut output); + output.shuffle(&mut rand::thread_rng()); let mut prover_transcript = Transcript::new(b"ShuffleBenchmark"); From 194787b334aa0648a3f149c334853ae80b095b92 Mon Sep 17 00:00:00 2001 From: Oleg Andreev Date: Thu, 12 Dec 2019 22:32:56 +0100 Subject: [PATCH 3/3] moar fixes --- benches/r1cs.rs | 2 +- tests/r1cs.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/benches/r1cs.rs b/benches/r1cs.rs index 67dc2d8a..356a6527 100644 --- a/benches/r1cs.rs +++ b/benches/r1cs.rs @@ -23,8 +23,8 @@ use bulletproofs::{BulletproofGens, PedersenGens}; use curve25519_dalek::ristretto::CompressedRistretto; use curve25519_dalek::scalar::Scalar; use merlin::Transcript; -use rand::{Rng}; use rand::seq::SliceRandom; +use rand::Rng; // Shuffle gadget (documented in markdown file) diff --git a/tests/r1cs.rs b/tests/r1cs.rs index 0e3680cb..93daefbe 100644 --- a/tests/r1cs.rs +++ b/tests/r1cs.rs @@ -10,6 +10,7 @@ use bulletproofs::{BulletproofGens, PedersenGens}; use curve25519_dalek::ristretto::CompressedRistretto; use curve25519_dalek::scalar::Scalar; use merlin::Transcript; +use rand::seq::SliceRandom; use rand::thread_rng; // Shuffle gadget (documented in markdown file) @@ -157,7 +158,7 @@ fn kshuffle_helper(k: usize) { .map(|_| Scalar::from(rng.gen_range(min, max))) .collect(); let mut output = input.clone(); - rand::thread_rng().shuffle(&mut output); + output.shuffle(&mut rand::thread_rng()); let mut prover_transcript = Transcript::new(b"ShuffleProofTest"); ShuffleProof::prove(&pc_gens, &bp_gens, &mut prover_transcript, &input, &output).unwrap() @@ -401,10 +402,10 @@ pub fn range_proof( #[test] fn range_proof_gadget() { - use rand::rngs::OsRng; + use rand::thread_rng; use rand::Rng; - let mut rng = OsRng::new().unwrap(); + let mut rng = thread_rng(); let m = 3; // number of values to test per `n` for n in [2, 10, 32, 63].iter() {