Files
powdr/openvm/src/plonk/mod.rs
Thibaut Schaeffer 2d6708bbc5 Add openvm crates (#2714)
Based on commit 1dbe4db
- Split into two crates, lib and cli
- upgrade stwo, marked one stwo test `should_panic` @ShuangWu121 
- various clippy and fmt fixes linked to the rust version update
- bring all rust versions to 2025-05-14. CI still installs other
versions for openvm which uses them internally. The stable rust version
we test on is bumped to 1.85
- remove `examples` and related tests, which test the powdr crate on the
previous version of powdr (since it uses another nightly). Happy to
discuss this if it's important @leonardoalt
2025-05-16 14:30:09 +00:00

32 lines
971 B
Rust

/// A variable in a PlonK gate.
enum Variable<V> {
/// A variable from the input constraint system.
/// At run-time, we can get the concrete values from the APC witness generation.
Witness(V),
/// A temporary variable (represented by an ID). Assuming there is at most one temporary variable in a gate,
/// we can solve for its value at run-time.
Tmp(usize),
}
/// A PlonK gate. For each gate, the following equation must hold:
/// q_l * a + q_r * b + q_o * c + q_mul * a * b + q_const = 0
/// where q_l, q_r, q_o, q_mul, and q_const are fixed coefficients
/// and a, b, c are variables.
/// If the same variable appears in multiple gates, a copy constraint
/// must be enforced.
struct Gate<T, V> {
q_l: T,
q_r: T,
q_o: T,
q_mul: T,
q_const: T,
a: Variable<V>,
b: Variable<V>,
c: Variable<V>,
}
/// The PlonK circuit, which is just a collection of gates.
struct PlonkCircuit<T, V> {
gates: Vec<Gate<T, V>>,
}