From bc30c465ed27bef38aef53624bbca81e01775c2e Mon Sep 17 00:00:00 2001 From: soham <22412996+zemse@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:58:56 +0530 Subject: [PATCH] Small updates to MockProver (#256) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * expose InstanceValue::value * expose region data * add conversion for Selector -> Column * Update halo2_proofs/src/dev.rs Co-authored-by: Carlos Pérez <37264926+CPerezz@users.noreply.github.com> * Revert "add conversion for Selector -> Column" This reverts commit 8cd137612b9b878dd243f1c7ab996e77b1c671dc. --------- Co-authored-by: Carlos Pérez <37264926+CPerezz@users.noreply.github.com> --- halo2_proofs/src/dev.rs | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) 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)]