From 4272cfa5b0dceac471bef115955e1534be84a018 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 6 Jul 2018 21:51:22 +0100 Subject: [PATCH] =?UTF-8?q?Make=20pairing=20and=20groth16=20optional=20?= =?UTF-8?q?=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 9 ++++++++- src/domain.rs | 3 +++ src/lib.rs | 2 ++ src/multiexp.rs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8abf83e..3a77fea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,13 @@ byteorder = "1" [dependencies.pairing] git = "https://github.com/str4d/pairing" rev = "3d41ee5abaa4888ff3607689aba007be8856816d" +optional = true [features] -default = [] +groth16 = ["pairing"] +default = ["groth16"] + +[[test]] +name = "mimc" +path = "tests/mimc.rs" +required-features = ["groth16"] diff --git a/src/domain.rs b/src/domain.rs index 87a8240..4606ce5 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -371,6 +371,7 @@ fn parallel_fft>( // Test multiplying various (low degree) polynomials together and // comparing with naive evaluations. +#[cfg(feature = "pairing")] #[test] fn polynomial_arith() { use pairing::bls12_381::Bls12; @@ -418,6 +419,7 @@ fn polynomial_arith() { test_mul::(rng); } +#[cfg(feature = "pairing")] #[test] fn fft_composition() { use pairing::bls12_381::Bls12; @@ -456,6 +458,7 @@ fn fft_composition() { test_comp::(rng); } +#[cfg(feature = "pairing")] #[test] fn parallel_fft_consistency() { use pairing::bls12_381::Bls12; diff --git a/src/lib.rs b/src/lib.rs index 42eccea..f6d7163 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ extern crate ff; extern crate group; +#[cfg(feature = "pairing")] extern crate pairing; extern crate rand; extern crate num_cpus; @@ -12,6 +13,7 @@ extern crate byteorder; pub mod multicore; mod multiexp; pub mod domain; +#[cfg(feature = "groth16")] pub mod groth16; use ff::{Field, ScalarEngine}; diff --git a/src/multiexp.rs b/src/multiexp.rs index cea13f3..d24572b 100644 --- a/src/multiexp.rs +++ b/src/multiexp.rs @@ -255,6 +255,7 @@ pub fn multiexp( multiexp_inner(pool, bases, density_map, exponents, 0, c, true) } +#[cfg(feature = "pairing")] #[test] fn test_with_bls12() { fn naive_multiexp(