diff --git a/zokrates_cli/examples/bool_or.code b/zokrates_cli/examples/bool_or.code index 5217cbbf..a698347f 100644 --- a/zokrates_cli/examples/bool_or.code +++ b/zokrates_cli/examples/bool_or.code @@ -1,6 +1,6 @@ // example using if-then-else-fi with || def main(field a, field b) -> (field): - field y = if x + 2 == 4 || x * 2 == 2 then 1 else 0 fi + field y = if a + 2 == 4 || b * 2 == 2 then 1 else 0 fi field z = if y == 1 || y == 0 then y else 1 fi z == 1 return z diff --git a/zokrates_core/src/flatten/mod.rs b/zokrates_core/src/flatten/mod.rs index c5d3baca..56917a5b 100644 --- a/zokrates_core/src/flatten/mod.rs +++ b/zokrates_core/src/flatten/mod.rs @@ -369,15 +369,15 @@ impl Flattener { rhs ); assert!(x.is_linear() && y.is_linear()); - let name_x_or_y = self.use_sym(); + let name_x_and_y = self.use_sym(); statements_flattened.push(FlatStatement::Definition( - name_x_or_y, - FlatExpression::Sub( - box FlatExpression::Add(x.clone(), y.clone()), - box FlatExpression::Mult(x, y) - ) + name_x_and_y, + FlatExpression::Mult(x.clone(), y.clone()) )); - FlatExpression::Identifier(name_x_or_y) + FlatExpression::Sub( + box FlatExpression::Add(x, y), + box FlatExpression::Identifier(name_x_and_y) + ) }, BooleanExpression::And(box lhs, box rhs) => { let x = self.flatten_boolean_expression(