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
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 `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`, and implements `KeyInit` for `SigningKey`. |
| `asm` | | Enables assembly optimizations in the SHA-512 compression functions |
| `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`. |
Expand Down
15 changes: 15 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::CryptoRngCore;
#[cfg(feature = "serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

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

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

Expand Down Expand Up @@ -536,6 +539,18 @@ impl SigningKey {
}
}

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

#[cfg(feature = "digest")]
impl KeyInit for SigningKey {
fn new(key: &Key<Self>) -> Self {
Self::from_bytes(key.as_ref())
}
}

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 @@ -109,6 +112,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