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加密学

Download history 265/week @ 2024-03-13 218/week @ 2024-03-20 134/week @ 2024-03-27 140/week @ 2024-04-03 102/week @ 2024-04-10 111/week @ 2024-04-17 93/week @ 2024-04-24 115/week @ 2024-05-01 90/week @ 2024-05-08 101/week @ 2024-05-15 102/week @ 2024-05-22 91/week @ 2024-05-29 76/week @ 2024-06-05 65/week @ 2024-06-12 64/week @ 2024-06-19 50/week @ 2024-06-26

263 每月下载量
用于 12 个包 (4 直接)

Apache-2.0

27KB
472

Rust 秘密整数

这个简单的包提供了整数包装器,确保它们以恒定时间的方式使用。因此,不允许除法和直接比较。通过 Rust 的类型系统,此包将帮助编译器系统地检查您的加密代码相对于秘密输入是否为恒定时间。

要使用此包,只需导入所有内容 (use secret_integers::*;) 并将整数类型替换为其名称的大写版本(例如 u8 -> U8)。

示例

以下两个示例展示了如何使用此包: DalekChacha20。要构建这些示例,使用

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`

无运行时依赖项