MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_turn_signer

Function resolve_turn_signer

atomic-agent/src/identity.rs:226–263  ·  view source on GitHub ↗

Resolve the signer for a recorded turn: the identity whose public key the header author claims. The levels mirror [`resolve_agent_author`] exactly, so the signature always proves the header's key claim: 1. A **selected delegated agent identity** — keyed attribution claims its public key, so the turn signs with its secret key. If the identity resolves but its keypair is not on disk (a verificatio

(
    agent_identity: Option<&str>,
    identity_dir: Option<&Path>,
)

Source from the content-addressed store, hash-verified

224///
225/// Never fails: a turn must not fail to record over identity selection.
226pub fn resolve_turn_signer(
227 agent_identity: Option<&str>,
228 identity_dir: Option<&Path>,
229) -> Option<atomic_repository::record::SigningIdentity> {
230 use atomic_canonical::did::did_for_public_key;
231 use atomic_identity::{Identity, KeyPair};
232
233 fn signing_identity(
234 identity: &Identity,
235 keypair: &KeyPair,
236 ) -> atomic_repository::record::SigningIdentity {
237 atomic_repository::record::SigningIdentity {
238 signer_did: did_for_public_key(&identity.public_key),
239 secret_key: *keypair.secret.as_bytes(),
240 }
241 }
242
243 // Level 1: the selected delegated identity — claim and proof must agree.
244 if let Some((store, identity)) = load_selected_agent_identity(agent_identity, identity_dir) {
245 return match store.load_keypair(&identity.id, None) {
246 Ok(keypair) => Some(signing_identity(&identity, &keypair)),
247 Err(e) => {
248 log::debug!(
249 "Agent identity '{}' has no usable local keypair ({e}); \
250 recording unsigned rather than signing as someone else",
251 identity.name
252 );
253 None
254 }
255 };
256 }
257
258 // Level 2: plus-tag attribution claims the default identity's key.
259 let store = open_identity_store(identity_dir)?;
260 let identity = store.get_default().ok()??;
261 let keypair = store.load_keypair(&identity.id, None).ok()?;
262 Some(signing_identity(&identity, &keypair))
263}
264
265/// Build an author from a delegated agent identity, if one is configured and
266/// resolvable.

Calls 6

open_identity_storeFunction · 0.85
load_keypairMethod · 0.80
signing_identityFunction · 0.70
okMethod · 0.45
get_defaultMethod · 0.45