Get started

Project layout

How the StateSync-GKR workspace is organized, from the eight member crates behind one facade package and their fixed dependency direction to the entry points that application code should use.

The repository is one Cargo workspace. Application code depends on a single package, the root facade statesync-gkr, which re-exports the eight member crates under crates/ as modules. This page maps those crates, the rules that keep them apart, and the parts of the API you are most likely to need.

Repository map#

PathContents
src/The facade (lib.rs), the host integration seam (oss_interface.rs) and three developer binaries: measure (measurement harness), profile (single-proof cost breakdown) and proof_digest (cross-build determinism check)
crates/The eight member crates
examples/state_sync_prove_verify, used in the Quickstart, and receipt_gated_transition_v1, a host-only reference that consumes recorded external-proof vectors and changes only an in-memory model
tests/Public vectors with positive and negative controls
docs/Architecture decisions, encoding specifications and frozen identifier definitions
benches/Development measurement notes for the measure binary, plus the controlled CPU, memory and serving studies, each with its own caller, data summary and replay instructions
formal/isabelle/Isabelle theory sources
verif/Creusot and Why3 replay records
spikes/zkvm-wrap/The selected zkVM integration source and its identity recipe
release/The public-surface verifier, manifests and release evidence

Workspace crates#

CrateImport pathOwns
ssgkr-primitivesstatesync_gkr::primitivesThe KoalaBear base field, the degree-four extension field used for verifier challenges, the Poseidon2 hash gadget, digests and the Fiat-Shamir transcript. It is the only crate that names Plonky3 (p3-*) paths.
ssgkr-sumcheckstatesync_gkr::sumcheckA generic multilinear sumcheck prover and verifier. The verifier returns a residual subclaim for the caller to discharge.
ssgkr-protocolstatesync_gkr::gkrThe layered-circuit representation with weighted linear, product and cube gates, multilinear extensions, sparse layer reduction, the wiring oracles, and GKR proving and verification.
ssgkr-compilerstatesync_gkr::compilerSparse-Merkle types and native operation semantics, the circuit compiler, witness generation and PublicInputs.
ssgkr-batchingstatesync_gkr::batchingProveJob, a witness queue with one lane per operation kind, a deadline-aware batch-size policy and a batch prover loop.
ssgkr-commitmentstatesync_gkr::wrap::commitmentThe full circuit commitment and the layer-strategy identity.
ssgkr-verificationTypes re-exported at the facade rootThe configuration, request, result and error types, circuit construction, the single prove and verify bodies, and the transcript preamble.
ssgkr-wrapstatesync_gkr::wrapThe external proof boundary: inner-proof encoding, the wrap statement and backend trait, the prepared-material codec, and the route manifest, destination policy and settlement records. The last three are host-only.
statesync-gkrstatesync_gkrStateSyncProver, PreparedSync, the module re-exports and the developer binaries.

Two import paths differ from the crate names: ssgkr-protocol is imported as gkr, and ssgkr-commitment is reached through wrap::commitment. The verification crate is not a module of the facade; its public types are re-exported at the root instead. These are the root-level items:

Rust
use statesync_gkr::{
    DOMAIN_TAG_V01, MockOssCore, OssCoreInterface, PreparedSync, StateSyncGkrConfig,
    StateSyncProver, SyncError, SyncRequest, SyncResult,
};

Dependency direction#

Text
ssgkr-primitives -> ssgkr-sumcheck -> ssgkr-protocol -> ssgkr-compiler
     -> {ssgkr-batching, ssgkr-commitment}
          -> {ssgkr-verification, ssgkr-wrap}
               -> statesync-gkr facade

Each arrow points from a crate to the crates built on it. The workspace manifest records this graph as a design boundary, and a change to it goes through design review rather than an ordinary edit. Three rules follow from it:

  • ssgkr-sumcheck and ssgkr-protocol never depend on ssgkr-compiler. They carry no sparse-Merkle assumptions, so another arithmetic-circuit frontend can build on them; see Custom frontends.
  • Only ssgkr-primitives may name a Plonky3 crate. Plonky3 is pinned to exactly 0.4.3, and moving that pin touches this one adapter crate.
  • ssgkr-verification and ssgkr-wrap have no edge between them. Both consume ssgkr-commitment.

