Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Expose Fixed columns & Assembly permutation structs in MockProver instance #123

Merged
merged 3 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions halo2_proofs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::time::{Duration, Instant};
use blake2b_simd::blake2b;
use ff::Field;

use crate::plonk::permutation::keygen::Assembly;
use crate::{
arithmetic::{FieldExt, Group},
circuit,
Expand Down Expand Up @@ -82,12 +83,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 @@ -1336,6 +1337,16 @@ impl<F: FieldExt> MockProver<F> {
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
}

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

#[cfg(test)]
Expand Down
15 changes: 10 additions & 5 deletions halo2_proofs/src/plonk/permutation/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ use crate::{
},
};

/// Struct that accumulates all the necessary data in order to construct the permutation argument.
#[derive(Debug)]
pub(crate) struct Assembly {
columns: Vec<Column<Any>>,
pub(crate) mapping: Vec<Vec<(usize, usize)>>,
aux: Vec<Vec<(usize, usize)>>,
sizes: Vec<Vec<usize>>,
pub struct Assembly {
/// Columns that participate on the copy permutation argument.
pub columns: Vec<Column<Any>>,
/// Mapping of the actual copies done.
pub mapping: Vec<Vec<(usize, usize)>>,
/// Some aux data used to swap positions directly when sorting.
pub aux: Vec<Vec<(usize, usize)>>,
/// More aux data
pub sizes: Vec<Vec<usize>>,
}

impl Assembly {
Expand Down