binius_circuits/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
// Copyright 2024-2025 Irreducible Inc.

//! The Binius frontend library, along with useful gadgets and examples.
//!
//! The frontend library provides high-level interfaces for constructing constraint systems in the
//! [`crate::builder`] module. Most other modules contain circuit gadgets that can be used to build
//! more complex constraint systems.

#![feature(array_try_map, array_try_from_fn)]
#![allow(clippy::module_inception)]

pub mod arithmetic;
pub mod bitwise;
pub mod builder;
pub mod collatz;
pub mod groestl;
pub mod keccakf;
pub mod lasso;
mod pack;
pub mod plain_lookup;
pub mod sha256;
pub mod transparent;
pub mod u32fib;
pub mod unconstrained;
pub mod vision;

#[cfg(test)]
mod tests {
	use std::array;

	use binius_core::{
		constraint_system::{
			self,
			channel::{Boundary, FlushDirection},
			validate::validate_witness,
		},
		fiat_shamir::HasherChallenger,
		oracle::OracleId,
		tower::CanonicalTowerFamily,
	};
	use binius_field::{
		arch::OptimalUnderlier,
		as_packed_field::PackedType,
		tower_levels::{TowerLevel1, TowerLevel16, TowerLevel2, TowerLevel4, TowerLevel8},
		underlier::WithUnderlier,
		AESTowerField16b, BinaryField128b, BinaryField1b, BinaryField32b, BinaryField64b,
		BinaryField8b, Field, TowerField,
	};
	use binius_hal::make_portable_backend;
	use binius_hash::compress::Groestl256ByteCompression;
	use binius_math::DefaultEvaluationDomainFactory;
	use groestl_crypto::Groestl256;
	use rand::{rngs::StdRng, Rng, SeedableRng};
	use sha2::{compress256, digest::generic_array::GenericArray};

	use crate::{
		arithmetic, bitwise,
		builder::ConstraintSystemBuilder,
		groestl::groestl_p_permutation,
		keccakf::{keccakf, KeccakfState},
		lasso::{
			self,
			batch::LookupBatch,
			big_integer_ops::byte_sliced_test_utils::{
				test_bytesliced_add, test_bytesliced_add_carryfree,
				test_bytesliced_double_conditional_increment, test_bytesliced_modular_mul,
				test_bytesliced_mul,
			},
			lookups,
			u32add::SeveralU32add,
		},
		plain_lookup,
		sha256::sha256,
		u32fib::u32fib,
		unconstrained::unconstrained,
		vision::vision_permutation,
	};

	type U = OptimalUnderlier;
	type F = BinaryField128b;

