use ark_crypto_primitives::snark::{FromFieldElementsGadget, SNARKGadget, SNARK}; use ark_ec::AffineRepr; use ark_ec::CurveGroup; use ark_ff::{fields::Fp256, Field, PrimeField}; use ark_r1cs_std::{ alloc::{AllocVar, AllocationMode}, bits::uint8::UInt8, boolean::Boolean, eq::EqGadget, fields::{fp::FpVar, FieldVar}, groups::GroupOpsBounds, prelude::CurveVar, ToBitsGadget, }; use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystemRef, Namespace, SynthesisError}; use ark_std::ops::Mul; use core::{borrow::Borrow, marker::PhantomData}; use derivative::Derivative; // pub trait Nova {} pub trait Config { type AugmentedFunctionCircuit: SNARK; // F' type FunctionCircuit: ConstraintSynthesizer; // F type DummyStepCircuit: SNARK; } pub struct AugmentedFCircuit< Fq: PrimeField, Fr: PrimeField, C: CurveGroup, GC: CurveVar, Cfg: Config, > { pub dummystep_vk: Option<>::VerifyingKey>, _c: PhantomData, _gc: PhantomData, } impl, Cfg: Config> ConstraintSynthesizer for AugmentedFCircuit { fn generate_constraints(self, cs: ConstraintSystemRef) -> Result<(), SynthesisError> { unimplemented!(); } } pub struct NIFSGadget> { _f: PhantomData, _c: PhantomData, _gc: PhantomData, } impl> NIFSGadget { // implements the constraints for NIFS.V pub fn verify( r: FpVar, cmT: GC, // phi1, phi2 and phi3 cmE1: GC, cmE2: GC, cmE3: GC, u1: FpVar, u2: FpVar, u3: FpVar, cmW1: GC, cmW2: GC, cmW3: GC, // x's size will depend on the num_publicinputs of F circuit x1: Vec>, x2: Vec>, x3: Vec>, ) -> Result, SynthesisError> { let r2 = r.square()?; cmE3.is_eq( &(cmE1 + cmT.scalar_mul_le(r.to_bits_le()?.iter())? + cmE2.scalar_mul_le(r2.to_bits_le()?.iter())?), )?; u3.is_eq(&(u1 + r.clone() * u2))?; cmW3.is_eq(&(cmW1 + cmW2.scalar_mul_le(r.to_bits_le()?.iter())?)) // TODO x's check } }