Skip to content

Commit

Permalink
Small updates to MockProver (privacy-scaling-explorations#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 committed Apr 24, 2024
1 parent 1faf1de commit c15ea3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
31 changes: 13 additions & 18 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ impl Region {
&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
Expand All @@ -112,12 +107,12 @@ impl Region {

/// The value of a particular cell within the circuit.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum CellValue<F: Group + Field> {
// An unassigned cell.
pub enum CellValue<F: Group + Field> {
/// An unassigned cell.
Unassigned,
// A cell that has been assigned a value.
/// A cell that has been assigned a value.
Assigned(F),
// A unique poisoned cell.
/// A unique poisoned cell.
Poison(usize),
}

Expand Down Expand Up @@ -347,18 +342,18 @@ impl<F: Field> InstanceValue<F> {
pub fn value(&self) -> F {
match self {
InstanceValue::Assigned(v) => *v,
InstanceValue::Padding => F::ZERO,
InstanceValue::Padding => F::zero(),
}
}
}

impl<F: Field> MockProver<F> {
fn in_phase<P: Phase>(&self, phase: P) -> bool {
self.current_phase == phase.to_sealed()
}
}
// impl<F: Field> MockProver<F> {
// fn in_phase<P: Phase>(&self, phase: P) -> bool {
// self.current_phase == phase.to_sealed()
// }
// }

impl<F: Field> Assignment<F> for MockProver<F> {
impl<F: Field + Group> Assignment<F> for MockProver<F> {
fn enter_region<NR, N>(&mut self, name: N)
where
NR: Into<String>,
Expand Down Expand Up @@ -1400,12 +1395,12 @@ impl<F: FieldExt> MockProver<F> {
}

/// Returns the list of Instance Columns used within a MockProver instance and the associated values contained on each Cell.
pub fn instance(&self) -> &Vec<Vec<InstanceValue<F>>> {
pub fn instance(&self) -> &Vec<Vec<F>> {
&self.instance
}

/// Returns the permutation argument (`Assembly`) used within a MockProver instance.
pub fn permutation(&self) -> &Assembly {
pub fn permutation(&self) -> &permutation::keygen::Assembly {
&self.permutation
}

Expand Down
2 changes: 1 addition & 1 deletion halo2_proofs/src/plonk/permutation/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
};

#[derive(Debug)]
pub(crate) struct Assembly {
pub struct Assembly {
columns: Vec<Column<Any>>,
pub(crate) mapping: Vec<Vec<(usize, usize)>>,
aux: Vec<Vec<(usize, usize)>>,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-07-26
nightly-2022-07-27

0 comments on commit c15ea3f

Please sign in to comment.