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

Function sign_change

atomic-core/src/change/signing.rs:36–49  ·  view source on GitHub ↗

Sign a change's content hash with an Ed25519 secret key. `secret_key_bytes` is the 32-byte Ed25519 seed (`atomic_identity::SecretKey::as_bytes`). `signer_did` is the signer's `did:atomic:...` fingerprint (see `atomic_canonical::did`). The signature is made over `domain || 0 || content_hash`, so a signature over a raw hash (or another object's signature input) never verifies as a change signature

(
    signer_did: &str,
    secret_key_bytes: &[u8; 32],
    content_hash: &Hash,
    timestamp: i64,
)

Source from the content-addressed store, hash-verified

34/// over a raw hash (or another object's signature input) never verifies as a
35/// change signature.
36pub fn sign_change(
37 signer_did: &str,
38 secret_key_bytes: &[u8; 32],
39 content_hash: &Hash,
40 timestamp: i64,
41) -> ChangeSignature {
42 use ed25519_dalek::Signer;
43
44 let signing_key = ed25519_dalek::SigningKey::from_bytes(secret_key_bytes);
45 let message = signature_message(content_hash);
46 let signature = signing_key.sign(&message).to_bytes();
47
48 ChangeSignature::new(signer_did, signature, *content_hash.as_bytes(), timestamp)
49}
50
51/// Verify a change signature against a *caller-supplied* Ed25519 public key.
52///

Callers 6

tampered_hash_failsFunction · 0.85
wrong_key_failsFunction · 0.85
sign_withMethod · 0.85
record_with_lifecycleMethod · 0.85

Calls 4

signature_messageFunction · 0.85
to_bytesMethod · 0.45
signMethod · 0.45
as_bytesMethod · 0.45

Tested by 4

tampered_hash_failsFunction · 0.68
wrong_key_failsFunction · 0.68