|
@ -26,7 +26,7 @@ use bellperson::{ |
|
|
},
|
|
|
},
|
|
|
Circuit, ConstraintSystem, SynthesisError,
|
|
|
Circuit, ConstraintSystem, SynthesisError,
|
|
|
};
|
|
|
};
|
|
|
use ff::{Field, PrimeField, PrimeFieldBits};
|
|
|
|
|
|
|
|
|
use ff::Field;
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct NIFSVerifierCircuitParams {
|
|
|
pub struct NIFSVerifierCircuitParams {
|
|
@ -44,10 +44,7 @@ impl NIFSVerifierCircuitParams { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub struct NIFSVerifierCircuitInputs<G>
|
|
|
|
|
|
where
|
|
|
|
|
|
G: Group,
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
pub struct NIFSVerifierCircuitInputs<G: Group> {
|
|
|
params: G::Base, // Hash(Shape of u2, Gens for u2). Needed for computing the challenge.
|
|
|
params: G::Base, // Hash(Shape of u2, Gens for u2). Needed for computing the challenge.
|
|
|
i: G::Base,
|
|
|
i: G::Base,
|
|
|
z0: G::Base,
|
|
|
z0: G::Base,
|
|
@ -85,10 +82,9 @@ where |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// Circuit that encodes only the folding verifier
|
|
|
/// Circuit that encodes only the folding verifier
|
|
|
pub struct NIFSVerifierCircuit<G, SC>
|
|
|
|
|
|
|
|
|
pub struct NIFSVerifierCircuit<G: Group, SC>
|
|
|
where
|
|
|
where
|
|
|
G: Group,
|
|
|
G: Group,
|
|
|
<G as Group>::Base: ff::PrimeField,
|
|
|
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
{
|
|
|
{
|
|
|
params: NIFSVerifierCircuitParams,
|
|
|
params: NIFSVerifierCircuitParams,
|
|
@ -100,8 +96,6 @@ where |
|
|
impl<G, SC> NIFSVerifierCircuit<G, SC>
|
|
|
impl<G, SC> NIFSVerifierCircuit<G, SC>
|
|
|
where
|
|
|
where
|
|
|
G: Group,
|
|
|
G: Group,
|
|
|
<G as Group>::Base: PrimeField + PrimeFieldBits,
|
|
|
|
|
|
<G as Group>::Scalar: PrimeField + PrimeFieldBits,
|
|
|
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
{
|
|
|
{
|
|
|
/// Create a new verification circuit for the input relaxed r1cs instances
|
|
|
/// Create a new verification circuit for the input relaxed r1cs instances
|
|
@ -111,10 +105,7 @@ where |
|
|
inputs: Option<NIFSVerifierCircuitInputs<G>>,
|
|
|
inputs: Option<NIFSVerifierCircuitInputs<G>>,
|
|
|
step_circuit: SC,
|
|
|
step_circuit: SC,
|
|
|
poseidon_constants: NovaPoseidonConstants<G::Base>,
|
|
|
poseidon_constants: NovaPoseidonConstants<G::Base>,
|
|
|
) -> Self
|
|
|
|
|
|
where
|
|
|
|
|
|
<G as Group>::Base: ff::PrimeField,
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
) -> Self {
|
|
|
Self {
|
|
|
Self {
|
|
|
params,
|
|
|
params,
|
|
|
inputs,
|
|
|
inputs,
|
|
@ -243,8 +234,6 @@ where |
|
|
impl<G, SC> Circuit<<G as Group>::Base> for NIFSVerifierCircuit<G, SC>
|
|
|
impl<G, SC> Circuit<<G as Group>::Base> for NIFSVerifierCircuit<G, SC>
|
|
|
where
|
|
|
where
|
|
|
G: Group,
|
|
|
G: Group,
|
|
|
<G as Group>::Base: PrimeField + PrimeFieldBits,
|
|
|
|
|
|
<G as Group>::Scalar: PrimeFieldBits,
|
|
|
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
SC: StepCircuit<G::Base>,
|
|
|
{
|
|
|
{
|
|
|
fn synthesize<CS: ConstraintSystem<<G as Group>::Base>>(
|
|
|
fn synthesize<CS: ConstraintSystem<<G as Group>::Base>>(
|
|
@ -347,18 +336,16 @@ mod tests { |
|
|
bellperson::r1cs::{NovaShape, NovaWitness},
|
|
|
bellperson::r1cs::{NovaShape, NovaWitness},
|
|
|
commitments::CommitTrait,
|
|
|
commitments::CommitTrait,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
use ff::PrimeField;
|
|
|
use std::marker::PhantomData;
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
|
|
|
|
struct TestCircuit<F>
|
|
|
|
|
|
where
|
|
|
|
|
|
F: PrimeField + ff::PrimeField,
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
struct TestCircuit<F: PrimeField> {
|
|
|
_p: PhantomData<F>,
|
|
|
_p: PhantomData<F>,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<F> StepCircuit<F> for TestCircuit<F>
|
|
|
impl<F> StepCircuit<F> for TestCircuit<F>
|
|
|
where
|
|
|
where
|
|
|
F: PrimeField + ff::PrimeField,
|
|
|
|
|
|
|
|
|
F: PrimeField,
|
|
|
{
|
|
|
{
|
|
|
fn synthesize<CS: ConstraintSystem<F>>(
|
|
|
fn synthesize<CS: ConstraintSystem<F>>(
|
|
|
&self,
|
|
|
&self,
|
|
|