-
Notifications
You must be signed in to change notification settings - Fork 169
[DRAFT ZIP] Circle STARK Verification as a Transparent Zcash Extension #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
3dc6662
a0ecc11
1c6e9a8
aa5c3b5
21d4fa0
2b371d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,150 @@ | ||||||
| ZIP: XXX | ||||||
| Title: Circle STARK Verification as a Transparent Zcash Extension | ||||||
| Owners: Abdel <[email protected]>, Michael Zaikin <[email protected]> | ||||||
| Status: Draft | ||||||
| Category: Consensus | ||||||
| Created: 2025-10-14 | ||||||
| License: MIT | ||||||
| Discussions-To: <https://forum.zcashcommunity.com/t/stark-verification-as-a-transparent-zcash-extension-tze-i-e-enabler-for-a-starknet-style-l2-on-zcash/52486> | ||||||
|
|
||||||
| # Terminology | ||||||
|
|
||||||
| The key words "MUST", "SHOULD", and "MAY" are to be interpreted as described in BCP 14 [^BCP14] when, and only when, they appear in all capitals. | ||||||
|
|
||||||
| ## Abstract | ||||||
|
|
||||||
| This ZIP defines a new Transparent Zcash Extension that verifies a bounded‑size Circle STARK proof (Stwo). The extension has a single `type` and a single mode, and exposes a compact precondition/witness interface suitable for verifying L2 validity proofs on Zcash L1. It specifies: | ||||||
|
||||||
|
|
||||||
| - a prefix‑free encoding of precondition and witness; | ||||||
| - pinned verifier parameter set via a `param_id` namespace; | ||||||
| - strict consensus bounds on sizes and verifier parameters for DoS safety; and | ||||||
| - digest integration consistent with a future transaction version that supports TZEs [^zip-0245]. | ||||||
|
|
||||||
| This ZIP does not change Sapling/Orchard; it only adds a TZE that can be used to enforce L2 state transitions or other validity claims. | ||||||
|
|
||||||
| ## Motivation | ||||||
|
|
||||||
| Zcash's programmability is restricted by the Bitcoin script, which lacks sufficient expressiveness and implies high costs that limit throughput. A Starknet‑style scaling solution can address the issue by providing an expressive programming language (Cairo), a ZK friendly virtual machine, and an effective proving system (Circle STARK/Stwo) that compresses large computation into a succinct proof, suitable for onchain verification. A custom transparent extension [^zip-0222] is the cleanest way to introduce such verifier and enable layer-2 solutions on top of Zcash. | ||||||
|
|
||||||
| ## Requirements | ||||||
|
|
||||||
| * Define a TZE `type` for Stwo/Circle STARK verification, and fully specify how this type is to be encoded, verified, and integrated into transaction digest computation, without allowing implementation‑defined behavior. | ||||||
| * Define a `param_id` namespace that pins the specification of the Stwo proof relation, the proof object wire format, field encodings, transcript/Merkle hash suite and personalization, FRI expansion and query caps, any grinding bounds, and any batch‑verification settings. | ||||||
| * A reference implementation of the prover and verifier, and reference test vectors (valid and invalid) must be provided for each such `param_id`. | ||||||
| * Limits on proof sizes, etc. must be chosen to avoid potential denial of service, and the necessary updates to ZIP 317 fee calculation [^zip-0317] must be specified. | ||||||
|
|
||||||
| ## Specification | ||||||
|
|
||||||
| ### TZE identification | ||||||
|
|
||||||
| - `tze_id`: TBD (assigned by ZIP Editors). | ||||||
| - `tze_mode`: 0 (only one mode is defined by this ZIP). Any other value MUST be rejected. | ||||||
|
|
||||||
| All serialization below is inside the `tze_data_payload` defined by [^zip-0222]; lengths are `compactSize`. | ||||||
|
|
||||||
| ### Precondition (prefix‑free) | ||||||
|
|
||||||
| ``` | ||||||
| u16 param_id // selects a pinned Stwo verifier parameter set (see below) | ||||||
| u8 flags // bit 0 = bind_ctx; all other bits MUST be 0 | ||||||
| vec pub_in // public inputs to the proved statement (len + bytes) | ||||||
| if (flags & 0x01) { | ||||||
| bytes32 ctx_digest // non-malleable transaction digest | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| - `param_id` selects an enumerated, pinned Stwo parameter set (field & hash suite, FRI/query caps, wire format version, endianness, personalization, etc.). Unknown `param_id` MUST be rejected. | ||||||
| - `pub_in` is an opaque byte string to consensus; it MUST be absorbed by the verifier transcript exactly as specified (byte‑for‑byte). | ||||||
| - If `bind_ctx` is set, `ctx_digest` MUST equal the transaction's non‑malleable digest [^zip-0244]. A mismatch MUST cause rejection. | ||||||
|
|
||||||
| ### Witness (prefix‑free) | ||||||
|
|
||||||
| ``` | ||||||
| vec proof // the Stwo (Circle STARK) proof object (len + bytes) | ||||||
| ``` | ||||||
|
|
||||||
| The `proof` MUST conform to the Stwo wire format pinned by `param_id`. | ||||||
|
|
||||||
| ### Verification | ||||||
|
|
||||||
| `bool tze_verify(0, precondition, witness, context)`: | ||||||
|
|
||||||
| 1. Parse `param_id`; load the exact pinned parameter set. Reject if unknown. | ||||||
| 2. Parse `flags`; if any reserved bits set, reject. | ||||||
| 3. If `bind_ctx`, compute the required `ctx_digest` from `context` and compare; on mismatch, reject. ([Zcash Zips][3]) | ||||||
| 4. Parse `pub_in` and `proof`. Enforce all consensus bounds (see Bounds). | ||||||
| 5. Initialize the Stwo transcript/channel, **absorb `pub_in` exactly**, and verify `proof` using the parameters pinned by `param_id`. | ||||||
| 6. Return `true` iff the verifier accepts; otherwise return `false`. | ||||||
|
|
||||||
| ### Parameter sets (`param_id`) | ||||||
|
|
||||||
| The namespace is 16‑bit (0x0001..0xFFFF). This ZIP introduces: | ||||||
|
|
||||||
| - `param_id = 0x0001` — `STWO_V1_P1` | ||||||
|
|
||||||
| - Upstream: `starkware-libs/stwo` at tag TBD, commit `TBD`. | ||||||
| - Wire format: Stwo proof object at v1.0.0 (exact byte layout pinned in this ZIP's test‑vector directory). | ||||||
|
||||||
| - Arithmetic & domains: per Stwo v1.0.0 (Circle STARK over the 31‑bit Mersenne field; exact domain and padding rules pinned by the vector files). | ||||||
| - Hash suite: as used by the v1.0.0 verifier for transcript/Merkle commitments (parameters and personalization strings pinned by vector files). | ||||||
| - FRI/query caps: exact maximums pinned by vector files. | ||||||
| - Grinding/nonce: if present in the format, upper bounds are pinned by vector files. | ||||||
|
|
||||||
| > Normative reference material for `STWO_V1_P1` (field encodings, wire format, hash personalization, FRI expansions, max queries) is included alongside this ZIP in `zip-XXXX/params/STWO_V1_P1.json` and the accompanying test vectors. Implementations MUST treat those files as normative parts of this ZIP. | ||||||
|
||||||
| > Normative reference material for `STWO_V1_P1` (field encodings, wire format, hash personalization, FRI expansions, max queries) is included alongside this ZIP in `zip-XXXX/params/STWO_V1_P1.json` and the accompanying test vectors. Implementations MUST treat those files as normative parts of this ZIP. | |
| > Normative reference material for `STWO_V1_P1` (field encodings, wire format, hash personalization, FRI expansions, max queries) is included alongside this ZIP in `zip-XXXX/params/STWO_V1_P1.json` and the accompanying test vectors. These files are to be treated as normative parts of this specification. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Nodes MUST reject if any bound is exceeded. Bounds MUST be enforced before allocation to prevent DoS. | |
| Nodes MUST reject if any bound is exceeded, and MUST NOT allow denial of service via memory exhaustion due to allocating memory before bounds are checked. |
The original second sentence would be a slight overspecification.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is insufficiently specified; it's fine for now but please write a TODO.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is the wrong format for Markdown references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.