The direct dependencies inside the workspace, as each manifest declares them:

CrateDepends directly on
ssgkr-primitivesPlonky3 crates only
ssgkr-sumcheckssgkr-primitives
ssgkr-protocolssgkr-primitives, ssgkr-sumcheck
ssgkr-compilerssgkr-primitives, ssgkr-protocol
ssgkr-batchingssgkr-primitives, ssgkr-protocol, ssgkr-compiler
ssgkr-commitmentssgkr-primitives, ssgkr-protocol, ssgkr-compiler
ssgkr-verificationssgkr-primitives, ssgkr-protocol, ssgkr-compiler, ssgkr-batching, ssgkr-commitment
ssgkr-wrapssgkr-primitives, ssgkr-sumcheck, ssgkr-protocol, ssgkr-compiler, ssgkr-commitment
statesync-gkrEvery member crate except ssgkr-commitment, which it reaches through ssgkr-wrap

Frozen interfaces#

The current release line binds its published external proof to an exact program identity, and six compatibility surfaces are frozen with that identity. Source comments label them SEAL[S-1] through SEAL[S-6]:

LabelSurfaceCanonical source
S-1Crate graph and dependency directionCargo.toml
S-2Sumcheck interface and round-message ordercrates/sumcheck/src/lib.rs
S-3Layered-circuit shape and gate semanticscrates/protocol/src/circuit.rs
S-4Boundary between native sparse-Merkle semantics and circuit acceptancecrates/compiler/src/lib.rs
S-5Transcript observation order and domain tagcrates/primitives/src/transcript.rs
S-6Field set and declaration order of PublicInputscrates/compiler/src/witness.rs

For application code, these surfaces stay fixed for the current release line. For contributors, changing a protected byte, even a comment, produces a different candidate identity, and that is never resolved by updating an expected hash. The labels are historical annotations kept byte for byte; they are not runtime checks or approvals. In 1.1.1 the root Cargo license field is the one recorded change among the protected files, and the published external proof remains evidence for its recorded 1.1 program only.

Entry points for application code#

TaskUseGuide
Prove and verify one operationStateSyncProver::prove_sync_op and verify_sync_op with a SyncRequestProving state operations
Serve repeated requests of one kindprepare, then prove_sync_op_prepared and verify_sync_op_preparedPrepared execution
Prove many independent requestsmake_job_prepared, then prove_batch_prepared or prove_batch_parallelBatching and parallelism
Send a proof to another processencode_sync_result and verify_encoded_sync_opEncoding and transport
Check an operation's semantics without a proofcompiler::smt_valid_nativeProving state operations
Build a different circuit frontendThe gkr and sumcheck modulesCustom frontends
Stand in for the host system in testsThe OssCoreInterface trait and its in-memory MockOssCoreAPI reference

Other public items serve audits, tests and the recorded external-proof route. Examples are verify_sync_op_reference, a slower reference verifier that uses fully materialized wiring, the wrap::prepared codec, and the route and settlement records under wrap. Ordinary proving does not need them. The API reference covers the full surface.

Workspace conventions#

  • unsafe code is forbidden in every workspace crate.
  • Workspace lints warn on missing documentation and on unwrap, expect and panic, and CI runs Clippy with warnings denied.
  • Every package uses edition 2024, declares Rust 1.85 as its minimum version and is built with the pinned 1.96.1.
  • The contract crate for the Creusot verifier is declared only for cfg(creusot). Normal builds on every platform never compile it.

Versions#

Every package in the workspace carries the Cargo version 0.1.0-dev and sets publish = false. These docs describe the 1.1 component release line, which is numbered separately from the Cargo packages. Versioning explains how the two relate.

Next steps#