Repository navigation
feat(contracts): pq-receipt-check, verify a receipt's ML-DSA-65 signature on chain - #585
Conversation
…ture on chain Soroban contract that checks the pq block of a Nirium receipt with the Protocol 30 host function (CAP-87). It builds the statement nirium-audit-v1:<content_sha256 hex> itself, calls ml_dsa_65_verify (pure, empty context) and returns sha-256 of the public key, the value an account registers under manage_data nirium-pq-v1. No storage, no admin. Tested on testnet: contract CBQKCPCC...AGC2, both real pq receipts verify and return each account's first registered key id; a flipped signature bit and a key/receipt mismatch are rejected. Not deployed on mainnet. CI: cargo test against the real receipt, wasm build with stellar-cli 30.0.1 pinned by sha-256 (soroban-sdk 30 requires it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M0nsxx
left a comment
There was a problem hiding this comment.
AI-assisted review (Claude)
Reviewed the contract and its tests. verify_receipt builds the nirium-audit-v1: statement inside the contract, so callers can't pass a different message, then calls ml_dsa_65_verify with an empty context and returns sha256 of the public key, which is the nirium-pq-v1 registration value. No storage, no admin, no upgrade path. The 5 tests use the real testnet receipt QmPW2nfY and cover the valid case, a flipped signature bit, a changed hash and a changed key. The testnet run in the description lines up: both real receipts return the key id each account registered first. CI is green, and the new job runs the tests and builds the wasm with stellar-cli 30.0.1 pinned by sha-256. Approving.
Adds
contracts/pq-receipt-check, a Soroban contract that checks thepqblock of a Nirium receipt on chain, using the ML-DSA host function that Protocol 30 added (CAP-87).What it does
verify_receipt(public_key, content_sha256, signature) -> BytesN<32>buildsnirium-audit-v1:<content_sha256 hex>itself, so a caller can't make it check any other message. It runsml_dsa_65_verify(pure ML-DSA, empty context) and traps if the signature is bad.manage_data nirium-pq-v1. The "only the first registration counts" lookup needs account history, so it stays with the caller (CLI, /verify, Action), which already does it since fix(pq): only the account's first post-quantum key counts #582/feat(action): verify-audit-cid checks the post-quantum signature (pq) #584.agentsignature are still ed25519.Tested on testnet (4 Dec), contract
CBQKCPCCGJ2OTGLUZ5XTKIRFJ3UHITDKMOUGOUKKKUT4O3X5CDFXAGC2:QmPW2nfY…verifies and returns626668…bf9e, the first keyGAZKTB4N…XN54registered. Txdac60c9b57cd282a26d66f576c594b96c75b7628756728c9e7094095c45dab65.QmWwdPH9…verifies and returns29ab77…2a6e, the first keyGDK7ODGX…GWRIregistered. Txb3c026d74a9d4c3d8ebebc8aa008aa4dfa89c3688d796b63cdb7befe4d9b0e93.Error(Crypto, InvalidInput).Not deployed on mainnet.
CI: new
pq-receipt-check.yml. It runs the 5cargo testcases against the real receipt intest_fixtures/, then builds the wasm with stellar-cli 30.0.1 pinned by sha-256. soroban-sdk 30 refuses to build wasm with older CLIs.🤖 Generated with Claude Code