pub struct AuditPrivacy { /* private fields */ }audit only.Expand description
The keys an AuditLog protects its records with.
Who and what a record names, protected at rest, and a person erased from the records without breaking the chain (GDPR Art. 25(1), 32(1)(a), 17; ADR 0015, amended 2026-10-16).
With AuditLog::with_privacy, every
record is changed as follows before it is hashed into its chain, so the
chain verifies over the protected form with no key:
- Who.
actor.subjectand everydetailfield that names a person (requestedBy,erasedCaller,reviewFor, and each element ofactorsandapprovedBy; one list, infields.rs) are each sealed under the named person’s own key;detail.reasonunder the actor’s (under the key of the empty name when there is no actor). A sealed value is the stringa2a-sealed:v1:<sid>:<base64>:sidis a random handle for the person, the rest a 96-bit nonce and AES-256-GCM output under a key derived for this value alone (HKDF-SHA-256 from the person’s key), with["a2a-audit-sealed/v1", chain, sid, field, seq]as both the HKDFinfoand the associated data. - What. Every digest
sha256:<hex>becomeshmac-sha256:<kid>:<hex>, HMAC-SHA-256 under the operator’s HMAC key of["a2a-audit-digest/v1", chain, seq, name, digest]. Bound toseq, so two records of the same content carry different tags: a reader of the store cannot confirm a guess, even by sending the guessed content themselves and comparing. With the key,AuditLog::digest_matcheschecks content against a record.
§Subject keys
A person’s key is 32 random bytes, kept by the audit store
(SubjectKey) wrapped by the operator’s key-encryption key (a
ContentCipher) under ["a2a-audit-subject-key/v1", chain, sid, lookup]. The store finds it by lookup, HMAC-SHA-256 under the HMAC key
of ["a2a-audit-subject/v1", chain, subject], so it holds no person’s
name either. Records carry only the random sid.
§Erasure
AuditLog::erase_subject deletes the
person’s key. Every value sealed under it then stops opening, and nothing
stored maps the person to their sid: the lookup row is gone and the
sid is random. The chain still verifies, because its hashes were taken
over the sealed values. Erasure is refused while a legal hold is placed
on the chain (GDPR Art. 17(3)(e)), and reports any record that names the
person unsealed, from before protection was on.
What erasure does not do:
- Unlink. The person’s records keep their common
sid, so they stay linkable to one another: one pseudonymous activity, its times, methods, outcomes, and task, message and trace ids, which other data (the task store, a tracing backend) can tie back to them. Pseudonymised, not anonymised. - Reach copies. A copy of the key outside the live table survives: a
database’s write-ahead log or free pages until overwritten (the SQLite
store overwrites the freed page and truncates its log unless a reader
holds it, and logs a warning when one does), PostgreSQL’s dead tuples
until
VACUUM(runVACUUM a2a_audit_subject_keysafter erasing), replicas and backups. The key-encryption key unwraps any such copy. - Erase under a dropped HMAC key. A key is found by its lookup under every HMAC key in the ring. Keep an old HMAC key in the ring for as long as subject keys made under it may exist; without it, erasure cannot find them, and reports nothing erased.
- Sort free text. A
reasonis sealed under the actor’s key: erasing the actor erases it, and a person it names is not erased with it.
§Keys
One HMAC key is active; older ones, added with
with_hmac_key, still find the subject keys and
check the digests made under them, so the HMAC key can be rotated. The
key-encryption key rotates through its own ring (for example
Aes256GcmCipher).
Implementations§
Source§impl AuditPrivacy
impl AuditPrivacy
Sourcepub fn new(
kek: Arc<dyn ContentCipher>,
hmac_kid: impl Into<String>,
hmac_key: [u8; 32],
) -> Result<AuditPrivacy, A2aError>
pub fn new( kek: Arc<dyn ContentCipher>, hmac_kid: impl Into<String>, hmac_key: [u8; 32], ) -> Result<AuditPrivacy, A2aError>
Protects records with kek wrapping each person’s key, and the HMAC
key hmac_key under the id hmac_kid. The key bytes handed in are
zeroed once ring has taken them; the caller’s own copy is the
caller’s to zero.
§Errors
A2aError::invalid_params when hmac_kid is empty or holds :.
Sourcepub fn with_hmac_key(
self,
kid: impl Into<String>,
key: [u8; 32],
) -> Result<AuditPrivacy, A2aError>
pub fn with_hmac_key( self, kid: impl Into<String>, key: [u8; 32], ) -> Result<AuditPrivacy, A2aError>
Adds an older HMAC key, for finding the subject keys and checking the digests made under it; the active key is unchanged. Keep it in the ring for as long as subject keys made under it may exist: erasure finds a person’s key only under a key the ring holds.
§Errors
A2aError::invalid_params when kid is empty, holds :, or is
already in the ring.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AuditPrivacy
impl !UnwindSafe for AuditPrivacy
impl Forget for AuditPrivacy
impl Freeze for AuditPrivacy
impl Move for AuditPrivacy
impl Send for AuditPrivacy
impl Sync for AuditPrivacy
impl Unpin for AuditPrivacy
impl UnsafeUnpin for AuditPrivacy
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].