Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first sketch of the environment for the serializer circuit #1860

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions msm/src/serialization/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod columns;
pub mod interpreter;
pub mod witness;
29 changes: 29 additions & 0 deletions msm/src/serialization/witness.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use ark_ff::Field;

use crate::LIMBS_NUM;

/// Environment for the serializer interpreter
/// It is parametrized by the number of field elements to be serialized and the
/// field
pub struct Env<const N: usize, Fp> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is building witness, right? We have three kind of environments IIRC: witness, constraint, and column (anything else?). I won't block on naming conventions, but WitnessBuilder perhaps would be a more descriptive name?

pub step: usize,
pub kimchi_limbs: [[Fp; 3]; N],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also thinking if it's a builder-like struct, then probably the fields should be not arrays but vectors, and we intend to append to them? So far this Env seems to express just one row of our computation -- is that intentional or we want to have multiple rows?..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One row of computation.

pub current_kimchi_limbs: [Fp; 3],
/// The LIMB_NUM limbs that is used to encode a field element for the MSM
pub msm_limbs: [Fp; LIMBS_NUM],
/// Used for the decomposition in base 4 of the last limb of the foreign
/// field Kimchi gate
pub intermediate_limbs: [Fp; 19],
}

impl<const N: usize, Fp: Field> Env<N, Fp> {
pub fn create(kimchi_limbs: [[Fp; 3]; N]) -> Self {
Self {
step: 0,
kimchi_limbs,
current_kimchi_limbs: [Fp::zero(); 3],
msm_limbs: [Fp::zero(); LIMBS_NUM],
intermediate_limbs: [Fp::zero(); 19],
}
}
}