From 02e6b32d7d8794e85ed8f34e02cc60cedb717ca0 Mon Sep 17 00:00:00 2001 From: howardwu Date: Sun, 16 Feb 2020 12:34:26 -0800 Subject: [PATCH] Cargo fmt --- .../benches/crypto_primitives/nizk.rs | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/crypto-primitives/benches/crypto_primitives/nizk.rs b/crypto-primitives/benches/crypto_primitives/nizk.rs index d449272..ac68acd 100644 --- a/crypto-primitives/benches/crypto_primitives/nizk.rs +++ b/crypto-primitives/benches/crypto_primitives/nizk.rs @@ -1,11 +1,7 @@ #[macro_use] extern crate criterion; -use algebra::{ - curves::bls12_377::Bls12_377, - fields::bls12_377::Fr, - Field, -}; +use algebra::{curves::bls12_377::Bls12_377, fields::bls12_377::Fr, Field}; use crypto_primitives::nizk::*; use r1cs_core::{ConstraintSynthesizer, ConstraintSystem, SynthesisError}; @@ -15,7 +11,7 @@ use rand::{thread_rng, Rng}; type TestProofSystem = Gm17, Fr>; struct Bench { - inputs: Vec>, + inputs: Vec>, num_constraints: usize, } @@ -40,8 +36,8 @@ impl ConstraintSynthesizer for Bench { let new_entry = { let (input_1_val, input_1_var) = variables[i]; let (input_2_val, input_2_var) = variables[i + 1]; - let result_val = input_1_val - .and_then(|input_1| input_2_val.map(|input_2| input_1 * &input_2)); + let result_val = + input_1_val.and_then(|input_1| input_2_val.map(|input_2| input_1 * &input_2)); let result_var = cs.alloc( || format!("Result {}", i), || result_val.ok_or(SynthesisError::AssignmentMissing), @@ -70,7 +66,16 @@ fn gm17_setup(c: &mut Criterion) { } c.bench_function("gm17_setup", move |b| { - b.iter(|| TestProofSystem::setup(Bench:: { inputs: vec![None; num_inputs], num_constraints }, rng).unwrap()) + b.iter(|| { + TestProofSystem::setup( + Bench:: { + inputs: vec![None; num_inputs], + num_constraints, + }, + rng, + ) + .unwrap() + }) }); } @@ -83,10 +88,27 @@ fn gm17_prove(c: &mut Criterion) { inputs.push(Some(rng.gen())); } - let params = TestProofSystem::setup(Bench:: { inputs: vec![None; num_inputs], num_constraints }, rng).unwrap(); + let params = TestProofSystem::setup( + Bench:: { + inputs: vec![None; num_inputs], + num_constraints, + }, + rng, + ) + .unwrap(); c.bench_function("gm17_prove", move |b| { - b.iter(|| TestProofSystem::prove(¶ms.0, Bench { inputs: inputs.clone(), num_constraints }, rng).unwrap()) + b.iter(|| { + TestProofSystem::prove( + ¶ms.0, + Bench { + inputs: inputs.clone(), + num_constraints, + }, + rng, + ) + .unwrap() + }) }); }