Skip to main content

InMemoryJournal

Struct InMemoryJournal 

Source
pub struct InMemoryJournal { /* private fields */ }
Expand description

Dev-only in-memory chain-signed journal.

entries is the ordered chain (walked by verify_chain / tip_hash); seen is a parallel token_hash set so is_duplicate (and therefore append’s replay guard) runs in O(1) instead of an O(n) scan per append.

Implementations§

Source§

impl InMemoryJournal

Source

pub fn new() -> Self

Empty journal.

Source

pub fn entries(&self) -> &[JournalEntry]

Borrow the full entry list — read-only view for transparency-log publishers.

Source

pub fn verify_chain_anchored( &self, trusted_pubkey: &[u8; 32], expected_tip: &[u8; 32], expected_len: usize, ) -> Result<(), JournalError>

Trust-anchored verification — the consumer-side check under an untrusted-producer threat model. Mirrors the kernel’s verify_chain_anchored: in addition to the self-consistency check run by verify_chain, it

verify_chain() alone is insufficient when the producer is untrusted: each entry validates against its OWN embedded signer_pubkey, so any keypair forges a self-consistent log.

Trait Implementations§

Source§

impl Debug for InMemoryJournal

Source§

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

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

impl Default for InMemoryJournal

Source§

fn default() -> InMemoryJournal

Returns the “default value” for a type. Read more
Source§

impl PersistentJournal for InMemoryJournal

Source§

fn append( &mut self, token: ConsumedToken, signer: &dyn JournalSigner, ) -> Result<JournalEntry, JournalError>

Append a consumed token. Duplicate token_hash is rejected with JournalError::DuplicateToken. Success returns the newly-created entry so the caller can verify / publish it.
Source§

fn verify_chain(&self) -> Result<(), JournalError>

Self-consistency check only. Returns Ok(()) if every entry’s entry_hash matches its re-computation and every signature validates under the entry’s OWN embedded signer_pubkey; otherwise surfaces the first failing index. Read more
Source§

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

Last entry’s entry_hash, or GENESIS_PREV_HASH for an empty journal. Useful for external publishing (transparency log).
Source§

fn len(&self) -> usize

Count entries.
Source§

fn is_duplicate(&self, token_hash: &[u8; 32]) -> bool

Duplicate check — O(n) linear scan on in-memory, backend-specific on WAL-backed.
Source§

fn is_empty(&self) -> bool

Empty journal check.

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.