pub struct Ed25519KeyPair { /* private fields */ }
Available on crate feature
signatures
only.Expand description
An Ed25519 key pair.
Implementations§
Source§impl Ed25519KeyPair
impl Ed25519KeyPair
Sourcepub fn new(
oid: ObjectIdentifier,
privkey: &[u8],
pubkey: Option<&[u8]>,
version: String,
) -> Result<Ed25519KeyPair, Error>
pub fn new( oid: ObjectIdentifier, privkey: &[u8], pubkey: Option<&[u8]>, version: String, ) -> Result<Ed25519KeyPair, Error>
Create a key pair from its constituent parts.
Sourcepub fn from_der(
document: &[u8],
version: String,
) -> Result<Ed25519KeyPair, Error>
pub fn from_der( document: &[u8], version: String, ) -> Result<Ed25519KeyPair, Error>
Initializes a new key pair.
§Parameters
- document: PKCS#8 v1/v2 DER-formatted document containing the private (and optionally public) key.
- version: The “version” of the key used for this signature. Versions are used as an identifier to distinguish signatures generated from different keys but using the same algorithm on the same homeserver.
§Errors
Returns an error if the public and private keys provided are invalid for the implementing algorithm.
Returns an error when the PKCS#8 document had a public key, but it doesn’t match the one generated from the private key. This is a fallback and extra validation against corruption or
Sourcepub fn from_pkcs8_oak(
oak: PrivateKeyInfo<'_>,
version: String,
) -> Result<Ed25519KeyPair, Error>
pub fn from_pkcs8_oak( oak: PrivateKeyInfo<'_>, version: String, ) -> Result<Ed25519KeyPair, Error>
Constructs a key pair from pkcs8::PrivateKeyInfo
.
Sourcepub fn from_pkcs8_pki(
oak: PrivateKeyInfo<'_>,
version: String,
) -> Result<Ed25519KeyPair, Error>
pub fn from_pkcs8_pki( oak: PrivateKeyInfo<'_>, version: String, ) -> Result<Ed25519KeyPair, Error>
Constructs a key pair from pkcs8::PrivateKeyInfo
.
Sourcepub fn public_key(&self) -> [u8; 32]
pub fn public_key(&self) -> [u8; 32]
Returns the public key.
Trait Implementations§
Source§impl Debug for Ed25519KeyPair
impl Debug for Ed25519KeyPair
Auto Trait Implementations§
impl Freeze for Ed25519KeyPair
impl RefUnwindSafe for Ed25519KeyPair
impl Send for Ed25519KeyPair
impl Sync for Ed25519KeyPair
impl Unpin for Ed25519KeyPair
impl UnwindSafe for Ed25519KeyPair
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