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

Arrabiata: define correctly the different challenges used in the protocol #2684

Merged
merged 8 commits into from
Oct 9, 2024
54 changes: 29 additions & 25 deletions kimchi/src/circuits/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,28 +843,6 @@ impl<Column: Copy> Variable<Column> {
}
}

impl<Column: FormattedOutput + Debug> Variable<Column> {
pub fn ocaml(&self) -> String {
format!("var({:?}, {:?})", self.col, self.row)
}

pub fn latex(&self) -> String {
let col = self.col.latex(&mut HashMap::new());
match self.row {
Curr => col,
Next => format!("\\tilde{{{col}}}"),
}
}

pub fn text(&self) -> String {
let col = self.col.text(&mut HashMap::new());
match self.row {
Curr => format!("Curr({col})"),
Next => format!("Next({col})"),
}
}
}

impl<F: FftField, Column: Copy, ChallengeTerm: Copy> PolishToken<F, Column, ChallengeTerm> {
/// Evaluate an RPN expression to a field element.
pub fn evaluate<Evaluations: ColumnEvaluations<F, Column = Column>>(
Expand Down Expand Up @@ -2870,6 +2848,32 @@ where
}
}

impl<Column: FormattedOutput + Debug> FormattedOutput for Variable<Column> {
fn is_alpha(&self) -> bool {
false
}

fn ocaml(&self, _cache: &mut HashMap<CacheId, Self>) -> String {
format!("var({:?}, {:?})", self.col, self.row)
}

fn latex(&self, _cache: &mut HashMap<CacheId, Self>) -> String {
let col = self.col.latex(&mut HashMap::new());
match self.row {
Curr => col,
Next => format!("\\tilde{{{col}}}"),
}
}

fn text(&self, _cache: &mut HashMap<CacheId, Self>) -> String {
let col = self.col.text(&mut HashMap::new());
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't the cache in the arg of the function given as arg to the recursive call of text ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not the same type, and also, it is unused in any case.

match self.row {
Curr => format!("Curr({col})"),
Next => format!("Next({col})"),
}
}
}

impl<T: FormattedOutput + Clone> FormattedOutput for Operations<T> {
fn is_alpha(&self) -> bool {
match self {
Expand Down Expand Up @@ -3011,7 +3015,7 @@ where
});
res
}
Atom(Cell(v)) => format!("cell({})", v.ocaml()),
Atom(Cell(v)) => format!("cell({})", v.ocaml(&mut HashMap::new())),
Atom(UnnormalizedLagrangeBasis(i)) => {
format!("unnormalized_lagrange_basis({}, {})", i.zk_rows, i.offset)
}
Expand Down Expand Up @@ -3075,7 +3079,7 @@ where
});
res
}
Atom(Cell(v)) => v.latex(),
Atom(Cell(v)) => v.latex(&mut HashMap::new()),
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't the cache in the arg of the function given as arg to the recursive call ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not the same type, and also, it is unused in any case.

Atom(UnnormalizedLagrangeBasis(RowOffset {
zk_rows: true,
offset: i,
Expand Down Expand Up @@ -3122,7 +3126,7 @@ where
});
res
}
Atom(Cell(v)) => v.text(),
Atom(Cell(v)) => v.text(&mut HashMap::new()),
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't the cache in the arg of the function given as arg to the recursive call ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not the same type, and also, it is unused in any case.

Atom(UnnormalizedLagrangeBasis(RowOffset {
zk_rows: true,
offset: i,
Expand Down
Loading