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

Method sign_with_did

atomic-core/src/change/attestation.rs:589–598  ·  view source on GitHub ↗

Sign this attestation in place with an agent DID identity (V4, CB-12A AC3). `did` is the signer's DID string (e.g. `did:atomic: ` — `atomic_canonical::did::did_for_public_key`); `secret_key_bytes` is the Ed25519 seed (32 bytes, `atomic_identity::SecretKey::as_bytes`). The signature is stored base32 (nopad), matching `atomic_identity::Signature::to_base32`. Unlike [`Attestation::sign_with_

(&mut self, did: &str, secret_key_bytes: &[u8; 32])

Source from the content-addressed store, hash-verified

587 /// holding the signer's public key can verify, and the private key never
588 /// has to live beside the evidence.
589 pub fn sign_with_did(&mut self, did: &str, secret_key_bytes: &[u8; 32]) {
590 use ed25519_dalek::Signer;
591 let signing_key = ed25519_dalek::SigningKey::from_bytes(secret_key_bytes);
592 // The signer is part of the signed payload: set it BEFORE computing
593 // the signature input (mirrors sign_with_mac).
594 self.signer = Some(did.to_string());
595 let input = self.did_signature_input();
596 self.signature =
597 Some(data_encoding::BASE32_NOPAD.encode(&signing_key.sign(&input).to_bytes()));
598 }
599
600 /// Verify a V4 DID signature against the signer's Ed25519 public key.
601 ///

Calls 4

did_signature_inputMethod · 0.80
encodeMethod · 0.45
to_bytesMethod · 0.45
signMethod · 0.45

Tested by

no test coverage detected