pub struct PublicKey(/* private fields */);Expand description
A public key.
The key itself is stored as the CompressedEdwards y-coordinate of the public key.
It is verified to decompress into a valid key when created.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub const LENGTH: usize = ed25519_dalek::PUBLIC_KEY_LENGTH
pub const LENGTH: usize = ed25519_dalek::PUBLIC_KEY_LENGTH
The length of an ed25519 PublicKey, in bytes.
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Result<PublicKey, KeyParsingError>
pub fn from_bytes(bytes: &[u8; 32]) -> Result<PublicKey, KeyParsingError>
Construct a PublicKey from a slice of bytes.
§Warning
This will return a SignatureError if the bytes passed into this method do not represent
a valid ed25519_dalek curve point. Will never fail for bytes return from Self::as_bytes.
See VerifyingKey::from_bytes for details.
Sourcepub fn verify(
&self,
message: &[u8],
signature: &Signature,
) -> Result<(), SignatureError>
pub fn verify( &self, message: &[u8], signature: &Signature, ) -> Result<(), SignatureError>
Verify a signature on a message with this public key.
§Return
Returns Ok(()) if the signature is valid, and Err otherwise.
Sourcepub fn fmt_short(&self) -> impl Display + Copy + 'static
pub fn fmt_short(&self) -> impl Display + Copy + 'static
Convert to a hex string limited to the first 5 bytes for a friendly string representation of the key.
Trait Implementations§
impl Copy for PublicKey
Source§impl<'de> Deserialize<'de> for PublicKey
impl<'de> Deserialize<'de> for PublicKey
Source§fn deserialize<D>(
deserializer: D,
) -> Result<PublicKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PublicKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for PublicKey
Source§impl From<PublicKey> for EndpointAddr
impl From<PublicKey> for EndpointAddr
Source§fn from(endpoint_id: PublicKey) -> EndpointAddr
fn from(endpoint_id: PublicKey) -> EndpointAddr
Source§impl FromStr for PublicKey
Parses a PublicKey from its hex or base32 encoding.
impl FromStr for PublicKey
Parses a PublicKey from its hex or base32 encoding.
Display produces the hex encoding.
Source§impl Ord for PublicKey
impl Ord for PublicKey
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for PublicKey
impl PartialOrd for PublicKey
Source§impl Serialize for PublicKey
impl Serialize for PublicKey
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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