pub struct KeypairBytes {
pub secret_key: [u8; 32],
pub public_key: Option<PublicKeyBytes>,
}Expand description
Ed25519 keypair serialized as bytes.
This type is primarily useful for decoding/encoding PKCS#8 private key files (either DER or PEM) encoded using the following traits:
DecodePrivateKey: decode DER or PEM encoded PKCS#8 private key.EncodePrivateKey: encode DER or PEM encoded PKCS#8 private key.
PKCS#8 private key files encoded with PEM begin with:
-----BEGIN PRIVATE KEY-----Note that this type operates on raw bytes and performs no validation that keys represent valid Ed25519 field elements.
Fields§
§secret_key: [u8; 32]Ed25519 secret key.
Little endian serialization of an element of the Curve25519 scalar field, prior to “clamping” (i.e. setting/clearing bits to ensure the scalar is actually a valid field element)
public_key: Option<PublicKeyBytes>Ed25519 public key (if available).
Compressed Edwards-y encoded curve point.
Implementations§
Source§impl KeypairBytes
impl KeypairBytes
Sourcepub fn from_bytes(bytes: &[u8; 64]) -> Self
pub fn from_bytes(bytes: &[u8; 64]) -> Self
Parse raw keypair from a 64-byte input.
Trait Implementations§
Source§impl Debug for KeypairBytes
impl Debug for KeypairBytes
Source§impl Drop for KeypairBytes
impl Drop for KeypairBytes
Source§impl EncodePrivateKey for KeypairBytes
Available on crate feature alloc only.
impl EncodePrivateKey for KeypairBytes
Available on crate feature
alloc only.Source§fn to_pkcs8_der(&self) -> Result<SecretDocument>
fn to_pkcs8_der(&self) -> Result<SecretDocument>
Serialize a
SecretDocument containing a PKCS#8-encoded private key. Read moreSource§fn to_pkcs8_pem(
&self,
line_ending: LineEnding,
) -> Result<Zeroizing<String>, Error>
fn to_pkcs8_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>
Serialize this private key as PEM-encoded PKCS#8 with the given
LineEnding. Read moreSource§fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER-encoded PKCS#8 private key to the given path. Read more
Source§fn write_pkcs8_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_pkcs8_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
Write ASN.1 PEM-encoded PKCS#8 private key to the given path. Read more
Source§impl TryFrom<&[u8]> for KeypairBytes
impl TryFrom<&[u8]> for KeypairBytes
Source§impl TryFrom<&KeypairBytes> for PublicKeyBytes
impl TryFrom<&KeypairBytes> for PublicKeyBytes
Source§fn try_from(keypair: &KeypairBytes) -> Result<PublicKeyBytes>
fn try_from(keypair: &KeypairBytes) -> Result<PublicKeyBytes>
Performs the conversion.
Source§impl TryFrom<KeypairBytes> for PublicKeyBytes
impl TryFrom<KeypairBytes> for PublicKeyBytes
Source§fn try_from(keypair: KeypairBytes) -> Result<PublicKeyBytes>
fn try_from(keypair: KeypairBytes) -> Result<PublicKeyBytes>
Performs the conversion.
Source§impl TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for KeypairBytes
impl TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for KeypairBytes
Auto Trait Implementations§
impl Freeze for KeypairBytes
impl RefUnwindSafe for KeypairBytes
impl Send for KeypairBytes
impl Sync for KeypairBytes
impl Unpin for KeypairBytes
impl UnsafeUnpin for KeypairBytes
impl UnwindSafe for KeypairBytes
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
Source§impl<T> DecodePrivateKey for Twhere
T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,
impl<T> DecodePrivateKey for Twhere
T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,
Source§fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format). Read more
Source§fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
Deserialize PKCS#8-encoded private key from PEM. Read more