4 个版本
0.0.1-sol5 | 2020年5月1日 |
---|---|
0.0.1-sol4 | 2019年10月25日 |
0.0.0 | 2019年8月6日 |
0.0.0-sol15 | 2019年7月27日 |
0.0.0-sol13 |
|
#6 in #libra
163 每月下载量
在 22 个crate中使用 (8 直接使用)
225KB
4K SLoC
id: crypto title: 密码学 custom_edit_url: https://github.com/libra/libra/edit/master/crypto/crypto/README.md
密码学
密码学组件包含我们在 Libra 中使用的所有加密原语的实现:散列、签名以及密钥推导/生成。使用 traits.rs 的库部分包含强制类型安全的密码学 API、可验证的随机函数、EdDSA & BLS 签名。
概述
Libra 使用了多种密码学算法
- SHA-3 作为主要的散列函数。它已在 FIPS 202 中标准化。它基于 tiny_keccak 库。
- HKDF:基于 RFC 5869 的基于 HMAC 的提取和扩展密钥推导函数 (HKDF)。它用于从盐(可选)、种子和应用信息(可选)生成密钥。
- traits.rs 引入了新的抽象来表示密码学 API。
- Ed25519 使用基于 ed25519-dalek 库的新 API 设计进行签名,并增加了额外的安全检查(例如,对于可塑性)。
- BLS12381 使用基于 threshold_crypto 库的新 API 设计进行签名。BLS 签名目前正在经历一个 标准化过程。
- ECVRF 实现了一个基于 curve25519 的可验证随机函数 (VRF),按照 draft-irtf-cfrg-vrf-04。
- SLIP-0010 实现了 Ed25519 的通用分层密钥推导,按照 SLIP-0010。
- 使用X25519进行密钥交换。它通过Noise Protocol Framework来保障验证者之间的通信安全。它基于x25519-dalek库。
该模块是如何组织的?
crypto/src
├── hash.rs # Hash function (SHA-3)
├── hkdf.rs # HKDF implementation (HMAC-based Extract-and-Expand Key Derivation Function based on RFC 5869)
├── macros/ # Derivations for SilentDebug and SilentDisplay
├── utils.rs # Serialization utility functions
├── lib.rs
├── bls12381.rs # Bls12-381 implementation of the signing/verification API in traits.rs
├── ed25519.rs # Ed25519 implementation of the signing/verification API in traits.rs
├── slip0010.rs # SLIP-0010 universal hierarchical key derivation for Ed25519
├── x25519.rs # X25519 keys generation
├── test_utils.rs
├── traits.rs # New API design and the necessary abstractions
├── unit_tests/ # Tests
└── vrf/
├── ecvrf.rs # ECVRF implementation using curve25519 and SHA512
├── mod.rs
└── unit_tests # Tests
依赖项
~7.5MB
~127K SLoC