pub struct KeyState {
pub prefix: Prefix,
pub current_keys: Vec<String>,
pub next_commitment: Vec<String>,
pub sequence: u64,
pub last_event_said: Said,
pub is_abandoned: bool,
pub threshold: u64,
pub next_threshold: u64,
}Expand description
Current key state derived from replaying a KEL.
This struct captures the complete state of a KERI identity at a given point in its event log. It is computed by walking the KEL from inception to the latest event.
Fields§
§prefix: PrefixThe KERI identifier prefix (used in did:keri:<prefix>)
current_keys: Vec<String>Current signing key(s), Base64url encoded with derivation code prefix. For Ed25519 keys, this is “D” + base64url(pubkey).
next_commitment: Vec<String>Next key commitment(s) for pre-rotation. These are Blake3 hashes of the next public key(s).
sequence: u64Current sequence number (0 for inception, increments with each event)
last_event_said: SaidSAID of the last processed event
is_abandoned: boolWhether this identity has been abandoned (empty next commitment)
threshold: u64Current signing threshold
next_threshold: u64Next signing threshold (committed)
Implementations§
Source§impl KeyState
impl KeyState
Sourcepub fn from_inception(
prefix: Prefix,
keys: Vec<String>,
next: Vec<String>,
threshold: u64,
next_threshold: u64,
said: Said,
) -> Self
pub fn from_inception( prefix: Prefix, keys: Vec<String>, next: Vec<String>, threshold: u64, next_threshold: u64, said: Said, ) -> Self
Create initial state from an inception event.
§Arguments
prefix- The KERI identifier (same as inception SAID)keys- The initial signing key(s)next- The next-key commitment(s)threshold- Initial signing thresholdnext_threshold- Committed next signing thresholdsaid- The inception event SAID
Sourcepub fn apply_rotation(
&mut self,
new_keys: Vec<String>,
new_next: Vec<String>,
threshold: u64,
next_threshold: u64,
sequence: u64,
said: Said,
)
pub fn apply_rotation( &mut self, new_keys: Vec<String>, new_next: Vec<String>, threshold: u64, next_threshold: u64, sequence: u64, said: Said, )
Apply a rotation event to update state.
This should only be called after verifying:
- The new key matches the previous next_commitment
- The event’s previous SAID matches last_event_said
- The sequence is exactly last_sequence + 1
Sourcepub fn apply_interaction(&mut self, sequence: u64, said: Said)
pub fn apply_interaction(&mut self, sequence: u64, said: Said)
Apply an interaction event (updates sequence and SAID only).
Interaction events anchor data but don’t change keys.
Sourcepub fn current_key(&self) -> Option<&str>
pub fn current_key(&self) -> Option<&str>
Get the current signing key (first key for single-sig).
Returns the encoded key string (e.g., “DBase64EncodedKey…”)
Sourcepub fn can_rotate(&self) -> bool
pub fn can_rotate(&self) -> bool
Check if key can be rotated.
Returns false if the identity has been abandoned (empty next commitment).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyState
impl<'de> Deserialize<'de> for KeyState
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>,
impl Eq for KeyState
impl StructuralPartialEq for KeyState
Auto Trait Implementations§
impl Freeze for KeyState
impl RefUnwindSafe for KeyState
impl Send for KeyState
impl Sync for KeyState
impl Unpin for KeyState
impl UnsafeUnpin for KeyState
impl UnwindSafe for KeyState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.