Skip to content

Commit

Permalink
Merge 0dcf7e7 into aabe5c1
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jan 2, 2024
2 parents aabe5c1 + 0dcf7e7 commit 743067f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,19 @@ impl AcirContext {
let lhs_data = self.vars[&lhs].clone();
let rhs_data = self.vars[&rhs].clone();
let result = match (lhs_data, rhs_data) {
// (x * 1) == (1 * x) == x
(AcirVarData::Const(constant), _) if constant.is_one() => rhs,
(_, AcirVarData::Const(constant)) if constant.is_one() => lhs,

// (x * 0) == (0 * x) == 0
(AcirVarData::Const(constant), _) | (_, AcirVarData::Const(constant))
if constant.is_zero() =>
{
self.add_constant(FieldElement::zero())
}

(AcirVarData::Const(lhs_constant), AcirVarData::Const(rhs_constant)) => {
self.add_data(AcirVarData::Const(lhs_constant * rhs_constant))
self.add_constant(lhs_constant * rhs_constant)
}
(AcirVarData::Witness(witness), AcirVarData::Const(constant))
| (AcirVarData::Const(constant), AcirVarData::Witness(witness)) => {
Expand Down

0 comments on commit 743067f

Please sign in to comment.