pub struct SigningKey { /* private fields */ }
Available on crate feature signature only.
Expand description

Ed25519 signing key.

Implementations§

source§

impl SigningKey

source

pub const SIZE: usize = 32usize

Size of a raw SigningKey (a.k.a. seed) in bytes.

source

pub fn generate(rng: &mut impl CryptoRngCore) -> Self

Available on crate feature rand_core only.

Generate a random Ed25519 key using the provided RNG.

source

pub fn from_bytes(seed: &[u8; 32]) -> Self

Create a new SigningKey from an unexpanded seed value (32-bytes).

source

pub fn from_slice(seed: &[u8]) -> Result<Self>

Create a new SigningKey from a byte slice containing a seed value.

source

pub fn from_seed(seed: &[u8]) -> Result<Self>

👎Deprecated since 0.7.0: use from_slice instead

Alias for from_slice.

source

pub fn to_bytes(&self) -> [u8; 32]

Serialize this SigningKey as a 32-byte “seed”.

source

pub fn verifying_key(&self) -> VerifyingKey

Get the VerifyingKey for this SigningKey.

Trait Implementations§

source§

impl Clone for SigningKey

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl EncodePrivateKey for SigningKey

Available on crate features alloc and pkcs8 only.
source§

fn to_pkcs8_der(&self) -> Result<SecretDocument>

Serialize a [SecretDocument] containing a PKCS#8-encoded private key.
source§

fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Available on crate feature std only.
Write ASN.1 DER-encoded PKCS#8 private key to the given path
source§

impl From<&SigningKey> for KeypairBytes

Available on crate feature pkcs8 only.
source§

fn from(signing_key: &SigningKey) -> KeypairBytes

Converts to this type from the input type.
source§

impl From<&SigningKey> for VerifyingKey

source§

fn from(signing_key: &SigningKey) -> Self

Converts to this type from the input type.
source§

impl From<SigningKey> for KeypairBytes

Available on crate feature pkcs8 only.
source§

fn from(signing_key: SigningKey) -> KeypairBytes

Converts to this type from the input type.
source§

impl Keypair for SigningKey

§

type VerifyingKey = VerifyingKey

Verifying key type for this keypair.
source§

fn verifying_key(&self) -> VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
source§

impl Signer<Signature> for SigningKey

source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
source§

impl TryFrom<&[u8]> for SigningKey

§

type Error = Error

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

fn try_from(slice: &[u8]) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<&KeypairBytes> for SigningKey

Available on crate feature pkcs8 only.
§

type Error = Error

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

fn try_from(pkcs8_key: &KeypairBytes) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<KeypairBytes> for SigningKey

Available on crate feature pkcs8 only.
§

type Error = Error

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

fn try_from(pkcs8_key: KeypairBytes) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<PrivateKeyInfo<'_>> for SigningKey

Available on crate feature pkcs8 only.
§

type Error = Error

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

fn try_from(private_key: PrivateKeyInfo<'_>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DecodePrivateKey for Twhere T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,

source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
source§

fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Available on crate feature std only.
Load PKCS#8 private key from an ASN.1 DER-encoded file on the local filesystem (binary format).
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<S, T> SignerMut<S> for Twhere T: Signer<S>,

source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.