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
impl AuditKey
Sourcepub fn load_or_generate(path: &Path) -> Result<Self, AuditKeyError>
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.
Sourcepub fn chain_hash(
&self,
content: &ChainContent<'_>,
prev_chain_hash: &str,
) -> String
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.
Sourcepub fn verifying_key(&self) -> VerifyingKey
pub fn verifying_key(&self) -> VerifyingKey
The public verifying key for this audit key.
Sourcepub fn verifying_key_hex(&self) -> String
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.
Sourcepub fn approval_receipt(
&self,
transaction_id: &str,
request_hash: &str,
) -> String
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.
Sourcepub fn approval_commitment(
&self,
transaction_id: &str,
request_hash: &str,
) -> String
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
impl AuditKey
Sourcepub fn event_hash(
&self,
content: &EventContent<'_>,
prev_chain_hash: &str,
) -> String
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
impl AuditKey
Sourcepub fn sign_checkpoint(
&self,
seq: u64,
chain_tip: &str,
created_at: &str,
) -> Checkpoint
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§
Auto Trait Implementations§
impl Freeze for AuditKey
impl RefUnwindSafe for AuditKey
impl Send for AuditKey
impl Sync for AuditKey
impl Unpin for AuditKey
impl UnsafeUnpin for AuditKey
impl UnwindSafe for AuditKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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