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

feat: public cells to allow for implementations of custom Layouter #192

Merged
merged 16 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion halo2_gadgets/src/poseidon/primitives/mds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ pub(super) fn generate_mds<F: FromUniformBytes<64> + Ord, const T: usize>(
if m == j {
acc
} else {
let diff: F = x_j - *x_m;
alexander-camuto marked this conversation as resolved.
Show resolved Hide resolved
// We can invert freely; by construction, the elements of xs are distinct.
acc * (x - x_m) * (x_j - x_m).invert().unwrap()
acc * (x - x_m) * diff.invert().unwrap()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be unnecessary change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was done to resolve some warnings that popped up

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same thing pops up again unfortunately

alexander-camuto marked this conversation as resolved.
Show resolved Hide resolved
}
})
};
Expand Down
7 changes: 4 additions & 3 deletions halo2_proofs/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub use value::Value;

pub mod floor_planner;
pub use floor_planner::single_pass::SimpleFloorPlanner;
pub use floor_planner::single_pass::SimpleTableLayouter;

pub mod layouter;

Expand Down Expand Up @@ -87,11 +88,11 @@ impl std::ops::Deref for RegionStart {
#[derive(Clone, Copy, Debug)]
pub struct Cell {
/// Identifies the region in which this cell resides.
region_index: RegionIndex,
pub region_index: RegionIndex,
/// The relative offset of this cell within its region.
row_offset: usize,
pub row_offset: usize,
/// The column of this cell.
column: Column<Any>,
pub column: Column<Any>,
}

/// An assigned cell.
Expand Down
10 changes: 6 additions & 4 deletions halo2_proofs/src/circuit/floor_planner/single_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,12 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a + SyncDeps> RegionLayouter<F>
/// witnesses or not.
type DefaultTableValue<F> = Option<Value<Assigned<F>>>;

pub(crate) struct SimpleTableLayouter<'r, 'a, F: Field, CS: Assignment<F> + 'a> {
/// A table layouter that can be used to assign values to a table.
pub struct SimpleTableLayouter<'r, 'a, F: Field, CS: Assignment<F> + 'a> {
cs: &'a mut CS,
used_columns: &'r [TableColumn],
// maps from a fixed column to a pair (default value, vector saying which rows are assigned)
pub(crate) default_and_assigned: HashMap<TableColumn, (DefaultTableValue<F>, Vec<bool>)>,
/// maps from a fixed column to a pair (default value, vector saying which rows are assigned)
pub default_and_assigned: HashMap<TableColumn, (DefaultTableValue<F>, Vec<bool>)>,
}

impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> fmt::Debug for SimpleTableLayouter<'r, 'a, F, CS> {
Expand All @@ -415,7 +416,8 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> fmt::Debug for SimpleTableLayoute
}

impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> SimpleTableLayouter<'r, 'a, F, CS> {
pub(crate) fn new(cs: &'a mut CS, used_columns: &'r [TableColumn]) -> Self {
///
alexander-camuto marked this conversation as resolved.
Show resolved Hide resolved
pub fn new(cs: &'a mut CS, used_columns: &'r [TableColumn]) -> Self {
SimpleTableLayouter {
cs,
used_columns,
Expand Down
3 changes: 2 additions & 1 deletion halo2_proofs/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ pub struct TableColumn {
}

impl TableColumn {
pub(crate) fn inner(&self) -> Column<Fixed> {
/// Returns inner column
pub fn inner(&self) -> Column<Fixed> {
self.inner
}
}
Expand Down
Loading