Ed25519PrivateKey

Struct Ed25519PrivateKey 

Source
pub struct Ed25519PrivateKey { /* private fields */ }
Expand description

An ed25519 private key.

This key type is used with crate::tor_provider::TorProvider trait for hosting onion-services and can be convertd to an Ed25519PublicKey. It can also be used to sign messages and create an Ed25519Signature.

Implementations§

Source§

impl Ed25519PrivateKey

A wrapper around tor_llcrypto::pk::ed25519::ExpandedKeypair.

Source

pub fn generate() -> Ed25519PrivateKey

Securely generate a new Ed25519PrivateKey.

Source

pub fn from_raw(raw: &[u8; 64]) -> Result<Ed25519PrivateKey, Error>

Attempt to create an Ed25519PrivateKey from an array of bytes. Not all byte buffers of the required size can create a valid Ed25519PrivateKey. Only buffers derived from Ed25519PrivateKey::to_bytes() are required to convert correctly.

To securely generate a valid Ed25519PrivateKey, use Ed25519PrivateKey::generate().

Source

pub fn from_key_blob(key_blob: &str) -> Result<Ed25519PrivateKey, Error>

Create an Ed25519PrivateKey from a String in the legacy c-tor daemon key blob format used in the ADD_ONION control-port command. From the c-tor control specification:

For a “ED25519-V3” key is the Base64 encoding of the concatenation of the 32-byte ed25519 secret scalar in little-endian and the 32-byte ed25519 PRF secret.

Only key blob strings derived from Ed25519PrivateKey::to_key_blob() are required to convert correctly.

Source

pub fn from_private_x25519( x25519_private: &X25519PrivateKey, ) -> Result<(Ed25519PrivateKey, SignBit), Error>

Construct an Ed25519PrivateKEy from an X25519PrivateKey.

Source

pub fn to_key_blob(&self) -> String

Write Ed25519PrivateKey to a c-tor key blob formatted String.

Source

pub fn sign_message(&self, message: &[u8]) -> Ed25519Signature

Sign the provided message and return an Ed25519Signature.

§⚠ Warning ⚠

Only ever sign messages the private key owner controls the contents of!

Source

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

Convert this private key to an array of bytes.

Trait Implementations§

Source§

impl Clone for Ed25519PrivateKey

Source§

fn clone(&self) -> Ed25519PrivateKey

Returns a duplicate 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 Debug for Ed25519PrivateKey

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Ed25519PrivateKey

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,