pub struct KeyRotationVerifier { /* private fields */ }Expand description
Tracks accepted key rotations for peer verification + grace windows.
During the grace period both the old and new pubkeys of a node are trusted for signature verification. After expiry the old key is revoked. Replays of the same (old, new) pair are rejected.
Implementations§
Source§impl KeyRotationVerifier
impl KeyRotationVerifier
Sourcepub fn new(clock: Arc<dyn Clock>) -> Self
pub fn new(clock: Arc<dyn Clock>) -> Self
Create a verifier bound to the given clock (production: RealClock).
Sourcepub fn with_real_clock() -> Self
pub fn with_real_clock() -> Self
Production default with RealClock.
Sourcepub fn trust_peer(
&self,
node_id: &str,
pubkey: [u8; 32],
) -> Result<(), KeyRotationError>
pub fn trust_peer( &self, node_id: &str, pubkey: [u8; 32], ) -> Result<(), KeyRotationError>
Seed a peer’s current public key (no expiry).
Sourcepub fn apply_rotation(
&self,
node_id: &str,
event: &ChainEvent,
) -> Result<KeyRotationPayload, KeyRotationError>
pub fn apply_rotation( &self, node_id: &str, event: &ChainEvent, ) -> Result<KeyRotationPayload, KeyRotationError>
Apply a verified key-rotation event for node_id.
Rejects:
- Invalid dual signatures
- Replay of the same (old, new) pair
- Rotations where the claimed old key is not currently trusted
- Rotations where the old key is past its grace period
Sourcepub fn is_trusted(&self, node_id: &str, pubkey: &[u8; 32]) -> bool
pub fn is_trusted(&self, node_id: &str, pubkey: &[u8; 32]) -> bool
Whether pubkey is currently trusted for node_id (grace-aware).
Sourcepub fn applied_count(&self) -> usize
pub fn applied_count(&self) -> usize
Number of applied (non-replay) rotations.
Auto Trait Implementations§
impl !Freeze for KeyRotationVerifier
impl !RefUnwindSafe for KeyRotationVerifier
impl !UnwindSafe for KeyRotationVerifier
impl Send for KeyRotationVerifier
impl Sync for KeyRotationVerifier
impl Unpin for KeyRotationVerifier
impl UnsafeUnpin for KeyRotationVerifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more