Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ crate-type = ["staticlib"]

[dependencies]
anyhow = "1"
binius_core = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" }
binius_circuits = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" }
binius_field = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" }
binius_macros = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" }
binius_math = { git = "https://gitlab.com/IrreducibleOSS/binius.git", rev = "0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" }
binius_core = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "a451f4cf277938ee968c34c2daf5945465a72d7c" }
binius_circuits = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "a451f4cf277938ee968c34c2daf5945465a72d7c" }
binius_field = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "a451f4cf277938ee968c34c2daf5945465a72d7c" }
binius_macros = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "a451f4cf277938ee968c34c2daf5945465a72d7c" }
binius_math = { git = "https://github.com/IrreducibleOSS/binius.git", rev = "a451f4cf277938ee968c34c2daf5945465a72d7c" }
blake3 = "1"
bytemuck = "1"
bumpalo = "3"
proptest = "1"
rayon = "1"
Expand Down
6 changes: 6 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ license-files = [
{ path = "../../LICENSE.txt", hash = 0 }
]
[[licenses.clarify]]
crate = "binius_maybe_rayon"
expression = "Apache-2.0"
license-files = [
{ path = "../../LICENSE.txt", hash = 0 }
]
[[licenses.clarify]]
crate = "binius_ntt"
expression = "Apache-2.0"
license-files = [
Expand Down
10 changes: 6 additions & 4 deletions src/eiur/binius.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use binius_circuits::builder::witness::Builder;
use binius_core::constraint_system::ConstraintSystem;
use binius_field::{as_packed_field::PackScalar, TowerField};
use binius_field::BinaryField128b;
use bumpalo::Bump;
use std::{cell::RefCell, rc::Rc};

#[inline]
pub fn witness_builder<'a, F: TowerField, U: PackScalar<F>>(
pub fn witness_builder<'a>(
allocator: &'a Bump,
cs: &ConstraintSystem<F>,
) -> Builder<'a, U, F> {
cs: &ConstraintSystem<BinaryField128b>,
) -> Builder<'a> {
// The following clone is cheap because `MultilinearOracleSet` is a wrapper
// around a `Vec<Arc<_>>`.
Builder::new(allocator, Rc::new(RefCell::new(cs.oracles.clone())))
}
12 changes: 4 additions & 8 deletions src/eiur/gadgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ pub mod uint_sub;
use anyhow::Result;
use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder};
use binius_core::oracle::OracleId;
use binius_field::{
as_packed_field::PackScalar, underlier::UnderlierType, BinaryField1b as B1, TowerField,
};
use bytemuck::Pod;

/// Trait for Eiur-compatible gadgets
pub trait Gadget {
Expand All @@ -20,16 +16,16 @@ pub trait Gadget {
/// Creates the constraints for the gadget. New columns, if needed, should be
/// transparent and returned. The constraints should be relaxed where `enabled`
/// is zero.
fn constrain<F: TowerField, U: UnderlierType + PackScalar<F>>(
builder: &mut ConstraintSystemBuilder<U, F>,
fn constrain(
builder: &mut ConstraintSystemBuilder,
name: impl ToString,
input: Self::InputOracles,
enabled: OracleId,
config: Self::Config,
) -> Result<Self::VirtualOracles>;
/// Populates the columns with witness data that satisfy the constraints.
fn generate_witness<F: TowerField, U: PackScalar<F> + PackScalar<B1> + Pod>(
builder: &mut Builder<U, F>,
fn generate_witness(
builder: &mut Builder,
input: Self::InputOracles,
vrtual: Self::VirtualOracles,
config: Self::Config,
Expand Down
21 changes: 8 additions & 13 deletions src/eiur/gadgets/uint_add.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use anyhow::Result;
use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder};
use binius_core::oracle::{OracleId, ShiftVariant};
use binius_field::{
as_packed_field::PackScalar, underlier::UnderlierType, BinaryField1b as B1, TowerField,
};
use binius_field::BinaryField1b as B1;
use binius_macros::arith_expr;
use bytemuck::Pod;
use rayon::prelude::*;

use super::{Gadget, UIntType};
Expand All @@ -30,8 +27,8 @@ impl Gadget for UIntAdd {
type VirtualOracles = UIntAddVirtual;
type Config = UIntType;

fn constrain<F: TowerField, U: UnderlierType + PackScalar<F>>(
builder: &mut ConstraintSystemBuilder<U, F>,
fn constrain(
builder: &mut ConstraintSystemBuilder,
name: impl ToString,
input: UIntAddInput,
enabled: OracleId,
Expand Down Expand Up @@ -69,8 +66,8 @@ impl Gadget for UIntAdd {

/// Populates new columns for `zout`, `cout` and `cin` based on the values
/// from `xin` and `yin`.
fn generate_witness<F: TowerField, U: PackScalar<F> + PackScalar<B1> + Pod>(
builder: &mut Builder<U, F>,
fn generate_witness(
builder: &mut Builder,
input: UIntAddInput,
vrtual: UIntAddVirtual,
config: UIntType,
Expand Down Expand Up @@ -114,9 +111,7 @@ impl Gadget for UIntAdd {
mod tests {
use binius_circuits::builder::{witness::Builder, ConstraintSystemBuilder};
use binius_core::constraint_system::validate::validate_witness;
use binius_field::{
arch::OptimalUnderlier, underlier::SmallU, BinaryField128b, BinaryField1b as B1, TowerField,
};
use binius_field::{underlier::SmallU, BinaryField1b as B1, TowerField};
use bumpalo::Bump;
use proptest::{collection::vec, prelude::*};

Expand All @@ -139,7 +134,7 @@ mod tests {
vec1 in vec(any::<$t>(), LEN),
vec2 in vec(any::<$t>(), LEN),
)| {
let mut csb = ConstraintSystemBuilder::<OptimalUnderlier, BinaryField128b>::new();
let mut csb = ConstraintSystemBuilder::new();
let xin = csb.add_committed("xin", N_VARS, B1::TOWER_LEVEL);
let yin = csb.add_committed("yin", N_VARS, B1::TOWER_LEVEL);
let cout = csb.add_committed("cout", N_VARS, B1::TOWER_LEVEL);
Expand All @@ -152,7 +147,7 @@ mod tests {
let cs = csb.build().unwrap();

let allocator = Bump::new();
let mut wb: Builder<OptimalUnderlier, _> = witness_builder(&allocator, &cs);
let mut wb: Builder = witness_builder(&allocator, &cs);

wb.new_column::<B1>(xin).as_mut_slice().copy_from_slice(&vec1);
wb.new_column::<B1>(yin).as_mut_slice().copy_from_slice(&vec2);
Expand Down
Loading