Skip to content

Commit

Permalink
Add case fod DivideZ in halo2's evaluate_expr
Browse files Browse the repository at this point in the history
  • Loading branch information
AHartNtkn committed May 16, 2023
1 parent e11fbcd commit e104589
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/halo2/synth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ where
Expr::Infix(InfixOp::Divide, a, b) => {
evaluate_expr(&a, defs, assigns) * evaluate_expr(&b, defs, assigns).invert().unwrap()
}
Expr::Infix(InfixOp::DivideZ, a, b) => {
let divisor = evaluate_expr(&b, defs, assigns);
if divisor.is_zero().into() {
0.into()
} else {
evaluate_expr(&a, defs, assigns) * divisor.invert().unwrap()
}
}
Expr::Infix(InfixOp::IntDivide, a, b) => {
let op1 = BigUint::from_bytes_le(evaluate_expr(&a, defs, assigns).to_repr().as_ref());
let op2 = BigUint::from_bytes_le(evaluate_expr(&b, defs, assigns).to_repr().as_ref());
Expand Down

0 comments on commit e104589

Please sign in to comment.