Skip to content

Commit

Permalink
feat: Add assert_satisfied_at_rows_par variant
Browse files Browse the repository at this point in the history
Resolves: #133
  • Loading branch information
CPerezz committed Feb 2, 2023
1 parent c7e42e4 commit c285368
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,7 @@ impl<F: FieldExt> MockProver<F> {

/// Returns `Ok(())` if this `MockProver` is satisfied, or a list of errors indicating
/// the reasons that the circuit is not satisfied.
/// Constraints are only checked at `gate_row_ids`,
/// and lookup inputs are only checked at `lookup_input_row_ids`, parallelly.
/// Constraints are only checked at `gate_row_ids`, and lookup inputs are only checked at `lookup_input_row_ids`, parallelly.
pub fn verify_at_rows_par<I: Clone + Iterator<Item = usize>>(
&self,
gate_row_ids: I,
Expand Down Expand Up @@ -1354,6 +1353,31 @@ impl<F: FieldExt> MockProver<F> {
}
}

/// Panics if the circuit being checked by this `MockProver` is not satisfied.
///
/// Any verification failures will be pretty-printed to stderr before the function
/// panics.
///
/// Constraints are only checked at `gate_row_ids`, and lookup inputs are only checked at `lookup_input_row_ids`, parallelly.
///
/// Apart from the stderr output, this method is equivalent to:
/// ```ignore
/// assert_eq!(prover.verify_at_rows_par(), Ok(()));
/// ```
pub fn assert_satisfied_at_rows_par<I: Clone + Iterator<Item = usize>>(
&self,
gate_row_ids: I,
lookup_input_row_ids: I,
) {
if let Err(errs) = self.verify_at_rows_par(gate_row_ids, lookup_input_row_ids) {
for err in errs {
err.emit(self);
eprintln!();
}
panic!("circuit was not satisfied");
}
}

/// Returns the list of Fixed Columns used within a MockProver instance and the associated values contained on each Cell.
pub fn fixed(&self) -> &Vec<Vec<CellValue<F>>> {
&self.fixed
Expand Down

0 comments on commit c285368

Please sign in to comment.