Commit f7d1214
feat: switch from num-bigint-dig to crypto-bigint´
The biggest refactor (to date)
Replaces all usage of `num-bigint-dig` based `BigInt` usage with the new
`crypto-bigint` crate, using `BoxedUint`
Current known issue is that we do have a performance regression, which
will be able to get rid of over time:
```
# crypto-bigint
# macbook m1
test bench_rsa_2048_pkcsv1_decrypt ... bench: 7,184,387.50 ns/iter (+/- 425,598.69)
test bench_rsa_2048_pkcsv1_sign_blinded ... bench: 13,453,579.10 ns/iter (+/- 686,276.31)
# AMD
test bench_rsa_2048_pkcsv1_decrypt ... bench: 9,260,832.80 ns/iter (+/- 30,013.38)
test bench_rsa_2048_pkcsv1_sign_blinded ... bench: 16,610,079.40 ns/iter (+/- 251,292.53)
# master
# macbook m1
test bench_rsa_2048_pkcsv1_decrypt ... bench: 1,117,479.15 ns/iter (+/- 31,334.30)
test bench_rsa_2048_pkcsv1_sign_blinded ... bench: 1,337,437.55 ns/iter (+/- 88,624.39)
# AMD
test bench_rsa_2048_pkcsv1_decrypt ... bench: 1,414,348.80 ns/iter (+/- 12,585.71)
test bench_rsa_2048_pkcsv1_sign_blinded ... bench: 1,685,650.00 ns/iter (+/- 11,105.71)
```
## TODOs
- [x] switch internal storage for `RsaPrivateKey`
- [x] switch internal storage for `RsaPublicKey`
- [x] switch all code to use the new `decrypt` implementation
- [x] update public traits using `BigUint` to return owned versions
- [x] fix blinding implementation
- [x] switch decryption algorithm with precompute to use crypto-bigint
ops
- [x] go through other algorithms and update what can be done without
having primality checks implemented
- [x] review & update code for constant time operation
- [x] review & update code for performance
- [x] benchmarks
---------
Co-authored-by: Fethbita <[email protected]>1 parent b019aa1 commit f7d1214
File tree
31 files changed
+1213
-945
lines changed- .github/workflows
- benches
- src
- algorithms
- oaep
- pkcs1v15
- pss
- traits
- tests
31 files changed
+1213
-945
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments