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_BYTES: usize = 8;
15
16/// The protocol proves constraint systems over 64-bit words.
17pub const WORD_SIZE_BITS: usize = WORD_SIZE_BYTES * 8;
18
19/// log2 of [`WORD_SIZE_BITS`].
20pub const LOG_WORD_SIZE_BITS: usize = checked_log_2(WORD_SIZE_BITS);
21
22/// The minimum number of words per segment.
23///
24/// This is the minimum size requirement for public input segments in the constraint system.
25pub const MIN_WORDS_PER_SEGMENT: usize = 2;
26
27/// Minimum number of AND constraints (must be a power of 2).
28/// This is a protocol requirement for the constraint system.
29pub const MIN_AND_CONSTRAINTS: usize = 8;
30
31/// Minimum number of MUL constraints (must be a power of 2).
32/// This is a protocol requirement for the constraint system.
33pub const MIN_MUL_CONSTRAINTS: usize = 1;
34
35/// The number of bits in a byte.
36pub const BYTE_BITS: usize = 8;
37
38/// log2 of [`BYTE_BITS`].
39pub const LOG_BYTE_BITS: usize = checked_log_2(BYTE_BITS);