#[repr(C)]
pub struct ExpandedSecretKey { /* fields omitted */ }
An "expanded" secret key.
This is produced by using an hash function with 512-bits output to digest a
SecretKey
. The output digest is then split in half, the lower half being
the actual key
used to sign messages, after twiddling with some bits.¹ The
upper half is used a sort of half-baked, ill-designed² pseudo-domain-separation
"nonce"-like thing, which is used during signature production by
concatenating it with the message to be signed before the message is hashed.
Convert this ExpandedSecretKey
into an array of 64 bytes.
An array of 64 bytes. The first 32 bytes represent the "expanded"
secret key, and the last 32 bytes represent the "domain-separation"
"nonce".
use rand::{Rng, OsRng};
use sha2::Sha512;
use ed25519_dalek::{SecretKey, ExpandedSecretKey};
let mut csprng: OsRng = OsRng::new().unwrap();
let secret_key: SecretKey = SecretKey::generate(&mut csprng);
let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);
let expanded_secret_key_bytes: [u8; 64] = expanded_secret_key.to_bytes();
assert!(&expanded_secret_key_bytes[..] != &[0u8; 64][..]);
Construct an ExpandedSecretKey
from a slice of bytes.
A Result
whose okay value is an EdDSA ExpandedSecretKey
or whose
error value is an SignatureError
describing the error that occurred.
use rand::{Rng, OsRng};
use ed25519_dalek::{SecretKey, ExpandedSecretKey};
use ed25519_dalek::SignatureError;
let mut csprng: OsRng = OsRng::new().unwrap();
let secret_key: SecretKey = SecretKey::generate(&mut csprng);
let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);
let bytes: [u8; 64] = expanded_secret_key.to_bytes();
let expanded_secret_key_again = ExpandedSecretKey::from_bytes(&bytes)?;
Construct an ExpandedSecretKey
from a SecretKey
, using hash function D
.
use rand::{Rng, OsRng};
use sha2::Sha512;
use ed25519_dalek::{SecretKey, ExpandedSecretKey};
let mut csprng: OsRng = OsRng::new().unwrap();
let secret_key: SecretKey = SecretKey::generate(&mut csprng);
let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from_secret_key::<Sha512>(&secret_key);
Sign a message with this ExpandedSecretKey
.
Sign a prehashed_message
with this ExpandedSecretKey
using the
Ed25519ph algorithm defined in RFC8032 §5.1.
prehashed_message
is an instantiated hash digest with 512-bits of
output which has had the message to be signed previously fed into its
state.
public_key
is a PublicKey
which corresponds to this secret key.
context
is an optional context string, up to 255 bytes inclusive,
which may be used to provide additional domain separation. If not
set, this will default to an empty string.
An Ed25519ph Signature
on the prehashed_message
.
Overwrite secret key material with null bytes when it goes out of scope.
Executes the destructor for this type. Read more
Returns the "default value" for a type. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Completely overwrites this value.
Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more