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)
Available on crate feature
rsa
and non-WebAssembly only.A public RSA key.
Secp256k1(PublicKey)
Available on crate feature
secp256k1
only.A public Secp256k1 key.
Ecdsa(PublicKey)
Available on crate feature
ecdsa
only.A public ECDSA key.
Implementations§
source§impl 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 to_protobuf_encoding(&self) -> Vec<u8>
pub fn to_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 to_peer_id(&self) -> PeerId
pub fn to_peer_id(&self) -> PeerId
Convert the PublicKey
into the corresponding PeerId
.
Trait Implementations§
source§impl Ord for PublicKey
impl Ord for PublicKey
source§impl PartialOrd<PublicKey> for PublicKey
impl PartialOrd<PublicKey> for PublicKey
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more