midnight-cryptography

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Midnight Node Cryptography

Midnight节点密码学

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.
Midnight Ledger(拥有独立ZK电路)之外,Midnight节点依赖基础密码学算法保障共识状态转换完整性网络通信

Algorithm map

算法映射

mermaid
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

mermaid
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(主哈希算法)

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.

Blake2-256是Midnight的主要密码学哈希函数。
  • 用于区块哈希和状态转换函数中的通用哈希操作。
  • 在运行时关键操作中平衡性能安全性

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
mermaid
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
Midnight根据不同角色使用三种不同的签名方案
方案构造/基础用途
sr25519Schnorrkel + Ristretto x25519签署AURA区块生成消息
ECDSA标准椭圆曲线ECDSA签署Partnerchain相关共识消息(跨链互操作性)
Ed25519Edwards曲线EdDSAGRANDPA最终性消息和libp2p协议消息
mermaid
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

sr25519

  • Efficient key derivation and signature aggregation.
  • Strong security guarantees for Substrate-style block production.
  • 高效的密钥派生和签名聚合。
  • 为Substrate风格的区块生成提供强安全保障。

ECDSA

ECDSA

  • Ensures interoperability with systems where ECDSA is the standard (Partnerchain / Cardano ecosystem bridges).
  • 确保与以ECDSA为标准的系统(Partnerchain/Cardano生态桥接)的互操作性。

Ed25519

Ed25519

  • Fast verification for high-frequency validator communication during finalization.
  • Also used for libp2p peer identity (separate keypair from consensus signing keys).

  • 在最终化过程中为高频验证者通信提供快速验证。
  • 也用于libp2p节点身份(与共识签名密钥分离的密钥对)。

twoxhash (storage keys)

twoxhash(存储键)

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.

twoxhash是一种非密码学哈希算法,用于在Patricia-Merkle树中生成存储键
  • 针对速度低碰撞率优化。
  • 适用于安全敏感的哈希操作。
  • 显著提升树查找性能。
查看
midnight-storage/
了解twoxhash如何适配ParityDB和状态承诺。

Ledger vs node crypto

Ledger与节点加密对比

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 LedgerZK证明、ZSwap电路、合约证明验证
Midnight NodeBlake2-256、sr25519、ECDSA、Ed25519、twoxhash
请勿将账本证明验证(由
pallet-midnight
处理)与节点级共识和P2P原语混淆。

Related skills

相关技能

  • 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
  • midnight-consensus/
    — 哪些方案用于签署AURA、GRANDPA和Partnerchain消息
  • midnight-storage/
    — twoxhash在树键生成中的应用
  • midnight-p2p-networking/
    — libp2p中的Ed25519节点身份