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

Function attach_proof

atomic-canonical/src/proof.rs:170–186  ·  view source on GitHub ↗

Second half of [`attest_value`]: attach the `eddsa-jcs-2022` proof for a signature over [`PreparedAttestation::signing_bytes`] made by `public_key`'s private key. Does not check the signature — run [`verify_value`] on the result for that.

(mut value: Value, public_key: &PublicKey, signature: &Signature)

Source from the content-addressed store, hash-verified

168/// `public_key`'s private key. Does not check the signature — run
169/// [`verify_value`] on the result for that.
170pub fn attach_proof(mut value: Value, public_key: &PublicKey, signature: &Signature) -> Value {
171 let did = did::did_for_public_key(public_key);
172 let proof = Proof {
173 type_: PROOF_TYPE.to_string(),
174 cryptosuite: CRYPTOSUITE.to_string(),
175 verification_method: did::verification_method(&did),
176 proof_purpose: PROOF_PURPOSE.to_string(),
177 proof_value: encode_proof_value(signature),
178 };
179 if let Some(obj) = value.as_object_mut() {
180 obj.insert(
181 PROP_PROOF.to_string(),
182 serde_json::to_value(proof).expect("proof serialization is infallible"),
183 );
184 }
185 value
186}
187
188/// The signature a value's proof carries — what `--signed` hands to the
189/// recording service after a key holder signed `--prepare`'s bytes elsewhere.

Callers 3

attest_valueFunction · 0.70
sign_elsewhereFunction · 0.50

Calls 4

verification_methodFunction · 0.85
encode_proof_valueFunction · 0.85
did_for_public_keyFunction · 0.70
insertMethod · 0.45

Tested by 2

sign_elsewhereFunction · 0.40