diff --git a/Cargo.lock b/Cargo.lock index ac8ae90d..5350d54e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -219,7 +219,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "binius_circuits" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "alloy-primitives", "anyhow", @@ -228,12 +228,12 @@ dependencies = [ "binius_hash", "binius_macros", "binius_math", + "binius_maybe_rayon", "binius_utils", "bumpalo", "bytemuck", "itertools 0.13.0", "rand", - "rayon", "tiny-keccak", "tracing", ] @@ -241,14 +241,16 @@ dependencies = [ [[package]] name = "binius_core" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "assert_matches", "auto_impl", "binius_field", "binius_hal", "binius_hash", + "binius_macros", "binius_math", + "binius_maybe_rayon", "binius_ntt", "binius_utils", "bytemuck", @@ -259,7 +261,6 @@ dependencies = [ "getset", "itertools 0.13.0", "rand", - "rayon", "stackalloc", "thiserror", "tracing", @@ -270,15 +271,16 @@ dependencies = [ [[package]] name = "binius_field" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ + "binius_maybe_rayon", "binius_utils", "bytemuck", "bytes", "cfg-if", "derive_more 0.99.19", + "generic-array", "rand", - "rayon", "seq-macro", "subtle", "thiserror", @@ -289,16 +291,16 @@ dependencies = [ [[package]] name = "binius_hal" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "auto_impl", "binius_field", "binius_math", + "binius_maybe_rayon", "binius_utils", "bytemuck", "itertools 0.13.0", "rand", - "rayon", "stackalloc", "thiserror", "tracing", @@ -307,7 +309,7 @@ dependencies = [ [[package]] name = "binius_hash" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "binius_field", "binius_ntt", @@ -325,7 +327,7 @@ dependencies = [ [[package]] name = "binius_macros" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "proc-macro2", "quote", @@ -335,45 +337,56 @@ dependencies = [ [[package]] name = "binius_math" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "auto_impl", "binius_field", + "binius_maybe_rayon", "binius_utils", "bytemuck", "either", "getset", "itertools 0.13.0", + "lazy_static", "rand", - "rayon", "stackalloc", "thiserror", "tracing", ] +[[package]] +name = "binius_maybe_rayon" +version = "0.2.0" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" +dependencies = [ + "cfg-if", + "either", + "itertools 0.13.0", +] + [[package]] name = "binius_ntt" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ "binius_field", "binius_math", + "binius_maybe_rayon", "binius_utils", "rand", - "rayon", "thiserror", ] [[package]] name = "binius_utils" version = "0.2.0" -source = "git+https://gitlab.com/IrreducibleOSS/binius.git?rev=0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a#0e5ec53f260f40fe6afcc741d4ff8f021a66dc1a" +source = "git+https://github.com/IrreducibleOSS/binius.git?rev=a451f4cf277938ee968c34c2daf5945465a72d7c#a451f4cf277938ee968c34c2daf5945465a72d7c" dependencies = [ + "binius_maybe_rayon", "bytemuck", - "bytes", + "cfg-if", "generic-array", "itertools 0.13.0", - "rayon", "thiserror", "thread_local", ] @@ -479,9 +492,9 @@ checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" [[package]] name = "cc" -version = "1.2.13" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -960,7 +973,6 @@ dependencies = [ "binius_math", "blake3", "bumpalo", - "bytemuck", "proptest", "rayon", "rustc-hash", @@ -1665,9 +1677,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.22.23" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "toml_datetime", diff --git a/Cargo.toml b/Cargo.toml index d68f72db..cb375d01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/deny.toml b/deny.toml index e37a8607..94e96f27 100644 --- a/deny.toml +++ b/deny.toml @@ -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 = [ diff --git a/src/eiur/binius.rs b/src/eiur/binius.rs index a06fc1e0..f562b774 100644 --- a/src/eiur/binius.rs +++ b/src/eiur/binius.rs @@ -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>( +pub fn witness_builder<'a>( allocator: &'a Bump, - cs: &ConstraintSystem, -) -> Builder<'a, U, F> { + cs: &ConstraintSystem, +) -> Builder<'a> { + // The following clone is cheap because `MultilinearOracleSet` is a wrapper + // around a `Vec>`. Builder::new(allocator, Rc::new(RefCell::new(cs.oracles.clone()))) } diff --git a/src/eiur/gadgets/mod.rs b/src/eiur/gadgets/mod.rs index 9a58e9da..0617f090 100644 --- a/src/eiur/gadgets/mod.rs +++ b/src/eiur/gadgets/mod.rs @@ -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 { @@ -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>( - builder: &mut ConstraintSystemBuilder, + fn constrain( + builder: &mut ConstraintSystemBuilder, name: impl ToString, input: Self::InputOracles, enabled: OracleId, config: Self::Config, ) -> Result; /// Populates the columns with witness data that satisfy the constraints. - fn generate_witness + PackScalar + Pod>( - builder: &mut Builder, + fn generate_witness( + builder: &mut Builder, input: Self::InputOracles, vrtual: Self::VirtualOracles, config: Self::Config, diff --git a/src/eiur/gadgets/uint_add.rs b/src/eiur/gadgets/uint_add.rs index 5f729f19..6662d0b4 100644 --- a/src/eiur/gadgets/uint_add.rs +++ b/src/eiur/gadgets/uint_add.rs @@ -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}; @@ -30,8 +27,8 @@ impl Gadget for UIntAdd { type VirtualOracles = UIntAddVirtual; type Config = UIntType; - fn constrain>( - builder: &mut ConstraintSystemBuilder, + fn constrain( + builder: &mut ConstraintSystemBuilder, name: impl ToString, input: UIntAddInput, enabled: OracleId, @@ -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 + PackScalar + Pod>( - builder: &mut Builder, + fn generate_witness( + builder: &mut Builder, input: UIntAddInput, vrtual: UIntAddVirtual, config: UIntType, @@ -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::*}; @@ -139,7 +134,7 @@ mod tests { vec1 in vec(any::<$t>(), LEN), vec2 in vec(any::<$t>(), LEN), )| { - let mut csb = ConstraintSystemBuilder::::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); @@ -152,7 +147,7 @@ mod tests { let cs = csb.build().unwrap(); let allocator = Bump::new(); - let mut wb: Builder = witness_builder(&allocator, &cs); + let mut wb: Builder = witness_builder(&allocator, &cs); wb.new_column::(xin).as_mut_slice().copy_from_slice(&vec1); wb.new_column::(yin).as_mut_slice().copy_from_slice(&vec2); diff --git a/src/eiur/gadgets/uint_sub.rs b/src/eiur/gadgets/uint_sub.rs index 28aae628..051b0912 100644 --- a/src/eiur/gadgets/uint_sub.rs +++ b/src/eiur/gadgets/uint_sub.rs @@ -1,10 +1,7 @@ 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; +use binius_field::BinaryField1b as B1; use rayon::prelude::*; use super::{ @@ -32,8 +29,8 @@ impl Gadget for UIntSub { type VirtualOracles = UIntSubVirtual; type Config = UIntType; - fn constrain>( - builder: &mut ConstraintSystemBuilder, + fn constrain( + builder: &mut ConstraintSystemBuilder, name: impl ToString, input: UIntSubInput, enabled: OracleId, @@ -60,8 +57,8 @@ impl Gadget for UIntSub { /// Populates new columns for `xout`, `cout` and `cin` based on the values /// from `zin` and `yin`. - fn generate_witness + PackScalar + Pod>( - builder: &mut Builder, + fn generate_witness( + builder: &mut Builder, input: UIntSubInput, vrtual: UIntSubVirtual, config: UIntType, @@ -105,9 +102,7 @@ impl Gadget for UIntSub { 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::*}; @@ -130,7 +125,7 @@ mod tests { vec1 in vec(any::<$t>(), LEN), vec2 in vec(any::<$t>(), LEN), )| { - let mut csb = ConstraintSystemBuilder::::new(); + let mut csb = ConstraintSystemBuilder::new(); let zin = csb.add_committed("zin", 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); @@ -143,7 +138,7 @@ mod tests { let cs = csb.build().unwrap(); let allocator = Bump::new(); - let mut wb: Builder = witness_builder(&allocator, &cs); + let mut wb: Builder = witness_builder(&allocator, &cs); wb.new_column::(zin).as_mut_slice().copy_from_slice(&vec1); wb.new_column::(yin).as_mut_slice().copy_from_slice(&vec2);