midnight-cryptography
Skill18 starsChanged 17 days agoMITView on GitHub
Cryptographic primitives used by the Midnight node — Blake2-256 hashing, sr25519/ECDSA/Ed25519 signatures, twoxhash storage keys, and how they map to consensus, P2P, and state. Use when debugging node crypto, signature verification, or hash function choices.
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 1am-walletSkill
- android-example-votingSkill
- ankr-midnightSkill
- compactSkill
- dynamic-midnight-walletSkill
- example-counterSkill
- example-hello-worldSkill
- example-leaderboard-dappSkill
- example-locker-dappSkill
- example-passport-dappSkill
- example-payment-dappSkill
- example-private-party-dappSkill
- example-private-reserve-auction-dappSkill
- example-zk-loan-applicationSkill
- gsap-coreSkill
- gsap-utilsSkill
- indexerSkill
- midnight-consensusSkill
- midnight-environment-setupSkill
- midnight-jsSkill
- midnight-onchain-logicSkill
- midnight-p2p-networkingSkill
- midnight-passportSkill
- midnight-rpcSkill
- midnightskillSkill
- midnight-storageSkill
- midnight-transactionsSkill
- multinetworkSkill
- nftSkill
- react-wallet-connectorSkill
- midnight-securitySkill
- testingSkill
- token-transfersSkill
- why-midnightSkill
- zk-vs-fhe-vs-mpcSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 105
Do not conflate ledger proof verification (handled by pallet-midnight) with node-level consensus and P2P primitives.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Midnight Node Cryptography
Outside the Midnight Ledger (which has its own ZK circuits), the Midnight node relies on foundational cryptographic algorithms for consensus, state transition integrity, and network communication.
Algorithm map
flowchart TB
subgraph Hash["Hashing"]
B2["Blake2-256 — cryptographic"]
T2["twoxhash — non-cryptographic storage keys"]
end
subgraph Sign["Signature schemes"]
SR["sr25519 — AURA block authorship"]
ECDSA["ECDSA — Partnerchain consensus messages"]
ED["Ed25519 — GRANDPA finality + libp2p"]
end
subgraph Use["Used for"]
B2 --> Blocks["Block hashes, state transitions"]
T2 --> Trie["Patricia-Merkle trie key generation"]
SR --> AURA["AURA block production"]
ECDSA --> PC["Partnerchain coordination"]
ED --> GRANDPA["GRANDPA votes"]
ED --> P2P["libp2p protocol messages"]
endBlake2-256 (primary hash)
Blake2-256 is the primary cryptographic hash function on Midnight.
- Used for block hashes and general-purpose hashing in state transition functions.
- Balances performance and security for runtime-critical operations.
Signature schemes
Midnight uses three distinct schemes depending on role:
| Scheme | Construction / basis | Used for |
| sr25519 | Schnorrkel + Ristretto x25519 | Signing AURA block authorship messages |
| ECDSA | Standard elliptic-curve ECDSA | Signing Partnerchain-related consensus messages (external interoperability) |
| Ed25519 | Edwards-curve EdDSA | GRANDPA finality messages and libp2p protocol messages |
flowchart LR
subgraph Consensus
AURA["AURA slot"] -->|sr25519| BA["Block authorship"]
GRANDPA["GRANDPA vote"] -->|Ed25519| FV["Finality message"]
PC["Partnerchain signal"] -->|ECDSA| PM["Cross-chain message"]
end
subgraph Network
L2P["libp2p handshake"] -->|Ed25519| PI["Peer identity separate from consensus keys"]
endsr25519
- Efficient key derivation and signature aggregation.
- Strong security guarantees for Substrate-style block production.
ECDSA
- Ensures interoperability with systems where ECDSA is the standard (Partnerchain / Cardano ecosystem bridges).
Ed25519
- Fast verification for high-frequency validator communication during finalization.
- Also used for libp2p peer identity (separate keypair from consensus signing keys).
twoxhash (storage keys)
twoxhash is a non-cryptographic hash used to generate storage keys in the Patricia-Merkle trie.
- Optimized for speed and low collision rates.
- Not suitable for security-sensitive hashing.
- Significantly improves trie lookup performance.
See midnight-storage/ for how twoxhash fits into ParityDB and state commitments.
Ledger vs node crypto
| Layer | Cryptography |
| Midnight Ledger | ZK proofs, ZSwap circuits, contract proof verification |
| Midnight Node | Blake2-256, sr25519, ECDSA, Ed25519, twoxhash |
Do not conflate ledger proof verification (handled by pallet-midnight) with node-level consensus and P2P primitives.
Related skills
midnight-consensus/— which schemes sign AURA vs GRANDPA vs Partnerchain messagesmidnight-storage/— twoxhash in trie key generationmidnight-p2p-networking/— Ed25519 peer identity in libp2p
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

