Skip to content

Commit

Permalink
Small updates to MockProver (#256)
Browse files Browse the repository at this point in the history
* expose InstanceValue::value

* expose region data

* add conversion for Selector -> Column<Any>

* Update halo2_proofs/src/dev.rs

Co-authored-by: Carlos Pérez <[email protected]>

* Revert "add conversion for Selector -> Column<Any>"

This reverts commit 8cd1376.

---------

Co-authored-by: Carlos Pérez <[email protected]>
  • Loading branch information
zemse and CPerezz authored Feb 5, 2024
1 parent 73408a1 commit bc30c46
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ mod graph;
#[cfg_attr(docsrs, doc(cfg(feature = "dev-graph")))]
pub use graph::{circuit_dot_graph, layout::CircuitLayout};

/// Region of assignments that are done during synthesis.
#[derive(Debug)]
struct Region {
pub struct Region {
/// The name of the region. Not required to be unique.
name: String,
/// The columns involved in this region.
Expand Down Expand Up @@ -85,6 +86,36 @@ impl Region {
}
self.rows = Some((start, end));
}

/// Returns the name of the region.
pub fn name(&self) -> &String {
&self.name
}

/// Returns the columns involved in this region.
pub fn columns(&self) -> &HashSet<Column<Any>> {
&self.columns
}

/// Returns the rows that this region starts and ends on, if known.
pub fn rows(&self) -> Option<(usize, usize)> {
self.rows
}

/// Returns the selectors that have been enabled in this region.
pub fn enabled_selectors(&self) -> &HashMap<Selector, Vec<usize>> {
&self.enabled_selectors
}

/// Returns the annotations given to Advice, Fixed or Instance columns within a region context.
pub fn annotations(&self) -> &HashMap<ColumnMetadata, String> {
&self.annotations
}

/// Returns the cells assigned in this region.
pub fn cells(&self) -> &HashMap<(Column<Any>, usize), usize> {
&self.cells
}
}

/// The value of a particular cell within the circuit.
Expand Down Expand Up @@ -328,7 +359,8 @@ pub enum InstanceValue<F: Field> {
}

impl<F: Field> InstanceValue<F> {
fn value(&self) -> F {
/// Field value on the instance cell
pub fn value(&self) -> F {
match self {
InstanceValue::Assigned(v) => *v,
InstanceValue::Padding => F::ZERO,
Expand Down Expand Up @@ -1260,6 +1292,11 @@ impl<F: FromUniformBytes<64> + Ord> MockProver<F> {
pub fn permutation(&self) -> &Assembly {
&self.permutation
}

/// Returns the Regions used during synthesis.
pub fn regions(&self) -> &[Region] {
&self.regions
}
}

#[cfg(test)]
Expand Down

0 comments on commit bc30c46

Please sign in to comment.