Struct sn_node::state_db::SecretKey[][src]

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[src]

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

Convert this secret key to a byte array.

pub fn as_bytes(&'a self) -> &'a [u8; 32][src]

View this secret key as a byte array.

pub fn from_bytes(bytes: &[u8]) -> Result<SecretKey, Error>[src]

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.

pub fn generate<T>(csprng: &mut T) -> SecretKey where
    T: CryptoRng + RngCore
[src]

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

impl AsRef<[u8]> for SecretKey[src]

pub fn as_ref(&self) -> &[u8][src]

Performs the conversion.

impl Debug for SecretKey[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<'d> Deserialize<'d> for SecretKey[src]

pub fn deserialize<D>(
    deserializer: D
) -> Result<SecretKey, <D as Deserializer<'d>>::Error> where
    D: Deserializer<'d>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Drop for SecretKey[src]

pub fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl<'a> From<&'a SecretKey> for PublicKey[src]

pub fn from(secret_key: &SecretKey) -> PublicKey[src]

Derive this public key from its corresponding SecretKey.

impl Serialize for SecretKey[src]

pub fn serialize<S>(
    &self,
    serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl Zeroize for SecretKey[src]

pub fn zeroize(&mut self)[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Sha3Hash for T where
    T: AsRef<[u8]>, 
[src]

pub fn hash(&self, hasher: &mut Sha3)[src]

Update the hasher with self’s data

impl<T> ToHex for T where
    T: AsRef<[u8]>, 
[src]

pub fn write_hex<W>(&self, w: &mut W) -> Result<(), Error> where
    W: Write
[src]

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

pub fn write_hex_upper<W>(&self, w: &mut W) -> Result<(), Error> where
    W: Write
[src]

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]