[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77KEWCV2RQ50THAM3MM86ND":3,"skill-same:01M77KEWCV2RQ50THAM3MM86ND":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":48},"01M77KEWCV2RQ50THAM3MM86ND","zk-proofs",null,"Zero-knowledge proofs and privacy patterns on Stellar. Covers Groth16 verification in smart contracts via BLS12-381 host functions (CAP-0059, available), the BN254 + Poseidon proposals (CAP-0074\u002F0075, status-sensitive), and concrete toolchain walkthroughs for Circom (on-chain verifiable today), Noir, and RISC Zero (attestation pattern until BN254 lands). Use when building privacy-preserving applications, ZK-verifier contracts, or wiring a proving toolchain to Stellar.","WritzProtocol\u002Fwritz","WritzProtocol","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F296057967?v=4","01M77K5N0T3073T814APZTAXM4","Writz Protocol","01M77K5N1WQ551ZKCCK9MR379A",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fzk-proofs\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: zk-proofs\ndescription: Zero-knowledge proofs and privacy patterns on Stellar. Covers Groth16 verification in smart contracts via BLS12-381 host functions (CAP-0059, available), the BN254 + Poseidon proposals (CAP-0074\u002F0075, status-sensitive), and concrete toolchain walkthroughs for Circom (on-chain verifiable today), Noir, and RISC Zero (attestation pattern until BN254 lands). Use when building privacy-preserving applications, ZK-verifier contracts, or wiring a proving toolchain to Stellar.\nuser-invocable: true\nargument-hint: \"[zk task]\"\n---\n\n# Zero-Knowledge Proofs & Privacy\n\nZK 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.\n\n## When to use this skill\n- Implementing a Groth16 (or other SNARK) verifier as a Stellar smart contract\n- Wiring Circom, Noir, or RISC Zero output to on-chain verification\n- Building privacy pools, confidential tokens, or Merkle-tree-backed commitments\n- Planning for BN254 \u002F Poseidon availability\n\n## Related skills\n- Contract patterns and deployment → `..\u002Fsmart-contracts\u002Fdevelopment.md`\n- Verifier security review → `..\u002Fsmart-contracts\u002Fsecurity.md`\n- CAPs referenced here → `..\u002Fstandards\u002FSKILL.md`\n\n## What's available - verify before building\n\n| Primitive | CAP | Status |\n|-----------|-----|--------|\n| BLS12-381 ops (G1\u002FG2 add, mul, MSM, pairing check, hash-to-curve, Fr arithmetic) | [CAP-0059](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0059.md) | **Available** (Protocol 22+) |\n| BN254 host functions | [CAP-0074](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0074.md) | Proposed - check current status |\n| Poseidon\u002FPoseidon2 hash | [CAP-0075](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0075.md) | Proposed - check current status |\n\nBefore implementation, always confirm:\n1. CAP status in the preamble (`Accepted`\u002F`Implemented` vs draft)\n2. Target network protocol version ([software versions](https:\u002F\u002Fdevelopers.stellar.org\u002Fdocs\u002Fnetworks\u002Fsoftware-versions))\n3. `soroban-sdk` release support for the host functions you need\n\n**The curve decides everything.** BLS12-381 proofs verify natively on-chain today; BN254 proofs (Circom's default, Barretenberg, RISC Zero's Groth16 wrapper) are gated on CAP-0074.\n\n| Toolchain | Proof system | Curve | On-chain on Stellar |\n|-----------|--------------|-------|---------------------|\n| Circom + snarkjs (`-p bls12381`) | Groth16 | BLS12-381 | ✅ Today, via CAP-0059 |\n| Circom + snarkjs (default) | Groth16 | BN254 | Gated on CAP-0074 |\n| Noir + Barretenberg | UltraHonk | BN254 | Not yet - attest off-chain verification |\n| RISC Zero (STARK → Groth16 wrap) | Groth16 | BN254 | Gated on CAP-0074 - attest meanwhile |\n\n## The on-chain verifier (Groth16 over BLS12-381)\n\nThe official [groth16_verifier example](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples\u002Ftree\u002Fmain\u002Fgroth16_verifier) is the canonical implementation - the full contract:\n\n```rust\n#![no_std]\nuse soroban_sdk::{\n    contract, contracterror, contractimpl, contracttype,\n    crypto::bls12_381::{Fr, G1Affine, G2Affine},\n    vec, Env, Vec,\n};\n\n#[contracterror]\n#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]\n#[repr(u32)]\npub enum Groth16Error {\n    MalformedVerifyingKey = 0,\n}\n\n#[derive(Clone)]\n#[contracttype]\npub struct VerificationKey {\n    pub alpha: G1Affine,\n    pub beta: G2Affine,\n    pub gamma: G2Affine,\n    pub delta: G2Affine,\n    pub ic: Vec\u003CG1Affine>,\n}\n\n#[derive(Clone)]\n#[contracttype]\npub struct Proof {\n    pub a: G1Affine,\n    pub b: G2Affine,\n    pub c: G1Affine,\n}\n\n#[contract]\npub struct Groth16Verifier;\n\n#[contractimpl]\nimpl Groth16Verifier {\n    pub fn verify_proof(\n        env: Env,\n        vk: VerificationKey,\n        proof: Proof,\n        pub_signals: Vec\u003CFr>,\n    ) -> Result\u003Cbool, Groth16Error> {\n        let bls = env.crypto().bls12_381();\n\n        \u002F\u002F vk_x = ic[0] + sum(pub_signals[i] * ic[i+1])\n        if pub_signals.len() + 1 != vk.ic.len() {\n            return Err(Groth16Error::MalformedVerifyingKey);\n        }\n        let mut vk_x = vk.ic.get(0).unwrap();\n        for (s, v) in pub_signals.iter().zip(vk.ic.iter().skip(1)) {\n            let prod = bls.g1_mul(&v, &s);\n            vk_x = bls.g1_add(&vk_x, &prod);\n        }\n\n        \u002F\u002F e(-A, B) * e(alpha, beta) * e(vk_x, gamma) * e(C, delta) == 1\n        let neg_a = -proof.a;\n        let vp1 = vec![&env, neg_a, vk.alpha, vk_x, proof.c];\n        let vp2 = vec![&env, proof.b, vk.beta, vk.gamma, vk.delta];\n\n        Ok(bls.pairing_check(vp1, vp2))\n    }\n}\n```\n\nPoint encodings are uncompressed big-endian: `G1Affine` wraps 96 bytes, `G2Affine` 192 bytes, `Fr` 32 bytes. The example's test suite shows the exact conversion from arkworks types (`ark-bls12-381` + `ark-serialize`) - reuse it when building fixtures from your proving toolchain's JSON output.\n\nIn production, wrap this verifier with application logic: fix the `VerificationKey` at deploy time (constructor) instead of taking it as a call argument, and bind proofs to context (see [Pitfalls](#pitfalls)).\n\n## Walkthrough: Circom → on-chain verification (works today)\n\nCircom supports BLS12-381 as a target field - this makes it the toolchain that verifies natively on Stellar right now.\n\n```bash\n# 1. Circuit\ncat > multiplier.circom \u003C\u003C'EOF'\npragma circom 2.1.6;\ntemplate Multiplier() {\n    signal input a;\n    signal input b;\n    signal output c;\n    c \u003C== a * b;\n}\ncomponent main = Multiplier();\nEOF\n\n# 2. Compile for BLS12-381 (NOT the default bn128 - that's gated on CAP-0074)\ncircom multiplier.circom --r1cs --wasm -p bls12381\n\n# 3. Trusted setup (powers of tau on bls12-381, then circuit-specific phase 2)\nsnarkjs powersoftau new bls12-381 12 pot12_0000.ptau\nsnarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name=\"contrib\" -e=\"random\"\nsnarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau\nsnarkjs groth16 setup multiplier.r1cs pot12_final.ptau multiplier.zkey\nsnarkjs zkey export verificationkey multiplier.zkey verification_key.json\n\n# 4. Witness + proof\necho '{\"a\": 3, \"b\": 11}' > input.json\nnode multiplier_js\u002Fgenerate_witness.js multiplier_js\u002Fmultiplier.wasm input.json witness.wtns\nsnarkjs groth16 prove multiplier.zkey witness.wtns proof.json public.json\n\n# 5. Sanity-check off-chain before going on-chain\nsnarkjs groth16 verify verification_key.json public.json proof.json\n```\n\nThen convert `proof.json` \u002F `verification_key.json` (decimal-string coordinates) into the contract's types - serialize each point uncompressed big-endian into the 96\u002F192-byte layouts, e.g. via arkworks as in the example's tests - and invoke `verify_proof`. Public signals (`public.json`) become the `Vec\u003CFr>` argument; the contract must also validate what those signals *mean* (see [Pitfalls](#pitfalls)).\n\nFor 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.\n\n## Walkthrough: Noir (off-chain verify + attestation, for now)\n\nNoir's standard backend (Barretenberg) produces UltraHonk proofs over BN254 - neither the proof system nor the curve is on-chain verifiable on Stellar today.\n\n```bash\n# Local proving workflow\nnargo new age_check && cd age_check\ncat > src\u002Fmain.nr \u003C\u003C'EOF'\nfn main(age: u64, threshold: pub u64) {\n    assert(age >= threshold);\n}\nEOF\nnargo check\nnargo execute witness          # writes the witness from Prover.toml inputs\nbb prove -b target\u002Fage_check.json -w target\u002Fwitness.gz -o target\u002Fproof\nbb verify -k target\u002Fvk -p target\u002Fproof   # off-chain verification\n```\n\nOn Stellar, two patterns until the curve\u002Fsystem gap closes:\n\n1. **Attestation oracle**: a verifier service runs `bb verify` (or the Noir JS verifier) off-chain and submits a signed attestation; the contract `require_auth()`s the attester address and applies policy. The trust assumption (the attester) must be explicit and documented - this is *not* trustless ZK, it's a verifiable-computation oracle.\n2. **Switch the proving stack for on-chain parts**: express the on-chain-critical statement as a Circom\u002FGroth16-BLS12-381 circuit (walkthrough above) and keep Noir for off-chain components.\n\nTrack 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.\n\n## Walkthrough: RISC Zero (same gate, clear path)\n\nRISC Zero proves arbitrary Rust execution (zkVM) and can wrap its STARK receipts into a Groth16 proof over BN254 (\"stark-to-snark\") - small enough for on-chain verification where BN254 is supported.\n\n```rust\n\u002F\u002F Guest (runs inside the zkVM): the computation being proven\nuse risc0_zkvm::guest::env;\n\nfn main() {\n    let input: u64 = env::read();\n    let result = expensive_check(input);\n    env::commit(&result);          \u002F\u002F becomes part of the public journal\n}\n```\n\n```rust\n\u002F\u002F Host: produce and verify a receipt locally\nlet receipt = prover.prove(env, ELF)?.receipt;\nreceipt.verify(IMAGE_ID)?;         \u002F\u002F off-chain verification\n```\n\nOn 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:\u002F\u002Fdev.risczero.com\u002Fapi) for the wrapping workflow.\n\n## Architecture patterns\n\n- **Verification gateway**: isolate cryptographic checks in a dedicated verifier contract\u002Fmodule - normalize inputs, verify, emit explicit success\u002Ffailure events. Smaller audit surface, cleaner upgrades.\n- **Policy-and-proof split**: `Verifier` (cryptographic validity) → `Policy` (business\u002Fcompliance rules) → `Application` (state transition). Each independently testable and upgradeable.\n- **Capability gating**: enable ZK flows only where required primitives are confirmed available; keep deterministic fallbacks and document the supported network\u002Fprotocol matrix.\n\nFor 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.\n\n## Pitfalls\n\n- **Verifying the proof but not the statement.** A valid proof only shows *some* witness satisfies the circuit. The contract must validate the public inputs' semantics: who is this proof for, which Merkle root, which action, which amount.\n- **Missing anti-replay binding.** Valid proofs can be replayed. Bind a nonce\u002Fsession\u002Faction into the public inputs and persist a replay guard (nullifier set) on-chain.\n- **Curve mismatch.** Circom defaults to bn128; on Stellar compile with `-p bls12381` or your proof will be unverifiable on-chain.\n- **Trusted-setup hygiene.** Groth16 needs a circuit-specific phase-2 setup; for production use a real multi-party ceremony, not a single-contributor dev setup.\n- **Hardcoded protocol assumptions.** Capability-gate; don't assume draft CAPs are live on the target network.\n\n## Testing\n\n- Unit: input domain validation, replay protection, event correctness, malformed\u002Ftampered proof rejection (negative paths are the important ones)\n- Integration: full prove → submit → verify → state-transition flow against a local network\n- Operational: resource costs for realistic proof sizes via simulation (`--send=no`) - pairing checks are expensive; budget before committing to per-transaction verification\n\n## References\n\n- [groth16_verifier example](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples\u002Ftree\u002Fmain\u002Fgroth16_verifier) - canonical verifier + arkworks test fixtures\n- [soroban-examples](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples)\n- [BLS12-381 SDK docs](https:\u002F\u002Fdocs.rs\u002Fsoroban-sdk\u002Flatest\u002Fsoroban_sdk\u002Fcrypto\u002Fbls12_381\u002Findex.html)\n- [Circom docs](https:\u002F\u002Fdocs.circom.io) · [snarkjs](https:\u002F\u002Fgithub.com\u002Fiden3\u002Fsnarkjs) · [Noir docs](https:\u002F\u002Fnoir-lang.org\u002Fdocs) · [RISC Zero docs](https:\u002F\u002Fdev.risczero.com)\n","# Zero-Knowledge Proofs & Privacy\n\nZK 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.\n\n## When to use this skill\n- Implementing a Groth16 (or other SNARK) verifier as a Stellar smart contract\n- Wiring Circom, Noir, or RISC Zero output to on-chain verification\n- Building privacy pools, confidential tokens, or Merkle-tree-backed commitments\n- Planning for BN254 \u002F Poseidon availability\n\n## Related skills\n- Contract patterns and deployment → `..\u002Fsmart-contracts\u002Fdevelopment.md`\n- Verifier security review → `..\u002Fsmart-contracts\u002Fsecurity.md`\n- CAPs referenced here → `..\u002Fstandards\u002FSKILL.md`\n\n## What's available - verify before building\n\n| Primitive | CAP | Status |\n|-----------|-----|--------|\n| BLS12-381 ops (G1\u002FG2 add, mul, MSM, pairing check, hash-to-curve, Fr arithmetic) | [CAP-0059](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0059.md) | **Available** (Protocol 22+) |\n| BN254 host functions | [CAP-0074](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0074.md) | Proposed - check current status |\n| Poseidon\u002FPoseidon2 hash | [CAP-0075](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fstellar-protocol\u002Fblob\u002Fmaster\u002Fcore\u002Fcap-0075.md) | Proposed - check current status |\n\nBefore implementation, always confirm:\n1. CAP status in the preamble (`Accepted`\u002F`Implemented` vs draft)\n2. Target network protocol version ([software versions](https:\u002F\u002Fdevelopers.stellar.org\u002Fdocs\u002Fnetworks\u002Fsoftware-versions))\n3. `soroban-sdk` release support for the host functions you need\n\n**The curve decides everything.** BLS12-381 proofs verify natively on-chain today; BN254 proofs (Circom's default, Barretenberg, RISC Zero's Groth16 wrapper) are gated on CAP-0074.\n\n| Toolchain | Proof system | Curve | On-chain on Stellar |\n|-----------|--------------|-------|---------------------|\n| Circom + snarkjs (`-p bls12381`) | Groth16 | BLS12-381 | ✅ Today, via CAP-0059 |\n| Circom + snarkjs (default) | Groth16 | BN254 | Gated on CAP-0074 |\n| Noir + Barretenberg | UltraHonk | BN254 | Not yet - attest off-chain verification |\n| RISC Zero (STARK → Groth16 wrap) | Groth16 | BN254 | Gated on CAP-0074 - attest meanwhile |\n\n## The on-chain verifier (Groth16 over BLS12-381)\n\nThe official [groth16_verifier example](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples\u002Ftree\u002Fmain\u002Fgroth16_verifier) is the canonical implementation - the full contract:\n\n```rust\n#![no_std]\nuse soroban_sdk::{\n    contract, contracterror, contractimpl, contracttype,\n    crypto::bls12_381::{Fr, G1Affine, G2Affine},\n    vec, Env, Vec,\n};\n\n#[contracterror]\n#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]\n#[repr(u32)]\npub enum Groth16Error {\n    MalformedVerifyingKey = 0,\n}\n\n#[derive(Clone)]\n#[contracttype]\npub struct VerificationKey {\n    pub alpha: G1Affine,\n    pub beta: G2Affine,\n    pub gamma: G2Affine,\n    pub delta: G2Affine,\n    pub ic: Vec\u003CG1Affine>,\n}\n\n#[derive(Clone)]\n#[contracttype]\npub struct Proof {\n    pub a: G1Affine,\n    pub b: G2Affine,\n    pub c: G1Affine,\n}\n\n#[contract]\npub struct Groth16Verifier;\n\n#[contractimpl]\nimpl Groth16Verifier {\n    pub fn verify_proof(\n        env: Env,\n        vk: VerificationKey,\n        proof: Proof,\n        pub_signals: Vec\u003CFr>,\n    ) -> Result\u003Cbool, Groth16Error> {\n        let bls = env.crypto().bls12_381();\n\n        \u002F\u002F vk_x = ic[0] + sum(pub_signals[i] * ic[i+1])\n        if pub_signals.len() + 1 != vk.ic.len() {\n            return Err(Groth16Error::MalformedVerifyingKey);\n        }\n        let mut vk_x = vk.ic.get(0).unwrap();\n        for (s, v) in pub_signals.iter().zip(vk.ic.iter().skip(1)) {\n            let prod = bls.g1_mul(&v, &s);\n            vk_x = bls.g1_add(&vk_x, &prod);\n        }\n\n        \u002F\u002F e(-A, B) * e(alpha, beta) * e(vk_x, gamma) * e(C, delta) == 1\n        let neg_a = -proof.a;\n        let vp1 = vec![&env, neg_a, vk.alpha, vk_x, proof.c];\n        let vp2 = vec![&env, proof.b, vk.beta, vk.gamma, vk.delta];\n\n        Ok(bls.pairing_check(vp1, vp2))\n    }\n}\n```\n\nPoint encodings are uncompressed big-endian: `G1Affine` wraps 96 bytes, `G2Affine` 192 bytes, `Fr` 32 bytes. The example's test suite shows the exact conversion from arkworks types (`ark-bls12-381` + `ark-serialize`) - reuse it when building fixtures from your proving toolchain's JSON output.\n\nIn production, wrap this verifier with application logic: fix the `VerificationKey` at deploy time (constructor) instead of taking it as a call argument, and bind proofs to context (see [Pitfalls](#pitfalls)).\n\n## Walkthrough: Circom → on-chain verification (works today)\n\nCircom supports BLS12-381 as a target field - this makes it the toolchain that verifies natively on Stellar right now.\n\n```bash\n# 1. Circuit\ncat > multiplier.circom \u003C\u003C'EOF'\npragma circom 2.1.6;\ntemplate Multiplier() {\n    signal input a;\n    signal input b;\n    signal output c;\n    c \u003C== a * b;\n}\ncomponent main = Multiplier();\nEOF\n\n# 2. Compile for BLS12-381 (NOT the default bn128 - that's gated on CAP-0074)\ncircom multiplier.circom --r1cs --wasm -p bls12381\n\n# 3. Trusted setup (powers of tau on bls12-381, then circuit-specific phase 2)\nsnarkjs powersoftau new bls12-381 12 pot12_0000.ptau\nsnarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name=\"contrib\" -e=\"random\"\nsnarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau\nsnarkjs groth16 setup multiplier.r1cs pot12_final.ptau multiplier.zkey\nsnarkjs zkey export verificationkey multiplier.zkey verification_key.json\n\n# 4. Witness + proof\necho '{\"a\": 3, \"b\": 11}' > input.json\nnode multiplier_js\u002Fgenerate_witness.js multiplier_js\u002Fmultiplier.wasm input.json witness.wtns\nsnarkjs groth16 prove multiplier.zkey witness.wtns proof.json public.json\n\n# 5. Sanity-check off-chain before going on-chain\nsnarkjs groth16 verify verification_key.json public.json proof.json\n```\n\nThen convert `proof.json` \u002F `verification_key.json` (decimal-string coordinates) into the contract's types - serialize each point uncompressed big-endian into the 96\u002F192-byte layouts, e.g. via arkworks as in the example's tests - and invoke `verify_proof`. Public signals (`public.json`) become the `Vec\u003CFr>` argument; the contract must also validate what those signals *mean* (see [Pitfalls](#pitfalls)).\n\nFor 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.\n\n## Walkthrough: Noir (off-chain verify + attestation, for now)\n\nNoir's standard backend (Barretenberg) produces UltraHonk proofs over BN254 - neither the proof system nor the curve is on-chain verifiable on Stellar today.\n\n```bash\n# Local proving workflow\nnargo new age_check && cd age_check\ncat > src\u002Fmain.nr \u003C\u003C'EOF'\nfn main(age: u64, threshold: pub u64) {\n    assert(age >= threshold);\n}\nEOF\nnargo check\nnargo execute witness          # writes the witness from Prover.toml inputs\nbb prove -b target\u002Fage_check.json -w target\u002Fwitness.gz -o target\u002Fproof\nbb verify -k target\u002Fvk -p target\u002Fproof   # off-chain verification\n```\n\nOn Stellar, two patterns until the curve\u002Fsystem gap closes:\n\n1. **Attestation oracle**: a verifier service runs `bb verify` (or the Noir JS verifier) off-chain and submits a signed attestation; the contract `require_auth()`s the attester address and applies policy. The trust assumption (the attester) must be explicit and documented - this is *not* trustless ZK, it's a verifiable-computation oracle.\n2. **Switch the proving stack for on-chain parts**: express the on-chain-critical statement as a Circom\u002FGroth16-BLS12-381 circuit (walkthrough above) and keep Noir for off-chain components.\n\nTrack 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.\n\n## Walkthrough: RISC Zero (same gate, clear path)\n\nRISC Zero proves arbitrary Rust execution (zkVM) and can wrap its STARK receipts into a Groth16 proof over BN254 (\"stark-to-snark\") - small enough for on-chain verification where BN254 is supported.\n\n```rust\n\u002F\u002F Guest (runs inside the zkVM): the computation being proven\nuse risc0_zkvm::guest::env;\n\nfn main() {\n    let input: u64 = env::read();\n    let result = expensive_check(input);\n    env::commit(&result);          \u002F\u002F becomes part of the public journal\n}\n```\n\n```rust\n\u002F\u002F Host: produce and verify a receipt locally\nlet receipt = prover.prove(env, ELF)?.receipt;\nreceipt.verify(IMAGE_ID)?;         \u002F\u002F off-chain verification\n```\n\nOn 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:\u002F\u002Fdev.risczero.com\u002Fapi) for the wrapping workflow.\n\n## Architecture patterns\n\n- **Verification gateway**: isolate cryptographic checks in a dedicated verifier contract\u002Fmodule - normalize inputs, verify, emit explicit success\u002Ffailure events. Smaller audit surface, cleaner upgrades.\n- **Policy-and-proof split**: `Verifier` (cryptographic validity) → `Policy` (business\u002Fcompliance rules) → `Application` (state transition). Each independently testable and upgradeable.\n- **Capability gating**: enable ZK flows only where required primitives are confirmed available; keep deterministic fallbacks and document the supported network\u002Fprotocol matrix.\n\nFor 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.\n\n## Pitfalls\n\n- **Verifying the proof but not the statement.** A valid proof only shows *some* witness satisfies the circuit. The contract must validate the public inputs' semantics: who is this proof for, which Merkle root, which action, which amount.\n- **Missing anti-replay binding.** Valid proofs can be replayed. Bind a nonce\u002Fsession\u002Faction into the public inputs and persist a replay guard (nullifier set) on-chain.\n- **Curve mismatch.** Circom defaults to bn128; on Stellar compile with `-p bls12381` or your proof will be unverifiable on-chain.\n- **Trusted-setup hygiene.** Groth16 needs a circuit-specific phase-2 setup; for production use a real multi-party ceremony, not a single-contributor dev setup.\n- **Hardcoded protocol assumptions.** Capability-gate; don't assume draft CAPs are live on the target network.\n\n## Testing\n\n- Unit: input domain validation, replay protection, event correctness, malformed\u002Ftampered proof rejection (negative paths are the important ones)\n- Integration: full prove → submit → verify → state-transition flow against a local network\n- Operational: resource costs for realistic proof sizes via simulation (`--send=no`) - pairing checks are expensive; budget before committing to per-transaction verification\n\n## References\n\n- [groth16_verifier example](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples\u002Ftree\u002Fmain\u002Fgroth16_verifier) - canonical verifier + arkworks test fixtures\n- [soroban-examples](https:\u002F\u002Fgithub.com\u002Fstellar\u002Fsoroban-examples)\n- [BLS12-381 SDK docs](https:\u002F\u002Fdocs.rs\u002Fsoroban-sdk\u002Flatest\u002Fsoroban_sdk\u002Fcrypto\u002Fbls12_381\u002Findex.html)\n- [Circom docs](https:\u002F\u002Fdocs.circom.io) · [snarkjs](https:\u002F\u002Fgithub.com\u002Fiden3\u002Fsnarkjs) · [Noir docs](https:\u002F\u002Fnoir-lang.org\u002Fdocs) · [RISC Zero docs](https:\u002F\u002Fdev.risczero.com)\n",{"name":5,"description":7,"argument-hint":24,"user-invocable":25},"[zk task]",true,"main","db2f47e2b79822ad3d8dd0f17489d5d15bcba96d",".claude\u002Fskills\u002Fzk-proofs",3,"https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz","https:\u002F\u002Fwritz.xyz","https:\u002F\u002Fgithub.com\u002FWritzProtocol","https:\u002F\u002Fwritz.xyz\u002F","Native Bitcoin lending on Stellar. No bridge, no custodian.","2026-11-14 18:13:11",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":25},[38,41,44],{"tool":39,"command":40},"npx","npx skills add WritzProtocol\u002Fwritz --skill zk-proofs",{"tool":42,"command":43},"bunx","bunx skills add WritzProtocol\u002Fwritz --skill zk-proofs",{"tool":45,"command":46},"pnpm","pnpm dlx skills add WritzProtocol\u002Fwritz --skill zk-proofs","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fzk-proofs\u002FSKILL.md",[],[50,55,62,69,76,83],{"skillNo":51,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M77KKJ6DYZP10BJ74CW4H0AE","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Fzk-proofs\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M77KKF3SK8JVBGRY4A89HYQC","tyler-architect","System architect and technical design leader. Use when the user asks to talk to Tyler or requests the architect.","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Ftyler-architect\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M77KKCD584VQA1TM1F9Q8JBH","stellar-help","Analyzes current state and user query to answer BMad questions or recommend the next skill(s) to use. Use when user asks for help, bmad help, what to do next, or what to start with in BMad.","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Fstellar-help\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M77KK7W2HKQ3QMAG0KJY1BHH","stellar-competitive-landscape","Map the competitive landscape for a Stellar project idea. Use when a user says \"who are my competitors on Stellar\", \"competitive analysis Stellar\", \"what already exists in this space on Stellar\", \"show me similar Stellar projects\", \"is anyone else building this on Stellar\", or \"map the Stellar landscape for X\". Queries the 728-project LumenLoop ecosystem database and Electric Capital developer activity to rank competitors by SCF funding history and repo activity.","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Fstellar-competitive-landscape\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M77KK1ACXYN5AZTWR8B5CKTX","standards","Stellar standards, ecosystem, and reference. Covers SEPs (Stellar Ecosystem Proposals), CAPs (Core Advancement Proposals), and a quick map for picking the right standard for wallets, anchors, payments, deposits\u002Fwithdrawals, federation, deep links, and KYC. Also bundles ecosystem references (DeFi protocols, dev tools, wallets, infra, community projects), curated documentation links, and MCP servers (live tools such as Raven). Use when you need to know which SEP applies, or want a starting point for ecosystem integrations, official docs, or live MCP tooling.","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Fstandards\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M77KJV8VW46WC58DHJR2296C","smart-contracts","Stellar smart contract development (Rust, soroban-sdk). Entry point with project setup, contract anatomy, and build\u002Fdeploy workflow, routing to three companion files in this directory - development.md (storage\u002FTTL, authorization, cross-contract calls, tokens, events, errors, upgrades, fees, troubleshooting), testing.md (unit, fuzz, property, fork, mutation, integration), and security.md (vulnerability classes, checklists, tooling, audits). Use when writing, testing, reviewing, securing, debugging, or shipping Stellar smart contracts, including anything the user calls \"Soroban\" - Soroban contracts, soroban-sdk, Soroban auth\u002Fstorage\u002FTTL errors, SEP-41 tokens, or SAC integration from contract code.","https:\u002F\u002Fgithub.com\u002FWritzProtocol\u002Fwritz\u002Fblob\u002Fmain\u002F.codex\u002Fskills\u002Fsmart-contracts\u002FSKILL.md",[],[]]