pub struct Keypair(/* private fields */);Expand description
Wrapper around pkarr::Keypair that customizes PublicKey rendering.
Implementations§
Source§impl Keypair
impl Keypair
Sourcepub fn from_secret_key_file(path: &Path) -> Result<Keypair, Error>
pub fn from_secret_key_file(path: &Path) -> Result<Keypair, Error>
Read a keypair from a pkarr secret key file.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Return the PublicKey associated with this Keypair.
Display the returned key with .to_string() to get the pubky<z32> identifier or
PublicKey::z32() when you specifically need the bare z-base32 text (e.g. hostnames).
Sourcepub const fn as_inner(&self) -> &Keypair
pub const fn as_inner(&self) -> &Keypair
Borrow the inner pkarr::Keypair.
Sourcepub fn write_secret_key_file(&self, path: &Path) -> Result<(), Error>
pub fn write_secret_key_file(&self, path: &Path) -> Result<(), Error>
Persist the secret key to disk using the pkarr format.
Sourcepub fn into_inner(self) -> Keypair
pub fn into_inner(self) -> Keypair
Extract the inner pkarr::Keypair.
Methods from Deref<Target = Keypair>§
Sourcepub fn to_rpk_certified_key(&self) -> CertifiedKey
pub fn to_rpk_certified_key(&self) -> CertifiedKey
Return a RawPublicKey certified key according to RFC 7250 useful to use with rustls::ConfigBuilder::with_cert_resolver and rustls::server::AlwaysResolvesServerRawPublicKeys
Sourcepub fn to_rpk_rustls_server_config(&self) -> ServerConfig
pub fn to_rpk_rustls_server_config(&self) -> ServerConfig
Create a rustls::ServerConfig using this keypair as a RawPublicKey certificate according to RFC 7250
Sourcepub fn sign(&self, message: &[u8]) -> Signature
pub fn sign(&self, message: &[u8]) -> Signature
Signs a message with the private key of this Keypair.
Sourcepub fn verify(&self, message: &[u8], signature: &Signature) -> Result<(), Error>
pub fn verify(&self, message: &[u8], signature: &Signature) -> Result<(), Error>
Verifies a message against a given signature using this Keypair.
Sourcepub fn secret_key(&self) -> [u8; 32]
pub fn secret_key(&self) -> [u8; 32]
Returns the secret part of this Keypair.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Returns the PublicKey of this Keypair.
Sourcepub fn to_z32(&self) -> String
pub fn to_z32(&self) -> String
Converts the public key of this Keypair to a z-base32 encoded string.
Sourcepub fn to_uri_string(&self) -> String
pub fn to_uri_string(&self) -> String
Converts the public key of this Keypair to a URI string.