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
.
impl Ed25519PrivateKey
A wrapper around tor_llcrypto::pk::ed25519::ExpandedKeypair
.
Sourcepub fn generate() -> Ed25519PrivateKey
pub fn generate() -> Ed25519PrivateKey
Securely generate a new Ed25519PrivateKey
.
Sourcepub fn from_raw(raw: &[u8; 64]) -> Result<Ed25519PrivateKey, Error>
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()
.
Sourcepub fn from_key_blob(key_blob: &str) -> Result<Ed25519PrivateKey, Error>
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.
Sourcepub fn from_private_x25519(
x25519_private: &X25519PrivateKey,
) -> Result<(Ed25519PrivateKey, SignBit), Error>
pub fn from_private_x25519( x25519_private: &X25519PrivateKey, ) -> Result<(Ed25519PrivateKey, SignBit), Error>
Construct an Ed25519PrivateKEy
from an X25519PrivateKey
.
Sourcepub fn to_key_blob(&self) -> String
pub fn to_key_blob(&self) -> String
Write Ed25519PrivateKey
to a c-tor key blob formatted String
.
Sourcepub fn sign_message(&self, message: &[u8]) -> Ed25519Signature
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!
Trait Implementations§
Source§impl Clone for Ed25519PrivateKey
impl Clone for Ed25519PrivateKey
Source§fn clone(&self) -> Ed25519PrivateKey
fn clone(&self) -> Ed25519PrivateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Ed25519PrivateKey
impl Debug for Ed25519PrivateKey
Source§impl PartialEq for Ed25519PrivateKey
impl PartialEq for Ed25519PrivateKey
Auto Trait Implementations§
impl Freeze for Ed25519PrivateKey
impl RefUnwindSafe for Ed25519PrivateKey
impl Send for Ed25519PrivateKey
impl Sync for Ed25519PrivateKey
impl Unpin for Ed25519PrivateKey
impl UnwindSafe for Ed25519PrivateKey
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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