-
Notifications
You must be signed in to change notification settings - Fork 21
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 #369 **Overview** This PR is intended to demonstrate the `Input` design for `cyclefold::StepFoldingCircuit` Note what types are used, what curves are presented and how this data is assumed to be reported inside the circuit
- Loading branch information
1 parent
f55ef9d
commit 5822211
Showing
3 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
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 +1,3 @@ | ||
mod support_circuit; | ||
|
||
mod sfc; |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::{ | ||
gadgets::nonnative::bn::big_uint::BigUint, | ||
halo2_proofs::halo2curves::{ff::PrimeField, CurveAffine}, | ||
nifs, plonk, | ||
}; | ||
|
||
pub struct BigUintPoint<F: PrimeField> { | ||
x: BigUint<F>, | ||
y: BigUint<F>, | ||
} | ||
|
||
impl<C: CurveAffine> From<&C> for BigUintPoint<C::ScalarExt> { | ||
fn from(_value: &C) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
pub struct PlonkInstance<F: PrimeField> { | ||
pub(crate) W_commitments: Vec<BigUintPoint<F>>, | ||
pub(crate) instances: Vec<Vec<F>>, | ||
pub(crate) challenges: Vec<F>, | ||
} | ||
|
||
impl<C: CurveAffine> From<plonk::PlonkInstance<C>> for PlonkInstance<C::ScalarExt> { | ||
fn from(value: plonk::PlonkInstance<C>) -> Self { | ||
Self { | ||
W_commitments: value.W_commitments.iter().map(BigUintPoint::from).collect(), | ||
instances: value.instances, | ||
challenges: value.challenges, | ||
} | ||
} | ||
} | ||
|
||
pub struct AccumulatorInstance<F: PrimeField> { | ||
pub(crate) ins: PlonkInstance<F>, | ||
pub(crate) betas: Box<[F]>, | ||
pub(crate) e: F, | ||
} | ||
|
||
impl<C: CurveAffine> From<nifs::protogalaxy::AccumulatorInstance<C>> | ||
for AccumulatorInstance<C::ScalarExt> | ||
{ | ||
fn from(_value: nifs::protogalaxy::AccumulatorInstance<C>) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
pub struct SelfTrace<F: PrimeField> { | ||
pub input_accumulator: AccumulatorInstance<F>, | ||
pub incoming: PlonkInstance<F>, | ||
pub output_accumulator: AccumulatorInstance<F>, | ||
} | ||
|
||
pub struct PairedTrace<C: CurveAffine> { | ||
pub input_accumulator: nifs::protogalaxy::AccumulatorInstance<C>, | ||
pub incoming: plonk::PlonkInstance<C>, | ||
pub output_accumulator: nifs::protogalaxy::AccumulatorInstance<C>, | ||
} | ||
|
||
pub struct Input<const ARITY: usize, C: CurveAffine> { | ||
pub pp_digest: (C::ScalarExt, C::ScalarExt), | ||
|
||
pub self_trace: SelfTrace<C::ScalarExt>, | ||
pub paired_trace: PairedTrace<C>, | ||
|
||
pub proof: nifs::protogalaxy::Proof<C::ScalarExt>, | ||
|
||
pub step: usize, | ||
pub z_0: [C::ScalarExt; ARITY], | ||
pub z_i: [C::ScalarExt; ARITY], | ||
} | ||
|
||
impl<const ARITY: usize, C: CurveAffine> Input<ARITY, C> { | ||
pub(super) fn without_witness(&self) -> Self { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::{ | ||
halo2_proofs::{ | ||
circuit::{Layouter, SimpleFloorPlanner}, | ||
halo2curves::CurveAffine, | ||
plonk::{Circuit, ConstraintSystem, Error as Halo2PlonkError}, | ||
}, | ||
ivc::StepCircuit, | ||
main_gate::{MainGate, MainGateConfig}, | ||
}; | ||
|
||
mod input; | ||
use input::Input; | ||
|
||
const T_MAIN_GATE: usize = 5; | ||
|
||
/// 'SCC' here is 'Step Circuit Config' | ||
#[derive(Debug, Clone)] | ||
pub struct Config<SCC> { | ||
sc: SCC, | ||
mg: MainGateConfig<T_MAIN_GATE>, | ||
} | ||
|
||
pub struct StepFoldingCircuit< | ||
'sc, | ||
const ARITY: usize, | ||
C: CurveAffine, | ||
SC: StepCircuit<ARITY, C::ScalarExt>, | ||
> { | ||
sc: &'sc SC, | ||
input: Input<ARITY, C>, | ||
} | ||
|
||
impl<'sc, const ARITY: usize, C: CurveAffine, SC: StepCircuit<ARITY, C::ScalarExt>> | ||
Circuit<C::ScalarExt> for StepFoldingCircuit<'sc, ARITY, C, SC> | ||
{ | ||
type Config = Config<SC::Config>; | ||
type FloorPlanner = SimpleFloorPlanner; | ||
|
||
fn without_witnesses(&self) -> Self { | ||
Self { | ||
sc: self.sc, | ||
input: self.input.without_witness(), | ||
} | ||
} | ||
|
||
fn configure(meta: &mut ConstraintSystem<C::ScalarExt>) -> Self::Config { | ||
Self::Config { | ||
sc: SC::configure(meta), | ||
mg: MainGate::configure(meta), | ||
} | ||
} | ||
|
||
fn synthesize( | ||
&self, | ||
_config: Self::Config, | ||
_layouter: impl Layouter<C::ScalarExt>, | ||
) -> Result<(), Halo2PlonkError> { | ||
todo!() | ||
} | ||
} |