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) -> PeerIdentity
pub fn from_pubkey(pubkey: XOnlyPublicKey) -> PeerIdentity
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) -> PeerIdentity
pub fn from_pubkey_full(pubkey: PublicKey) -> PeerIdentity
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<PeerIdentity, IdentityError>
pub fn from_npub(npub: &str) -> Result<PeerIdentity, 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 ==.impl Copy for PeerIdentity
impl Eq for PeerIdentity
impl StructuralPartialEq for PeerIdentity
Auto Trait Implementations§
impl Freeze for PeerIdentity
impl RefUnwindSafe for PeerIdentity
impl Send for PeerIdentity
impl Sync for PeerIdentity
impl Unpin for PeerIdentity
impl UnsafeUnpin for PeerIdentity
impl UnwindSafe for PeerIdentity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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