diff --git a/x25519-dalek/Cargo.toml b/x25519-dalek/Cargo.toml index 7919dc626..b901f85dd 100644 --- a/x25519-dalek/Cargo.toml +++ b/x25519-dalek/Cargo.toml @@ -60,11 +60,10 @@ name = "x25519" harness = false [features] -default = ["alloc", "precomputed-tables", "zeroize"] +default = ["precomputed-tables", "zeroize"] getrandom = ["dep:getrandom"] zeroize = ["dep:zeroize", "curve25519-dalek/zeroize"] serde = ["dep:serde", "curve25519-dalek/serde"] -alloc = ["curve25519-dalek/alloc", "serde?/alloc", "zeroize?/alloc"] precomputed-tables = ["curve25519-dalek/precomputed-tables"] reusable_secrets = [] static_secrets = [] diff --git a/x25519-dalek/README.md b/x25519-dalek/README.md index 4a056edcc..3ed0ebf01 100644 --- a/x25519-dalek/README.md +++ b/x25519-dalek/README.md @@ -97,15 +97,28 @@ This example used the ephemeral DH API, which ensures that secret keys cannot be reused; Alice and Bob could instead use the static DH API and load a long-term secret key. -# Installation +# Use -To install, add the following to your project's `Cargo.toml`: +To import `x25519-dalek`, add the following to your project's `Cargo.toml`: ```toml [dependencies] x25519-dalek = "3.0.0-pre.3" ``` +# Feature Flags + +This crate is `#[no_std]` compatible with `default-features = false`. + +| Feature | Default? | Description | +| :--- | :--- | :--- | +| `zeroize` | ✓ | Implements `Zeroize` and `ZeroizeOnDrop` for `EphemeralSecret`, `ReusableSecret`, and `StaticSecret` | +| `precomputed-tables` | ✓ | Includes precomputed basepoint multiplication tables. This speeds up `diffie_hellman()` by ~4x, at the cost of ~30KB added to the code size. | +| `getrandom` | | Exposes the `random()` constructor for `EphemeralSecret`, `ReusableSecret`, and `StaticSecret` | +| `reusable_secrets` | | Exposes the `ReusableSecret` struct | +| `static_secrets` | | Exposes the `StaticSecret` struct | +| `serde` | | Enables `serde` serialization/deserialization for `PublicKey` and `StaticSecret` | + # MSRV Current MSRV is 1.85. diff --git a/x25519-dalek/benches/x25519.rs b/x25519-dalek/benches/x25519.rs index bdbebc7a2..3d3e88cf1 100644 --- a/x25519-dalek/benches/x25519.rs +++ b/x25519-dalek/benches/x25519.rs @@ -30,11 +30,20 @@ fn bench_diffie_hellman(c: &mut Criterion) { }); } +fn bench_pubkey_constructor(c: &mut Criterion) { + let bob_secret = EphemeralSecret::random_from_rng(&mut OsRng.unwrap_err()); + + c.bench_function("PublicKey::from", move |b| { + b.iter(|| PublicKey::from(&bob_secret)) + }); +} + criterion_group! { name = x25519_benches; config = Criterion::default(); targets = bench_diffie_hellman, + bench_pubkey_constructor, } criterion_main! { x25519_benches,