Skip to content

Commit

Permalink
feat: nifs::protogalaxy from C::Base to C::Scalar
Browse files Browse the repository at this point in the history
**Motivation**
We need consistent types for #369 between nifs <-> ivc protogalaxy modules

**Overview**
I had to make many types independent of the curve. Since for the random oracle logic we are byte-by-by-byte distilling from all fields to the target field anyway, I got rid of Scalar -> Base in favor of any field.

So now it can be both C::Base (for sangria) and C::Scalar (for cyclefold)

There are no other functional changes, only generic refactoring
  • Loading branch information
cyphersnake committed Dec 16, 2024
1 parent 5930fa5 commit 9b3e6df
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 233 deletions.
2 changes: 1 addition & 1 deletion src/ivc/consistency_markers_computation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where
.absorb_field_iter(self.z_i.iter().copied())
.absorb(&relaxed)
.inspect(inspect)
.squeeze::<C>(NUM_CHALLENGE_BITS),
.squeeze::<C::ScalarExt>(NUM_CHALLENGE_BITS),
)
.unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/ivc/cyclefold/sfc/input/assigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ pub struct Input<const ARITY: usize, F: PrimeField> {
}

impl<const A: usize, F: PrimeField> Input<A, F> {
fn assign_advice_from(
pub fn assign_advice_from(
region: &mut RegionCtx<'_, F>,
original: &super::Input<A, F>,
main_gate_config: &MainGateConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/ivc/cyclefold/sfc/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
poseidon::{AbsorbInRO, ROTrait},
};

mod assigned;
pub mod assigned;

#[derive(Debug, Clone)]
pub struct BigUintPoint<F: PrimeField> {
Expand Down
21 changes: 18 additions & 3 deletions src/ivc/cyclefold/sfc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
plonk::{Circuit, ConstraintSystem, Error as Halo2PlonkError},
},
ivc::{cyclefold, StepCircuit},
main_gate::{MainGate, MainGateConfig},
main_gate::{MainGate, MainGateConfig, RegionCtx},
poseidon::ROTrait,
};

Expand Down Expand Up @@ -83,9 +83,24 @@ impl<const ARITY: usize, C: CurveAffine, SC: StepCircuit<ARITY, C::ScalarExt>> C

fn synthesize(
&self,
_config: Self::Config,
_layouter: impl Layouter<C::ScalarExt>,
config: Self::Config,
mut layouter: impl Layouter<C::ScalarExt>,
) -> Result<(), Halo2PlonkError> {
layouter.assign_region(
|| "sfc main",
|region| {
let mut region = RegionCtx::new(region, 0);

let _input = input::assigned::Input::assign_advice_from(
&mut region,
&self.input,
&config.mg,
)?;

Ok(())
},
)?;

todo!()
}
}
Loading

0 comments on commit 9b3e6df

Please sign in to comment.