pub struct MutationChain { /* private fields */ }Expand description
HYDRA mutation chain — each token mutation ratchets a SHA3-256 hash chain. This provides Post-Compromise Security (PCS): a stolen token becomes invalid once the legitimate holder advances the chain.
Implementations§
Source§impl MutationChain
impl MutationChain
Sourcepub fn new(seed: [u8; 32]) -> Self
pub fn new(seed: [u8; 32]) -> Self
Initialise from a random 32-byte seed (should be CSPRNG output).
Sourcepub fn from_state(state: [u8; 32], counter: u64) -> Self
pub fn from_state(state: [u8; 32], counter: u64) -> Self
Restore from persisted state.
Sourcepub fn advance(&mut self) -> [u8; 32]
pub fn advance(&mut self) -> [u8; 32]
Advance the chain once and return the new epoch tag. The new state is SHA3-256(old_state || counter_bytes).
pub fn current_counter(&self) -> u64
pub fn current_state(&self) -> &[u8; 32]
Sourcepub fn check_token_counter(&self, token_ctr: u64) -> QVResult<()>
pub fn check_token_counter(&self, token_ctr: u64) -> QVResult<()>
Verify a token’s mutation counter is strictly greater than the stored chain counter. Enforces monotonicity — replay of any previous token is immediately rejected.
Auto Trait Implementations§
impl Freeze for MutationChain
impl RefUnwindSafe for MutationChain
impl Send for MutationChain
impl Sync for MutationChain
impl Unpin for MutationChain
impl UnsafeUnpin for MutationChain
impl UnwindSafe for MutationChain
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