pub struct SharedKey(/* private fields */);Expand description
Shared ECDH secret between two parties’ trade (or admin) keys.
Internally a Keys instance whose secret is the 32-byte ECDH output of
(local_secret, counterparty_pubkey). Prefer SharedKey::chat_keys for
the on-the-wire K_conv / K_sign pair.
Implementations§
Sourcepub fn derive(
secret: &SecretKey,
counterparty: &PublicKey,
) -> Result<Self, MostroError>
pub fn derive( secret: &SecretKey, counterparty: &PublicKey, ) -> Result<Self, MostroError>
Derive the ECDH shared secret from a local secret key and the counterparty’s public key.
Both peers obtain the same SharedKey by swapping arguments
(A.derive(a_sk, b_pk) == B.derive(b_sk, a_pk)).
Sourcepub fn keys(&self) -> &Keys
pub fn keys(&self) -> &Keys
Borrow the underlying ECDH Keys (IKM as a keypair).
For gift-wrap dual-read decrypt only. New envelopes use Self::chat_keys.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Public key of the raw ECDH secret interpreted as a keypair.
This was the GiftWrap p tag under the superseded envelope. The new
envelope uses pub(K_conv) from Self::chat_keys instead.
Sourcepub fn secret_key(&self) -> &SecretKey
pub fn secret_key(&self) -> &SecretKey
Borrow the underlying ECDH secret key.
Sourcepub fn chat_keys(&self) -> Result<(Keys, Keys), MostroError>
pub fn chat_keys(&self) -> Result<(Keys, Keys), MostroError>
Derive (K_conv, K_sign) from this ECDH secret.
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Serialize the ECDH secret as lower-case hex for client persistence.
Sourcepub fn from_hex(hex: &str) -> Result<Self, MostroError>
pub fn from_hex(hex: &str) -> Result<Self, MostroError>
Rebuild from hex previously produced by SharedKey::to_hex.
Trait Implementations§
Auto Trait Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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