8 个版本
0.1.7 | 2023 年 3 月 20 日 |
---|---|
0.1.6 | 2020 年 1 月 30 日 |
0.1.5 | 2019 年 12 月 23 日 |
0.1.3 | 2019 年 2 月 7 日 |
0.1.2 | 2019 年 1 月 30 日 |
#385 在 加密学
263 每月下载量
用于 12 个包 (4 直接)
27KB
472 行
Rust 秘密整数
这个简单的包提供了整数包装器,确保它们以恒定时间的方式使用。因此,不允许除法和直接比较。通过 Rust 的类型系统,此包将帮助编译器系统地检查您的加密代码相对于秘密输入是否为恒定时间。
要使用此包,只需导入所有内容 (use secret_integers::*;
) 并将整数类型替换为其名称的大写版本(例如 u8
-> U8
)。
示例
以下两个示例展示了如何使用此包: Dalek 和 Chacha20。要构建这些示例,使用
cargo build --example dalek
cargo build --example chacha20
然而,如果您尝试
cargo build --example biguint
您将收到以下错误消息
error[E0599]: no method named `leading_zeros` found for type `&secret_integers::U32` in the current scope
--> examples/biguint.rs:24:46
|
24 | let zeros = self.data.last().unwrap().leading_zeros();
| ^^^^^^^^^^^^^
error[E0369]: binary operation `!=` cannot be applied to type `secret_integers::U32`
--> examples/biguint.rs:48:11
|
48 | while r != 0 {
| ^^^^^^
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `secret_integers::U32`