Enum libp2p_core::identity::PublicKey
source · [−]Expand description
The public key of a node’s identity keypair.
Variants
Ed25519(PublicKey)
A public Ed25519 key.
Rsa(PublicKey)
A public RSA key.
Secp256k1(PublicKey)
A public Secp256k1 key.
Implementations
sourceimpl PublicKey
impl PublicKey
sourcepub fn verify(&self, msg: &[u8], sig: &[u8]) -> bool
pub fn verify(&self, msg: &[u8], sig: &[u8]) -> bool
Verify a signature for a message using this public key, i.e. check that the signature has been produced by the corresponding private key (authenticity), and that the message has not been tampered with (integrity).
sourcepub fn into_protobuf_encoding(self) -> Vec<u8>
pub fn into_protobuf_encoding(self) -> Vec<u8>
Encode the public key into a protobuf structure for storage or exchange with other nodes.
sourcepub fn from_protobuf_encoding(bytes: &[u8]) -> Result<PublicKey, DecodingError>
pub fn from_protobuf_encoding(bytes: &[u8]) -> Result<PublicKey, DecodingError>
Decode a public key from a protobuf structure, e.g. read from storage or received from another node.
sourcepub fn into_peer_id(self) -> PeerId
pub fn into_peer_id(self) -> PeerId
Convert the PublicKey
into the corresponding PeerId
.
Trait Implementations
impl Eq for PublicKey
impl StructuralEq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more