You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`force-scalar`| no | Disable SIMD (AVX2/NEON) and use pure-Rust scalar code |
51
+
|`alloc`| no | Allocator-dependent APIs |
52
+
|`std`| no | Standard-library integration; implies `alloc`|
53
+
|`force-scalar`| no | Compile out every SIMD kernel and use the portable scalar code paths only |
54
+
|`kem`| no | Implements the [`kem`](https://docs.rs/kem) crate's traits (`Encapsulate`, `Decapsulate`, `Kem`, ...) so this crate can be used generically alongside other KEMs. See [`sntrup_kem::kem`](src/kem.rs) and `examples/kem_traits.rs`. |
52
55
|`serde`| no | Enables `Serialize`/`Deserialize` for all key and ciphertext types (via `serdect` for constant-time hex encoding) |
53
56
|`js`| no | Enables WebAssembly support for `wasm32-unknown-unknown` by configuring `getrandom` to use JavaScript's `crypto.getRandomValues()`|
54
57
58
+
The synchronized x86_64 SIMD implementation requires Rust 1.95 or newer. Builds
59
+
with the Rust 1.85 MSRV automatically use the portable scalar paths; AArch64
60
+
builds retain NEON acceleration on Rust 1.85.
61
+
55
62
To use only a subset of the KEM API, disable defaults and pick the features you need:
56
63
57
64
```toml
@@ -175,6 +182,30 @@ let ek2 = EncapsulationKey::<Sntrup761Params>::try_from(ek_bytes).unwrap();
175
182
assert_eq!(ek, ek2);
176
183
```
177
184
185
+
### `kem` crate integration
186
+
187
+
With the `kem` feature enabled, the [`kem`](https://docs.rs/kem) module implements that crate's
188
+
traits for every parameter set, so Streamlined NTRU Prime can be used in generic code alongside
189
+
other KEMs. The traits and the parameter-set marker types are re-exported there, so no direct
let (dk, ek) =Sntrup761Params::generate_keypair_from_rng(&mutrng);
201
+
let (ct, sent) =ek.encapsulate_with_rng(&mutrng);
202
+
assert_eq!(dk.decapsulate(&ct), sent);
203
+
# }
204
+
```
205
+
206
+
Run `cargo run --release --example kem_traits --features kem` for KEM-generic code and key
207
+
export.
208
+
178
209
## WebAssembly
179
210
180
211
To compile for `wasm32-unknown-unknown`, enable the `js` feature so that `getrandom` uses JavaScript's `crypto.getRandomValues()` for randomness:
@@ -206,10 +237,56 @@ For `wasm32-wasi` (or `wasm32-wasip1`), the `js` feature is **not** needed since
206
237
207
238
This implementation has not undergone any security auditing and while care has been taken no guarantees can be made for either correctness or the constant time running of the underlying functions. **Please use at your own risk.**
randomness, hash intermediates) are wiped with the [`zeroize`](https://docs.rs/zeroize) crate
242
+
before being freed. One documented exception: `generate_key_deterministic`'s ChaCha20 RNG state
243
+
cannot be wiped because `rand_chacha` offers no zeroization support.
244
+
209
245
#### Algorithm
210
246
211
247
Streamlined NTRU Prime was first published in 2016. The algorithm still requires careful security review. Please see [here](https://ntruprime.cr.yp.to/warnings.html) for further warnings from the authors regarding NTRU Prime and lattice-based encryption schemes.
212
248
249
+
## Performance
250
+
251
+
`cargo bench` runs this crate's Criterion suite (`benches/mod.rs`) across all six parameter
252
+
sets. The synchronized standalone implementation also has a
253
+
[comparison harness](https://github.com/mikelodder7/sntrup/tree/main/benches/comparison) for
254
+
sntrup761 — the parameter set with independent PQClean and liboqs implementations.
255
+
256
+
This crate is faster than both C references on every operation, on both
257
+
architectures, while also zeroizing every secret-derived scratch buffer — which neither C
258
+
reference does.
259
+
260
+
On x86_64 (AMD Ryzen AI 9 HX 370, Zen 5), sntrup761, against liboqs's AVX2 build:
0 commit comments