From fd0b0b787bf7b5183f7f61242ec522783aa935a2 Mon Sep 17 00:00:00 2001 From: Srinath Setty Date: Mon, 25 Apr 2022 15:58:30 -0700 Subject: [PATCH] remove unused where (#38) --- src/circuit.rs | 27 +++++++-------------------- src/gadgets/r1cs.rs | 8 +------- src/traits.rs | 6 +++--- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/circuit.rs b/src/circuit.rs index 002a7c2..4ebbe1c 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -26,7 +26,7 @@ use bellperson::{ }, Circuit, ConstraintSystem, SynthesisError, }; -use ff::{Field, PrimeField, PrimeFieldBits}; +use ff::Field; #[derive(Debug, Clone)] pub struct NIFSVerifierCircuitParams { @@ -44,10 +44,7 @@ impl NIFSVerifierCircuitParams { } } -pub struct NIFSVerifierCircuitInputs -where - G: Group, -{ +pub struct NIFSVerifierCircuitInputs { params: G::Base, // Hash(Shape of u2, Gens for u2). Needed for computing the challenge. i: G::Base, z0: G::Base, @@ -85,10 +82,9 @@ where } /// Circuit that encodes only the folding verifier -pub struct NIFSVerifierCircuit +pub struct NIFSVerifierCircuit where G: Group, - ::Base: ff::PrimeField, SC: StepCircuit, { params: NIFSVerifierCircuitParams, @@ -100,8 +96,6 @@ where impl NIFSVerifierCircuit where G: Group, - ::Base: PrimeField + PrimeFieldBits, - ::Scalar: PrimeField + PrimeFieldBits, SC: StepCircuit, { /// Create a new verification circuit for the input relaxed r1cs instances @@ -111,10 +105,7 @@ where inputs: Option>, step_circuit: SC, poseidon_constants: NovaPoseidonConstants, - ) -> Self - where - ::Base: ff::PrimeField, - { + ) -> Self { Self { params, inputs, @@ -243,8 +234,6 @@ where impl Circuit<::Base> for NIFSVerifierCircuit where G: Group, - ::Base: PrimeField + PrimeFieldBits, - ::Scalar: PrimeFieldBits, SC: StepCircuit, { fn synthesize::Base>>( @@ -347,18 +336,16 @@ mod tests { bellperson::r1cs::{NovaShape, NovaWitness}, commitments::CommitTrait, }; + use ff::PrimeField; use std::marker::PhantomData; - struct TestCircuit - where - F: PrimeField + ff::PrimeField, - { + struct TestCircuit { _p: PhantomData, } impl StepCircuit for TestCircuit where - F: PrimeField + ff::PrimeField, + F: PrimeField, { fn synthesize>( &self, diff --git a/src/gadgets/r1cs.rs b/src/gadgets/r1cs.rs index 4d92dd0..2b229ce 100644 --- a/src/gadgets/r1cs.rs +++ b/src/gadgets/r1cs.rs @@ -18,7 +18,7 @@ use bellperson_nonnative::{ mp::bignat::BigNat, util::{convert::f_to_nat, num::Num}, }; -use ff::{Field, PrimeField, PrimeFieldBits}; +use ff::Field; /// An Allocated R1CS Instance #[derive(Clone)] @@ -34,8 +34,6 @@ where impl AllocatedR1CSInstance where G: Group, - ::Base: PrimeField + PrimeFieldBits, - ::Scalar: PrimeFieldBits, { /// Takes the r1cs instance and creates a new allocated r1cs instance pub fn alloc::Base>>( @@ -74,8 +72,6 @@ where pub struct AllocatedRelaxedR1CSInstance where G: Group, - ::Base: PrimeField + PrimeFieldBits, - ::Scalar: PrimeFieldBits, { pub(crate) W: AllocatedPoint, pub(crate) E: AllocatedPoint, @@ -87,8 +83,6 @@ where impl AllocatedRelaxedR1CSInstance where G: Group, - ::Base: PrimeField + PrimeFieldBits, - ::Scalar: PrimeFieldBits, { /// Allocates the given RelaxedR1CSInstance as a witness of the circuit pub fn alloc::Base>>( diff --git a/src/traits.rs b/src/traits.rs index dfb0dd4..adf9a6e 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -5,7 +5,7 @@ use core::{ fmt::Debug, ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign}, }; -use ff::PrimeField; +use ff::{PrimeField, PrimeFieldBits}; use merlin::Transcript; use rug::Integer; @@ -22,10 +22,10 @@ pub trait Group: + ScalarMulOwned<::Scalar> { /// A type representing an element of the base field of the group - type Base: PrimeField; + type Base: PrimeField + PrimeFieldBits; /// A type representing an element of the scalar field of the group - type Scalar: PrimeField + ChallengeTrait; + type Scalar: PrimeField + PrimeFieldBits + ChallengeTrait; /// A type representing the compressed version of the group element type CompressedGroupElement: CompressedGroup;