Struct diem_sdk::crypto::ed25519::ed25519_dalek::SecretKey [−]
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
impl SecretKey
impl SecretKey
Construct a SecretKey from a slice of bytes.
Example
use ed25519_dalek_fiat::SecretKey;
use ed25519_dalek_fiat::SECRET_KEY_LENGTH;
use ed25519_dalek_fiat::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_fiat;
use rand::rngs::OsRng;
use ed25519_dalek_fiat::PublicKey;
use ed25519_dalek_fiat::SecretKey;
use ed25519_dalek_fiat::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
impl<'d> Deserialize<'d> for SecretKey
impl<'d> Deserialize<'d> for SecretKey
pub fn deserialize<D>(
deserializer: D
) -> Result<SecretKey, <D as Deserializer<'d>>::Error> where
D: Deserializer<'d>,
pub fn deserialize<D>(
deserializer: D
) -> Result<SecretKey, <D as Deserializer<'d>>::Error> where
D: Deserializer<'d>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a> From<&'a SecretKey> for ExpandedSecretKey
impl<'a> From<&'a SecretKey> for ExpandedSecretKey
pub fn from(secret_key: &'a SecretKey) -> ExpandedSecretKey
pub fn from(secret_key: &'a SecretKey) -> ExpandedSecretKey
Construct an ExpandedSecretKey from a SecretKey.
Examples
use rand::rngs::OsRng;
use ed25519_dalek_fiat::{SecretKey, ExpandedSecretKey};
let mut csprng = OsRng{};
let secret_key: SecretKey = SecretKey::generate(&mut csprng);
let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self
Generates a hash used only for tests.