pub struct SecretKey { /* private fields */ }Expand description
X25519 Diffie-Hellman key exchange private key (RFC 7748).
§Generating a key
ⓘ
use crypto::curve25519::x25519::SecretKey;
let alice = SecretKey::generate();
let bob = SecretKey::generate();§Diffie-Hellman key exchange
ⓘ
use crypto::curve25519::x25519::SecretKey;
let alice = SecretKey::generate();
let bob = SecretKey::generate();
let alice_shared = alice.ecdh(&bob.public_key());
let bob_shared = bob.ecdh(&alice.public_key());
assert_eq!(alice_shared, bob_shared);§Conversion from Ed25519
An Ed25519 SecretKey can be
converted to an X25519 key via From<&ed25519::SecretKey>.
§Security
The shared secret produced by ecdh must not be used
directly as an encryption key. Apply a KDF (e.g. HKDF) first.
Implementations§
Trait Implementations§
impl Eq for SecretKey
impl StructuralPartialEq for SecretKey
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations§
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
Mutably borrows from an owned value. Read more