pub struct X25519PrivateKey { /* private fields */ }
Expand description
An x25519 private key
Implementations§
Source§impl X25519PrivateKey
A wrapper around tor_llcrypto::pk::curve25519::StaticSecret
impl X25519PrivateKey
A wrapper around tor_llcrypto::pk::curve25519::StaticSecret
Sourcepub fn generate() -> X25519PrivateKey
pub fn generate() -> X25519PrivateKey
Securely generate a new X25519PrivateKey
Sourcepub fn from_raw(raw: &[u8; 32]) -> Result<X25519PrivateKey, Error>
pub fn from_raw(raw: &[u8; 32]) -> Result<X25519PrivateKey, Error>
Attempt to create an X25519PrivateKey
from an array of bytes. Not all byte buffers of the required size can create a valid X25519PrivateKey
. Only buffers derived from X25519PrivateKey::to_bytes()
are required to convert correctly.
To securely generate a valid X25519PrivateKey
, use X25519PrivateKey::generate()
.
Sourcepub fn from_base64(base64: &str) -> Result<X25519PrivateKey, Error>
pub fn from_base64(base64: &str) -> Result<X25519PrivateKey, Error>
Create an X25519PrivateKey
from a String
in the legacy c-tor daemon key blob format used in the ONION_CLIENT_AUTH_ADD
control-port command. From the c-tor control specification:
PrivateKeyBlob = base64 encoding of x25519 key
Only key blob strings derived from X25519PrivateKey::to_base64()
are required to convert correctly.
Sourcepub fn sign_message(
&self,
message: &[u8],
) -> Result<(Ed25519Signature, SignBit), Error>
pub fn sign_message( &self, message: &[u8], ) -> Result<(Ed25519Signature, SignBit), Error>
Sign the provided message and return an Ed25519Signature
and SignBit
.
This method first converts this X25519PrivateKey
to an Ed25519PrivateKey
and SignBit
. Then, the message is signed using the derived Ed25519PrivateKey
. To verify the signature, both the X25519PublicKey
and this calculated SignBit
are required.
§⚠ Warning ⚠
Only ever sign messages the private key owner controls the contents of!
Trait Implementations§
Source§impl Clone for X25519PrivateKey
impl Clone for X25519PrivateKey
Source§fn clone(&self) -> X25519PrivateKey
fn clone(&self) -> X25519PrivateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for X25519PrivateKey
impl Debug for X25519PrivateKey
Source§impl PartialEq for X25519PrivateKey
impl PartialEq for X25519PrivateKey
Auto Trait Implementations§
impl Freeze for X25519PrivateKey
impl RefUnwindSafe for X25519PrivateKey
impl Send for X25519PrivateKey
impl Sync for X25519PrivateKey
impl Unpin for X25519PrivateKey
impl UnwindSafe for X25519PrivateKey
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