Skip to main content

AuditLog

Struct AuditLog 

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

Appends signed, hash-chained entries to a tamper-evident log.

Each append signs the new entry’s digest and links it to the previous entry, so the log can later be proven complete and unaltered. The log holds the signing identity and the chain head; it does not store the entries itself, so the caller persists each entry’s to_bytes to durable storage (a file or SD card in the field) and rebuilds the chain from there.

§Examples

use pamoja_audit::{verify_chain, AuditLog};
use pamoja_security::DeviceIdentity;

let device = DeviceIdentity::from_seed(&[9u8; 32]);
let public = device.public();

let mut log = AuditLog::new(device);
let entries = [log.append(b"4.6C"), log.append(b"4.9C")];

assert!(verify_chain(&public, &entries).is_ok());

Implementations§

Source§

impl AuditLog

Source

pub fn new(identity: DeviceIdentity) -> Self

Starts a fresh log signed by identity.

§Arguments
  • identity - the device identity that signs each entry.
§Returns

An empty log positioned at the first entry.

Source

pub fn resume(identity: DeviceIdentity, last: &Entry) -> Self

Resumes a log after its last entry, to keep appending across a restart.

§Arguments
  • identity - the device identity that signs each entry.
  • last - the most recent entry already in durable storage.
§Returns

A log positioned to append after last.

Source

pub fn append(&mut self, payload: &[u8]) -> Entry

Appends payload, returning the new signed, chained entry.

The caller persists the returned entry’s to_bytes.

§Arguments
  • payload - the bytes to record, such as an encoded reading.
§Returns

The new Entry.

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.