Skip to content

Commit

Permalink
[#1793] Outline column structure for FFMul in serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
volhovm committed Mar 28, 2024
1 parent 7273015 commit 4ab1b42
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
48 changes: 41 additions & 7 deletions msm/src/serialization/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@ use crate::{
N_LIMBS,
};

/// Total number of columns in the serialization circuit
pub const SER_N_COLUMNS: usize = 6 * N_LIMBS + N_INTERMEDIATE_LIMBS + 9;

/// Column used by the serialization subcircuit
/// It is not used yet.
pub enum SerializationColumn {
/// 3 88 bits inputs
/// 3 88 bits inputs. For the row #i this represents the IPA challenge xi_{log(i)}.
KimchiLimb(usize),
/// N_LIMBS values, representing the limbs used by the MSM
MSMLimb(usize),
/// N_INTERMEDIATE_LIMBS intermediate values, 4 bits long.
IntermediateLimb(usize),
/// N_LIMBS values, representing the limbs used by the MSM
MSMLimb(usize),
/// Previous C_j, this one is looked up. For the row i, the expected
/// value is (C_i >> 1).
CoeffInput(usize),
/// Trusted (for range) foreign field modulus, in 4 big limbs.
FFieldModulus(usize),
/// Quotient limbs
Quotient(usize),
/// Carry limbs
Carry(usize),
/// The resulting coefficient C_i = (C_i >> 1) * xi_{log(i)}. In small limbs.
CoeffResult(usize),
}

impl ColumnIndexer for SerializationColumn {
Expand All @@ -22,13 +36,33 @@ impl ColumnIndexer for SerializationColumn {
assert!(j < 3);
Column::X(j)
}
Self::IntermediateLimb(j) => {
assert!(j < N_INTERMEDIATE_LIMBS);
Column::X(3 + j)
}
Self::MSMLimb(j) => {
assert!(j < N_LIMBS);
Column::X(j + 3)
Column::X(N_INTERMEDIATE_LIMBS + 3 + j)
}
Self::IntermediateLimb(j) => {
assert!(j < N_INTERMEDIATE_LIMBS);
Column::X(j + N_LIMBS + 3)
Self::CoeffInput(j) => {
assert!(j < N_LIMBS);
Column::X(N_INTERMEDIATE_LIMBS + N_LIMBS + 3 + j)
}
Self::FFieldModulus(j) => {
assert!(j < 4);
Column::X(N_INTERMEDIATE_LIMBS + 2 * N_LIMBS + 3 + j)
}
Self::Quotient(j) => {
assert!(j < N_LIMBS);
Column::X(N_INTERMEDIATE_LIMBS + 2 * N_LIMBS + 7 + j)
}
Self::Carry(j) => {
assert!(j < 2 * N_LIMBS + 2);
Column::X(N_INTERMEDIATE_LIMBS + 3 * N_LIMBS + 7 + j)
}
Self::CoeffResult(j) => {
assert!(j < N_LIMBS);
Column::X(N_INTERMEDIATE_LIMBS + 5 * N_LIMBS + 9 + j)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions msm/src/serialization/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{mvlookup::LookupTableID, MVLookup};

/// The number of intermediate limbs of 4 bits required for the circuit
pub const N_INTERMEDIATE_LIMBS: usize = 20;

pub mod column;
pub mod constraints;
pub mod interpreter;
pub mod witness;

/// The number of intermediate limbs of 4 bits required for the circuit
pub const N_INTERMEDIATE_LIMBS: usize = 20;

#[derive(Clone, Copy, Debug)]
pub enum LookupTable {
RangeCheck15,
Expand Down

0 comments on commit 4ab1b42

Please sign in to comment.