aegis-delegate
Delegation and authority model for AEGIS. Create and verify cryptographic delegation proofs, manage delegation trees with depth limits, issue time-limited session keys, validate scope anti-amplification, and track revocations with cascading.
Delegation Proofs
Create Ed25519-signed delegation proofs using JCS canonicalization. The delegator signs a canonical JSON payload binding the delegate's DID to a specific scope.
use ;
use DelegationScope;
use SigningKey;
let scope = DelegationScope ;
let delegation = create_delegation_proof?;
// Verify the proof
let valid = verify_delegation_proof?;
assert!;
Functions
/// Create a signed delegation proof.
///
/// Signs a JCS-canonicalized JSON payload containing:
/// delegator DID, delegate DID, scope, and optional expiry.
/// Proof type: "AegisDelegationProof2025"
;
/// Verify a delegation proof against the delegator's public key.
///
/// Re-canonicalizes the payload and verifies the JWS signature.
;
Scope Validation
Prevent scope amplification: a delegate's scope must be a subset of (or equal to) the delegator's scope.
use ;
// Ensure a scope is well-formed
check_scope_validity?;
// Check that delegate scope does not exceed delegator scope
amplify_scope?;
// Returns Ok(()) if valid, Err(ScopeAmplification) if delegate exceeds delegator
Functions
/// Validate that a delegation scope is well-formed.
/// Checks: non-empty actions, valid chain names.
;
/// Check for scope amplification.
/// Returns Err(ScopeAmplification) if delegate_scope contains
/// actions, resources, or chains not present in delegator_scope.
;
Delegation Tree
Track delegations as a directed tree. Enforces maximum depth, provides chain verification, and computes effective scopes by intersecting parent scopes.
use DelegationTree;
let mut tree = new; // max depth = 5
tree.add_delegation?;
// Verify the delegation chain for a delegate
let chain_valid = tree.verify_chain?;
// Get the effective scope (intersection of all parent scopes)
let effective = tree.get_effective_scope?;
// Get depth of a node in the tree
let depth = tree.get_depth;
// Revoke a delegation (cascading to all children)
let revoked_ids = tree.revoke?;
DelegationTree
Session Keys
Issue time-limited session keys with constrained scope and optional transaction limits.
use SessionKeyIssuer;
let session_key = issue_session_key?;
// Verify the session key
let valid = verify_session_key?;
assert!;
SessionKeyIssuer
Storage Traits
DelegationStore
RevocationStore
Both have in-memory implementations (InMemoryDelegationStore, InMemoryRevocationStore).
License
Copyright © 2026 L1fe Labs, Inc.
Licensed under either of Apache License 2.0 or MIT license, at your option.