diff --git a/Cargo.toml b/Cargo.toml index 5a200e5..18db298 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ecies" -version = "0.2.1" +version = "0.2.2" # docs authors = ["Weiliang Li "] description = "Elliptic Curve Integrated Encryption Scheme for secp256k1 in Rust" @@ -25,11 +25,11 @@ libsecp256k1 = "0.7.0" sha2 = "0.9.8" # openssl aes -openssl = {version = "0.10.32", optional = true} +openssl = {version = "0.10.38", optional = true} # pure rust aes -aes-gcm = {version = "0.9.0", optional = true} -typenum = {version = "1.12.0", optional = true} +aes-gcm = {version = "0.9.4", optional = true} +typenum = {version = "1.14.0", optional = true} [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = {version = "0.2.3", features = ["js"]} @@ -43,8 +43,8 @@ default = ["openssl"] pure = ["aes-gcm", "typenum"] [dev-dependencies] -criterion = "0.3.3" -hex = "0.4.2" +criterion = "0.3.5" +hex = "0.4.3" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.28" @@ -52,7 +52,7 @@ wasm-bindgen-test = "0.3.28" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] futures-util = "0.3.17" reqwest = "0.11.6" -tokio = {version = "1.13.0", features = ["rt-multi-thread"]} +tokio = {version = "1.14.0", features = ["rt-multi-thread"]} [[bench]] harness = false diff --git a/README.md b/README.md index ec684ea..c3cad2f 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,69 @@ Following dependencies are audited: - [aes-gcm](https://research.nccgroup.com/2020/02/26/public-report-rustcrypto-aes-gcm-and-chacha20poly1305-implementation-review/) - [OpenSSL](https://ostif.org/the-ostif-and-quarkslab-audit-of-openssl-is-complete/) +## Benchmark + +The result shows that the pure Rust backend is around 20% ~ 50% slower compared to OpenSSL on MacBook Pro mid-2015 (2.8 GHz Quad-Core Intel Core i7). + +### OpenSSL backend + +```bash +$ cargo bench --no-default-features --features openssl +encrypt 100M time: [110.25 ms 115.77 ms 120.22 ms] + change: [-10.123% -3.0504% +4.2342%] (p = 0.44 > 0.05) + No change in performance detected. + +encrypt 200M time: [435.22 ms 450.50 ms 472.17 ms] + change: [-7.5254% +3.6572% +14.508%] (p = 0.56 > 0.05) + No change in performance detected. +Found 1 outliers among 10 measurements (10.00%) + 1 (10.00%) high mild + +decrypt 100M time: [60.439 ms 66.276 ms 70.959 ms] + change: [+0.1986% +7.7620% +15.995%] (p = 0.08 > 0.05) + No change in performance detected. + +decrypt 200M time: [182.10 ms 185.85 ms 190.63 ms] + change: [-4.8452% +5.2114% +16.370%] (p = 0.40 > 0.05) + No change in performance detected. +Found 1 outliers among 10 measurements (10.00%) + 1 (10.00%) high severe + +``` + +### Pure Rust backend + +```bash +$ export RUSTFLAGS="-Ctarget-cpu=sandybridge -Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3" +$ cargo bench --no-default-features --features pure +encrypt 100M time: [196.85 ms 201.97 ms 205.67 ms] + change: [-9.8235% -7.9098% -5.9849%] (p = 0.00 < 0.05) + Performance has improved. +Found 1 outliers among 10 measurements (10.00%) + 1 (10.00%) low severe + +encrypt 200M time: [554.62 ms 585.01 ms 599.71 ms] + change: [-15.036% -11.698% -8.6460%] (p = 0.00 < 0.05) + Performance has improved. + +decrypt 100M time: [131.26 ms 134.39 ms 140.54 ms] + change: [-3.9509% +2.9485% +10.198%] (p = 0.42 > 0.05) + No change in performance detected. + +decrypt 200M time: [288.13 ms 296.64 ms 311.78 ms] + change: [-16.887% -13.038% -8.6679%] (p = 0.00 < 0.05) + Performance has improved. +Found 1 outliers among 10 measurements (10.00%) + 1 (10.00%) high mild +``` + ## Release Notes +### 0.2.2 + +- Bump dependencies +- Migrate to edition 2021 + ### 0.2.1 - Revamp error handling diff --git a/bench/simple.rs b/bench/simple.rs index 6f05f26..24479b9 100644 --- a/bench/simple.rs +++ b/bench/simple.rs @@ -27,7 +27,7 @@ fn criterion_benchmark(c: &mut Criterion) { criterion_group! { name = benches; - config = Criterion::default().sample_size(10).measurement_time(Duration::new(20, 0)); + config = Criterion::default().sample_size(10).measurement_time(Duration::new(30, 0)); targets = criterion_benchmark } criterion_main!(benches);