diff --git a/ed25519-dalek/README.md b/ed25519-dalek/README.md index da29362b5..f22a8d1c6 100644 --- a/ed25519-dalek/README.md +++ b/ed25519-dalek/README.md @@ -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) | diff --git a/ed25519-dalek/src/signing.rs b/ed25519-dalek/src/signing.rs index a451b1141..3f7c98e75 100644 --- a/ed25519-dalek/src/signing.rs +++ b/ed25519-dalek/src/signing.rs @@ -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}; @@ -549,6 +552,11 @@ impl SigningKey { } } +#[cfg(feature = "digest")] +impl KeySizeUser for SigningKey { + type KeySize = U32; +} + impl AsRef for SigningKey { fn as_ref(&self) -> &VerifyingKey { &self.verifying_key diff --git a/ed25519-dalek/src/verifying.rs b/ed25519-dalek/src/verifying.rs index 2dc2eba0e..b3b4ef71a 100644 --- a/ed25519-dalek/src/verifying.rs +++ b/ed25519-dalek/src/verifying.rs @@ -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}; @@ -116,6 +119,11 @@ impl From for VerifyingKey { } } +#[cfg(feature = "digest")] +impl KeySizeUser for VerifyingKey { + type KeySize = U32; +} + impl VerifyingKey { /// Convert this public key to a byte array. #[inline]