-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1793] Implement EC ADD circuit + witness generation
Squash
- Loading branch information
Showing
10 changed files
with
870 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,4 @@ | ||
use crate::N_LIMBS; | ||
|
||
/// Number of columns in the FEC circuits. | ||
pub const FEC_N_COLUMNS: usize = 34 * N_LIMBS + 42 * N_LIMBS; // 42 LIMBS is for debugging |
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,54 @@ | ||
use crate::{columns::Column, expr::E, fec::interpreter::FECInterpreterEnv}; | ||
use ark_ff::PrimeField; | ||
use kimchi::circuits::{ | ||
expr::{ConstantExpr, ConstantTerm, Expr, ExprInner, Variable}, | ||
gate::CurrOrNext, | ||
}; | ||
|
||
/// Contains constraints for just one row. | ||
pub struct ConstraintBuilderEnv<F> { | ||
pub constraints: Vec<E<F>>, | ||
} | ||
|
||
impl<F: PrimeField> FECInterpreterEnv<F> for ConstraintBuilderEnv<F> { | ||
type Variable = E<F>; | ||
|
||
fn empty() -> Self { | ||
ConstraintBuilderEnv { | ||
constraints: vec![], | ||
} | ||
} | ||
|
||
fn assert_zero(&mut self, cst: Self::Variable) { | ||
self.constraints.push(cst) | ||
} | ||
|
||
fn copy(&mut self, x: &Self::Variable, position: Column) -> Self::Variable { | ||
let y = Expr::Atom(ExprInner::Cell(Variable { | ||
col: position, | ||
row: CurrOrNext::Curr, | ||
})); | ||
self.constraints.push(y.clone() - x.clone()); | ||
y | ||
} | ||
|
||
fn constant(value: F) -> Self::Variable { | ||
let cst_expr_inner = ConstantExpr::from(ConstantTerm::Literal(value)); | ||
Expr::Atom(ExprInner::Constant(cst_expr_inner)) | ||
} | ||
|
||
fn read_column(&self, ix: Column) -> Self::Variable { | ||
Expr::Atom(ExprInner::Cell(Variable { | ||
col: ix, | ||
row: CurrOrNext::Curr, | ||
})) | ||
} | ||
|
||
fn range_check_abs1(&mut self, _value: &Self::Variable) { | ||
// FIXME unimplemented | ||
} | ||
|
||
fn range_check_15bit(&mut self, _value: &Self::Variable) { | ||
// FIXME unimplemented | ||
} | ||
} |
Oops, something went wrong.