Skip to content

Use closures in enforce_constraints #405

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions relations/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ impl ConstraintSynthesizer<Fr> for BenchCircuit {
);
let extra_lc = cs.new_lc(extra_lc)?;
lcs.push(extra_lc);
cs.enforce_r1cs_constraint(a_i + extra_lc, b_i, c_i.into())?;
cs.enforce_r1cs_constraint(|| a_i + extra_lc, || b_i, || c_i.into())?;
} else {
cs.enforce_r1cs_constraint(a_i, b_i, c_i.into())?;
cs.enforce_r1cs_constraint(|| a_i, || b_i, || c_i.into())?;
};
let v1 = cs.new_witness_variable(|| Ok(self.a))?;
let v2 = cs.new_witness_variable(|| Ok(self.a))?;
Expand Down
18 changes: 9 additions & 9 deletions relations/examples/non_satisfiable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ fn generate_constraints<F: Field>(
let final_result = enforce_addition(cs.clone(), subcircuit1_result, subcircuit2_result)?;
// Verify that the final result matches the expected result
cs.enforce_r1cs_constraint(
LinearCombination::from(final_result),
LinearCombination::from(Variable::One),
LinearCombination::from(expected_result),
|| LinearCombination::from(final_result),
|| LinearCombination::from(Variable::One),
|| LinearCombination::from(expected_result),
)?;

Ok(final_result)
Expand Down Expand Up @@ -134,9 +134,9 @@ fn enforce_multiplication<F: Field>(
})?; // Placeholder for product

cs.enforce_r1cs_constraint(
LinearCombination::from(left),
LinearCombination::from(right),
LinearCombination::from(product),
|| LinearCombination::from(left),
|| LinearCombination::from(right),
|| LinearCombination::from(product),
)?;

Ok(product)
Expand All @@ -157,9 +157,9 @@ fn enforce_addition<F: Field>(
})?; // Placeholder for sum

cs.enforce_r1cs_constraint(
LinearCombination::from(left) + LinearCombination::from(right),
LinearCombination::from(Variable::One),
LinearCombination::from(sum),
|| LinearCombination::from(left) + LinearCombination::from(right),
|| LinearCombination::from(Variable::One),
|| LinearCombination::from(sum),
)?;

Ok(sum)
Expand Down
18 changes: 9 additions & 9 deletions relations/examples/satisfiable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ fn generate_constraints<F: Field>(
let final_result = enforce_addition(cs.clone(), subcircuit1_result, subcircuit2_result)?;
// Verify that the final result matches the expected result
cs.enforce_r1cs_constraint(
LinearCombination::from(final_result),
LinearCombination::from(Variable::One),
LinearCombination::from(expected_result),
|| LinearCombination::from(final_result),
|| LinearCombination::from(Variable::One),
|| LinearCombination::from(expected_result),
)?;

Ok(final_result)
Expand Down Expand Up @@ -123,9 +123,9 @@ fn enforce_multiplication<F: Field>(
})?; // Placeholder for product

cs.enforce_r1cs_constraint(
LinearCombination::from(left),
LinearCombination::from(right),
LinearCombination::from(product),
|| LinearCombination::from(left),
|| LinearCombination::from(right),
|| LinearCombination::from(product),
)?;

Ok(product)
Expand All @@ -145,9 +145,9 @@ fn enforce_addition<F: Field>(
})?; // Placeholder for sum

cs.enforce_r1cs_constraint(
LinearCombination::from(left) + LinearCombination::from(right),
LinearCombination::from(Variable::One),
LinearCombination::from(sum),
|| LinearCombination::from(left) + LinearCombination::from(right),
|| LinearCombination::from(Variable::One),
|| LinearCombination::from(sum),
)?;

Ok(sum)
Expand Down
Loading
Loading