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
impl Aid
Sourcepub fn parse(s: &str) -> Result<Self, AidParseError>
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).
Sourcepub fn from_ed25519(pubkey: &[u8; 32]) -> Self
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.
Sourcepub fn from_ed25519_tagged(pubkey: &[u8; 32]) -> Self
pub fn from_ed25519_tagged(pubkey: &[u8; 32]) -> Self
Construct an algorithm-tagged Ed25519 AID (v0.2 form).
Sourcepub fn from_p256(compressed_point: &[u8; 33]) -> Self
pub fn from_p256(compressed_point: &[u8; 33]) -> Self
Construct a P-256 AID from a 33-byte SEC1 compressed point.
Sourcepub fn algorithm(&self) -> AidAlgorithm
pub fn algorithm(&self) -> AidAlgorithm
Algorithm bound to this AID, derived from the prefix.
Sourcepub fn identifier(&self) -> &str
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>:.
Sourcepub fn try_to_ed25519_bytes(&self) -> Option<[u8; 32]>
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.
Sourcepub fn try_to_p256_bytes(&self) -> Option<[u8; 33]>
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.
Sourcepub fn pubkey_compressed_bytes(&self) -> Vec<u8> ⓘ
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Aid
impl<'de> Deserialize<'de> for Aid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Aid
impl StructuralPartialEq for Aid
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.