Skip to main content

SecretKey

Struct SecretKey 

Source
pub struct SecretKey(/* private fields */);
Expand description

An ed25519 signing key. Its bytes are wiped when it is dropped, and Debug never prints them.

Implementations§

Source§

impl SecretKey

Source

pub fn generate() -> Result<Self>

A new key from the operating system’s random source.

§Errors

The random source cannot be read.

Source

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

The key with this 32-byte seed (for tests and fixtures).

Source

pub fn public(&self) -> PublicKey

Its public key.

Source

pub fn to_text(&self) -> String

The key file text: sail-ed25519-secret-v1 <hex>.

Source

pub fn parse(text: &str) -> Option<Self>

Source

pub fn read_file(path: &Path) -> Result<Self, String>

Reads a key file.

§Errors

The file cannot be read or is not a secret key.

Source

pub fn write_files(&self, path: &Path) -> Result<PathBuf>

Writes this key to path (readable by its owner only) and its public key to <path>.pub. Refuses to overwrite either file.

§Errors

Either file exists, or cannot be written.

Trait Implementations§

Source§

impl Debug for SecretKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.