Back to Browse

Use with your AI agent

  1. Install — run npx skills add Kali-Decoder/Midnight-skills --skill midnight-cryptography for this skill, or npx skills add Kali-Decoder/Midnight-skills for all
  2. Prompt — copy the example prompt and paste it into Cursor, Claude Code, or Codex
  3. Build — the agent loads this skill and scaffolds your Midnight work

Midnight Cryptography

FoundationIntermediateReviewedUnchanged since v1.0.7v1.0.0

Agent picks this when: Explain Midnight node cryptography — hashes and signature schemes

Node cryptographic primitives — Blake2-256, sr25519, ECDSA, Ed25519, and twoxhash storage keys.

Good for

  • Blake2-256 for block hashes; twoxhash for trie storage keys.
  • sr25519 (AURA), ECDSA (Partnerchain), Ed25519 (GRANDPA + libp2p).

Preview in agent

Suggested prompts

Explain Midnight node cryptography — hashes and signature schemes. Use the "midnight-cryptography" 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-cryptography

What the skill guides the agent to do:

  1. Blake2-256 for block hashes; twoxhash for trie storage keys.
  2. sr25519 (AURA), ECDSA (Partnerchain), Ed25519 (GRANDPA + libp2p).

Illustrative — based on the skill's description, not recorded agent output.

Try it without installing: npx skills use Kali-Decoder/Midnight-skills@midnight-cryptography

What changed in v1.0.16

All registry changes

No changes in v1.0.16 or the releases before it that we track.

On this page · 9 sections
SKILL.md

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"]
  end

Blake2-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:

SchemeConstruction / basisUsed for
sr25519Schnorrkel + Ristretto x25519Signing AURA block authorship messages
ECDSAStandard elliptic-curve ECDSASigning Partnerchain-related consensus messages (external interoperability)
Ed25519Edwards-curve EdDSAGRANDPA 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"]
  end

sr25519

  • 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

LayerCryptography
Midnight LedgerZK proofs, ZSwap circuits, contract proof verification
Midnight NodeBlake2-256, sr25519, ECDSA, Ed25519, twoxhash

Do not conflate ledger proof verification (handled by pallet-midnight) with node-level consensus and P2P primitives.


  • midnight-consensus/ — which schemes sign AURA vs GRANDPA vs Partnerchain messages
  • midnight-storage/ — twoxhash in trie key generation
  • midnight-p2p-networking/ — Ed25519 peer identity in libp2p

Start in 2 steps

  1. 1. Install — one skill or the full set
  2. 2. Prompt — paste the example into your agent

Install all skills (recommended)

npx skills add Kali-Decoder/Midnight-skills

One command adds every Midnight skill to Cursor, Claude Code, and similar agents.

Install this skill only

npx skills add Kali-Decoder/Midnight-skills --skill midnight-cryptography

Installs only "midnight-cryptography" into every detected agent (Cursor, Claude Code, Codex, …).

Example agent prompt

Explain Midnight node cryptography — hashes and signature schemes. Use the "midnight-cryptography" 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.

Paste into Cursor, Claude Code, or Codex after installing.

Author
Kali-Decoder
Category
Foundation
Difficulty
intermediate
Version
v1.0.0

Tags

CryptographyBlake2SignaturesNode

Files included

SKILL.md
Create Social CardLive HackathonsGallery
Mock Demo
Midnight Cryptography