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,
)
| 34 | /// over a raw hash (or another object's signature input) never verifies as a |
| 35 | /// change signature. |
| 36 | pub 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 | /// |