binius_core/
consts.rs

1// Copyright 2025 Irreducible Inc.
2//! Protocol-level constants for the Binius64 constraint system.
3
4/// Computes the base-2 logarithm of a value, panicking if it's not a power of 2.
5///
6/// We redefine this function here instead of using the one from binius-utils
7/// to avoid bringing in unnecessary dependencies and cruft.
8const fn checked_log_2(val: usize) -> usize {
9	assert!(val.is_power_of_two(), "Value is not a power of 2");
10	val.ilog2() as usize
11}
12
13/// The protocol proves constraint systems over 64-bit words.
14pub const WORD_SIZE_BITS: usize = 64;
15
16/// log2 of [`WORD_SIZE_BITS`].
17pub const LOG_WORD_SIZE_BITS: usize = checked_log_2(WORD_SIZE_BITS);
18
19/// The minimum number of words per segment.
20///
21/// This is the minimum size requirement for public input segments in the constraint system.
22pub const MIN_WORDS_PER_SEGMENT: usize = 2;
23
24/// Minimum number of AND constraints (must be a power of 2).
25/// This is a protocol requirement for the constraint system.
26pub const MIN_AND_CONSTRAINTS: usize = 8;
27
28/// Minimum number of MUL constraints (must be a power of 2).
29/// This is a protocol requirement for the constraint system.
30pub const MIN_MUL_CONSTRAINTS: usize = 1;
31
32/// The number of bits in a byte.
33pub const BYTE_BITS: usize = 8;
34
35/// log2 of [`BYTE_BITS`].
36pub const LOG_BYTE_BITS: usize = checked_log_2(BYTE_BITS);