Struct ed25519_dalek::hazmat::ExpandedSecretKey

source ·
pub struct ExpandedSecretKey {
    pub scalar: Scalar,
    pub hash_prefix: [u8; 32],
}
Expand description

Contains the secret scalar and domain separator used for generating signatures.

This is used internally for signing.

In the usual Ed25519 signing algorithm, scalar and hash_prefix are defined such that scalar || hash_prefix = H(sk) where sk is the signing key and H is SHA-512. WARNING: Deriving the values for these fields in any other way can lead to full key recovery, as documented in raw_sign and [raw_sign_prehashed].

Instances of this secret are automatically overwritten with zeroes when they fall out of scope.

Fields§

§scalar: Scalar

The secret scalar used for signing

§hash_prefix: [u8; 32]

The domain separator used when hashing the message to generate the pseudorandom r value

Implementations§

source§

impl ExpandedSecretKey

source

pub fn from_bytes(bytes: &[u8; 64]) -> Self

Construct an ExpandedSecretKey from an array of 64 bytes. In the spec, the bytes are the output of a SHA-512 hash. This clamps the first 32 bytes and uses it as a scalar, and uses the second 32 bytes as a domain separator for hashing.

source

pub fn from_slice(bytes: &[u8]) -> Result<Self, SignatureError>

Construct an ExpandedSecretKey from a slice of 64 bytes.

§Returns

A Result whose okay value is an EdDSA ExpandedSecretKey or whose error value is an SignatureError describing the error that occurred, namely that the given slice’s length is not 64.

Trait Implementations§

source§

impl Drop for ExpandedSecretKey

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<&[u8; 32]> for ExpandedSecretKey

The spec-compliant way to define an expanded secret key. This computes SHA512(sk), clamps the first 32 bytes and uses it as a scalar, and uses the second 32 bytes as a domain separator for hashing.

source§

fn from(secret_key: &SecretKey) -> ExpandedSecretKey

Converts to this type from the input type.
source§

impl From<&ExpandedSecretKey> for VerifyingKey

source§

fn from(expanded_secret_key: &ExpandedSecretKey) -> VerifyingKey

Derive this public key from its corresponding ExpandedSecretKey.

source§

impl TryFrom<&[u8]> for ExpandedSecretKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl ZeroizeOnDrop for ExpandedSecretKey

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.