Fraunhofer-AISEC/hbs-lms-rust
GitHub: Fraunhofer-AISEC/hbs-lms-rust
一个遵循 IETF RFC 8554 的纯 Rust LMS(Leighton-Micali 签名)实现,解决抗量子签名在嵌入式与无 std 环境中的可用性问题。
Stars: 14 | Forks: 9
# Leighton-Micali 基于哈希的签名
[][crate-link]
[][docs-link]


[][build-link]
根据 [IETF RFC 8554](https://datatracker.ietf.org/doc/html/rfc8554) 实现的 LMS(Leighton-Micali 签名)Rust 实现。
该实现与以下参考实现二进制兼容:[hash-sigs](https://github.com/cisco/hash-sigs)。
此 crate 不需要标准库(即支持 `no_std`),可用于裸机编程。
## 演示
`examples` 文件夹中提供了一个演示应用程序,用于展示库的使用方法。
该演示应用程序可以在控制台中使用如下方式运行:
```
# 密钥生成
# 生成 `mykey.prv`、`mykey.pub`,默克尔树高度为 10,温特尼茨参数为 2
cargo run --release --example lms-demo -- genkey mykey 10/2 --seed 0123456701234567012345670123456701234567012345670123456701234567
# 签名
# 生成 `message.txt.sig`
cargo run --release --example lms-demo -- sign mykey message.txt
# 签名(fast_verification)
# 生成 `message.txt_mut`、`message.txt_mut.sig`
HBS_LMS_MAX_HASH_OPTIMIZATIONS=1000 HBS_LMS_THREADS=2 cargo run --release --example lms-demo \
--features fast_verify -- sign_mut mykey message.txt
# 验证
# 使用 `message.txt.sig` 和 `mykey.pub` 验证 `message.txt`
cargo run --release --example lms-demo -- verify mykey message.txt
```
## 与 IETF RFC 相关的命名约定
RFC 中的命名使用单个字符。
为了更好地理解实现,我们决定使用更具描述性的命名方式。
下表展示了 RFC 命名与库命名之间的映射关系,包括简要说明。
| RFC Naming | Library Naming | Meaning |
|------------|----------------------|-----------------------------------------------------------|
| I | lms_tree_identifier | 16-byte random value to identify a single LMS tree |
| q | lms_leaf_identifier | 4-byte value to identify all leafs in a single LMS tree |
| C | signature_randomizer | 32-byte random value added to every signature |
| Q | message_hash | Output of hashed message together with I, q, D_MESG and C |
| y | signature_data | The actual data of the signature |
| p | hash_chain_count | The number of hash chains for a certain W parameter |
| ls | checksum_left_shift | How many bits the checksum is shifted into the coef-value |
| n | hash_function_output_size | Number of bytes that the lm_ots hash functions generates |
| m | hash_function_output_size | Number of bytes that the lms hash functions generates |
## 最低支持的 Rust 版本
该 crate 支持 Rust **1.70** 或更高版本。
最低支持的 Rust 版本未来可能会更改,但会通过次要版本号进行升级。
## 许可
本项目根据 Apache-2.0 许可条款授权(详见 [LICENSE 文件](LICENSE))。
### 贡献
任何有意提交至本项目的贡献,在 Apache-2.0 许可定义下,均按上述条款授权,不附加任何额外条款或条件。
标签:Apache 2, cargo, crate, fast_verify, Hash-Based Signatures, HBS_LMS_MAX_HASH_OPTIMIZATIONS, HBS_LMS_THREADS, IETF, Leighton-Micali, LMOTS, LMS, RFC 8554, Rust, SEO: Leighton Micali, SEO: LMS 签名, SEO: 哈希基签名, SEO: 嵌入式密码学, SEO: 无操作系统签名, SEO: 纯Rust, 二进制兼容, 可视化界面, 哈希, 安全, 密码学, 密钥生成, 嵌入式, 开源, 手动系统调用, 无操作系统, 无标准库, 演示, 网络流量审计, 超时处理, 通知系统, 验证