	#[test]
	fn test_lasso_u8add_carryfree_rejects_carry() {
		// TODO: Make this test 100% certain to pass instead of 2^14 bits of security from randomness
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 14;
		let x_in = unconstrained::<_, _, BinaryField8b>(&mut builder, "x", log_size).unwrap();
		let y_in = unconstrained::<_, _, BinaryField8b>(&mut builder, "y", log_size).unwrap();
		let c_in = unconstrained::<_, _, BinaryField1b>(&mut builder, "c", log_size).unwrap();

		let lookup_t =
			lookups::u8_arithmetic::add_carryfree_lookup(&mut builder, "add cf table").unwrap();
		let mut lookup_batch = LookupBatch::new(lookup_t);
		let _sum_and_cout = lasso::u8add_carryfree(
			&mut builder,
			&mut lookup_batch,
			"lasso_u8add",
			x_in,
			y_in,
			c_in,
			log_size,
		)
		.unwrap();

		lookup_batch
			.execute::<_, _, BinaryField32b, BinaryField32b>(&mut builder)
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness)
			.expect_err("Rejected overflowing add");
	}

	#[test]
	fn test_lasso_add_bytesliced() {
		test_bytesliced_add::<1, TowerLevel1>();
		test_bytesliced_add::<2, TowerLevel2>();
		test_bytesliced_add::<4, TowerLevel4>();
		test_bytesliced_add::<8, TowerLevel8>();
	}

	#[test]
	fn test_lasso_mul_bytesliced() {
		test_bytesliced_mul::<1, TowerLevel2>();
		test_bytesliced_mul::<2, TowerLevel4>();
		test_bytesliced_mul::<4, TowerLevel8>();
		test_bytesliced_mul::<8, TowerLevel16>();
	}

	#[test]
	fn test_lasso_modular_mul_bytesliced() {
		test_bytesliced_modular_mul::<1, TowerLevel2>();
		test_bytesliced_modular_mul::<2, TowerLevel4>();
		test_bytesliced_modular_mul::<4, TowerLevel8>();
		test_bytesliced_modular_mul::<8, TowerLevel16>();
	}

	#[test]
	fn test_lasso_bytesliced_double_conditional_increment() {
		test_bytesliced_double_conditional_increment::<1, TowerLevel1>();
		test_bytesliced_double_conditional_increment::<2, TowerLevel2>();
		test_bytesliced_double_conditional_increment::<4, TowerLevel4>();
		test_bytesliced_double_conditional_increment::<8, TowerLevel8>();
	}

	#[test]
	fn test_lasso_bytesliced_add_carryfree() {
		test_bytesliced_add_carryfree::<1, TowerLevel1>();
		test_bytesliced_add_carryfree::<2, TowerLevel2>();
		test_bytesliced_add_carryfree::<4, TowerLevel4>();
		test_bytesliced_add_carryfree::<8, TowerLevel8>();
	}

	#[test]
	fn test_lasso_u8mul() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 10;

		let mult_a =
			unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_a", log_size).unwrap();
		let mult_b =
			unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_b", log_size).unwrap();

		let mul_lookup_table =
			lookups::u8_arithmetic::mul_lookup(&mut builder, "mul table").unwrap();

		let mut lookup_batch = LookupBatch::new(mul_lookup_table);

		let _product = lasso::u8mul(
			&mut builder,
			&mut lookup_batch,
			"lasso_u8mul",
			mult_a,
			mult_b,
			1 << log_size,
		)
		.unwrap();

		lookup_batch
			.execute::<_, _, BinaryField32b, BinaryField32b>(&mut builder)
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_lasso_batched_u8mul() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 10;
		let mul_lookup_table =
			lookups::u8_arithmetic::mul_lookup(&mut builder, "mul table").unwrap();

		let mut lookup_batch = LookupBatch::new(mul_lookup_table);

		for _ in 0..10 {
			let mult_a =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_a", log_size).unwrap();
			let mult_b =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_b", log_size).unwrap();

			let _product = lasso::u8mul(
				&mut builder,
				&mut lookup_batch,
				"lasso_u8mul",
				mult_a,
				mult_b,
				1 << log_size,
			)
			.unwrap();
		}

		lookup_batch
			.execute::<_, _, BinaryField32b, BinaryField32b>(&mut builder)
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_lasso_batched_u8mul_rejects() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 10;

		// We try to feed in the add table instead
		let mul_lookup_table =
			lookups::u8_arithmetic::add_lookup(&mut builder, "mul table").unwrap();

		let mut lookup_batch = LookupBatch::new(mul_lookup_table);

		// TODO?: Make this test fail 100% of the time, even though its almost impossible with rng
		for _ in 0..10 {
			let mult_a =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_a", log_size).unwrap();
			let mult_b =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "mult_b", log_size).unwrap();

			let _product = lasso::u8mul(
				&mut builder,
				&mut lookup_batch,
				"lasso_u8mul",
				mult_a,
				mult_b,
				1 << log_size,
			)
			.unwrap();
		}

		lookup_batch
			.execute::<_, _, BinaryField32b, BinaryField32b>(&mut builder)
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness)
			.expect_err("Channels should be unbalanced");
	}

	#[test]
	fn test_several_lasso_u32add() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);

		let mut several_u32_add = SeveralU32add::new(&mut builder).unwrap();

		[11, 12, 13].into_iter().for_each(|log_size| {
			// BinaryField8b is used here because we utilize an 8x8x1→8 table
			let add_a_u8 =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "add_a", log_size).unwrap();
			let add_b_u8 =
				unconstrained::<_, _, BinaryField8b>(&mut builder, "add_b", log_size).unwrap();
			let _sum = several_u32_add
				.u32add::<BinaryField8b, BinaryField8b>(
					&mut builder,
					"lasso_u32add",
					add_a_u8,
					add_b_u8,
				)
				.unwrap();
		});

		several_u32_add
			.finalize(&mut builder, "lasso_u32add")
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_lasso_u32add() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 14;

		let add_a = unconstrained::<_, _, BinaryField1b>(&mut builder, "add_a", log_size).unwrap();
		let add_b = unconstrained::<_, _, BinaryField1b>(&mut builder, "add_b", log_size).unwrap();
		let _sum = lasso::u32add::<_, _, BinaryField1b, BinaryField1b>(
			&mut builder,
			"lasso_u32add",
			add_a,
			add_b,
		)
		.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_u32add() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 14;
		let a = unconstrained::<_, _, BinaryField1b>(&mut builder, "a", log_size).unwrap();
		let b = unconstrained::<_, _, BinaryField1b>(&mut builder, "b", log_size).unwrap();
		let _c = arithmetic::u32::add(&mut builder, "u32add", a, b, arithmetic::Flags::Unchecked)
			.unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_u32fib() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size_1b = 14;
		let _ = u32fib(&mut builder, "u32fib", log_size_1b).unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_bitwise() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 6;
		let a = unconstrained::<_, _, BinaryField1b>(&mut builder, "a", log_size).unwrap();
		let b = unconstrained::<_, _, BinaryField1b>(&mut builder, "b", log_size).unwrap();
		let _and = bitwise::and(&mut builder, "and", a, b).unwrap();
		let _xor = bitwise::xor(&mut builder, "xor", a, b).unwrap();
		let _or = bitwise::or(&mut builder, "or", a, b).unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_keccakf() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);
		let log_size = 5;

		let mut rng = StdRng::seed_from_u64(0);
		let input_states = vec![KeccakfState(rng.gen())];
		let _state_out = keccakf(&mut builder, Some(input_states), log_size);

		let witness = builder.take_witness().unwrap();

		let constraint_system = builder.build().unwrap();

		let boundaries = vec![];

		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_sha256() {
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, BinaryField1b>::new_with_witness(&allocator);
		let log_size = PackedType::<U, BinaryField1b>::LOG_WIDTH;
		let input: [OracleId; 16] = array::from_fn(|i| {
			unconstrained::<_, _, BinaryField1b>(&mut builder, i, log_size).unwrap()
		});
		let state_output = sha256(&mut builder, input, log_size).unwrap();

		let witness = builder.witness().unwrap();

		let input_witneses: [_; 16] =
			array::from_fn(|i| witness.get(input[i]).unwrap().as_slice::<u32>());

		let output_witneses: [_; 8] =
			array::from_fn(|i| witness.get(state_output[i]).unwrap().as_slice::<u32>());

		let mut generic_array_input = GenericArray::<u8, _>::default();

		let n_compressions = input_witneses[0].len();

		for j in 0..n_compressions {
			for i in 0..16 {
				for z in 0..4 {
					generic_array_input[i * 4 + z] = input_witneses[i][j].to_be_bytes()[z];
				}
			}

			let mut output = crate::sha256::INIT;
			compress256(&mut output, &[generic_array_input]);

			for i in 0..8 {
				assert_eq!(output[i], output_witneses[i][j]);
			}
		}

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_sha256_lasso() {
		let allocator = bumpalo::Bump::new();
		let mut builder =
			ConstraintSystemBuilder::<U, BinaryField32b>::new_with_witness(&allocator);
		let log_size = PackedType::<U, BinaryField1b>::LOG_WIDTH + BinaryField8b::TOWER_LEVEL;
		let input: [OracleId; 16] = array::from_fn(|i| {
			unconstrained::<_, _, BinaryField1b>(&mut builder, i, log_size).unwrap()
		});
		let state_output = lasso::sha256(&mut builder, input, log_size).unwrap();

		let witness = builder.witness().unwrap();

		let input_witneses: [_; 16] = array::from_fn(|i| {
			witness
				.get::<BinaryField1b>(input[i])
				.unwrap()
				.as_slice::<u32>()
		});

		let output_witneses: [_; 8] = array::from_fn(|i| {
			witness
				.get::<BinaryField1b>(state_output[i])
				.unwrap()
				.as_slice::<u32>()
		});

		let mut generic_array_input = GenericArray::<u8, _>::default();

		let n_compressions = input_witneses[0].len();

		for j in 0..n_compressions {
			for i in 0..16 {
				for z in 0..4 {
					generic_array_input[i * 4 + z] = input_witneses[i][j].to_be_bytes()[z];
				}
			}

			let mut output = crate::sha256::INIT;
			compress256(&mut output, &[generic_array_input]);

			for i in 0..8 {
				assert_eq!(output[i], output_witneses[i][j]);
			}
		}

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_groestl() {
		let allocator = bumpalo::Bump::new();
		let mut builder =
			ConstraintSystemBuilder::<OptimalUnderlier, AESTowerField16b>::new_with_witness(
				&allocator,
			);
		let log_size = 9;
		let _state_out = groestl_p_permutation(&mut builder, log_size).unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_vision32b() {
		let allocator = bumpalo::Bump::new();
		let mut builder =
			ConstraintSystemBuilder::<OptimalUnderlier, BinaryField64b>::new_with_witness(
				&allocator,
			);
		let log_size = 8;
		let state_in: [OracleId; 24] = array::from_fn(|i| {
			unconstrained::<_, _, BinaryField32b>(&mut builder, format!("p_in[{i}]"), log_size)
				.unwrap()
		});
		let _state_out = vision_permutation(&mut builder, log_size, state_in).unwrap();

		let witness = builder.take_witness().unwrap();
		let constraint_system = builder.build().unwrap();
		let boundaries = vec![];
		validate_witness(&constraint_system, &boundaries, &witness).unwrap();
	}

	#[test]
	fn test_boundaries() {
		// Proving Collatz Orbits
		let allocator = bumpalo::Bump::new();
		let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);

		let log_size = PackedType::<U, BinaryField8b>::LOG_WIDTH + 2;

		let channel_id = builder.add_channel();

		let push_boundaries = Boundary {
			values: vec![F::from_underlier(6)],
			channel_id,
			direction: FlushDirection::Push,
			multiplicity: 1,
		};

		let pull_boundaries = Boundary {
			values: vec![F::ONE],
			channel_id,
			direction: FlushDirection::Pull,
			multiplicity: 1,
		};

		let even = builder.add_committed("even", log_size, 3);

		let half = builder.add_committed("half", log_size, 3);

		let odd = builder.add_committed("odd", log_size, 3);

		let output = builder.add_committed("output", log_size, 3);

		let mut even_counter = 0;

		let mut odd_counter = 0;

		if let Some(witness) = builder.witness() {
			let mut current = 6;

			let mut even = witness.new_column::<BinaryField8b>(even);

			let even_u8 = even.as_mut_slice::<u8>();

			let mut half = witness.new_column::<BinaryField8b>(half);

			let half_u8 = half.as_mut_slice::<u8>();

			let mut odd = witness.new_column::<BinaryField8b>(odd);

			let odd_u8 = odd.as_mut_slice::<u8>();

			let mut output = witness.new_column::<BinaryField8b>(output);

			let output_u8 = output.as_mut_slice::<u8>();

			while current != 1 {
				if current & 1 == 0 {
					even_u8[even_counter] = current;
					half_u8[even_counter] = current / 2;
					current = half_u8[even_counter];
					even_counter += 1;
				} else {
					odd_u8[odd_counter] = current;
					output_u8[odd_counter] = 3 * current + 1;
					current = output_u8[odd_counter];
					odd_counter += 1;
				}
			}
		}

		builder.flush(FlushDirection::Pull, channel_id, even_counter, [even]);
		builder.flush(FlushDirection::Push, channel_id, even_counter, [half]);
		builder.flush(FlushDirection::Pull, channel_id, odd_counter, [odd]);
		builder.flush(FlushDirection::Push, channel_id, odd_counter, [output]);

		let witness = builder
			.take_witness()
			.expect("builder created with witness");

		let constraint_system = builder.build().unwrap();

		let domain_factory = DefaultEvaluationDomainFactory::default();
		let backend = make_portable_backend();

		let proof = constraint_system::prove::<
			U,
			CanonicalTowerFamily,
			_,
			Groestl256,
			Groestl256ByteCompression,
			HasherChallenger<Groestl256>,
			_,
		>(&constraint_system, 1, 10, witness, &domain_factory, &backend)
		.unwrap();

		constraint_system::verify::<
			U,
			CanonicalTowerFamily,
			Groestl256,
			Groestl256ByteCompression,
			HasherChallenger<Groestl256>,
		>(&constraint_system, 1, 10, vec![pull_boundaries, push_boundaries], proof)
		.unwrap();
	}

	#[test]
	fn test_plain_u8_mul_lookup() {
		const MAX_LOG_MULTIPLICITY: usize = 18;
		let log_lookup_count = 19;

		let log_inv_rate = 1;
		let security_bits = 20;

		let proof = {
			let allocator = bumpalo::Bump::new();
			let mut builder = ConstraintSystemBuilder::<U, F>::new_with_witness(&allocator);

			let _boundary = plain_lookup::test_plain_lookup::test_u8_mul_lookup::<
				_,
				_,
				MAX_LOG_MULTIPLICITY,
			>(&mut builder, log_lookup_count)
			.unwrap();

			let witness = builder.take_witness().unwrap();
			let constraint_system = builder.build().unwrap();
			// validating witness with `validate_witness` is too slow for large transparents like the `table`

			let domain_factory = DefaultEvaluationDomainFactory::default();
			let backend = make_portable_backend();

			constraint_system::prove::<
				U,
				CanonicalTowerFamily,
				_,
				Groestl256,
				Groestl256ByteCompression,
				HasherChallenger<Groestl256>,
				_,
			>(&constraint_system, log_inv_rate, security_bits, witness, &domain_factory, &backend)
			.unwrap()
		};

		// verify
		{
			let mut builder = ConstraintSystemBuilder::<U, F>::new();

			let boundary = plain_lookup::test_plain_lookup::test_u8_mul_lookup::<
				_,
				_,
				MAX_LOG_MULTIPLICITY,
			>(&mut builder, log_lookup_count)
			.unwrap();

			let constraint_system = builder.build().unwrap();

			constraint_system::verify::<
				U,
				CanonicalTowerFamily,
				Groestl256,
				Groestl256ByteCompression,
				HasherChallenger<Groestl256>,
			>(&constraint_system, log_inv_rate, security_bits, vec![boundary], proof)
			.unwrap();
		}
	}
}