Struct ruma_signatures::Ed25519KeyPair
source · pub struct Ed25519KeyPair { /* private fields */ }
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<Self, Error>
pub fn new( oid: ObjectIdentifier, privkey: &[u8], pubkey: Option<&[u8]>, version: String, ) -> Result<Self, Error>
Create a key pair from its constituent parts.
sourcepub fn from_der(document: &[u8], version: String) -> Result<Self, Error>
pub fn from_der(document: &[u8], version: String) -> Result<Self, 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<Self, Error>
pub fn from_pkcs8_oak( oak: PrivateKeyInfo<'_>, version: String, ) -> Result<Self, Error>
Constructs a key pair from pkcs8::PrivateKeyInfo
.
sourcepub fn from_pkcs8_pki(
oak: PrivateKeyInfo<'_>,
version: String,
) -> Result<Self, Error>
pub fn from_pkcs8_pki( oak: PrivateKeyInfo<'_>, version: String, ) -> Result<Self, 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