Enum libp2p_identity::PublicKey
source · pub enum PublicKey {
Ed25519(PublicKey),
Rsa(PublicKey),
Secp256k1(PublicKey),
Ecdsa(PublicKey),
}ecdsa or secp256k1 or ed25519 or rsa only.Expand description
The public key of a node’s identity keypair.
Variants§
Ed25519(PublicKey)
PublicKey::from and PublicKey::into_ed25519 instead.ed25519 only.A public Ed25519 key.
Rsa(PublicKey)
PublicKey::from and PublicKey::into_rsa instead.rsa and non-WebAssembly only.A public RSA key.
Secp256k1(PublicKey)
PublicKey::from and PublicKey::into_secp256k1 instead.secp256k1 only.A public Secp256k1 key.
Ecdsa(PublicKey)
PublicKey::from and PublicKey::into_ecdsa instead.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).
pub fn into_ed25519(self) -> Option<PublicKey>
PublicKey::try_into_ed25519 instead.ed25519 only.pub fn try_into_ed25519(self) -> Result<PublicKey, OtherVariantError>
ed25519 only.pub fn into_secp256k1(self) -> Option<PublicKey>
PublicKey::try_into_secp256k1 instead.secp256k1 only.pub fn try_into_secp256k1(self) -> Result<PublicKey, OtherVariantError>
secp256k1 only.pub fn into_rsa(self) -> Option<PublicKey>
PublicKey::try_into_rsa instead.rsa and non-WebAssembly only.pub fn try_into_rsa(self) -> Result<PublicKey, OtherVariantError>
rsa and non-WebAssembly only.pub fn into_ecdsa(self) -> Option<PublicKey>
PublicKey::try_into_ecdsa instead.ecdsa only.pub fn try_into_ecdsa(self) -> Result<PublicKey, OtherVariantError>
ecdsa only.sourcepub fn to_protobuf_encoding(&self) -> Vec<u8>
👎Deprecated: Renamed to PublicKey::encode_protobuf.
pub fn to_protobuf_encoding(&self) -> Vec<u8>
PublicKey::encode_protobuf.Encode the public key into a protobuf structure for storage or exchange with other nodes.
sourcepub fn encode_protobuf(&self) -> Vec<u8>
pub fn encode_protobuf(&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>
👎Deprecated: This method name does not follow Rust naming conventions, use PublicKey::try_decode_protobuf instead.
pub fn from_protobuf_encoding(bytes: &[u8]) -> Result<PublicKey, DecodingError>
PublicKey::try_decode_protobuf instead.Decode a public key from a protobuf structure, e.g. read from storage or received from another node.
sourcepub fn try_decode_protobuf(bytes: &[u8]) -> Result<PublicKey, DecodingError>
pub fn try_decode_protobuf(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
Available on crate feature peerid only.
pub fn to_peer_id(&self) -> PeerId
peerid only.Convert the PublicKey into the corresponding PeerId.
Trait Implementations§
source§impl Ord for PublicKey
impl Ord for PublicKey
source§impl PartialEq<PublicKey> for PublicKey
impl PartialEq<PublicKey> 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
self and other) and is used by the <=
operator. Read moresource§impl TryInto<PublicKey> for PublicKey
Available on crate feature rsa and non-WebAssembly only.
impl TryInto<PublicKey> for PublicKey
rsa and non-WebAssembly only.