From 13b9c6c6fef60de9a49c2b44d847ed44931eeb94 Mon Sep 17 00:00:00 2001 From: Pascal Berrang Date: Tue, 14 Apr 2020 10:33:33 +0200 Subject: [PATCH 1/3] Split FpParameters/PrimeField and add FFT related traits --- crypto-primitives/src/nizk/gm17/constraints.rs | 8 ++++---- crypto-primitives/src/nizk/groth16/constraints.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto-primitives/src/nizk/gm17/constraints.rs b/crypto-primitives/src/nizk/gm17/constraints.rs index 6f09608..02e6670 100644 --- a/crypto-primitives/src/nizk/gm17/constraints.rs +++ b/crypto-primitives/src/nizk/gm17/constraints.rs @@ -627,7 +627,7 @@ mod test_recursive { use super::*; use algebra::{ - fields::FpParameters, + fields::{FftParameters, FpParameters}, mnt4_298::{Fq as MNT4Fq, FqParameters as MNT4FqParameters, Fr as MNT4Fr, MNT4_298}, mnt6_298::{Fq as MNT6Fq, FqParameters as MNT6FqParameters, Fr as MNT6Fr, MNT6_298}, test_rng, BigInteger, PrimeField, @@ -735,7 +735,7 @@ mod test_recursive { // Allocate this byte array as input packed into field elements. let input_bytes = UInt8::alloc_input_vec(cs.ns(|| "Input"), &input_bytes[..])?; // 40 byte - let element_size = ::BigInt::NUM_LIMBS * 8; + let element_size = ::BigInt::NUM_LIMBS * 8; input_gadgets = input_bytes .chunks(element_size) .map(|chunk| { @@ -821,7 +821,7 @@ mod test_recursive { let mut input_gadgets = Vec::new(); { - let bigint_size = ::BigInt::NUM_LIMBS * 64; + let bigint_size = ::BigInt::NUM_LIMBS * 64; let mut input_bits = Vec::new(); let mut cs = cs.ns(|| "Allocate Input"); for (i, input) in inputs.into_iter().enumerate() { @@ -847,7 +847,7 @@ mod test_recursive { // Pack input bits into field elements of the underlying circuit. let max_size = 8 * (::CAPACITY / 8) as usize; let max_size = max_size as usize; - let bigint_size = ::BigInt::NUM_LIMBS * 64; + let bigint_size = ::BigInt::NUM_LIMBS * 64; for chunk in input_bits.chunks(max_size) { let mut chunk = chunk.to_vec(); let len = chunk.len(); diff --git a/crypto-primitives/src/nizk/groth16/constraints.rs b/crypto-primitives/src/nizk/groth16/constraints.rs index 49e07d7..ca13d90 100644 --- a/crypto-primitives/src/nizk/groth16/constraints.rs +++ b/crypto-primitives/src/nizk/groth16/constraints.rs @@ -570,7 +570,7 @@ mod test_recursive { use super::*; use algebra::{ - fields::FpParameters, + fields::{FftParameters, FpParameters}, mnt4_298::{Fq as MNT4Fq, FqParameters as MNT4FqParameters, Fr as MNT4Fr, MNT4_298}, mnt6_298::{Fq as MNT6Fq, FqParameters as MNT6FqParameters, Fr as MNT6Fr, MNT6_298}, test_rng, BigInteger, PrimeField, @@ -678,7 +678,7 @@ mod test_recursive { // Allocate this byte array as input packed into field elements. let input_bytes = UInt8::alloc_input_vec(cs.ns(|| "Input"), &input_bytes[..])?; // 40 byte - let element_size = ::BigInt::NUM_LIMBS * 8; + let element_size = ::BigInt::NUM_LIMBS * 8; input_gadgets = input_bytes .chunks(element_size) .map(|chunk| { @@ -764,7 +764,7 @@ mod test_recursive { let mut input_gadgets = Vec::new(); { - let bigint_size = ::BigInt::NUM_LIMBS * 64; + let bigint_size = ::BigInt::NUM_LIMBS * 64; let mut input_bits = Vec::new(); let mut cs = cs.ns(|| "Allocate Input"); for (i, input) in inputs.into_iter().enumerate() { @@ -790,7 +790,7 @@ mod test_recursive { // Pack input bits into field elements of the underlying circuit. let max_size = 8 * (::CAPACITY / 8) as usize; let max_size = max_size as usize; - let bigint_size = ::BigInt::NUM_LIMBS * 64; + let bigint_size = ::BigInt::NUM_LIMBS * 64; for chunk in input_bits.chunks(max_size) { let mut chunk = chunk.to_vec(); let len = chunk.len(); From 9455f00c01b7052a7f3c1602a20d51dbc5ecfd82 Mon Sep 17 00:00:00 2001 From: Pascal Berrang Date: Tue, 14 Apr 2020 13:58:14 +0200 Subject: [PATCH 2/3] Add benchmark for mixed-radix and radix-2 FFT resembling the Groth16 operations. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 92009fd..3814505 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "crypto-primitives", "dpc", "ff-fft", + "ff-fft-benches", "gm17", "groth16", "r1cs-core", From 3708a444a20264e179cfb6016fbb2af379a0746c Mon Sep 17 00:00:00 2001 From: Pascal Berrang Date: Mon, 20 Apr 2020 08:46:03 +0200 Subject: [PATCH 3/3] Give Travis more time --- crypto-primitives/src/nizk/gm17/constraints.rs | 2 +- crypto-primitives/src/nizk/groth16/constraints.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto-primitives/src/nizk/gm17/constraints.rs b/crypto-primitives/src/nizk/gm17/constraints.rs index 02e6670..7c0c2f5 100644 --- a/crypto-primitives/src/nizk/gm17/constraints.rs +++ b/crypto-primitives/src/nizk/gm17/constraints.rs @@ -762,7 +762,7 @@ mod test_recursive { #[test] fn gm17_recursive_verifier_test() { - let num_inputs = 100; + let num_inputs = 5; let num_constraints = num_inputs; let rng = &mut test_rng(); let mut inputs: Vec> = Vec::with_capacity(num_inputs); diff --git a/crypto-primitives/src/nizk/groth16/constraints.rs b/crypto-primitives/src/nizk/groth16/constraints.rs index ca13d90..dbf2dc8 100644 --- a/crypto-primitives/src/nizk/groth16/constraints.rs +++ b/crypto-primitives/src/nizk/groth16/constraints.rs @@ -705,7 +705,7 @@ mod test_recursive { #[test] fn groth16_recursive_verifier_test() { - let num_inputs = 100; + let num_inputs = 5; let num_constraints = num_inputs; let rng = &mut test_rng(); let mut inputs: Vec> = Vec::with_capacity(num_inputs);