halo2_axiom::circuit

Trait Layouter

Source
pub trait Layouter<F: Field> {
    type Root: Layouter<F>;

    // Required methods
    fn assign_region<A, AR, N, NR>(
        &mut self,
        name: N,
        assignment: A,
    ) -> Result<AR, Error>
       where A: FnOnce(Region<'_, F>) -> Result<AR, Error>,
             N: Fn() -> NR,
             NR: Into<String>;
    fn assign_table<A, N, NR>(
        &mut self,
        name: N,
        assignment: A,
    ) -> Result<(), Error>
       where A: FnMut(Table<'_, F>) -> Result<(), Error>,
             N: Fn() -> NR,
             NR: Into<String>;
    fn constrain_instance(
        &mut self,
        cell: Cell,
        column: Column<Instance>,
        row: usize,
    );
    fn next_phase(&mut self);
    fn get_challenge(&self, challenge: Challenge) -> Value<F>;
    fn get_root(&mut self) -> &mut Self::Root;
    fn push_namespace<NR, N>(&mut self, name_fn: N)
       where NR: Into<String>,
             N: FnOnce() -> NR;
    fn pop_namespace(&mut self, gadget_name: Option<String>);

    // Provided method
    fn namespace<NR, N>(
        &mut self,
        name_fn: N,
    ) -> NamespacedLayouter<'_, F, Self::Root>
       where NR: Into<String>,
             N: FnOnce() -> NR { ... }
}
Expand description

A layout strategy within a circuit. The layouter is chip-agnostic and applies its strategy to the context and config it is given.

This abstracts over the circuit assignments, handling row indices etc.

Required Associated Types§

Source

type Root: Layouter<F>

Represents the type of the “root” of this layouter, so that nested namespaces can minimize indirection.

Required Methods§

Source

fn assign_region<A, AR, N, NR>( &mut self, name: N, assignment: A, ) -> Result<AR, Error>
where A: FnOnce(Region<'_, F>) -> Result<AR, Error>, N: Fn() -> NR, NR: Into<String>,

Assign a region of gates to an absolute row number.

Inside the closure, the chip may freely use relative offsets; the Layouter will treat these assignments as a single “region” within the circuit. Outside this closure, the Layouter is allowed to optimise as it sees fit.

fn assign_region(&mut self, || "region name", |region| {
    let config = chip.config();
    region.assign_advice(config.a, offset, || { Some(value)});
});
Source

fn assign_table<A, N, NR>( &mut self, name: N, assignment: A, ) -> Result<(), Error>
where A: FnMut(Table<'_, F>) -> Result<(), Error>, N: Fn() -> NR, NR: Into<String>,

Assign a table region to an absolute row number.

fn assign_table(&mut self, || "table name", |table| {
    let config = chip.config();
    table.assign_fixed(config.a, offset, || { Some(value)});
});
Source

fn constrain_instance( &mut self, cell: Cell, column: Column<Instance>, row: usize, )

Constrains a Cell to equal an instance column’s row value at an absolute position.

Source

fn next_phase(&mut self)

Commit advice columns in current phase and squeeze challenges. This can be called DURING synthesize.

Source

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.

Source

fn get_root(&mut self) -> &mut Self::Root

Gets the “root” of this assignment, bypassing the namespacing.

Not intended for downstream consumption; use Layouter::namespace instead.

Source

fn push_namespace<NR, N>(&mut self, name_fn: N)
where NR: Into<String>, N: FnOnce() -> NR,

Creates a new (sub)namespace and enters into it.

Not intended for downstream consumption; use Layouter::namespace instead.

Source

fn pop_namespace(&mut self, gadget_name: Option<String>)

Exits out of the existing namespace.

Not intended for downstream consumption; use Layouter::namespace instead.

Provided Methods§

Source

fn namespace<NR, N>( &mut self, name_fn: N, ) -> NamespacedLayouter<'_, F, Self::Root>
where NR: Into<String>, N: FnOnce() -> NR,

Enters into a namespace.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, F: Field, L: Layouter<F> + 'a> Layouter<F> for NamespacedLayouter<'a, F, L>

Source§

type Root = <L as Layouter<F>>::Root