-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Motivation** Part of #373 and testing of #369 **Overview** The first part of the implementation of the zero step cyclefold __Temporarily commented out part of cyclefold step folding circuit concerning pairing check__
- Loading branch information
1 parent
8681bd5
commit ddd13b6
Showing
8 changed files
with
805 additions
and
222 deletions.
There are no files selected for viewing
136 changes: 132 additions & 4 deletions
136
src/ivc/cyclefold/incrementally_verifiable_computation/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,151 @@ | ||
use std::marker::PhantomData; | ||
|
||
use public_params::PublicParams; | ||
use tracing::info_span; | ||
|
||
use super::{ | ||
ro, | ||
support_circuit::{self, SupportCircuit}, | ||
}; | ||
use crate::{ | ||
halo2_proofs::halo2curves::{ | ||
ff::{FromUniformBytes, PrimeFieldBits}, | ||
ff::{Field, FromUniformBytes, PrimeFieldBits}, | ||
group::prime::PrimeCurveAffine, | ||
CurveAffine, | ||
}, | ||
ivc::StepCircuit, | ||
ivc::{ | ||
cyclefold::sfc::{self, StepFoldingCircuit}, | ||
StepCircuit, | ||
}, | ||
nifs::{ | ||
self, | ||
protogalaxy::{AccumulatorArgs, ProtoGalaxy}, | ||
sangria::{FoldablePlonkTrace, VanillaFS}, | ||
}, | ||
table::CircuitRunner, | ||
}; | ||
|
||
mod public_params; | ||
|
||
pub struct IVC<const A1: usize, const A2: usize, C1, C2, SC> | ||
pub struct IVC<const ARITY: usize, C1, C2, SC> | ||
where | ||
C1: CurveAffine<Base = <C2 as PrimeCurveAffine>::Scalar>, | ||
C2: CurveAffine<Base = <C1 as PrimeCurveAffine>::Scalar>, | ||
SC: StepCircuit<A1, C1::Scalar>, | ||
SC: StepCircuit<ARITY, C1::Scalar>, | ||
C1::Scalar: PrimeFieldBits + FromUniformBytes<64>, | ||
C2::Scalar: PrimeFieldBits + FromUniformBytes<64>, | ||
{ | ||
_p: PhantomData<(C1, C2, SC)>, | ||
} | ||
|
||
impl<const ARITY: usize, CMain, CSup, SC> IVC<ARITY, CMain, CSup, SC> | ||
where | ||
CMain: CurveAffine<Base = <CSup as PrimeCurveAffine>::Scalar>, | ||
CSup: CurveAffine<Base = <CMain as PrimeCurveAffine>::Scalar>, | ||
SC: StepCircuit<ARITY, CMain::Scalar>, | ||
CMain::Scalar: PrimeFieldBits + FromUniformBytes<64>, | ||
CSup::Scalar: PrimeFieldBits + FromUniformBytes<64>, | ||
{ | ||
pub fn new( | ||
pp: &PublicParams<ARITY, ARITY, CMain, CSup, SC>, | ||
sc: &SC, | ||
z_0: [CMain::ScalarExt; ARITY], | ||
) -> Self { | ||
let _primary_span = info_span!("primary").entered(); | ||
|
||
let initial_self_acc = ProtoGalaxy::<CMain, 1>::new_accumulator( | ||
AccumulatorArgs::from(&pp.primary_S), | ||
&nifs::protogalaxy::ProverParam { | ||
S: pp.primary_S.clone(), | ||
pp_digest: pp.cmain_pp_digest(), | ||
}, | ||
&mut ro(), | ||
); | ||
|
||
let (_new_acc, self_proof) = ProtoGalaxy::prove( | ||
&pp.primary_ck, | ||
&nifs::protogalaxy::ProverParam { | ||
S: pp.primary_S.clone(), | ||
pp_digest: pp.cmain_pp_digest(), | ||
}, | ||
&mut ro(), | ||
initial_self_acc.clone(), | ||
&[pp.primary_initial_trace.clone()], | ||
) | ||
.unwrap(); | ||
|
||
let mut acc_ptr = nifs::sangria::accumulator::RelaxedPlonkTrace::from_regular( | ||
pp.support_initial_trace.clone(), | ||
SupportCircuit::<CMain>::MIN_K_TABLE_SIZE as usize, | ||
); | ||
let mut paired_incoming = vec![]; | ||
|
||
for _ in 0..initial_self_acc.W_commitment_len() { | ||
let (new_acc, paired_proof) = | ||
VanillaFS::<CSup, { support_circuit::INSTANCES_LEN }>::prove( | ||
&pp.support_ck, | ||
&nifs::sangria::ProverParam { | ||
S: pp.support_S.clone(), | ||
pp_digest: pp.csup_pp_digest(), | ||
}, | ||
&mut ro(), | ||
acc_ptr, | ||
&[pp.support_initial_trace.clone()], | ||
) | ||
.unwrap(); | ||
|
||
paired_incoming.push((pp.support_initial_trace.u.clone(), paired_proof)); | ||
|
||
acc_ptr = new_acc; | ||
} | ||
|
||
let _primary_sfc = StepFoldingCircuit::<'_, ARITY, CMain, CSup, SC> { | ||
sc, | ||
input: sfc::InputBuilder { | ||
pp_digest: pp.csup_pp_digest(), | ||
step: 0, | ||
self_incoming: &pp.primary_initial_trace.u, | ||
self_proof, | ||
paired_acc: &pp.support_initial_trace.u.clone().into(), | ||
paired_incoming: paired_incoming.as_slice(), | ||
self_acc: &initial_self_acc.into(), | ||
z_i: z_0, | ||
z_0, | ||
} | ||
.build(), | ||
_p: PhantomData, | ||
}; | ||
|
||
let _initial_support_trace: FoldablePlonkTrace<CSup> = { | ||
let _support_span = info_span!("support").entered(); | ||
|
||
let support_circuit_instances: Vec<Vec<CMain::Base>> = support_circuit::InstanceInput { | ||
p0: CMain::identity(), | ||
l0: CMain::Base::ZERO, | ||
p1: CMain::identity(), | ||
l1: CMain::Base::ZERO, | ||
} | ||
.into_instance(); | ||
|
||
let support_cr = CircuitRunner::<CMain::Base, _>::new( | ||
SupportCircuit::<CMain>::MIN_K_TABLE_SIZE, | ||
SupportCircuit::<CMain>::default(), | ||
support_circuit_instances.clone(), | ||
); | ||
|
||
VanillaFS::<CSup, { support_circuit::INSTANCES_LEN }>::generate_plonk_trace( | ||
&pp.support_ck, | ||
&support_circuit_instances, | ||
&support_cr.try_collect_witness().unwrap(), | ||
&nifs::sangria::ProverParam { | ||
S: support_cr.try_collect_plonk_structure().unwrap(), | ||
pp_digest: CSup::identity(), | ||
}, | ||
&mut ro(), | ||
) | ||
.unwrap() | ||
}; | ||
|
||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.