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
This commit is contained in:
Michael Rosenberg 2025-12-19 12:33:31 +01:00 committed by GitHub
parent 7751957445
commit 0fbf15e3c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 5 deletions

View file

@ -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. |

View file

@ -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

View file

@ -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 = []

View file

@ -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.

View file

@ -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,