A comprehensive suite of Rust libraries for building sophisticated zero-knowledge protocols and applications. SL-Core provides modular, high-performance implementations of core cryptographic primitives and proof systems.
This workspace contains several specialized crates that work together to provide a complete toolkit for zero-knowledge proof development:
- Circuit representations for arithmetic computations
- Polynomial operations including multilinear extensions
- Interactive proof protocols like GKR and Sumcheck
- Field arithmetic supporting both base and extension fields
- Transcript management for non-interactive proofs
🔌 circuits
Implementation of layered arithmetic circuits with support for GKR (Goldwasser-Kalai-Rothblum) protocols.
Features:
- Layered circuit representation with ADD and MUL gates
- Circuit execution and evaluation traces
- GKR protocol integration with multilinear extensions
- Support for both deterministic and randomized circuit generation
🔢 fields
Unified field arithmetic supporting both base fields and extension fields.
Features:
- Generic
Fields<F, E>enum for seamless base/extension field operations - Arithmetic operations that automatically handle field promotions
- Conversion utilities and type safety
📊 poly
Comprehensive polynomial operations with focus on multilinear extensions.
Features:
- Dense multilinear polynomial representations
- Virtual polynomials (VPoly) for complex polynomial combinations
- Efficient partial evaluation and sum-over-hypercube operations
- Barycentric evaluation for univariate polynomials
Implementation of the sumcheck interactive proof protocol.
Features:
- Complete prover and verifier for sumcheck protocol
- Support for partial verification (useful in GKR)
- Padded sumcheck for handling non-power-of-two polynomials
- Generic over different polynomial types
Fiat-Shamir transcript management for converting interactive proofs to non-interactive ones.
Features:
- Keccak-based challenge generation
- Support for both base and extension field elements
- Serialization-friendly design
Add to your Cargo.toml:
[dependencies]
# Individual cratescircuits = { git = "https://github.com/sublinearlabs/sl-core.git" }
poly = { git = "https://github.com/sublinearlabs/sl-core.git" }
sum_check = { git = "https://github.com/sublinearlabs/sl-core.git" }
fields = { git = "https://github.com/sublinearlabs/sl-core.git" }
transcript = { git = "https://github.com/sublinearlabs/sl-core.git" }use circuits::{LayeredCircuit,CircuitTr};use circuits::layered_circuit::primitives::{Layer,Gate,GateOp};use p3_goldilocks::GoldilocksasF;use poly::Fields;// Create a simple circuit: (a + b) * (c + d)let layer1 = Layer::new(vec![Gate::new(GateOp::Add,[0,1]),// a + bGate::new(GateOp::Add,[2,3]),// c + d]);let layer2 = Layer::new(vec![Gate::new(GateOp::Mul,[0,1]),// (a + b) * (c + d)]);let circuit = LayeredCircuit::new(vec![layer1, layer2]);// Execute with inputs [1, 2, 3, 4]let input = [1,2,3,4].into_iter().map(|x| Fields::Base(F::from_canonical_u32(x))).collect::<Vec<_>>();let result = circuit.execute(&input);println!("Circuit output: {:?}", result.layers.last());use sum_check::{SumCheck,SumCheckInterface};use poly::{MultilinearExtension, mle::MultilinearPoly};use transcript::Transcript;use p3_mersenne_31::Mersenne31asF;use p3_field::extension::BinomialExtensionField;typeE = BinomialExtensionField<F,3>;// Create a multilinear polynomiallet poly = MultilinearPoly::new_from_vec(3,// 3 variablesvec![0,0,0,3,0,0,2,5]// evaluations over {0,1}^3.into_iter().map(|x| Fields::Base(F::new(x))).collect());let claimed_sum = poly.sum_over_hypercube();letmut transcript = Transcript::init();// Generate prooflet proof = SumCheck::prove(claimed_sum, poly.clone(),&mut transcript).unwrap();// Verify proofletmut verify_transcript = Transcript::init();let is_valid = SumCheck::verify(&poly,&proof,&mut verify_transcript).unwrap();assert!(is_valid);# Build all crates
cargo build
# Run tests
cargo test# Run tests with all features
cargo test --all-features
# Run benchmarks
cargo bench
# Check formatting
cargo fmt --all --check
# Run clippy
cargo clippy --workspace --all-targets --all-featuresThis project uses Rust nightly. The toolchain is specified in rust-toolchain.toml.
The project primarily uses:
- Plonky3 ecosystem for field arithmetic and cryptographic primitives
- p3-field, p3-challenger, p3-mersenne-31, p3-goldilocks for core functionality
- criterion for benchmarking
- anyhow for error handling
The project includes GitHub Actions workflows for:
- Testing across multiple configurations
- Documentation generation
- Code formatting and linting
- Clippy analysis
sl-core/
├── circuits/ # Circuit representations and GKR, Libra, Virgo, support
├── fields/ # Unified field arithmetic
├── poly/ # Polynomial operations and MLE
├── iops/
│ └── sum_check/ # Sumcheck protocol implementation
└── transcript/ # Fiat-Shamir transcript management
Each crate is designed to be:
- Modular: Can be used independently or together
- Generic: Works with different field types and configurations
- Performant: Optimized for cryptographic workloads
- Safe: Leverages Rust's type system for correctness
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure all CI checks pass
- Submit a pull request
Please ensure:
- Code is formatted with
cargo fmt - All tests pass with
cargo test - Clippy warnings are addressed
- New features include documentation and tests
This project is licensed under the MIT License.
Built on the excellent Plonky3 framework for zero-knowledge proof systems.