binius_core/constraint_system/
mod.rs

1// Copyright 2024-2025 Irreducible Inc.
2
3pub mod channel;
4mod common;
5pub mod error;
6pub mod exp;
7mod prove;
8pub mod validate;
9mod verify;
10
11use binius_field::{BinaryField128b, TowerField};
12use binius_macros::{DeserializeBytes, SerializeBytes};
13use channel::{ChannelId, Flush};
14use exp::Exp;
15pub use prove::prove;
16pub use verify::verify;
17
18use crate::oracle::{ConstraintSet, MultilinearOracleSet, OracleId};
19
20/// Contains the 3 things that place constraints on witness data in Binius
21/// - virtual oracles
22/// - polynomial constraints
23/// - channel flushes
24///
25/// As a result, a ConstraintSystem allows us to validate all of these
26/// constraints against a witness, as well as enabling generic prove/verify
27#[derive(Debug, Clone, SerializeBytes, DeserializeBytes)]
28#[deserialize_bytes(eval_generics(F = BinaryField128b))]
29pub struct ConstraintSystem<F: TowerField> {
30	pub oracles: MultilinearOracleSet<F>,
31	pub table_constraints: Vec<ConstraintSet<F>>,
32	pub non_zero_oracle_ids: Vec<OracleId>,
33	pub flushes: Vec<Flush<F>>,
34	pub exponents: Vec<Exp<F>>,
35	pub max_channel_id: ChannelId,
36}
37
38impl<F: TowerField> ConstraintSystem<F> {
39	pub const fn no_base_constraints(self) -> Self {
40		self
41	}
42}
43
44/// Constraint system proof that has been serialized into bytes
45#[derive(Debug, Clone)]
46pub struct Proof {
47	pub transcript: Vec<u8>,
48}
49
50impl Proof {
51	pub fn get_proof_size(&self) -> usize {
52		self.transcript.len()
53	}
54}