Skip to content

Update zk-proofs for Protocol 25: BN254 and Poseidon are live#72

Open
kaankacar wants to merge 1 commit into
mainfrom
fix-zk-protocol-25
Open

Update zk-proofs for Protocol 25: BN254 and Poseidon are live#72
kaankacar wants to merge 1 commit into
mainfrom
fix-zk-protocol-25

Conversation

@kaankacar

Copy link
Copy Markdown
Contributor

Closes #51.

Applies @briwylde08's report, with every claim independently re-verified before writing:

  • cap-0074.md and cap-0075.md in stellar-protocol both read Status: Final, Protocol version: 25, and a live getVersionInfo against mainnet RPC returns protocol 27 — the capabilities have been live for months while the skill still said "Proposed" and steered builders to attestation workarounds.
  • NethermindEth/rs-soroban-ultrahonk exists and its only host calls are env.crypto().bn254().g1_msm and pairing_check (per the project's milestone docs); it is the stack under OpenZeppelin's Confidential Tokens developer preview. The skill links it with an explicit young-verifier maturity caveat.
  • The crypto::bn254 module page on docs.rs resolves (link checked before adding).

Changes follow the issue's suggested fix list: status table rows to Available (Protocol 25+), all four toolchain rows now on-chain verifiable, the Noir walkthrough rewritten with on-chain UltraHonk as option one and attestation demoted to fallback, RISC Zero's Groth16 wrap marked natively verifiable, the Circom walkthrough and curve-mismatch pitfall reframed from "avoid bn128" to "match circuit curve to verifier", Poseidon Merkle guidance updated, and a "Last verified against Protocol 27" line at the top so future staleness is self-documenting. Frontmatter description and the site card updated to match.

Also picked up the issue's optional suggestion and added the official ZK and Privacy docs pages to references.

CAP-0074 and CAP-0075 both read Status: Final, Protocol version: 25
in stellar-protocol, and mainnet is on protocol 27 — the skill was
still calling them proposed and steering builders to attestation
workarounds for capabilities that ship natively.

- Status table: both CAPs marked Available (Protocol 25+), with the
  BN254 host-function surface named (crypto::bn254)
- Toolchain table: all four rows now on-chain verifiable; UltraHonk
  routes through Nethermind's rs-soroban-ultrahonk verifier (the
  stack under OpenZeppelin's Confidential Tokens preview), with a
  maturity caveat
- Noir walkthrough: on-chain verification is now option one;
  attestation demoted to a fallback
- RISC Zero: Groth16-wrapped receipts verify natively
- Circom: both curves work; walkthrough stays on bls12381 to match
  the canonical verifier, and the curve-mismatch pitfall now says
  match circuit to verifier rather than avoid bn128
- Poseidon Merkle guidance updated; last-verified line added at top
- References: official ZK/privacy docs pages, the UltraHonk verifier,
  and the bn254 SDK module (link checked)

Closes #51.
Copilot AI review requested due to automatic review settings July 20, 2026 19:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://stellar.github.io/stellar-dev-skill/pr/pr-72/

Built to branch gh-pages at 2026-07-20 19:17 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

Comment thread skills/zk-proofs/SKILL.md
| BLS12-381 ops (G1/G2 add, mul, MSM, pairing check, hash-to-curve, Fr arithmetic) | [CAP-0059](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0059.md) | **Available** (Protocol 22+) |
| BN254 host functions | [CAP-0074](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0074.md) | Proposed — check current status |
| Poseidon/Poseidon2 hash | [CAP-0075](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0075.md) | Proposed — check current status |
| BN254 ops (G1 add/mul/MSM, pairing check, Fr arithmetic — `crypto::bn254`) | [CAP-0074](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0074.md) | **Available** (Protocol 25+) |
Comment thread skills/zk-proofs/SKILL.md
| RISC Zero (STARK → Groth16 wrap) | Groth16 | BN254 | Gated on CAP-0074 — attest meanwhile |
| Circom + snarkjs (`-p bls12381`) | Groth16 | BLS12-381 | ✅ via CAP-0059 (Protocol 22+) |
| Circom + snarkjs (default `bn128`) | Groth16 | BN254 | ✅ via CAP-0074 (Protocol 25+) |
| Noir + Barretenberg | UltraHonk | BN254 | ✅ via CAP-0074 (Protocol 25+) — needs the [rs-soroban-ultrahonk](https://github.com/NethermindEth/rs-soroban-ultrahonk) verifier contract |
Comment thread skills/zk-proofs/SKILL.md
For real applications the per-proof flow is: client proves locally (WASM prover or native), submits `(proof, public_signals)` in a contract invocation, contract verifies + applies policy + updates state.

## Walkthrough: Noir (off-chain verify + attestation, for now)
## Walkthrough: Noir (UltraHonk, on-chain verifiable since Protocol 25)
Comment thread skills/zk-proofs/SKILL.md
## Walkthrough: Noir (UltraHonk, on-chain verifiable since Protocol 25)

Noir's standard backend (Barretenberg) produces UltraHonk proofs over BN254 — neither the proof system nor the curve is on-chain verifiable on Stellar today.
Noir's standard backend (Barretenberg) produces UltraHonk proofs over BN254. Since Protocol 25 the curve is native (CAP-0074), and UltraHonk verification runs on-chain through [Nethermind's rs-soroban-ultrahonk](https://github.com/NethermindEth/rs-soroban-ultrahonk) verifier contract, whose only host calls are `env.crypto().bn254().g1_msm` and `pairing_check` — this is the stack OpenZeppelin's [Confidential Tokens developer preview](https://stellar.org/blog/developers/developer-preview-confidential-tokens-on-stellar) runs on (testnet). It is a young, community-maintained verifier: check its audit status and maturity before mainnet use.
Comment thread skills/zk-proofs/SKILL.md
Three ways to get a Noir statement on-chain, in order of preference:

Track CAP-0074 (BN254): when implemented, BN254 Groth16 verification becomes possible — but UltraHonk would additionally need a verifier implementation in-contract, so Groth16-based paths will land first.
1. **On-chain UltraHonk verification** (Protocol 25+): deploy or call an [rs-soroban-ultrahonk](https://github.com/NethermindEth/rs-soroban-ultrahonk)-based verifier and submit `(proof, public inputs)` directly — trustless, no oracle.
Comment thread skills/zk-proofs/SKILL.md
| BN254 host functions | [CAP-0074](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0074.md) | Proposed — check current status |
| Poseidon/Poseidon2 hash | [CAP-0075](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0075.md) | Proposed — check current status |
| BN254 ops (G1 add/mul/MSM, pairing check, Fr arithmetic — `crypto::bn254`) | [CAP-0074](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0074.md) | **Available** (Protocol 25+) |
| Poseidon/Poseidon2 hash | [CAP-0075](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0075.md) | **Available** (Protocol 25+) |
Comment thread skills/zk-proofs/SKILL.md
- **Capability gating**: enable ZK flows only where required primitives are confirmed available; keep deterministic fallbacks and document the supported network/protocol matrix.

For Merkle-tree commitments (privacy pools, allowlists): until Poseidon (CAP-0075) lands, in-circuit-friendly hashing on-chain is expensive — design trees so the contract only needs root comparisons and membership proofs verified inside the SNARK.
For Merkle-tree commitments (privacy pools, allowlists): the Poseidon/Poseidon2 host functions (CAP-0075, Protocol 25+) make circuit-friendly hashing cheap on-chain, so contracts can recompute Poseidon Merkle roots and commitments directly. On pre-Protocol-25 targets, design trees so the contract only needs root comparisons and membership proofs verified inside the SNARK.
Comment thread skills/zk-proofs/SKILL.md
```

On Stellar today, use the **attestation pattern** (as with Noir): verify the receipt off-chain — locally or via a proving service — and have an authorized attester submit the journal + attestation to your contract. Once CAP-0074 (BN254) is implemented, the Groth16-wrapped receipt becomes verifiable natively with a BN254 verifier contract mirroring the BLS12-381 one above; the `IMAGE_ID` (which program ran) and journal digest become public inputs. See the [RISC Zero docs](https://dev.risczero.com/api) for the wrapping workflow.
Since Protocol 25 (CAP-0074), the Groth16-wrapped receipt verifies **natively on-chain**: a BN254 verifier contract mirroring the BLS12-381 one above, with the `IMAGE_ID` (which program ran) and the journal digest as public inputs. See the [RISC Zero docs](https://dev.risczero.com/api) for the wrapping workflow. The attestation pattern remains a fallback for STARK-only receipts (no Groth16 wrap) or pre-Protocol-25 targets.
Comment thread skills/zk-proofs/SKILL.md

ZK verification on Stellar. Capability is protocol- and SDK-version dependent — always verify CAP status, network version, and `soroban-sdk` host-function support before relying on a primitive.

> **Last verified against Protocol 27** (mainnet, July 2026). CAP-0074/0075 shipped in Protocol 25 "X-Ray" — if a doc tells you BN254 or Poseidon is "proposed", it predates that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zk-proofs skill predates Protocol 25 — CAP-0074/0075 shipped, UltraHonk/BN254 now verifiable on-chain

2 participants