Skip to content

Commit f7d1214

Browse files
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

31 files changed

+1213
-945
lines changed

.github/workflows/ci.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
rust:
19-
- 1.81.0 # MSRV
19+
- 1.83.0 # MSRV
2020
- stable
2121
target:
2222
- thumbv7em-none-eabi
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
matrix:
3737
rust:
38-
- 1.81.0 # MSRV
38+
- 1.83.0 # MSRV
3939
- stable
4040
steps:
4141
- uses: actions/checkout@v4
@@ -44,7 +44,7 @@ jobs:
4444
with:
4545
toolchain: ${{ matrix.rust }}
4646
- uses: RustCrypto/actions/cargo-hack-install@master
47-
- run: cargo hack test --release --feature-powerset --exclude-features nightly,getrandom,serde
47+
- run: cargo hack test --release --feature-powerset --exclude-features getrandom,serde
4848
- run: cargo test --release --features getrandom
4949
- run: cargo test --release --features serde
5050

@@ -66,5 +66,4 @@ jobs:
6666
- uses: dtolnay/rust-toolchain@master
6767
with:
6868
toolchain: nightly-2024-10-06
69-
- run: cargo test --release --features nightly
7069
- run: cargo build --benches

.github/workflows/workspace.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: RustCrypto/actions/cargo-cache@master
1818
- uses: dtolnay/rust-toolchain@master
1919
with:
20-
toolchain: 1.81.0
20+
toolchain: 1.83.0
2121
components: clippy
2222
- run: cargo clippy --all -- -D warnings
2323

@@ -40,7 +40,7 @@ jobs:
4040
- uses: dtolnay/rust-toolchain@master
4141
with:
4242
# We need Nightly for doc_auto_cfg
43-
toolchain: nightly-2024-06-25
43+
toolchain: nightly-2024-11-30
4444
- uses: Swatinem/rust-cache@v2
4545
- env:
4646
RUSTDOCFLAGS: "-Dwarnings --cfg docsrs"

0 commit comments

Comments
 (0)