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

Method from_delegation_data

atomic-identity/src/delegation.rs:584–595  ·  view source on GitHub ↗

Derive the deterministic id for a delegation's defining triple. Deterministic so a verifier can recompute it from the certificate body and confirm the `@id` was not swapped — the id is a claim like any other, and the only claims worth trusting are the ones you can recheck.

(
        delegator_id: &IdentityId,
        delegate_id: &IdentityId,
        created_at: DateTime<Utc>,
    )

Source from the content-addressed store, hash-verified

582 /// and confirm the `@id` was not swapped — the id is a claim like any
583 /// other, and the only claims worth trusting are the ones you can recheck.
584 pub fn from_delegation_data(
585 delegator_id: &IdentityId,
586 delegate_id: &IdentityId,
587 created_at: DateTime<Utc>,
588 ) -> Self {
589 let mut hasher = blake3::Hasher::new();
590 hasher.update(b"atomic:delegation:v1");
591 hasher.update(delegator_id.as_bytes());
592 hasher.update(delegate_id.as_bytes());
593 hasher.update(&created_at.timestamp().to_le_bytes());
594 Self(*hasher.finalize().as_bytes())
595 }
596
597 /// Wrap raw bytes.
598 pub fn from_bytes(bytes: [u8; 32]) -> Self {

Callers

nothing calls this directly

Calls 5

to_le_bytesMethod · 0.80
updateMethod · 0.45
as_bytesMethod · 0.45
timestampMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected