pub struct PeerIdentity { /* private fields */ }Expand description
A known peer’s identity (public key only, no signing capability).
Use this to represent remote peers whose npub you know. For a local
identity with signing capability, use [Identity] instead.
Implementations§
Source§impl PeerIdentity
impl PeerIdentity
Sourcepub fn from_pubkey(pubkey: XOnlyPublicKey) -> Self
pub fn from_pubkey(pubkey: XOnlyPublicKey) -> Self
Create a PeerIdentity from an x-only public key.
Note: When only the x-only key is available, the full public key will be derived assuming even parity for ECDH operations.
Precomputes the even-parity full pubkey eagerly so pubkey_full()
is a constant-time field load. Without this, every send-side hot-path
caller (e.g. send_endpoint_data per packet) re-derived the full
key, which spends ~6% of CPU on a secp256k1 EC point parse for what
should be a memoized lookup.
Sourcepub fn from_pubkey_full(pubkey: PublicKey) -> Self
pub fn from_pubkey_full(pubkey: PublicKey) -> Self
Create a PeerIdentity from a full public key (includes parity).
Use this when you have the complete public key (e.g., from a Noise handshake) to preserve parity information for ECDH operations.
Sourcepub fn from_npub(npub: &str) -> Result<Self, IdentityError>
pub fn from_npub(npub: &str) -> Result<Self, IdentityError>
Create a PeerIdentity from a bech32-encoded npub string.
Sourcepub fn pubkey(&self) -> XOnlyPublicKey
pub fn pubkey(&self) -> XOnlyPublicKey
Return the x-only public key.
Sourcepub fn pubkey_full(&self) -> PublicKey
pub fn pubkey_full(&self) -> PublicKey
Return the full public key for ECDH operations.
If the full key was provided during construction, it is returned. Otherwise, the key is derived from the x-only key assuming even parity.
Sourcepub fn short_npub(&self) -> String
pub fn short_npub(&self) -> String
Return a shortened npub for log display (e.g., npub1abcd...wxyz).
Sourcepub fn address(&self) -> &FipsAddress
pub fn address(&self) -> &FipsAddress
Return the FIPS address.
Trait Implementations§
Source§impl Clone for PeerIdentity
impl Clone for PeerIdentity
Source§fn clone(&self) -> PeerIdentity
fn clone(&self) -> PeerIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PeerIdentity
impl Debug for PeerIdentity
Source§impl Display for PeerIdentity
impl Display for PeerIdentity
Source§impl PartialEq for PeerIdentity
impl PartialEq for PeerIdentity
Source§fn eq(&self, other: &PeerIdentity) -> bool
fn eq(&self, other: &PeerIdentity) -> bool
self and other values to be equal, and is used by ==.