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
impl InMemoryJournal
Sourcepub fn entries(&self) -> &[JournalEntry]
pub fn entries(&self) -> &[JournalEntry]
Borrow the full entry list — read-only view for transparency-log publishers.
Sourcepub fn verify_chain_anchored(
&self,
trusted_pubkey: &[u8; 32],
expected_tip: &[u8; 32],
expected_len: usize,
) -> Result<(), JournalError>
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
- asserts every entry was signed under
trusted_pubkey(rejects a forged log re-signed under an attacker key —JournalError::SignerKeyMismatch), - asserts the chain tip equals
expected_tip(JournalError::TipMismatch), - asserts the entry count equals
expected_len(JournalError::LengthMismatch— catches truncation / rollback).
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
impl Debug for InMemoryJournal
Source§impl Default for InMemoryJournal
impl Default for InMemoryJournal
Source§fn default() -> InMemoryJournal
fn default() -> InMemoryJournal
Returns the “default value” for a type. Read more
Source§impl PersistentJournal for InMemoryJournal
impl PersistentJournal for InMemoryJournal
Source§fn append(
&mut self,
token: ConsumedToken,
signer: &dyn JournalSigner,
) -> Result<JournalEntry, JournalError>
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>
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 moreSource§fn tip_hash(&self) -> [u8; 32]
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).Auto Trait Implementations§
impl Freeze for InMemoryJournal
impl RefUnwindSafe for InMemoryJournal
impl Send for InMemoryJournal
impl Sync for InMemoryJournal
impl Unpin for InMemoryJournal
impl UnsafeUnpin for InMemoryJournal
impl UnwindSafe for InMemoryJournal
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