Struct halo2_base::gates::builder::GateThreadBuilder
source · [−]pub struct GateThreadBuilder<F: ScalarField> {
pub threads: [Vec<Context<F>>; 3],
pub witness_gen_only: bool,
/* private fields */
}
Expand description
Builds the process for gate threading
Fields
threads: [Vec<Context<F>>; 3]
Threads for each challenge phase
witness_gen_only: bool
Flag for witness generation. If true, the gate thread builder is used for witness generation only.
Implementations
sourceimpl<F: ScalarField> GateThreadBuilder<F>
impl<F: ScalarField> GateThreadBuilder<F>
sourcepub fn new(witness_gen_only: bool) -> Self
pub fn new(witness_gen_only: bool) -> Self
Creates a new GateThreadBuilder and spawns a main thread in phase 0.
witness_gen_only
: If true, the GateThreadBuilder is used for witness generation only.- If true, the gate thread builder only does witness asignments and does not store constraint information – this should only be used for the real prover.
- If false, the gate thread builder is used for keygen and mock prover (it can also be used for real prover) and the builder stores circuit information (e.g. copy constraints, fixed columns, enabled selectors).
- These values are fixed for the circuit at key generation time, and they do not need to be re-computed by the prover in the actual proving phase.
sourcepub fn mock() -> Self
pub fn mock() -> Self
Creates a new GateThreadBuilder with witness_gen_only
set to false.
Performs the witness assignment computations and then checks using normal programming logic whether the gate constraints are all satisfied.
sourcepub fn keygen() -> Self
pub fn keygen() -> Self
Creates a new GateThreadBuilder with witness_gen_only
set to false.
Performs the witness assignment computations and generates prover and verifier keys.
sourcepub fn prover() -> Self
pub fn prover() -> Self
Creates a new GateThreadBuilder with witness_gen_only
set to true.
Performs the witness assignment computations and then runs the proving system.
sourcepub fn unknown(self, use_unknown: bool) -> Self
pub fn unknown(self, use_unknown: bool) -> Self
Creates a new GateThreadBuilder with use_unknown
flag set.
use_unknown
: If true, during key generation witness [Value]s are replaced with Value::unknown() for safety.
sourcepub fn main(&mut self, phase: usize) -> &mut Context<F>
pub fn main(&mut self, phase: usize) -> &mut Context<F>
Returns a mutable reference to the Context of a gate thread. Spawns a new thread for the given phase, if none exists.
phase
: The challenge phase (as an index) of the gate thread.
sourcepub fn witness_gen_only(&self) -> bool
pub fn witness_gen_only(&self) -> bool
Returns the witness_gen_only
flag.
sourcepub fn use_unknown(&self) -> bool
pub fn use_unknown(&self) -> bool
Returns the use_unknown
flag.
sourcepub fn thread_count(&self) -> usize
pub fn thread_count(&self) -> usize
Returns the current number of threads in the GateThreadBuilder.
sourcepub fn get_new_thread_id(&mut self) -> usize
pub fn get_new_thread_id(&mut self) -> usize
Creates a new thread id by incrementing the thread count
sourcepub fn new_thread(&mut self, phase: usize) -> &mut Context<F>
pub fn new_thread(&mut self, phase: usize) -> &mut Context<F>
Spawns a new thread for a new given phase
. Returns a mutable reference to the Context of the new thread.
phase
: The phase (index) of the gate thread.
sourcepub fn config(
&self,
k: usize,
minimum_rows: Option<usize>
) -> FlexGateConfigParams
pub fn config(
&self,
k: usize,
minimum_rows: Option<usize>
) -> FlexGateConfigParams
Auto-calculates configuration parameters for the circuit
k
: The number of in the circuit (i.e. numeber of rows = 2k)minimum_rows
: The minimum number of rows in the circuit that cannot be used for witness assignments and contain randomblinding factors
to ensure zk property, defaults to 0.
sourcepub fn assign_all(
&self,
config: &FlexGateConfig<F>,
lookup_advice: &[Vec<Column<Advice>>],
q_lookup: &[Option<Selector>],
region: &mut Region<'_, F>,
_: KeygenAssignments<F>
) -> KeygenAssignments<F>
pub fn assign_all(
&self,
config: &FlexGateConfig<F>,
lookup_advice: &[Vec<Column<Advice>>],
q_lookup: &[Option<Selector>],
region: &mut Region<'_, F>,
_: KeygenAssignments<F>
) -> KeygenAssignments<F>
Assigns all advice and fixed cells, turns on selectors, and imposes equality constraints.
Returns the assigned advices, and constants in the form of KeygenAssignments.
Assumes selector and advice columns are already allocated and of the same length.
Note: assign_all()
should be called during keygen or if using mock prover. It also works for the real prover, but there it is more optimal to use assign_threads_in
instead.
config
: The FlexGateConfig of the circuit.lookup_advice
: The lookup advice columns.q_lookup
: The lookup advice selectors.region
: The [Region] of the circuit.assigned_advices
: The assigned advice cells.assigned_constants
: The assigned fixed cells.break_points
: The break points of the circuit.
Trait Implementations
sourceimpl<F: Clone + ScalarField> Clone for GateThreadBuilder<F>
impl<F: Clone + ScalarField> Clone for GateThreadBuilder<F>
sourcefn clone(&self) -> GateThreadBuilder<F>
fn clone(&self) -> GateThreadBuilder<F>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<F: Debug + ScalarField> Debug for GateThreadBuilder<F>
impl<F: Debug + ScalarField> Debug for GateThreadBuilder<F>
sourceimpl<F: Default + ScalarField> Default for GateThreadBuilder<F>
impl<F: Default + ScalarField> Default for GateThreadBuilder<F>
sourcefn default() -> GateThreadBuilder<F>
fn default() -> GateThreadBuilder<F>
Auto Trait Implementations
impl<F> RefUnwindSafe for GateThreadBuilder<F>where
F: RefUnwindSafe,
impl<F> Send for GateThreadBuilder<F>
impl<F> Sync for GateThreadBuilder<F>
impl<F> Unpin for GateThreadBuilder<F>where
F: Unpin,
impl<F> UnwindSafe for GateThreadBuilder<F>where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
self
, then passes self.deref()
into the pipe function.impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read morefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read morefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read morefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read morefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more