关于 midnight-cryptography
介绍 Midnight 节点层密码学原语的技能,适合研究共识、状态转换和网络通信的读者。内容区分密码学哈希与签名方案,以及 Ledger 使用的 ZK 证明密码学。
主要功能
- 01Blake2-256 用于区块哈希
- 02sr25519 用于 AURA 出块签名
- 03ECDSA 用于 Partnerchain 消息
- 04Ed25519 用于 GRANDPA 和 libp2p
- 05twoxhash 用于存储键
适用场景
- 01识别共识使用的算法
- 02区分节点与 Ledger 密码学
- 03了解 Trie 存储键的哈希方式
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ kali-decoder/ midnight-skills --skill midnight-cryptography安装后在 Claude Code 中输入/midnight-cryptography确认已加载。
详细介绍
Midnight 节点加密
在 Midnight Ledger(拥有自己的 ZK 电路)之外,Midnight 节点依赖基础加密算法来保障共识、状态转换完整性和网络通信。
算法概览
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(主要哈希)
Blake2-256 是 Midnight 的主要加密哈希函数。
- 用于区块哈希,以及状态转换函数中的通用哈希。
- 在运行时关键操作中兼顾性能与安全性。
签名方案
Midnight 根据用途使用三种不同的方案:
| 方案 | 构造/基础 | 用途 |
|---|---|---|
| sr25519 | Schnorrkel + Ristretto x25519 | 对 AURA 区块作者身份消息进行签名 |
| ECDSA | 标准椭圆曲线 ECDSA | 对与 Partnerchain 相关的共识消息进行签名(外部互操作) |
| Ed25519 | Edwards 曲线 EdDSA | GRANDPA 最终性消息和 libp2p 协议消息 |
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
- 高效的密钥派生与签名聚合。
- 为 Substrate 风格的区块生产提供强大的安全保障。
ECDSA
- 确保与 ECDSA 标准系统的互操作性(Partnerchain/Cardano 生态系统桥接)。
Ed25519
- 在最终确定期间,为高频验证者通信提供快速验证。
- 也用于 libp2p 对等节点身份(与共识签名密钥分开的一对密钥)。
twoxhash(存储键)
twoxhash 是一种非加密哈希,用于在 Patricia-Merkle trie 中生成存储键。
- 针对速度和低碰撞率进行了优化。
- 不适用于安全敏感型哈希。
- 显著提升 trie 查找性能。
请参阅 midnight-storage/,了解 twoxhash 如何用于 ParityDB 和状态承诺。
账本与节点加密
| 层 | 加密技术 |
|---|---|
| Midnight Ledger | ZK 证明、ZSwap 电路、合约证明验证 |
| Midnight Node | Blake2-256、sr25519、ECDSA、Ed25519、twoxhash |
请勿将账本证明验证(由 pallet-midnight 处理)与节点级共识和 P2P 基础机制混为一谈。
相关技能
midnight-consensus/— 哪些方案用于对 AURA、GRANDPA 和 Partnerchain 消息签名midnight-storage/— twoxhash 在 trie 键生成中的应用midnight-p2p-networking/— libp2p 中的 Ed25519 对等节点身份
评论
支持 Markdown