pub struct PublicKey { /* private fields */ }
Expand description
The public key of a node’s identity keypair.
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 try_into_ed25519(self) -> Result<PublicKey, OtherVariantError>
Available on crate feature
ed25519
only.pub fn try_into_secp256k1(self) -> Result<PublicKey, OtherVariantError>
Available on crate feature
secp256k1
only.pub fn try_into_rsa(self) -> Result<PublicKey, OtherVariantError>
Available on crate feature
rsa
and non-WebAssembly only.pub fn try_into_ecdsa(self) -> Result<PublicKey, OtherVariantError>
Available on crate feature
ecdsa
only.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 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 PartialOrd for PublicKey
impl PartialOrd for PublicKey
Source§impl TryInto<PublicKey> for PublicKey
Available on crate feature rsa
and non-WebAssembly only.
impl TryInto<PublicKey> for PublicKey
Available on crate feature
rsa
and non-WebAssembly only.impl Eq for PublicKey
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 UnwindSafe for PublicKey
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
Mutably borrows from an owned value. Read more