Use with your AI agent
- Install — run
npx skills add Kali-Decoder/Midnight-skills --skill midnight-security-checklistfor this skill, ornpx skills add Kali-Decoder/Midnight-skillsfor all - Prompt — copy the example prompt and paste it into Cursor, Claude Code, or Codex
- Build — the agent loads this skill and scaffolds your Midnight work
Security Checklist
Agent picks this when: Run a pre-ship security and privacy gate
Pre-ship pass/fail security and privacy gate for a Midnight dApp: disclosure, cryptography, authorization, transaction semantics, keys, and deploy.
Good for
- Pass/fail checklist over disclosure, crypto, witnesses, auth, transaction phases, keys, and deploy.
- Each item links to the midnight-security section that explains it.
Preview in agent
Suggested promptsRun a pre-ship security and privacy gate. Use the "midnight-security-checklist" skill from MIDSKILLS. Follow Compact smart-contract best practices, wire wallet flows where needed, and explain each step as you implement. Target Midnight Preprod unless I specify otherwise.
Loaded skill midnight-security-checklist
What the skill guides the agent to do:
- Pass/fail checklist over disclosure, crypto, witnesses, auth, transaction phases, keys, and deploy.
- Each item links to the midnight-security section that explains it.
Illustrative — based on the skill's description, not recorded agent output.
Try it without installing: npx skills use Kali-Decoder/Midnight-skills@midnight-security-checklist
What changed in v1.0.16
All registry changesNew skill — first published in v1.0.16 (not in v1.0.14).
On this page · 8 sections
Midnight Security Checklist
A gate, not a tutorial: go through every box, mark it pass / fail / n.a., and report the failures. The why and the fixes live in midnight-security/ (section numbers below).
What this skill produces: a filled checklist with a verdict (ship / fix first) and one line per failed item.
Workflow
- List every
.compactfile, every witness implementation (witnesses.ts), and every place the frontend handles secrets. - Walk sections A–F in order. Answer each item for each contract; quote the line when something fails.
- Any fail in A, B, or C blocks a mainnet deploy. Fails in D–F are reported with a severity.
- Run
midnight-testing-checklisttoo: every security property you rely on needs a negative test that proves it. - Report: the verdict, then the failures with file:line and the matching
midnight-securitysection.
A. What is public (midnight-security §1–§4)
- Every
export ledgerfield is meant to be public; per-user data that only its owner needs stays in private state. - No sensitive value is a circuit argument (all arguments are in the public transcript); secrets come from witnesses.
- Every
disclose()is intentional: you can say in one sentence why that value may become public. -
Mapkeys are not sensitive (keys are public on insert and lookup). - Anonymous membership uses
MerkleTree/HistoricMerkleTree, notSet.member(which reveals the element). - Every
emit(...)sends only disclosed values: events are public, indexed, and permanent (§5b). - Calling the circuit at all does not leak intent you meant to hide (e.g. a
submitVotecall reveals that someone voted).
B. Cryptography (midnight-security §2, §4, §9)
- No
persistentHashover a small value space (bool, vote, role, small amount): usepersistentCommitwith a fresh nonce. - No nonce is reused across commitments.
- Every hash / commitment has a unique domain separator; a commitment and its nullifier use different ones.
- Ledger-stored hashes use
persistent*, nevertransient*. - Signatures (
secp256k1EcdsaVerify) verify a hash you computed in-circuit with domain separation, the result isasserted, and no signature or signature hash is used as a nullifier or replay key (§5b).
C. Authorization and witnesses (midnight-security §2, §5, §7)
- Every witness output is validated with
assertbefore it drives logic: the proof only guarantees what the circuit checks. - Every privileged circuit checks authority in-circuit (hash-based key, Merkle membership, or
kernel.caller()withis_somechecked); none trusts the frontend. - Replay is impossible: one-shot actions use a nullifier set, repeated auth includes a round or counter.
- Cross-contract callees are compared against a stored address before their results are trusted (§5b).
- Every invariant the contract relies on is an
assert, not a comment.
D. Transaction semantics (midnight-security §6)
- Nothing consequential happens in the guaranteed phase if the fallible phase can still fail (partial success is permanent).
- No
assertin a fallible path can be tripped by state an attacker changes between proving and submission (fees are forfeited). - Order-sensitive actions (swaps, auctions) carry bounds or use commit-reveal against front-running.
-
Uint<N>widths hold every value (Uint<64>for Unix seconds,bigintamounts in Stars); casts are bounds-checked. - Merkle tree depth covers the expected maximum (inserting into a full tree fails) (§8).
E. Keys, secrets, and the frontend
- No mnemonic, seed, private key, Blockfrost token, or
.envfile is committed (git log -p/ a secret scanner). - User secrets (commitment nonces, private state) are stored where the user can recover them, and the UI says what is lost if they are cleared.
- Private-state storage uses a strong password provider (16+ chars, 3 classes).
- The UI explains the privacy boundary before any action that discloses something (e.g. an unshielded payout reveals the recipient).
F. Build and deploy
-
midnight-doctorreports0 fail: the deployed contract was compiled by the pinned toolchain. - Deployed artifacts (
compiler/,keys/,zkir/) come from the same build as the audited source. - After a recompile that changes verifier keys, callers and callees are re-audited together and redeployed (§5b).
- Who holds the contract maintenance authority, and what they can change, is written down for users.
Related skills
| Task | Skill |
|---|---|
| Explanations, leak patterns, defensive code | midnight-security/ |
| Prove each property with tests | midnight-testing-checklist/ |
| Version and toolchain gate | midnight-doctor/ |
Related skills
Security
Privacy audit checklist, data leak patterns, defensive Compact patterns.
NFT
Build shielded and unshielded NFTs on Midnight using OpenZeppelin Compact contracts.
Token Transfers
Shielded and unshielded token transfers, balance queries, multi-party flows on Midnight.
Midnight Environment Setup
Automatically prepare a Midnight dev environment — Compact, PATH, Docker, proof server, and VS Code extension. Run before building or deploying.