pub struct X25519PrivateKey(/* private fields */);Expand description
A Curve25519 private key used for X25519 key agreement.
Implementations§
Source§impl X25519PrivateKey
impl X25519PrivateKey
pub const KEY_SIZE: usize = 32usize
Sourcepub fn keypair() -> (X25519PrivateKey, X25519PublicKey)
pub fn keypair() -> (X25519PrivateKey, X25519PublicKey)
Generate a new random X25519PrivateKey and corresponding X25519PublicKey.
Sourcepub fn keypair_using(
rng: &mut impl RandomNumberGenerator,
) -> (X25519PrivateKey, X25519PublicKey)
pub fn keypair_using( rng: &mut impl RandomNumberGenerator, ) -> (X25519PrivateKey, X25519PublicKey)
Generate a new random X25519PrivateKey and corresponding X25519PublicKey using the given random number generator.
Sourcepub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
pub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
Generate a new random X25519PrivateKey using the given random number generator.
Sourcepub const fn from_data(data: [u8; 32]) -> Self
pub const fn from_data(data: [u8; 32]) -> Self
Restore an X25519PrivateKey from a fixed-size array of bytes.
Sourcepub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
pub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
Restore an X25519PrivateKey from a reference to an array of bytes.
Sourcepub fn from_hex(hex: impl AsRef<str>) -> Self
pub fn from_hex(hex: impl AsRef<str>) -> Self
Restore an X25519PrivateKey from a hex string.
§Panics
Panics if the hex string is invalid or the length is not X25519PrivateKey::KEY_SIZE * 2.
Sourcepub fn public_key(&self) -> X25519PublicKey
pub fn public_key(&self) -> X25519PublicKey
Get the X25519PublicKey corresponding to this X25519PrivateKey.
Sourcepub fn derive_from_key_material(key_material: impl AsRef<[u8]>) -> Self
pub fn derive_from_key_material(key_material: impl AsRef<[u8]>) -> Self
Derive an X25519PrivateKey from the given key material.
Derive a shared symmetric key from this X25519PrivateKey and the given X25519PublicKey.
Trait Implementations§
Source§impl AsRef<X25519PrivateKey> for X25519PrivateKey
impl AsRef<X25519PrivateKey> for X25519PrivateKey
Source§impl CBORTagged for X25519PrivateKey
impl CBORTagged for X25519PrivateKey
Source§impl CBORTaggedDecodable for X25519PrivateKey
impl CBORTaggedDecodable for X25519PrivateKey
Source§fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
Source§fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
Source§impl CBORTaggedEncodable for X25519PrivateKey
impl CBORTaggedEncodable for X25519PrivateKey
Source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
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 more