Skip to main content

PublicKeyBundle

Struct PublicKeyBundle 

Source
pub struct PublicKeyBundle { /* private fields */ }
Expand description

The public keys of a hybrid keypair.

Serialize with PublicKeyBundle::to_bytes; parsing via PublicKeyBundle::from_bytes validates every component.

Implementations§

Source§

impl PublicKeyBundle

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialize to the v2 public-key bundle format (QSP2).

Source

pub fn key_id(&self) -> KeyId

This bundle’s KeyIdSHA3-256(self.to_bytes())[..16].

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse a v2 public-key bundle, validating the length and the components that support validation.

The X25519, ML-KEM-1024, and Ed25519 components are checked (a non-canonical Ed25519 point or an out-of-range ML-KEM key is rejected). ML-DSA-87 verifying keys have no upstream validation and are only length-checked; a structurally-invalid one simply fails verification later. X25519 has no point validation by design (every 32-byte string is a valid u-coordinate).

§Errors

Returns Error::InvalidKey if the encoding is malformed or a validatable component fails validation.

Source§

impl PublicKeyBundle

Source

pub fn to_pem(&self) -> Result<String>

Available on crate feature pem only.

Serialize the public keys as a concatenated multi-PEM document.

§Errors

Returns Error::InvalidKey if any component fails to PEM-encode (not expected for a valid bundle).

Source

pub fn from_pem(pem: &str) -> Result<Self>

Available on crate feature pem only.

Parse a public-key bundle from a PublicKeyBundle::to_pem document.

The four blocks must appear in order (X25519, ML-KEM, ML-DSA, Ed25519). Every component is validated (the result round-trips through the canonical QSP2 parser).

§Errors

Returns Error::InvalidKey on any malformed block, wrong count, wrong order, or component that fails validation.

Trait Implementations§

Source§

impl Clone for PublicKeyBundle

Source§

fn clone(&self) -> PublicKeyBundle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PublicKeyBundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PublicKeyBundle

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PublicKeyBundle

Source§

impl PartialEq for PublicKeyBundle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PublicKeyBundle

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.