pub trait RegionLayouter<F: Field>: Debug + SyncDeps {
// Required methods
fn enable_selector<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
selector: &Selector,
offset: usize,
) -> Result<(), Error>;
fn name_column<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
column: Column<Any>,
);
fn assign_advice<'v>(
&mut self,
column: Column<Advice>,
offset: usize,
to: Value<Assigned<F>>,
) -> AssignedCell<&'v Assigned<F>, F>;
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, Value<F>), Error>;
fn instance_value(
&mut self,
instance: Column<Instance>,
row: usize,
) -> Result<Value<F>, Error>;
fn assign_fixed(
&mut self,
column: Column<Fixed>,
offset: usize,
to: Assigned<F>,
) -> Cell;
fn constrain_constant(
&mut self,
cell: Cell,
constant: Assigned<F>,
) -> Result<(), Error>;
fn constrain_equal(&mut self, left: Cell, right: Cell);
fn get_challenge(&self, challenge: Challenge) -> Value<F>;
fn next_phase(&mut self);
}
Expand description
Helper trait for implementing a custom Layouter
.
This trait is used for implementing region assignments:
impl<'a, F: Field, 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§
Sourcefn enable_selector<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
selector: &Selector,
offset: usize,
) -> Result<(), Error>
fn enable_selector<'v>( &'v mut self, annotation: &'v (dyn Fn() -> String + 'v), selector: &Selector, offset: usize, ) -> Result<(), Error>
Enables a selector at the given offset.
Sourcefn name_column<'v>(
&'v mut self,
annotation: &'v (dyn Fn() -> String + 'v),
column: Column<Any>,
)
fn name_column<'v>( &'v mut self, annotation: &'v (dyn Fn() -> String + 'v), column: Column<Any>, )
Allows the circuit implementor to name/annotate a Column within a Region context.
This is useful in order to improve the amount of information that prover.verify()
and prover.assert_satisfied()
can provide.
Sourcefn assign_advice<'v>(
&mut self,
column: Column<Advice>,
offset: usize,
to: Value<Assigned<F>>,
) -> AssignedCell<&'v Assigned<F>, F>
fn assign_advice<'v>( &mut self, column: Column<Advice>, offset: usize, to: Value<Assigned<F>>, ) -> AssignedCell<&'v Assigned<F>, F>
Assign an advice column value (witness)
Sourcefn 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_constant<'v>( &'v mut self, annotation: &'v (dyn Fn() -> String + 'v), column: Column<Advice>, offset: usize, constant: Assigned<F>, ) -> Result<Cell, Error>
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.
Sourcefn 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, Value<F>), 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, Value<F>), Error>
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 that has been equality-constrained to the instance cell, and its value if known.
Sourcefn instance_value(
&mut self,
instance: Column<Instance>,
row: usize,
) -> Result<Value<F>, Error>
fn instance_value( &mut self, instance: Column<Instance>, row: usize, ) -> Result<Value<F>, Error>
Returns the value of the instance column’s cell at absolute location row
.
Sourcefn assign_fixed(
&mut self,
column: Column<Fixed>,
offset: usize,
to: Assigned<F>,
) -> Cell
fn assign_fixed( &mut self, column: Column<Fixed>, offset: usize, to: Assigned<F>, ) -> Cell
Assign a fixed value
Sourcefn constrain_constant(
&mut self,
cell: Cell,
constant: Assigned<F>,
) -> Result<(), Error>
fn constrain_constant( &mut self, cell: Cell, constant: Assigned<F>, ) -> Result<(), Error>
Constrains a cell to have a constant value.
Returns an error if the cell is in a column where equality has not been enabled.
Sourcefn constrain_equal(&mut self, left: Cell, right: Cell)
fn constrain_equal(&mut self, left: Cell, right: Cell)
Constraint two cells to have the same value.
Returns an error if either of the cells is not within the given permutation.
Sourcefn get_challenge(&self, challenge: Challenge) -> Value<F>
fn get_challenge(&self, challenge: Challenge) -> Value<F>
Queries the value of the given challenge.
Returns Value::unknown()
if the current synthesis phase is before the challenge can be queried.
Sourcefn next_phase(&mut self)
fn next_phase(&mut self)
Commit advice columns in current phase and squeeze challenges. This can be called DURING synthesize.