strata/proof/src/lib.rs

#![no_std]
//! strata-proof — tier 2: proof system traits.
//!
//! traits needed by lens (polynomial commitment) and zheng (constraint verification).
//! consumers that only do field arithmetic (hemera) don't need this tier.
//!
//! ## Reduce
//!
//! derive a field element from hash output bytes. this is the bridge between
//! hemera (which produces bytes) and field operations (which need elements).
//! used for Fiat-Shamir challenges in lens and zheng.
//!
//! ## Dot
//!
//! compute the inner product Σ aᵢ·bᵢ of two field element vectors.
//! zheng uses this for CCS constraint evaluation (matrix-vector products).
//! lens uses it for multilinear polynomial evaluation.
//! algebras can override the default loop with hardware FMA, delayed
//! modular reduction, or vectorized operations.

use strata_core::Field;

/// derive a field element from arbitrary bytes.
///
/// the bytes typically come from a hash function (hemera). the reduction
/// maps bytes to a field element deterministically. the distribution
/// should be close to uniform over the field.
///
/// used by lens Transcript::squeeze_field and zheng Fiat-Shamir.
pub trait Reduce: Field {
    /// reduce hash output bytes to a field element.
    /// the input length depends on the field:
    /// - Goldilocks: ≥ 8 bytes (take low 8 bytes, reduce mod p)
    /// - F₂¹²⁸: ≥ 16 bytes (take low 16 bytes, interpret as u128)
    /// - F_q: ≥ 64 bytes (take 64 bytes, reduce mod q)
    fn reduce(bytes: &[u8]) -> Self;
}

/// inner product of two field element vectors: Σ aᵢ·bᵢ.
///
/// the fundamental operation for constraint evaluation and polynomial
/// evaluation. given vectors a = [a₀, a₁, ...] and b = [b₀, b₁, ...],
/// computes a₀·b₀ + a₁·b₁ + ... + aₙ·bₙ.
///
/// default implementation is a simple loop. algebras can override with:
/// - hardware FMA (fused multiply-add, avoids intermediate rounding)
/// - delayed modular reduction (accumulate in wider integer, reduce once)
/// - SIMD vectorization (process 4-8 products in parallel)
///
/// consumers:
/// - zheng: Σ constraint_coeff[i] · witness[i] (CCS evaluation)
/// - lens: Σ eval[i] · basis[i] (multilinear extension evaluation)
/// - nox: Σ weight[i] · value[i] (linear combination jets)
pub trait Dot: Field {
    /// compute a[0]*b[0] + a[1]*b[1] + ... + a[n-1]*b[n-1].
    /// panics if slices differ in length.
    fn dot(a: &[Self], b: &[Self]) -> Self {
        assert_eq!(a.len(), b.len());
        let mut acc = Self::ZERO;
        for (&ai, &bi) in a.iter().zip(b.iter()) {
            acc += ai * bi;
        }
        acc
    }
}

Synonyms

bbg/src/lib.rs
optica/src/lib.rs
zheng/src/lib.rs
nox/rs/lib.rs
honeycrisp/src/lib.rs
trident/src/lib.rs
lens/src/lib.rs
strata/src/lib.rs
rs/macros/src/lib.rs
strata/nebu/rs/lib.rs
honeycrisp/rane/src/lib.rs
honeycrisp/acpu/src/lib.rs
lens/core/src/lib.rs
rs/mir-format/src/lib.rs
rs/core/src/lib.rs
hemera/wgsl/src/lib.rs
strata/kuro/rs/lib.rs
radio/iroh-ffi/src/lib.rs
cyb/src-tauri/src/lib.rs
strata/core/src/lib.rs
radio/iroh-docs/src/lib.rs
strata/compute/src/lib.rs
lens/porphyry/src/lib.rs
radio/cyber-bao/src/lib.rs
radio/iroh-relay/src/lib.rs
lens/assayer/src/lib.rs
lens/brakedown/src/lib.rs
radio/iroh-car/src/lib.rs
honeycrisp/unimem/src/lib.rs
honeycrisp/aruminium/src/lib.rs
lens/binius/src/lib.rs
hemera/rs/src/lib.rs
strata/ext/src/lib.rs
radio/iroh/src/lib.rs
radio/iroh-gossip/src/lib.rs
radio/iroh-blobs/src/lib.rs
radio/iroh-base/src/lib.rs
radio/iroh-dns-server/src/lib.rs
radio/iroh-willow/src/lib.rs
lens/ikat/src/lib.rs
rs/tests/macro-integration/src/lib.rs
cw-cyber/contracts/hub-networks/src/lib.rs
radio/tests/integration/src/lib.rs
cw-cyber/contracts/litium-core/src/lib.rs
strata/trop/wgsl/src/lib.rs
strata/kuro/wgsl/src/lib.rs
cw-cyber/contracts/hub-protocols/src/lib.rs
cw-cyber/contracts/cw-cyber-gift/src/lib.rs
strata/trop/rs/src/lib.rs
cw-cyber/contracts/cybernet/src/lib.rs
cw-cyber/contracts/hub-channels/src/lib.rs
strata/nebu/wgsl/src/lib.rs
cw-cyber/contracts/graph-filter/src/lib.rs
cw-cyber/contracts/litium-stake/src/lib.rs
trident/editor/zed/src/lib.rs
radio/iroh-ffi/iroh-js/src/lib.rs
cw-cyber/contracts/hub-tokens/src/lib.rs
cyb/cyb/cyb-services/src/lib.rs
cw-cyber/packages/hub-base/src/lib.rs
strata/genies/rs/src/lib.rs
cw-cyber/contracts/std-test/src/lib.rs
cw-cyber/packages/cyber-std-test/src/lib.rs
cw-cyber/contracts/litium-refer/src/lib.rs
strata/jali/rs/src/lib.rs
cw-cyber/contracts/hub-libs/src/lib.rs
cw-cyber/contracts/litium-wrap/src/lib.rs
cw-cyber/packages/cyber-std/src/lib.rs
strata/genies/wgsl/src/lib.rs
cw-cyber/contracts/hub-skills/src/lib.rs
strata/jali/wgsl/src/lib.rs
cw-cyber/contracts/cw-cyber-subgraph/src/lib.rs
radio/iroh/bench/src/lib.rs
cw-cyber/contracts/litium-mine/src/lib.rs
cw-cyber/contracts/cw-cyber-passport/src/lib.rs

Neighbours