Struct ruma::signatures::Ed25519KeyPair
source · 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
source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more