Skip to content
Open
2 changes: 1 addition & 1 deletion ed25519-dalek/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This crate is `#[no_std]` compatible with `default-features = false`.
| `zeroize` | ✓ | Implements `Zeroize` and `ZeroizeOnDrop` for `SigningKey` |
| `rand_core` | | Enables `SigningKey::generate` |
| `batch` | | Enables `verify_batch` for verifying many signatures quickly. Also enables `alloc` and `rand_core`. |
| `digest` | | Enables `Context`, `SigningKey::{with_context, sign_prehashed}` and `VerifyingKey::{with_context, verify_prehashed, verify_prehashed_strict}` for Ed25519ph prehashed signatures |
| `digest` | | Enables `Context`, `SigningKey::{with_context, sign_prehashed}` and `VerifyingKey::{with_context, verify_prehashed, verify_prehashed_strict}` for Ed25519ph prehashed signatures. Also implements `KeySizeUser` for `SigningKey` and `VerifyingKey`. |
| `pkcs8` | | Enables [PKCS#8](https://en.wikipedia.org/wiki/PKCS_8) serialization/deserialization for `SigningKey` and `VerifyingKey` |
| `pem` | | Enables PEM serialization support for PKCS#8 private keys and SPKI public keys. Also enables `alloc`. |
| `legacy_compatibility` | | **Unsafe:** Disables certain signature checks. See [below](#malleability-and-the-legacy_compatibility-feature) |
Expand Down
8 changes: 8 additions & 0 deletions ed25519-dalek/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use rand_core::CryptoRng;
#[cfg(feature = "serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[cfg(feature = "digest")]
use curve25519_dalek::digest::{crypto_common::KeySizeUser, typenum::U32};

use sha2::Sha512;
use subtle::{Choice, ConstantTimeEq};

Expand Down Expand Up @@ -549,6 +552,11 @@ impl SigningKey {
}
}

#[cfg(feature = "digest")]
impl KeySizeUser for SigningKey {
type KeySize = U32;
}

impl AsRef<VerifyingKey> for SigningKey {
fn as_ref(&self) -> &VerifyingKey {
&self.verifying_key
Expand Down
8 changes: 8 additions & 0 deletions ed25519-dalek/src/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

//! ed25519 public keys.

#[cfg(feature = "digest")]
use curve25519_dalek::digest::{crypto_common::KeySizeUser, typenum::U32};

use core::fmt::Debug;
use core::hash::{Hash, Hasher};

Expand Down Expand Up @@ -116,6 +119,11 @@ impl From<EdwardsPoint> for VerifyingKey {
}
}

#[cfg(feature = "digest")]
impl KeySizeUser for VerifyingKey {
type KeySize = U32;
}

impl VerifyingKey {
/// Convert this public key to a byte array.
#[inline]
Expand Down