Skip to content

Commit 844bdc1

Browse files
committed
example: Blake3 permutation using channels API (#10)
* Support for Karatsuba "infinity" point in evaluation & interpolation domains * [sumcheck] Small field zerocheck and its HAL support removed * [ring_switch] Optimize RingSwitchEqInd::multilinear_extension * [clippy]: avoid needless pass by value * [math] Fix `fold_right` crash on big multilinears and make it single threaded * [math] Use specialized zero variable folding in the first sumcheck round. * [test]: add test coverage for eq_ind_partial_eval * [test]: add test coverage for inner_product_par * [test]: test coverage for MultilinearQuery update * [tracing] Display proof size in graph * [ci]: Setting Up GitHub Pipelines * [ci]: Setting Up Mirror to GitLab (#8) * Fix typos (#2) [nicetohave] fix typos * [ci]: Improvements (IrreducibleOSS#17) [ci]: Removing continue or error, and depricating Gitlab pipelines * Improve test compilation time (#10) Co-authored-by: Dmytro Gordon <dgordon@irreducible.io> This MR addresses tow issues that make cargo test slow: Thin LTO slows down compilation of all the crates a bit. It takes quite a time to compile and link all the examples with test profile which are not actually executed. So I've added an alias to compile and run tests only for fast local usage. * [serialization] Add canonical serialize/deserialize traits + derive macros Introduces the following traits: SerializeCanonical (which replaces most uses of SerializeBytes) DeserializeCanonical (which replaces most uses of DeserializeBytes) Conveniently, this also comes with proc-macros for deriving these traits for an arbitrary struct/enum (unions are not supported). * [security]: Add CODEOWNERS file for GitHub * [scripts] Added benchmarking script This adds the script to benchmark various of our examples, default sampling is set to 5 to reduce total time to benchmark. * [field] Implement PackedField::unzip * [cleanup]: Remove some useless checked_log_2 calls * [field] Add TowerField::min_tower_level(self), and use it to derive ArithExpr tower_level from its constants (#6) In contrast to TowerField::TOWER_LEVEL, TowerField::binary_tower_level(self) returns the smallest tower level that can fit the current value. This can be useful for shrinking field values to the smaller container that fits them, for the purpose of making arithmetic operations (in particular multiplication) cheaper. * [core]: simplify merkle tree `verify_opening` (IrreducibleOSS#14) * [ci] Adjusting nightly benchmark repository (IrreducibleOSS#23) * [ci]: Adjusting nightly benchmark repository * [ci]: Adjusting CODEOWNERS for .github/ subdir * [circuits] Simplify usage of ConstraintSystemBuilder by making it less generic (IrreducibleOSS#22) [circuits] Simplfy ConstraintSystemBuilder to only support BinaryField128b for the top field. * [field] Simplify usage of PackedExtension, RepackedExtension by making each trait imply its bounds (IrreducibleOSS#24) * [macros] Remove unused IterOracles, IterPolys derive proc macros (IrreducibleOSS#25) * [matrix]: simplify scale_row (IrreducibleOSS#31) * [field] Remove unnecessary `WithUnderlier` trait bound (IrreducibleOSS#32) * [field] Optimize SIMD element access for Zen4 architecture as well. (IrreducibleOSS#28) * refactor: Use binary_tower_level for base field detection (IrreducibleOSS#30) * [serialization] impl SerializeCanonical, DeserializeCanonical for ConstraintSystem (IrreducibleOSS#11) * [circuits] Optimize plain_lookup using selector flushing (IrreducibleOSS#29) * [scripts] Remove groestl run from benchmark script (IrreducibleOSS#26) * [arith_expr]: Statically compile exponentiation in ArithCircuitPoly (IrreducibleOSS#15) * [serialization] Introduce SerializationMode (IrreducibleOSS#36) Changes: Adds SerializaitonMode that specifies whether to use native (fast) or canonical (needed for transcript) serialization/deserializtion. You need to use the same mode for serialization and deserialization. SerializeCanonical is renamed to SerializeBytes, and takes an extra argument of type SerializationMode DeserializeCanonical is renamed to DeserializeBytes and takes an extra argument of type SerializationMode SerializeBytes and DeserializeBytes are now required bounds for the Field trait, rather than being generically implemented for TowerField. u16, u32, u64, u128 now serialize to/deserialize from little-endian rather than big-endian byte order, to be consistent with BinaryField*b serialization. The serialization traits are moved back to binius_utils Automatic implementations of SerializeBytes for Box<T: SerializeBytes> and &(T: SerializeBytes) Automatic implementation of DeserializeBytes for Box<T: DeserializeBytes> * [gkr_int_mul] Fix type bounds (IrreducibleOSS#34) * feat: Blake3 G function gadget (IrreducibleOSS#16) * [circuits] Add test_circuit helper (IrreducibleOSS#27) * Leave only the object-safe version of the `CompositionPoly` trait (IrreducibleOSS#43) * ]field] Byte-sliced fields changes (IrreducibleOSS#21) * Refactor a bit TowerLevels to remove packed field parameter from the TowerLevel to the Data associated type. This also makes generic bounds a bit more clean, since TowerLevel itself doesn't depend on a concrete packed field type. * Add support of byte-sliced fields with arbitrary register size, i.e. 128b, 256b, 512b. * Add shifts and unpack low/high within 128-bit lanes to UnderlierWithBitOps. This allows implementing transposition in an efficient way. * Add the transparent implementation of UnderlierWithBitOps for PackedScaledUnderlier as we need it to re-use PackedScaledField. * feat: Add example of LinearCombination column usage * ci: Add basic Rust CI (#2) * ci: Add basic Rust CI * Fix test flags * example: Linear combination with offset (#4) * example: Add linear-combination-with-offset usage example * chore: Add example for bit masking using LinearCombination * chore: Add byte decomposition constraint * example: Implement bit-shifting/rotating and packing (#5) * example: Add example of Shifted column usage * example: Add example of Packed column usage * chore: Add 'unconstrained gadgets' warning * example: Projected / Repeated columns usage (#6) * example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage * examples: Transparent columns usage (part 1) (#8) * feat: Add example of Transparent (Constant) column usage * example: Add example of Transparent (Powers) column usage * example: Add example of Transparent (DisjointProduct) column usage * example: Add example of Transparent (EqIndPartialEval) column usage * examples: Transparent columns usage (part 2) (#9) * example: Add example of Transparent (MultilinearExtensionTransparent) column usage * example: Add example of Transparent (SelectRow) column usage * example: Add example of Transparent (ShiftIndPartialEval) column usage * example: Add example of Transparent (StepDown) column usage * example: Add example of Transparent (StepUp) column usage * example: Add example of Transparent (TowerBasis) column usage * chore: Forward port * feat: Blake3 permutation using channels API * chore: Formatting --------- Co-authored-by: Nikita Lesnikov <nlesnikov@ulvetanna.io> Co-authored-by: Dmitry Gordon <dgordon@irreducible.com> Co-authored-by: Thomas Coratger <thomas.coratger@gmail.com> Co-authored-by: Aliaksei Dziadziuk <adziadziuk@irreducible.com> Co-authored-by: Milos Backonja <mbackonja@irreducible.com> Co-authored-by: Milos Backonja <35807060+milosbackonja@users.noreply.github.com> Co-authored-by: chloefeal <188809157+chloefeal@users.noreply.github.com> Co-authored-by: Dmytro Gordon <g-d@ukr.net> Co-authored-by: Tobias Bergkvist <tbergkvist@ulvetanna.io> Co-authored-by: Anex007 <anexjohnson007@gmail.com> Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Co-authored-by: Nikita Lesnikov <nlesnikov@irreducible.com> Co-authored-by: Joseph Johnston <josephljohnston@mac.com> Co-authored-by: Samuel Burnham <45365069+samuelburnham@users.noreply.github.com> rebase
1 parent 3fdf78c commit 844bdc1

23 files changed

Lines changed: 184 additions & 207 deletions

.github/workflows/benchmark.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/mirror.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

crates/circuits/src/vision.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ use anyhow::Result;
1313
use binius_core::{oracle::OracleId, transparent::constant::Constant};
1414
use binius_field::{
1515
linear_transformation::Transformation, make_aes_to_binary_packed_transformer,
16-
packed::get_packed_slice, AESTowerField32b, BinaryField1b, BinaryField32b, ExtensionField,
17-
Field, PackedAESBinaryField8x32b, PackedBinaryField8x32b, PackedExtension, PackedField,
18-
TowerField,
16+
packed::get_packed_slice, BinaryField1b, BinaryField32b, ExtensionField, Field,
17+
PackedAESBinaryField8x32b, PackedBinaryField8x32b, PackedExtension, PackedField, TowerField,
1918
};
2019
use binius_hash::{Vision32MDSTransform, INV_PACKED_TRANS_AES};
2120
use binius_macros::arith_expr;

crates/core/src/protocols/sumcheck/prove/regular_sumcheck.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ where
142142
.collect();
143143

144144
let nontrivial_evaluation_points = get_nontrivial_evaluation_points(&domains)?;
145-
146145
let state = ProverState::new(
147146
evaluation_order,
148147
multilinears,

examples/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ path = "blake3_circuit.rs"
8181
name = "acc-linear-combination"
8282
path = "acc-linear-combination.rs"
8383

84-
[[example]]
85-
name = "acc-linear-combination-with-offset"
86-
path = "acc-linear-combination-with-offset.rs"
84+
#[[example]]
85+
#name = "acc-linear-combination-with-offset"
86+
#path = "acc-linear-combination-with-offset.rs"
8787

8888
[[example]]
8989
name = "acc-shifted"
@@ -145,6 +145,10 @@ path = "acc-step-up.rs"
145145
name = "acc-tower-basis"
146146
path = "acc-tower-basis.rs"
147147

148+
[[example]]
149+
name = "acc-permutation-channels"
150+
path = "acc-permutation-channels.rs"
151+
148152
[lints.clippy]
149153
needless_range_loop = "allow"
150154

examples/acc-constants.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
use binius_circuits::{builder::ConstraintSystemBuilder, sha256::u32const_repeating};
1+
use binius_circuits::{arithmetic::u32::u32const_repeating, builder::ConstraintSystemBuilder};
22
use binius_core::{
33
constraint_system::validate::validate_witness, oracle::OracleId,
44
transparent::constant::Constant,
55
};
6-
use binius_field::{arch::OptimalUnderlier, BinaryField128b, BinaryField1b, BinaryField32b};
7-
8-
type U = OptimalUnderlier;
9-
type F128 = BinaryField128b;
6+
use binius_field::{BinaryField1b, BinaryField32b};
107
type F32 = BinaryField32b;
118
type F1 = BinaryField1b;
129

@@ -17,7 +14,7 @@ const LOG_SIZE: usize = 4;
1714
fn constants_gadget(
1815
name: impl ToString,
1916
log_size: usize,
20-
builder: &mut ConstraintSystemBuilder<U, F128>,
17+
builder: &mut ConstraintSystemBuilder,
2118
constant_value: u32,
2219
) -> OracleId {
2320
builder.push_namespace(name);
@@ -45,7 +42,8 @@ fn constants_gadget(
4542
// Transparent column.
4643
fn main() {
4744
let allocator = bumpalo::Bump::new();
48-
let mut builder = ConstraintSystemBuilder::<U, F128>::new_with_witness(&allocator);
45+
46+
let mut builder = ConstraintSystemBuilder::new_with_witness(&allocator);
4947

5048
pub const SHA256_INIT: [u32; 8] = [
5149
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab,

examples/acc-disjoint-product.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ use binius_core::{
33
constraint_system::validate::validate_witness,
44
transparent::{constant::Constant, disjoint_product::DisjointProduct, powers::Powers},
55
};
6-
use binius_field::{
7-
arch::OptimalUnderlier, BinaryField, BinaryField128b, BinaryField8b, PackedField,
8-
};
6+
use binius_field::{BinaryField, BinaryField8b, PackedField};
97

10-
type U = OptimalUnderlier;
11-
type F128 = BinaryField128b;
128
type F8 = BinaryField8b;
139

1410
const LOG_SIZE: usize = 4;
@@ -29,7 +25,7 @@ const LOG_SIZE: usize = 4;
2925
// of heights (n_vars) of Powers and Constant, so actual data could be repeated multiple times
3026
fn main() {
3127
let allocator = bumpalo::Bump::new();
32-
let mut builder = ConstraintSystemBuilder::<U, F128>::new_with_witness(&allocator);
28+
let mut builder = ConstraintSystemBuilder::new_with_witness(&allocator);
3329

3430
let generator = F8::MULTIPLICATIVE_GENERATOR;
3531
let powers = Powers::new(LOG_SIZE, generator.into());

examples/acc-eq-ind-partial-eval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use binius_circuits::builder::ConstraintSystemBuilder;
22
use binius_core::{
33
constraint_system::validate::validate_witness, transparent::eq_ind::EqIndPartialEval,
44
};
5-
use binius_field::{arch::OptimalUnderlier, BinaryField128b, PackedField};
5+
use binius_field::{BinaryField128b, PackedField};
66

7-
type U = OptimalUnderlier;
87
type F128 = BinaryField128b;
98

109
const LOG_SIZE: usize = 3;
@@ -21,7 +20,8 @@ const LOG_SIZE: usize = 3;
2120
//
2221
fn main() {
2322
let allocator = bumpalo::Bump::new();
24-
let mut builder = ConstraintSystemBuilder::<U, F128>::new_with_witness(&allocator);
23+
24+
let mut builder = ConstraintSystemBuilder::new_with_witness(&allocator);
2525

2626
// A truth table [000, 001, 010, 011 ... 111] where each row is in reversed order
2727
let rev_basis = [
@@ -44,7 +44,7 @@ fn main() {
4444
// challenges size correlates with LOG_SIZE
4545
assert_eq!(challenges.len(), LOG_SIZE);
4646

47-
let eq_ind_partial_eval = EqIndPartialEval::new(LOG_SIZE, challenges.clone()).unwrap();
47+
let eq_ind_partial_eval = EqIndPartialEval::new(challenges.clone());
4848

4949
let id = builder
5050
.add_transparent("eq_ind_partial_eval", eq_ind_partial_eval)
File renamed without changes.

examples/acc-linear-combination.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
use binius_circuits::{builder::ConstraintSystemBuilder, unconstrained::unconstrained};
22
use binius_core::{constraint_system::validate::validate_witness, oracle::OracleId};
33
use binius_field::{
4-
arch::OptimalUnderlier, packed::set_packed_slice, BinaryField128b, BinaryField1b,
5-
BinaryField8b, ExtensionField, TowerField,
4+
packed::set_packed_slice, BinaryField1b, BinaryField8b, ExtensionField, TowerField,
65
};
76
use binius_macros::arith_expr;
87

9-
type U = OptimalUnderlier;
10-
type F128 = BinaryField128b;
118
type F8 = BinaryField8b;
129
type F1 = BinaryField1b;
1310

1411
// FIXME: Following gadgets are unconstrained. Only for demonstrative purpose, don't use in production
1512

1613
fn bytes_decomposition_gadget(
17-
builder: &mut ConstraintSystemBuilder<U, F128>,
14+
builder: &mut ConstraintSystemBuilder,
1815
name: impl ToString,
1916
log_size: usize,
2017
input: OracleId,
@@ -146,7 +143,7 @@ fn bytes_decomposition_gadget(
146143
}
147144

148145
fn elder_4bits_masking_gadget(
149-
builder: &mut ConstraintSystemBuilder<U, F128>,
146+
builder: &mut ConstraintSystemBuilder,
150147
name: impl ToString,
151148
log_size: usize,
152149
input: OracleId,
@@ -241,12 +238,12 @@ fn elder_4bits_masking_gadget(
241238

242239
fn main() {
243240
let allocator = bumpalo::Bump::new();
244-
let mut builder = ConstraintSystemBuilder::<U, F128>::new_with_witness(&allocator);
241+
let mut builder = ConstraintSystemBuilder::new_with_witness(&allocator);
245242

246243
let log_size = 1usize;
247244

248245
// Define set of bytes that we want to decompose
249-
let p_in = unconstrained::<U, F128, F8>(&mut builder, "p_in".to_string(), log_size).unwrap();
246+
let p_in = unconstrained::<F8>(&mut builder, "p_in".to_string(), log_size).unwrap();
250247

251248
let _ =
252249
bytes_decomposition_gadget(&mut builder, "bytes decomposition", log_size, p_in).unwrap();

0 commit comments

Comments
 (0)