Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions x25519-dalek/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
17 changes: 15 additions & 2 deletions x25519-dalek/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions x25519-dalek/benches/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down