Skip to main content

MutationChain

Struct MutationChain 

Source
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

Source

pub fn new(seed: [u8; 32]) -> Self

Initialise from a random 32-byte seed (should be CSPRNG output).

Source

pub fn from_state(state: [u8; 32], counter: u64) -> Self

Restore from persisted state.

Source

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).

Source

pub fn current_counter(&self) -> u64

Source

pub fn current_state(&self) -> &[u8; 32]

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V