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

Function mint

atomic-canonical/src/delegation.rs:104–130  ·  view source on GitHub ↗

Mint a signed delegation certificate. The delegator's keypair signs; the returned value is the complete document, including `contentHash` and `proof`. Persist and transmit these exact bytes — re-serializing a parsed struct risks producing different bytes than the proof covers.

(delegator: &Identity, delegator_key: &KeyPair, terms: &Delegation)

Source from the content-addressed store, hash-verified

102/// — re-serializing a parsed struct risks producing different bytes than the
103/// proof covers.
104pub fn mint(delegator: &Identity, delegator_key: &KeyPair, terms: &Delegation) -> Value {
105 let mut doc = Map::new();
106 doc.insert("@context".into(), json!(CONTEXT_URL));
107 doc.insert("@type".into(), json!(TYPE_DELEGATION));
108 doc.insert("@id".into(), json!(terms.id.to_urn()));
109
110 doc.insert("delegator".into(), json!(terms.delegator));
111 doc.insert("delegatorKey".into(), json!(terms.delegator_key));
112 doc.insert("delegatorName".into(), json!(terms.delegator_name));
113 doc.insert("delegate".into(), json!(terms.delegate));
114 doc.insert("delegateKey".into(), json!(terms.delegate_key));
115 doc.insert("delegateName".into(), json!(terms.delegate_name));
116 if let Some(agent) = &terms.software_agent {
117 doc.insert("softwareAgent".into(), json!(agent));
118 }
119
120 doc.insert(
121 "scope".into(),
122 serde_json::to_value(&terms.scope).expect("scope serialization is infallible"),
123 );
124 doc.insert("issued".into(), json!(rfc3339(terms.issued)));
125 if let Some(expires) = terms.expires {
126 doc.insert("expires".into(), json!(rfc3339(expires)));
127 }
128
129 proof::attest_value(Value::Object(doc), delegator, delegator_key)
130}
131
132/// Verify a certificate against the delegator's public key and return the
133/// typed view.

Callers 7

issueFunction · 0.85
runMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
certificateFunction · 0.85

Calls 2

attest_valueFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected