From 6a19eedbf179158a9c365e0f45ce589f0d64066f Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 13 Mar 2024 11:14:41 +0100 Subject: [PATCH] MSM: add rangecheck4 and rangecheck15 lookups --- msm/src/serialization/constraints.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/msm/src/serialization/constraints.rs b/msm/src/serialization/constraints.rs index 28cad3d9c1..368362524d 100644 --- a/msm/src/serialization/constraints.rs +++ b/msm/src/serialization/constraints.rs @@ -6,7 +6,8 @@ use kimchi::circuits::{ use crate::{columns::Column, expr::E, serialization::N_INTERMEDIATE_LIMBS, N_LIMBS}; -use super::interpreter::InterpreterEnv; +use super::Lookup; +use super::{interpreter::InterpreterEnv, LookupTable}; pub struct Env { /// An indexed set of constraints. @@ -15,6 +16,8 @@ pub struct Env { /// folding for instance. pub constraints: Vec<(usize, Expr, Column>)>, pub constrain_index: usize, + pub rangecheck4_lookups: Vec>>, + pub rangecheck15_lookups: Vec>>, } impl Env { @@ -22,6 +25,8 @@ impl Env { Self { constraints: vec![], constrain_index: 0, + rangecheck4_lookups: vec![], + rangecheck15_lookups: vec![], } } } @@ -63,12 +68,22 @@ impl InterpreterEnv for Env { Column::X(3 + j) } - fn range_check15(&mut self, _value: &Self::Variable) { - // TODO + fn range_check15(&mut self, value: &Self::Variable) { + let one = ConstantExpr::from(ConstantTerm::Literal(F::one())); + self.rangecheck15_lookups.push(Lookup { + table_id: LookupTable::RangeCheck15, + numerator: Expr::Atom(ExprInner::Constant(one)), + value: vec![value.clone()], + }) } - fn range_check4(&mut self, _value: &Self::Variable) { - // TODO + fn range_check4(&mut self, value: &Self::Variable) { + let one = ConstantExpr::from(ConstantTerm::Literal(F::one())); + self.rangecheck4_lookups.push(Lookup { + table_id: LookupTable::RangeCheck4, + numerator: Expr::Atom(ExprInner::Constant(one)), + value: vec![value.clone()], + }) } fn constant(value: F) -> Self::Variable {