diff --git a/src/gates/arithmetic.rs b/src/gates/arithmetic.rs index 4a2f63b7..f24ea7c1 100644 --- a/src/gates/arithmetic.rs +++ b/src/gates/arithmetic.rs @@ -142,13 +142,14 @@ impl SimpleGenerator for ArithmeticGenerator { } } -// #[cfg(test)] -// mod tests { -// use crate::{test_gate_low_degree, ArithmeticGate, Tweedledum}; -// -// test_gate_low_degree!( -// low_degree_ArithmeticGate, -// Tweedledum, -// ArithmeticGate -// ); -// } +#[cfg(test)] +mod tests { + use crate::field::crandall_field::CrandallField; + use crate::gates::arithmetic::ArithmeticGate; + use crate::gates::gate_testing::test_low_degree; + + #[test] + fn low_degree() { + test_low_degree(ArithmeticGate::new::()) + } +} diff --git a/src/gates/constant.rs b/src/gates/constant.rs index 8482a6de..a0a7685e 100644 --- a/src/gates/constant.rs +++ b/src/gates/constant.rs @@ -89,3 +89,15 @@ impl SimpleGenerator for ConstantGenerator { PartialWitness::singleton_target(Target::Wire(wire), self.constant) } } + +#[cfg(test)] +mod tests { + use crate::field::crandall_field::CrandallField; + use crate::gates::constant::ConstantGate; + use crate::gates::gate_testing::test_low_degree; + + #[test] + fn low_degree() { + test_low_degree(ConstantGate::get::()) + } +} diff --git a/src/gates/gate_testing.rs b/src/gates/gate_testing.rs index 2b0cb84b..b7a62c7e 100644 --- a/src/gates/gate_testing.rs +++ b/src/gates/gate_testing.rs @@ -1,5 +1,5 @@ use crate::field::field::Field; -use crate::gates::gate::Gate; +use crate::gates::gate::{Gate, GateRef}; use crate::polynomial::polynomial::{PolynomialCoeffs, PolynomialValues}; use crate::util::{log2_ceil, transpose}; use crate::vars::EvaluationVars; @@ -9,7 +9,8 @@ const WITNESS_DEGREE: usize = WITNESS_SIZE - 1; /// Tests that the constraints imposed by the given gate are low-degree by applying them to random /// low-degree witness polynomials. -pub(crate) fn test_low_degree>(gate: G) { +pub(crate) fn test_low_degree(gate: GateRef) { + let gate = gate.0; let rate_bits = log2_ceil(gate.degree() + 1); let wire_ldes = random_low_degree_matrix(gate.num_wires(), rate_bits); diff --git a/src/gates/gmimc.rs b/src/gates/gmimc.rs index de957deb..8263c46a 100644 --- a/src/gates/gmimc.rs +++ b/src/gates/gmimc.rs @@ -349,6 +349,7 @@ mod tests { use crate::gmimc::gmimc_permute_naive; use crate::wire::Wire; use crate::witness::PartialWitness; + use crate::gates::gate_testing::test_low_degree; #[test] fn generated_output() { @@ -411,4 +412,14 @@ mod tests { }); assert_eq!(acc_new, F::from_canonical_usize(7 * 2)); } + + #[test] + fn low_degree() { + type F = CrandallField; + const R: usize = 101; + let constants = Arc::new([F::TWO; R]); + type Gate = GMiMCGate; + let gate = Gate::with_constants(constants); + test_low_degree(gate) + } } diff --git a/src/gates/gmimc_eval.rs b/src/gates/gmimc_eval.rs index 413ccd70..57d9206c 100644 --- a/src/gates/gmimc_eval.rs +++ b/src/gates/gmimc_eval.rs @@ -1,3 +1,5 @@ +use std::marker::PhantomData; + use crate::circuit_builder::CircuitBuilder; use crate::field::field::Field; use crate::gates::gate::{Gate, GateRef}; @@ -6,7 +8,6 @@ use crate::target::Target; use crate::vars::{EvaluationTargets, EvaluationVars}; use crate::wire::Wire; use crate::witness::PartialWitness; -use std::marker::PhantomData; /// Performs some arithmetic involved in the evaluation of GMiMC's constraint polynomials for one /// round. In particular, this performs the following computations: @@ -224,3 +225,15 @@ impl SimpleGenerator for GMiMCEvalGenerator { witness } } + +#[cfg(test)] +mod tests { + use crate::field::crandall_field::CrandallField; + use crate::gates::gate_testing::test_low_degree; + use crate::gates::gmimc_eval::GMiMCEvalGate; + + #[test] + fn low_degree() { + test_low_degree(GMiMCEvalGate::::get()) + } +} diff --git a/src/gates/interpolation.rs b/src/gates/interpolation.rs index 1e6006c5..272c0a05 100644 --- a/src/gates/interpolation.rs +++ b/src/gates/interpolation.rs @@ -266,10 +266,7 @@ mod tests { #[test] fn low_degree() { type F = CrandallField; - let gate = InterpolationGate:: { - num_points: 4, - _phantom: PhantomData, - }; - test_low_degree(gate); + test_low_degree(InterpolationGate::::new(4)); + test_low_degree(InterpolationGate::::new(4)); } } diff --git a/src/gates/mod.rs b/src/gates/mod.rs index 0c8b04b8..afc0b904 100644 --- a/src/gates/mod.rs +++ b/src/gates/mod.rs @@ -1,6 +1,5 @@ pub(crate) mod arithmetic; pub mod constant; -pub(crate) mod fri_consistency_gate; pub(crate) mod gate; pub mod gmimc; pub(crate) mod gmimc_eval; diff --git a/src/gates/noop.rs b/src/gates/noop.rs index edd4e5dd..fdde6ec6 100644 --- a/src/gates/noop.rs +++ b/src/gates/noop.rs @@ -55,3 +55,15 @@ impl Gate for NoopGate { 0 } } + +#[cfg(test)] +mod tests { + use crate::field::crandall_field::CrandallField; + use crate::gates::gate_testing::test_low_degree; + use crate::gates::noop::NoopGate; + + #[test] + fn low_degree() { + test_low_degree(NoopGate::get::()) + } +}