Skip to main content

Aid

Struct Aid 

Source
pub struct Aid(/* private fields */);
Expand description

A validated AITP Agent Identifier.

Construct via Aid::parse or Aid::from_ed25519. Holding an Aid is proof that the value passed format validation: the string starts with aid:pubkey: and the identifier component is the expected length and alphabet for its algorithm.

Implementations§

Source§

impl Aid

Source

pub fn parse(s: &str) -> Result<Self, AidParseError>

Parse and validate an AID string. Accepts:

  • Legacy v0.1 (untagged): aid:pubkey:<43-char-b64url> — interpreted as Ed25519.
  • v0.2 tagged Ed25519: aid:pubkey:ed25519:<43-char-b64url>.
  • v0.2 tagged P-256: aid:pubkey:p256:<44-char-b64url> (SEC1 compressed point).
Source

pub fn from_ed25519(pubkey: &[u8; 32]) -> Self

Construct a legacy (untagged) Ed25519 AID from a raw 32-byte public key. Kept for backward-compat; new code should prefer Aid::from_ed25519_tagged which emits the v0.2 algorithm-tagged form.

Source

pub fn from_ed25519_tagged(pubkey: &[u8; 32]) -> Self

Construct an algorithm-tagged Ed25519 AID (v0.2 form).

Source

pub fn from_p256(compressed_point: &[u8; 33]) -> Self

Construct a P-256 AID from a 33-byte SEC1 compressed point.

Source

pub fn algorithm(&self) -> AidAlgorithm

Algorithm bound to this AID, derived from the prefix.

Source

pub fn identifier(&self) -> &str

Return the identifier component (everything after the algorithm prefix). For legacy AIDs this is everything after aid:pubkey: (43 chars); for tagged AIDs it’s everything after aid:pubkey:<alg>:.

Source

pub fn try_to_ed25519_bytes(&self) -> Option<[u8; 32]>

Decode the identifier back to the raw 32-byte Ed25519 public key, or None if this AID is not an Ed25519 AID. This is the only accessor — there is no panicking form; callers on paths that may receive an AID of attacker-controlled algorithm (e.g. handshake verification) handle the None case explicitly.

Source

pub fn try_to_p256_bytes(&self) -> Option<[u8; 33]>

Decode the identifier back to the 33-byte SEC1 compressed P-256 public key, or None if this AID is not a P-256 AID.

Source

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

Decode the identifier back to the AID’s algorithm-agile compressed public-key bytes — 32 bytes for Ed25519 (raw pubkey) or 33 bytes for P-256 (SEC1-compressed). This is the canonical encoding embedded in TctBinding.cnf / DelegationBinding.cnf for algorithm-agile signing-key bindings; callers verifying a cnf against an AID should byte-compare against this value rather than the legacy Ed25519-only Self::try_to_ed25519_bytes.

Source

pub fn as_str(&self) -> &str

Return the full AID string verbatim.

Trait Implementations§

Source§

impl Clone for Aid

Source§

fn clone(&self) -> Aid

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 Aid

Source§

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

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

impl<'de> Deserialize<'de> for Aid

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 Display for Aid

Source§

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

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

impl Eq for Aid

Source§

impl From<Aid> for String

Source§

fn from(a: Aid) -> String

Converts to this type from the input type.
Source§

impl Hash for Aid

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Aid

Source§

fn eq(&self, other: &Aid) -> 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 Aid

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

impl StructuralPartialEq for Aid

Source§

impl TryFrom<String> for Aid

Source§

type Error = AidParseError

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

fn try_from(s: String) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Aid

§

impl RefUnwindSafe for Aid

§

impl Send for Aid

§

impl Sync for Aid

§

impl Unpin for Aid

§

impl UnsafeUnpin for Aid

§

impl UnwindSafe for Aid

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.