Skip to main content

AuditKey

Struct AuditKey 

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

Loaded Ed25519 signing key + its identifier. Construct via AuditKey::load_or_generate.

Clone is intentional: the audit-verify CLI needs to load the key once and share it between the SQLite read-only path and the Postgres pool.

Debug is implemented manually to redact the signing key. A derived Debug would dump the private key via any tracing::debug!("{key:?}") or dbg!(key) site, which would leak the audit secret into journald. We keep key_id visible because operators need to identify which key generation a record belongs to when triaging chain breaks.

Implementations§

Source§

impl AuditKey

Source

pub fn load_or_generate(path: &Path) -> Result<Self, AuditKeyError>

Load the audit key from path. If the file does not exist, generate a 32-byte cryptographically random key and write it with mode 0o600.

On every load (including freshly generated), the file’s permissions are checked: any bit beyond 0o600 for owner-only access is rejected — a world-readable audit key is a self-defeating audit chain.

Source

pub fn key_id(&self) -> &str

Stable identifier for this key generation.

Source

pub fn chain_hash( &self, content: &ChainContent<'_>, prev_chain_hash: &str, ) -> String

Compute the chain signature for content linked to prev_chain_hash.

Hex-encoded Ed25519 signature over canonical(content) || prev_chain_hash. Deterministic (RFC 8032): identical inputs always yield the same value.

Source

pub fn verifying_key(&self) -> VerifyingKey

The public verifying key for this audit key.

Source

pub fn verifying_key_hex(&self) -> String

Hex-encoded 32-byte Ed25519 public key. Safe to publish; auditors use it to verify the chain without the ability to forge entries.

Source

pub fn approval_receipt( &self, transaction_id: &str, request_hash: &str, ) -> String

Derive the bearer receipt for one immutable preview. The signature is deterministic, so a failed response delivery can be retried without storing plaintext bearer credentials in the database.

Source

pub fn approval_commitment( &self, transaction_id: &str, request_hash: &str, ) -> String

Chain-stored SHA-256 commitment to the deterministic approval receipt.

Source§

impl AuditKey

Source

pub fn event_hash( &self, content: &EventContent<'_>, prev_chain_hash: &str, ) -> String

Compute the event-chain signature for content linked to prev_chain_hash. Separate domain tag from rows and checkpoints, so an event signature can never be replayed as a transaction row.

Source§

impl AuditKey

Source

pub fn sign_checkpoint( &self, seq: u64, chain_tip: &str, created_at: &str, ) -> Checkpoint

Sign a checkpoint committing to (seq, chain_tip) at created_at.

Trait Implementations§

Source§

impl Clone for AuditKey

Source§

fn clone(&self) -> AuditKey

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 AuditKey

Source§

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

Formats the value using the given formatter. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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