pub struct ClearanceRegistry { /* private fields */ }Expand description
Maps daemon names to identities with O(1) pubkey lookups via reverse index.
Implementations§
Source§impl ClearanceRegistry
impl ClearanceRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, name: String, pubkey: [u8; 32], level: SecurityLevel)
pub fn register(&mut self, name: String, pubkey: [u8; 32], level: SecurityLevel)
Register a daemon with its initial pubkey and clearance level. Generation starts at 0. Overwrites any existing registration for this name.
Sourcepub fn register_with_generation(
&mut self,
name: String,
pubkey: [u8; 32],
level: SecurityLevel,
generation: u64,
)
pub fn register_with_generation( &mut self, name: String, pubkey: [u8; 32], level: SecurityLevel, generation: u64, )
Register with an explicit generation (used after revoke-then-reregister).
Sourcepub fn lookup(&self, pubkey: &[u8; 32]) -> Option<&DaemonIdentity>
pub fn lookup(&self, pubkey: &[u8; 32]) -> Option<&DaemonIdentity>
Look up a daemon identity by pubkey. O(1) via reverse index.
Returns None for unregistered keys (ephemeral CLI clients).
Sourcepub fn lookup_name(&self, pubkey: &[u8; 32]) -> Option<&str>
pub fn lookup_name(&self, pubkey: &[u8; 32]) -> Option<&str>
Look up the daemon name for a pubkey. O(1) via reverse index.
Sourcepub fn find_by_name(&self, name: &str) -> Option<&DaemonIdentity>
pub fn find_by_name(&self, name: &str) -> Option<&DaemonIdentity>
Find a daemon identity by name. O(1). Always deterministic.
Sourcepub fn register_pending(
&mut self,
daemon_name: &str,
new_pubkey: [u8; 32],
) -> bool
pub fn register_pending( &mut self, daemon_name: &str, new_pubkey: [u8; 32], ) -> bool
Register a pending rotation pubkey for an existing daemon.
Both old (current) and new (pending) pubkeys are valid for identity
resolution during the grace period. The pending key gets the same
security_level and generation as the current identity — register_pending
does NOT accept these as parameters to prevent accidental clearance changes.
If a pending key already exists (double rotation without finalize), the old pending key is removed from the index and replaced.
Returns true if the daemon was found and the pending key was registered.
Returns false if no daemon with that name exists.
Sourcepub fn finalize_rotation(&mut self, daemon_name: &str) -> bool
pub fn finalize_rotation(&mut self, daemon_name: &str) -> bool
Finalize rotation: promote pending to current, remove old from index, increment generation.
Returns true if the daemon was found and had a pending key to finalize.
Returns false if the daemon doesn’t exist or has no pending key.
Sourcepub fn revoke_by_name(&mut self, daemon_name: &str) -> Option<DaemonIdentity>
pub fn revoke_by_name(&mut self, daemon_name: &str) -> Option<DaemonIdentity>
Revoke a daemon entirely: remove identity and all pubkey index entries.
Handles the dual-key case atomically: removes both current and pending pubkeys from the reverse index in one operation.
Returns the removed identity (for generation continuity) or None.
Sourcepub fn snapshot_generations(&self) -> HashMap<String, u64>
pub fn snapshot_generations(&self) -> HashMap<String, u64>
Snapshot all daemon generations. Used by rotation phase 1 baseline.
Trait Implementations§
Source§impl Clone for ClearanceRegistry
impl Clone for ClearanceRegistry
Source§fn clone(&self) -> ClearanceRegistry
fn clone(&self) -> ClearanceRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more