Trait halo2_proofs::circuit::layouter::RegionLayouter
source · [−]pub trait RegionLayouter<F: Field>: Debug {
fn enable_selector<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
selector: &Selector,
offset: usize
) -> Result<(), Error>;
fn assign_advice<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
column: Column<Advice>,
offset: usize,
to: &'v mut (dyn FnMut() -> Result<Assigned<F>, Error> + 'v)
) -> Result<Cell, Error>;
fn assign_advice_from_constant<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
column: Column<Advice>,
offset: usize,
constant: Assigned<F>
) -> Result<Cell, Error>;
fn assign_advice_from_instance<'v>(
&mut self,
annotation: &'v (dyn Fn() -> String + 'v),
instance: Column<Instance>,
row: usize,
advice: Column<Advice>,
offset: usize
) -> Result<(Cell, Option<F>), Error>;
fn assign_fixed<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
column: Column<Fixed>,
offset: usize,
to: &'v mut (dyn FnMut() -> Result<Assigned<F>, Error> + 'v)
) -> Result<Cell, Error>;
fn constrain_constant(
&mut self,
cell: Cell,
constant: Assigned<F>
) -> Result<(), Error>;
fn constrain_equal(&mut self, left: Cell, right: Cell) -> Result<(), Error>;
}
Expand description
Helper trait for implementing a custom Layouter
.
This trait is used for implementing region assignments:
impl<'a, F: FieldExt, C: Chip<F>, CS: Assignment<F> + 'a> Layouter<C> for MyLayouter<'a, C, CS> {
fn assign_region(
&mut self,
assignment: impl FnOnce(Region<'_, F, C>) -> Result<(), Error>,
) -> Result<(), Error> {
let region_index = self.regions.len();
self.regions.push(self.current_gate);
let mut region = MyRegion::new(self, region_index);
{
let region: &mut dyn RegionLayouter<F> = &mut region;
assignment(region.into())?;
}
self.current_gate += region.row_count;
Ok(())
}
}
TODO: It would be great if we could constrain the columns in these types to be
“logical” columns that are guaranteed to correspond to the chip (and have come from
Chip::Config
).
Required Methods
Enables a selector at the given offset.
Assign an advice column value (witness)
Assigns a constant value to the column advice
at offset
within this region.
The constant value will be assigned to a cell within one of the fixed columns
configured via ConstraintSystem::enable_constant
.
Returns the advice cell that has been equality-constrained to the constant.
Assign the value of the instance column’s cell at absolute location
row
to the column advice
at offset
within this region.
Returns the advice cell, and its value if known.
Assign a fixed value
Constrains a cell to have a constant value.
Returns an error if the cell is in a column where equality has not been enabled.
Trait Implementations
sourceimpl<'r, F: Field> From<&'r mut (dyn RegionLayouter<F> + 'r)> for Region<'r, F>
impl<'r, F: Field> From<&'r mut (dyn RegionLayouter<F> + 'r)> for Region<'r, F>
sourcefn from(region: &'r mut dyn RegionLayouter<F>) -> Self
fn from(region: &'r mut dyn RegionLayouter<F>) -> Self
Converts to this type from the input type.