Skip to content

Commit

Permalink
fix nand
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnevadoc committed Jan 25, 2024
1 parent e7bb340 commit 6e505a9
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions maingate/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,22 @@ pub trait MainGateInstructions<F: PrimeField, const WIDTH: usize>: Chip<F> {
ctx: &mut RegionCtx<'_, F>,
a: &AssignedCondition<F>,
b: &AssignedCondition<F>,
) -> Result<(), Error> {
self.apply(
ctx,
[Term::assigned_to_mul(a), Term::assigned_to_mul(b)],
F::ZERO,
CombinationOptionCommon::OneLinerMul.into(),
)?;
Ok(())
) -> Result<AssignedCondition<F>, Error> {
// result + ab - 1 =0
let result = a.value().zip(b.value()).map(|(a, b)| F::ONE - *a * b);
let result = self
.apply(
ctx,
[
Term::assigned_to_mul(a),
Term::assigned_to_mul(b),
Term::unassigned_to_add(result),
],
-F::ONE,
CombinationOptionCommon::OneLinerMul.into(),
)?
.swap_remove(2);
Ok(result)
}

/// Assigns a new witness `r` as:
Expand Down

0 comments on commit 6e505a9

Please sign in to comment.