pub struct ConversationKey(/* private fields */);nip44 only.Expand description
32-byte HKDF-Extract result over the secp256k1 ECDH shared X coordinate.
Two parties holding the same (secret, peer_public) pair and the
reverse pair derive bit-identical conversation keys: NIP-44 uses
the unhashed shared X coordinate, which is symmetric in
(sk, pk_peer) ↔ (sk_peer, pk). Cache and reuse the
ConversationKey across messages between the same two pubkeys —
it does not depend on the per-message nonce.
The struct zeroes its bytes on drop; clone explicitly when handing the key to long-lived state.
Implementations§
Source§impl ConversationKey
impl ConversationKey
Sourcepub fn derive(secret: &SecretKey, peer_public: &PublicKey) -> Self
pub fn derive(secret: &SecretKey, peer_public: &PublicKey) -> Self
Derive a conversation key from (secret, peer_public).
The derivation is HKDF-Extract(salt = "nip44-v2", ikm = ecdh_x)
where ecdh_x is the unhashed 32-byte X coordinate of the
shared point produced by secp256k1 ECDH.
Sourcepub const fn from_byte_array(bytes: [u8; 32]) -> Self
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
Construct from raw 32 bytes.
Useful for deserializing test vectors or persisted state. The
bytes must be a valid HKDF-SHA256 PRK; we do not (and cannot)
validate that property, so callers MUST treat any value coming
from outside Self::derive as untrusted.
Sourcepub const fn as_byte_array(&self) -> &[u8; 32]
pub const fn as_byte_array(&self) -> &[u8; 32]
View as raw 32 bytes (for serialization / vectors).
Trait Implementations§
Source§impl Clone for ConversationKey
impl Clone for ConversationKey
Source§fn clone(&self) -> ConversationKey
fn clone(&self) -> ConversationKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more