pub struct ConstraintSystemBuilder<'arena> { /* private fields */ }
Implementations§
Source§impl<'arena> ConstraintSystemBuilder<'arena>
impl<'arena> ConstraintSystemBuilder<'arena>
pub fn new() -> Self
pub fn new_with_witness(allocator: &'arena Bump) -> Self
pub fn build(self) -> Result<ConstraintSystem<F>, Error>
pub const fn witness(&mut self) -> Option<&mut Builder<'arena>>
pub fn take_witness( &mut self, ) -> Result<MultilinearExtensionIndex<'arena, PackedType<U, F>>, Error>
pub fn flush( &mut self, direction: FlushDirection, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleOrConst<F>> + Clone, ) -> Result<()>
pub fn flush_with_multiplicity( &mut self, direction: FlushDirection, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleOrConst<F>> + Clone, multiplicity: u64, ) -> Result<()>
pub fn flush_custom( &mut self, direction: FlushDirection, channel_id: ChannelId, selector: OracleId, oracle_ids: impl IntoIterator<Item = OracleOrConst<F>> + Clone, multiplicity: u64, ) -> Result<()>
pub fn send( &mut self, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleOrConst<F>> + Clone, ) -> Result<()>
pub fn receive( &mut self, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleOrConst<F>> + Clone, ) -> Result<()>
pub fn assert_zero( &mut self, name: impl ToString, oracle_ids: impl IntoIterator<Item = OracleId>, composition: ArithExpr<F>, )
pub fn assert_not_zero(&mut self, oracle_id: OracleId)
pub const fn add_channel(&mut self) -> ChannelId
pub fn add_committed( &mut self, name: impl ToString, n_vars: usize, tower_level: usize, ) -> OracleId
Sourcepub fn add_static_exp(
&mut self,
bits_ids: Vec<OracleId>,
exp_result_id: OracleId,
base: F,
base_tower_level: usize,
)
pub fn add_static_exp( &mut self, bits_ids: Vec<OracleId>, exp_result_id: OracleId, base: F, base_tower_level: usize, )
Adds an exponentiation operation to the constraint system.
§Parameters
bits_ids
: A vector ofOracleId
representing the exponent in little-endian bit order.exp_result_id
: TheOracleId
that holds the result of the exponentiation..base
: The static base value.base_tower_level
: Specifies the field level in the tower wherebase
is defined
Sourcepub fn add_dynamic_exp(
&mut self,
bits_ids: Vec<OracleId>,
exp_result_id: OracleId,
base: OracleId,
)
pub fn add_dynamic_exp( &mut self, bits_ids: Vec<OracleId>, exp_result_id: OracleId, base: OracleId, )
Adds an exponentiation operation to the constraint system.
§Parameters
bits_ids
: A vector ofOracleId
representing the exponent in little-endian bit order.exp_result_id
: TheOracleId
that holds the result of the exponentiation..base
: The dynamic base value.
pub fn add_committed_multiple<const N: usize>( &mut self, name: impl ToString, n_vars: usize, tower_level: usize, ) -> [OracleId; N]
pub fn add_linear_combination( &mut self, name: impl ToString, n_vars: usize, inner: impl IntoIterator<Item = (OracleId, F)>, ) -> Result<OracleId, OracleError>
pub fn add_linear_combination_with_offset( &mut self, name: impl ToString, n_vars: usize, offset: F, inner: impl IntoIterator<Item = (OracleId, F)>, ) -> Result<OracleId, OracleError>
pub fn add_composite_mle( &mut self, name: impl ToString, n_vars: usize, inner: impl IntoIterator<Item = OracleId>, comp: ArithExpr<F>, ) -> Result<OracleId, OracleError>
pub fn add_packed( &mut self, name: impl ToString, id: OracleId, log_degree: usize, ) -> Result<OracleId, OracleError>
Sourcepub fn add_projected(
&mut self,
name: impl ToString,
id: OracleId,
values: Vec<F>,
start_index: usize,
) -> Result<usize, OracleError>
pub fn add_projected( &mut self, name: impl ToString, id: OracleId, values: Vec<F>, start_index: usize, ) -> Result<usize, OracleError>
Adds a projection to the variables starting at start_index
.
Sourcepub fn add_projected_last_vars(
&mut self,
name: impl ToString,
id: OracleId,
values: Vec<F>,
) -> Result<usize, OracleError>
pub fn add_projected_last_vars( &mut self, name: impl ToString, id: OracleId, values: Vec<F>, ) -> Result<usize, OracleError>
Adds a projection to the last variables.
pub fn add_repeating( &mut self, name: impl ToString, id: OracleId, log_count: usize, ) -> Result<OracleId, OracleError>
pub fn add_shifted( &mut self, name: impl ToString, id: OracleId, offset: usize, block_bits: usize, variant: ShiftVariant, ) -> Result<OracleId, OracleError>
pub fn add_transparent( &mut self, name: impl ToString, poly: impl MultivariatePoly<F> + 'static, ) -> Result<OracleId, OracleError>
pub fn add_zero_padded( &mut self, name: impl ToString, id: OracleId, n_vars: usize, ) -> Result<OracleId, OracleError>
Sourcepub fn push_namespace(&mut self, name: impl ToString)
pub fn push_namespace(&mut self, name: impl ToString)
Anything pushed to the namespace will become part of oracle name, which is useful for debugging.
Use pop_namespace(&mut self)
to remove the latest name.
Example
use binius_circuits::builder::ConstraintSystemBuilder;
use binius_field::{TowerField, BinaryField128b, BinaryField1b, arch::OptimalUnderlier};
let log_size = 14;
let mut builder = ConstraintSystemBuilder::new();
builder.push_namespace("a");
let x = builder.add_committed("x", log_size, BinaryField1b::TOWER_LEVEL);
builder.push_namespace("b");
let y = builder.add_committed("y", log_size, BinaryField1b::TOWER_LEVEL);
builder.pop_namespace();
builder.pop_namespace();
let z = builder.add_committed("z", log_size, BinaryField1b::TOWER_LEVEL);
let system = builder.build().unwrap();
assert_eq!(system.oracles.oracle(x).name().unwrap(), "a::x");
assert_eq!(system.oracles.oracle(y).name().unwrap(), "a::b::y");
assert_eq!(system.oracles.oracle(z).name().unwrap(), "z");
pub fn pop_namespace(&mut self)
Sourcepub fn log_rows(
&self,
oracle_ids: impl IntoIterator<Item = OracleId>,
) -> Result<usize>
pub fn log_rows( &self, oracle_ids: impl IntoIterator<Item = OracleId>, ) -> Result<usize>
Returns the number of rows shared by a set of columns.
Fails if no columns are provided, or not all columns have the same number of rows.
This is useful for writing circuits with internal columns that depend on the height of input columns.
Trait Implementations§
Source§impl<'arena> Default for ConstraintSystemBuilder<'arena>
impl<'arena> Default for ConstraintSystemBuilder<'arena>
Source§fn default() -> ConstraintSystemBuilder<'arena>
fn default() -> ConstraintSystemBuilder<'arena>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'arena> Freeze for ConstraintSystemBuilder<'arena>
impl<'arena> !RefUnwindSafe for ConstraintSystemBuilder<'arena>
impl<'arena> !Send for ConstraintSystemBuilder<'arena>
impl<'arena> !Sync for ConstraintSystemBuilder<'arena>
impl<'arena> Unpin for ConstraintSystemBuilder<'arena>
impl<'arena> !UnwindSafe for ConstraintSystemBuilder<'arena>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more