Skip to main content

Anchor

Struct Anchor 

Source
pub struct Anchor {
    pub version: u8,
    pub epoch: u32,
    pub count: u64,
    pub head_hex: String,
    pub written_at: u64,
    pub orphaned_since: Option<u64>,
}
Expand description

A per-file downgrade-resistance record, stored as an age-vault secret keyed by anchor_key.

Authenticity comes entirely from the vault’s own AEAD encryption — the anchor carries no MAC of its own, since an attacker who cannot decrypt the vault cannot forge or delete an entry either way.

Fields§

§version: u8

Format version, for forward compatibility.

§epoch: u32

The finalizing key epoch (cross-check + operator diagnostics only — not required to match on read, since a legitimately re-keyed file may resolve under a different epoch).

§count: u64

Total on-disk entry count at the time this anchor was written.

§head_hex: String

The verified chain head at exactly count entries, hex-encoded.

§written_at: u64

Wall-clock milliseconds at write time, embedded inside this AEAD-protected value so it is unforgeable by a file-write-only attacker (unlike filesystem mtime, which such an attacker can freely rewrite via utimensat). Used by the session-anchor reconcile-and-cap sweep to select the true oldest anchor for eviction (issue #6449 rev2 critic S3) — eviction ordering must never depend on an attacker-controlled signal.

§orphaned_since: Option<u64>

Wall-clock milliseconds at which the reconcile-and-cap sweep first observed this anchor’s backing file/session-directory absent. None while the file exists. Set on the first sweep that finds the file gone, cleared if the file reappears before the grace window elapses (self-heal), and used to gate orphan reap behind a grace window so a delete→wait-out-a-sweep→recreate-forged-legacy sequence cannot make the sweep delete the anchor on the attacker’s behalf (issue #6462). #[serde(default)] means pre-existing persisted anchors deserialize with None, no vault migration needed; skip_serializing_if keeps steady-state (never-orphaned) anchors byte-identical to their pre-#6462 serialization.

Implementations§

Source§

impl Anchor

Source

pub fn new(epoch: u32, count: u64, head: ChainHash) -> Self

Construct a new anchor for a file finalized with epoch/count/head, stamping Self::written_at with the current wall-clock time.

Source

pub fn head(&self) -> Result<ChainHash, AnchorError>

Parse Self::head_hex back into a ChainHash.

§Errors

Returns AnchorError::Malformed if the stored hex is not a valid chain hash — this can only happen if the vault entry was corrupted or hand-edited by the age-key holder, not by a file-write-only attacker.

Trait Implementations§

Source§

impl Clone for Anchor

Source§

fn clone(&self) -> Anchor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Anchor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Anchor

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Anchor

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more