logo
pub struct SecretKey(_);
Expand description

An EdDSA secret key.

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

Implementations

Convert this secret key to a byte array.

View this secret key as a byte array.

Construct a SecretKey from a slice of bytes.

Example
use ed25519_dalek::SecretKey;
use ed25519_dalek::SECRET_KEY_LENGTH;
use ed25519_dalek::SignatureError;

let secret_key_bytes: [u8; SECRET_KEY_LENGTH] = [
   157, 097, 177, 157, 239, 253, 090, 096,
   186, 132, 074, 244, 146, 236, 044, 196,
   068, 073, 197, 105, 123, 050, 105, 025,
   112, 059, 172, 003, 028, 174, 127, 096, ];

let secret_key: SecretKey = SecretKey::from_bytes(&secret_key_bytes)?;
Returns

A Result whose okay value is an EdDSA SecretKey or whose error value is an SignatureError wrapping the internal error that occurred.

Generate a SecretKey from a csprng.

Example
extern crate rand;
extern crate ed25519_dalek;

use rand::rngs::OsRng;
use ed25519_dalek::PublicKey;
use ed25519_dalek::SecretKey;
use ed25519_dalek::Signature;

let mut csprng = OsRng{};
let secret_key: SecretKey = SecretKey::generate(&mut csprng);

Afterwards, you can generate the corresponding public:


let public_key: PublicKey = (&secret_key).into();
Input

A CSPRNG with a fill_bytes() method, e.g. rand::OsRng

Trait Implementations

Performs the conversion.

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Executes the destructor for this type. Read more

Derive this public key from its corresponding SecretKey.

Performs the conversion.

Serialize this value into the given Serde serializer. Read more

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

Update the hasher with self’s data

Writes the hex string representing self into w. Lower case letters are used (e.g. f9b4ca). Read more

Writes the hex string representing self into w. Upper case letters are used (e.g. F9B4CA). Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more