From 0fbf15e3c26705a98b5b592f04d923b2f0fb1bd7 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Fri, 19 Dec 2025 12:33:31 +0100 Subject: [PATCH] x: Remove vestigial feature and update feature docs (#857) * Clarify features in x25519 README * Remove alloc feature from x25519 bc it was doing nothing * Add pubkey constructor benchmark * Correct code size claim on README * Update changelog --- curve25519-dalek/README.md | 2 +- x25519-dalek/CHANGELOG.md | 4 ++++ x25519-dalek/Cargo.toml | 3 +-- x25519-dalek/README.md | 17 +++++++++++++++-- x25519-dalek/benches/x25519.rs | 9 +++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/curve25519-dalek/README.md b/curve25519-dalek/README.md index cefa433..9fc7bb4 100644 --- a/curve25519-dalek/README.md +++ b/curve25519-dalek/README.md @@ -50,7 +50,7 @@ curve25519-dalek = ">= 5.0, < 5.2" | :--- | :---: | :--- | | `alloc` | ✓ | Enables Edwards and Ristretto multiscalar multiplication, batch scalar inversion, and batch Ristretto double-and-compress. | | `zeroize` | ✓ | Enables [`Zeroize`][zeroize-trait] for all scalar and curve point types. | -| `precomputed-tables` | ✓ | Includes precomputed basepoint multiplication tables. This speeds up `EdwardsPoint::mul_base` and `RistrettoPoint::mul_base` by ~4x, at the cost of ~30KB added to the code size. | +| `precomputed-tables` | ✓ | Includes precomputed basepoint multiplication tables. This speeds up `EdwardsPoint::mul_base` and `RistrettoPoint::mul_base` by ~4x, at the cost of ~400KB added to the code size. | | `rand_core` | | Enables `Scalar::random` and `RistrettoPoint::random`. This is an optional dependency whose version is not subject to SemVer. See [below](#public-api-semver-exemptions) for more details. | | `digest` | | Enables `RistrettoPoint::{from_hash, hash_from_bytes}` and `Scalar::{from_hash, hash_from_bytes}`. Also enables hash-to-curve methods `EdwardsPoint::{encode_to_curve, hash_to_curve}`. This is an optional dependency whose version is not subject to SemVer. See [below](#public-api-semver-exemptions) for more details. | | `serde` | | Enables `serde` serialization/deserialization for all the point and scalar types. | diff --git a/x25519-dalek/CHANGELOG.md b/x25519-dalek/CHANGELOG.md index fa88bd9..e096fa0 100644 --- a/x25519-dalek/CHANGELOG.md +++ b/x25519-dalek/CHANGELOG.md @@ -4,6 +4,10 @@ Entries are listed in reverse chronological order. # 3.x Series +## Unreleased + +* Removed `alloc` feature flag, which was doing nothing + ## 3.0.0-pre.3 * Upgrade `rand_core` to v0.10.0-rc-2 diff --git a/x25519-dalek/Cargo.toml b/x25519-dalek/Cargo.toml index 7919dc6..b901f85 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 4a056ed..46be7d9 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 `PublicKey::from` by ~3x, at the cost of ~400KB 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 bdbebc7..3d3e88c 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,