Help us improve
Share bugs, ideas, or general feedback.
From midnight-verify
Verification by source code inspection of the Midnight ledger Rust codebase. Searches and reads the actual Rust implementation to verify claims about transaction structure, token mechanics, cost model, on-chain VM, contract execution, and cryptographic primitives. Routes claims to specific crates within the 24-crate workspace. Uses octocode-mcp for quick lookups, falls back to local cloning for deep investigation. Loaded by the source-investigator agent when the claim domain is ledger/protocol.
npx claudepluginhub devrelaicom/midnight-expert --plugin midnight-verifyHow this skill is triggered — by the user, by Claude, or both
Slash command
/midnight-verify:verify-by-ledger-sourceThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are verifying a claim about the Midnight ledger protocol by reading the actual Rust source code. Follow these steps in order.
Verification by source code inspection. Searches and reads the actual compiler, ledger, and runtime source code to verify structural or architectural claims about Compact and Midnight that cannot be tested via compilation. Uses octocode-mcp for quick lookups, falls back to local cloning for deep investigation. Loaded by the source-investigator agent.
This skill should be used when reviewing Compact smart contract code, TypeScript witness implementations, or test files for a Midnight project. Applies when a user asks to "review my Compact contract", "audit this smart contract", "check my Midnight code", or "run a code review checklist". Provides category-specific checklists covering privacy, security, cryptographic correctness, token economics, concurrency, compilation, performance, architecture, code quality, testing, and documentation, plus mechanical verification via /midnight-verify:verify.
This skill should be used when the user asks about the Midnight.js SDK, midnight-js packages, @midnight-ntwrk npm packages, setting up SDK providers, deploying or finding contracts with deployContract or findDeployedContract, calling circuits with callTx or submitCallTx, the transaction lifecycle, SDK provider types (WalletProvider, MidnightProvider, PublicDataProvider, ProofProvider, ZkConfigProvider, PrivateStateProvider), testkit-js testing, observable state subscriptions, contract maintenance and verifier keys, or connecting to the indexer or proof server.
Share bugs, ideas, or general feedback.
You are verifying a claim about the Midnight ledger protocol by reading the actual Rust source code. Follow these steps in order.
Source code is evidence. Everything else is a hint.
| Source | Role | Rule |
|---|---|---|
| Rust source code (function definitions, type definitions, implementations) | Primary evidence | Always the target. Verdicts must cite Rust source. |
| Test files in the repo | Navigation aid | Follow test imports to find the right source code. Can be run as a last resort (clone to /tmp, cargo test), but realistically never needed. |
spec/ documents (13 specification files) | Hints only | Useful for orienting where to look. Never evidence on their own. Any claim derived from specs must be corroborated by Rust source inspection. |
docs/api/ generated TypeScript docs | Navigation aid | Useful for finding what's exported via WASM, then trace back to Rust source. |
Crate routing — match the claim to the right crate and path:
| Claim About | Crate | Key Paths |
|---|---|---|
| Coin types, commitments, nullifiers, token types | coin-structure | src/coin.rs, src/contract.rs, src/transfer.rs |
| NIGHT constant, ShieldedTokenType, UnshieldedTokenType | coin-structure | src/coin.rs |
| Hashing (persistent, transient, Poseidon) | base-crypto | src/hash.rs |
| Signatures (Schnorr/Secp256k1, BIP340) | base-crypto | src/signatures.rs |
| FAB encoding (field-aligned binary) | base-crypto | src/fab/ |
| Pedersen commitments, value commitments | transient-crypto | src/commitment.rs |
| Encryption (Poseidon CTR, ECDH) | transient-crypto | src/encryption.rs |
| Merkle trees | transient-crypto | src/merkle_tree.rs |
| Curve operations (Fr, embedded curve) | transient-crypto | src/curve.rs |
| ZK proof structures, prover traits | transient-crypto | src/proofs.rs |
| VM opcodes, instruction execution | onchain-vm | src/ops.rs, src/vm.rs |
| VM cost model (per-instruction costs) | onchain-vm | src/cost_model.rs |
| StateValue types (Null, Cell, Map, Array, BoundedMerkleTree) | onchain-state | src/ |
| Contract state, runtime context, transcripts | onchain-runtime | src/context.rs, src/transcript.rs |
| Communication commitment | onchain-runtime | src/ (re-exported) |
| Transaction structure, assembly, well-formedness | ledger | src/structure.rs, src/construct.rs, src/semantics.rs |
| Transaction proving and verification | ledger | src/prove.rs, src/verify.rs |
| Dust operations (spend, registration, generation) | ledger | src/dust.rs |
| Intent structure, replay protection | ledger | src/structure.rs |
| Zswap offers, inputs, outputs, transients | zswap | src/ |
| Zswap local state, chain state | zswap | src/ |
| Fee token, cost model at ledger level | ledger | src/structure.rs (FEE_TOKEN) |
| Serialization format | serialize | src/ |
| Storage (MPT, delta tracking) | storage, storage-core | src/ |
| WASM bindings (ledger-v8 JS API) | ledger-wasm | src/lib.rs, src/crypto.rs, src/tx.rs, src/zswap_wasm.rs, src/dust.rs |
| WASM bindings (onchain-runtime JS API) | onchain-runtime-wasm | src/ |
| ZKIR v2 checker/prover | zkir | src/ir.rs, src/ir_vm.rs |
| Precompiled circuits | zkir-precompiles | dust/, zswap/, token-vault/, etc. |
| Proof server HTTP API | proof-server | src/main.rs |
Crate dependency graph:
base-crypto → transient-crypto → coin-structure → onchain-state → onchain-vm → onchain-runtime
↓
zswap ← ledger ← ledger-wasm (WASM)
Supporting: serialize, storage-core, storage. Proofs: zkir, zkir-v3.
Start with targeted lookups using the octocode-mcp tools:
githubSearchCode — search for specific function names, type names, implementations in midnightntwrk/midnight-ledgergithubGetFileContent — read a specific file once you know the pathgithubViewRepoStructure — understand crate layout if unsureSearch strategy:
base-crypto/src/ or transient-crypto/src/ledger/src/ then trace to zswap/, coin-structure/onchain-vm/src/ then onchain-runtime/ledger-wasm/src/ to find the WASM binding, then trace to the underlying Rust implementationIf octocode-mcp results are insufficient — tracing cross-crate dependencies, following trait implementations across crates, or understanding the full call chain:
CLONE_DIR=$(mktemp -d)
git clone --depth 1 git@github.com:midnightntwrk/midnight-ledger.git "$CLONE_DIR/midnight-ledger"
Always use SSH protocol (git@github.com:), not HTTPS.
After investigation, clean up:
rm -rf "$CLONE_DIR"
What counts as evidence (ordered by strength):
spec/ documents — hints for where to look. The 13 spec files (preliminaries, intents-transactions, zswap, dust, night, contracts, cost-model, field-aligned-binary, onchain-runtime, properties, storage-io-cost-modeling, cardano-system-transactions) describe intended behavior but must be corroborated by Rust source.docs/api/ TypeScript docs — navigation aid. Generated from WASM bindings. Trace back to Rust.Watch for:
coin-structure may be re-exported through ledger and appear via WASM in ledger-wasm. Trace to the original definition.#[wasm_bindgen] functions in *-wasm crates are thin wrappers. The real implementation is in the underlying Rust crate.proof-verifying (default), proving, test-utilities, mock-verify. Some code only exists behind features.static crate provides version identifiers via proc macro.Your report must include:
https://github.com/midnightntwrk/midnight-ledger/blob/main/coin-structure/src/coin.rs#L42)Report format:
### Source Investigation Report
**Claim:** [verbatim]
**Searched:** [crate(s) and method — octocode-mcp search / local clone]
**Found:**
- Crate: [crate-name]
- File: [path/to/file.rs:line-range]
- Link: [full GitHub URL]
- Content: [relevant Rust code snippet or summary]
**Interpretation:** [Confirmed / Refuted / Inconclusive] — [explanation]
If inconclusive, explain: