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)
| 168 | /// `public_key`'s private key. Does not check the signature — run |
| 169 | /// [`verify_value`] on the result for that. |
| 170 | pub 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. |