Skip to content

feat: CAT minting + nullifier v2 (PR5)#21

Open
almogdepaz wants to merge 1 commit intopr/04-stealth-nonce-encryptionfrom
pr/05-cat-minting
Open

feat: CAT minting + nullifier v2 (PR5)#21
almogdepaz wants to merge 1 commit intopr/04-stealth-nonce-encryptionfrom
pr/05-cat-minting

Conversation

@almogdepaz
Copy link
Copy Markdown
Owner

Summary

  • CoinMode::Mint implemented across all backends (mock, risc0, sp1) — was panic/error
  • compute_genesis_nullifier: one-time-use genesis coin enforcement via SHA256("clvm_zk_genesis_v1.0" || serial || tail_hash) — prevents double-minting
  • compute_nullifier_v2 (ZK-01 fix): SHA256("clvm_zk_nullifier_v2.0" || tail_hash || serial || program || amount) — tail_hash binding prevents cross-asset nullifier collision attacks. v1 deprecated.
  • mint_cat simulator method + mint_command CLI
  • CoinInfo.tail_source: stored at mint, auto-retrieved at spend — CAT coins now spend correctly via spend_coins
  • 6 new tests covering: unlimited TAIL, genesis nullifier, double-mint prevention, nil TAIL rejection, hash mismatch, mint-then-spend

Files changed (13)

  • clvm_zk_core/src/lib.rscompute_genesis_nullifier, compute_nullifier_v2, v1 deprecated
  • backends/mock/src/backend.rs — full Mint arm, enforce_ring_balance guard, v2 nullifier
  • backends/risc0/guest/src/main.rs — Mint arm, v2 nullifier
  • backends/sp1/program/src/main.rs — mirror risc0
  • backends/risc0/src/lib.rs, backends/sp1/src/lib.rs — removed host-side Mint guards
  • backends/risc0/guest_settlement/src/main.rs, backends/sp1/program_settlement/src/main.rs — v2 nullifier
  • src/lib.rsClvmZkProver::prove_with_input
  • src/simulator.rsmint_cat, CoinInfo.tail_source, UTXO key fix, CAT spend tail_source lookup
  • src/cli.rsSimAction::Mint, mint_command
  • tests/test_cat_minting.rs — 6 tests

Test plan

  • cargo test --no-default-features --features mock,testing --test test_cat_minting — 6/6 pass
  • cargo test --no-default-features --features mock,testing — full suite green, no regressions

CAT minting stack:
- CoinMode::Mint in mock, risc0, sp1 backends (was panic/error)
- compute_genesis_nullifier for one-time-use genesis enforcement
- mint_cat simulator method + mint_command CLI
- enforce_ring_balance guard skips Mint (no input coin)
- 6 new tests in test_cat_minting.rs

Nullifier v2 (ZK-01 security fix):
- compute_nullifier_v2: SHA256(domain || tail_hash || serial || program || amount)
- tail_hash binding prevents cross-asset nullifier collision attacks
- compute_nullifier v1 deprecated
- all 8 callsites updated (mock, risc0, sp1, settlement guests)

Simulator fixes:
- CoinInfo.tail_source field for CAT spend authorization
- Fixed UTXO key in mint_cat (serial_number, not serial_commitment)
- spend_coins looks up tail_source for CAT coins automatically
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.

1 participant