pub struct KeyRotation {
pub type_: String,
pub version: String,
pub did: String,
pub rotation_type: RotationType,
pub new_key: NewKey,
pub previous_key: String,
pub effective_at: i64,
pub overlap_until: i64,
pub reason: RotationReason,
pub signature: Option<String>,
}Expand description
A key rotation event.
Fields§
§type_: StringType identifier.
version: StringProtocol version.
did: StringThe DID this rotation is for.
rotation_type: RotationTypeType of rotation.
new_key: NewKeyThe new key.
previous_key: StringReference to the previous key.
effective_at: i64When this rotation takes effect (unix ms).
overlap_until: i64When the overlap period ends (unix ms).
reason: RotationReasonReason for rotation.
signature: Option<String>Signature from the previous key.
Implementations§
Source§impl KeyRotation
impl KeyRotation
Sourcepub const DEFAULT_OVERLAP: Duration
pub const DEFAULT_OVERLAP: Duration
Default overlap period (24 hours).
Sourcepub fn new(
did: Did,
rotation_type: RotationType,
new_key: NewKey,
previous_key: String,
reason: RotationReason,
) -> Self
pub fn new( did: Did, rotation_type: RotationType, new_key: NewKey, previous_key: String, reason: RotationReason, ) -> Self
Create a new unsigned key rotation.
Sourcepub fn effective_at(self, time: DateTime<Utc>) -> Self
pub fn effective_at(self, time: DateTime<Utc>) -> Self
Set custom effective time.
Sourcepub fn overlap_duration(self, duration: Duration) -> Self
pub fn overlap_duration(self, duration: Duration) -> Self
Set custom overlap period.
Sourcepub fn sign(self, old_key: &RootKey) -> Result<Self>
pub fn sign(self, old_key: &RootKey) -> Result<Self>
Sign this rotation with the previous (old) key.
Sourcepub fn verify(&self) -> Result<()>
pub fn verify(&self) -> Result<()>
Verify this rotation’s signature against the DID’s public key.
Sourcepub fn is_old_key_valid_at(&self, time: DateTime<Utc>) -> bool
pub fn is_old_key_valid_at(&self, time: DateTime<Utc>) -> bool
Check if a key is valid at a given time (considering overlap).
Sourcepub fn is_new_key_active_at(&self, time: DateTime<Utc>) -> bool
pub fn is_new_key_active_at(&self, time: DateTime<Utc>) -> bool
Check if the new key is active at a given time.
Trait Implementations§
Source§impl Clone for KeyRotation
impl Clone for KeyRotation
Source§fn clone(&self) -> KeyRotation
fn clone(&self) -> KeyRotation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyRotation
impl Debug for KeyRotation
Source§impl<'de> Deserialize<'de> for KeyRotation
impl<'de> Deserialize<'de> for KeyRotation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for KeyRotation
impl RefUnwindSafe for KeyRotation
impl Send for KeyRotation
impl Sync for KeyRotation
impl Unpin for KeyRotation
impl UnwindSafe for KeyRotation
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