diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 7a3aca10cc..05d1bca041 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -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. @@ -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> { + &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> { + &self.enabled_selectors + } + + /// Returns the annotations given to Advice, Fixed or Instance columns within a region context. + pub fn annotations(&self) -> &HashMap { + &self.annotations + } + + /// Returns the cells assigned in this region. + pub fn cells(&self) -> &HashMap<(Column, usize), usize> { + &self.cells + } } /// The value of a particular cell within the circuit. @@ -328,7 +359,8 @@ pub enum InstanceValue { } impl InstanceValue { - 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, @@ -1260,6 +1292,11 @@ impl + Ord> MockProver { pub fn permutation(&self) -> &Assembly { &self.permutation } + + /// Returns the Regions used during synthesis. + pub fn regions(&self) -> &[Region] { + &self.regions + } } #[cfg(test)]