Skip to main content

AgentKey

Struct AgentKey 

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

A short-lived per-agent keypair, signed by the user’s root key.

AgentKey deliberately omits any save/load API: agent keys live in memory for the lifetime of the agent process and are regenerated on restart. The certificate (AgentKey::cert) stores enough provenance for peers to trust the public half.

Implementations§

Source§

impl AgentKey

Source

pub fn issue(user: &UserKey, metadata: AgentMetadata) -> Self

Issue a new agent key, signed by the given user.

The user’s private key is used exactly once here to sign (agent_pubkey || canonical_metadata_bytes), producing the issuer_sig of the embedded CertChain (a root Issuer::User). Use AgentKey::delegate to mint an attenuated sub-agent.

Source

pub fn delegate(&self, metadata: AgentMetadata) -> Result<Self>

Delegate a sub-agent key from this agent — attenuation-only.

The child’s caveats must be this agent’s caveats (the parent authority), otherwise MeshError::CaveatAmplification is returned and no key is minted. The sub-cert is signed by this agent’s key and embeds this agent’s cert as its parent, so it roots at the same user and every verifier re-checks attenuation at each link. A confused or compromised agent therefore cannot mint a child with more authority than it holds.

Source

pub fn sign(&self, message: &[u8]) -> Signature

Sign a message with the agent’s sub-key.

Source

pub fn fingerprint(&self) -> Fingerprint

BLAKE3 fingerprint of the agent’s public key bytes.

Source

pub fn cert(&self) -> &CertChain

Borrow the cert chain proving this agent’s authority.

Source

pub fn public_bytes(&self) -> [u8; 32]

Raw 32-byte ed25519 public key for this agent.

Source

pub fn signing_key_bytes(&self) -> [u8; 32]

Expose the raw 32-byte ed25519 signing key bytes.

This is the ONLY method that surfaces an agent’s private bytes. It exists for one reason: the transport layer (agent-mesh-transport) needs to construct an iroh SecretKey from the same ed25519 seed so the agent’s pubkey doubles as its iroh EndpointId. Callers must NOT persist or transmit these bytes — the agent key is ephemeral by design.

Source

pub fn from_seed_and_cert(seed: &[u8; 32], cert: CertChain) -> Result<Self>

Reconstruct an AgentKey from a 32-byte ed25519 seed and an existing cert chain.

Mirror of signing_key_bytes: used by the PyO3 bindings (and any FFI consumer) to ship an AgentKey across a tokio-spawn boundary without forcing Clone on the underlying ed25519 signing key. Returns MeshError::BadSignature if the seed produces a public key that doesn’t match the cert chain’s agent_pubkey — i.e. rejects a forged pairing.

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> 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, 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,