Skip to main content

PqcCredential

Struct PqcCredential 

Source
pub struct PqcCredential {
    pub spiffe_id: SpiffeId,
    pub algo: u8,
    pub verifying_key_bytes: Vec<u8>,
    pub created_at: DateTime<Utc>,
    pub expires_at: DateTime<Utc>,
}
Expand description

A shareable PQC credential containing a verifying key and identity metadata.

PqcCredential contains only public material and is safe to share with peers. It does not contain the signing key. Think of it as the post-quantum equivalent of an X.509 certificate.

§Wire format

Serialized with serde/bincode. The algo field identifies the key type for forward compatibility. Version 1 uses hybrid Ed25519+ML-DSA-65.

§Examples

use okami::identity::{AgentIdentity, PqcCredential};

// Obtain a credential from an identity (contains only public material).
let identity = AgentIdentity::new("example.com", "agent/worker").unwrap();
let cred: PqcCredential = identity.credential();

assert!(!cred.is_expired());
assert!(cred.is_valid_at(chrono::Utc::now()));

// Round-trip through bytes (e.g. for network transport).
let bytes = cred.to_bytes().unwrap();
let cred2 = PqcCredential::from_bytes(&bytes).unwrap();
assert_eq!(cred.spiffe_id, cred2.spiffe_id);

Fields§

§spiffe_id: SpiffeId

SPIFFE ID identifying the agent this credential belongs to.

§algo: u8

Algorithm version byte (0x01 = hybrid Ed25519+ML-DSA-65).

§verifying_key_bytes: Vec<u8>

Raw serialized verifying key bytes (format determined by algo).

§created_at: DateTime<Utc>

When this credential was created.

§expires_at: DateTime<Utc>

When this credential expires.

Implementations§

Source§

impl PqcCredential

Source

pub fn is_expired(&self) -> bool

Check whether this credential has expired.

Source

pub fn is_valid_at(&self, t: DateTime<Utc>) -> bool

Check whether this credential is valid at the given time.

Source

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

Serialize this credential to bytes (bincode).

§Errors

Returns Error::Serialization if bincode encoding fails.

Source

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

Deserialize a credential from bytes (bincode).

Enforces a MAX_CREDENTIAL_BYTES allocation cap to prevent DoS via crafted length-prefix fields (e.g. [0xFF; 8] triggering multi-exabyte allocation). See /cso audit Finding #4 (fingerprint 30a553fc).

§Errors

Returns Error::Serialization if the input exceeds MAX_CREDENTIAL_BYTES or if bincode decoding fails.

Trait Implementations§

Source§

impl Clone for PqcCredential

Source§

fn clone(&self) -> PqcCredential

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PqcCredential

Source§

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

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

impl<'de> Deserialize<'de> for PqcCredential

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Serialize for PqcCredential

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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