Skip to main content

AuditPrivacy

Struct AuditPrivacy 

Source
pub struct AuditPrivacy { /* private fields */ }
Available on crate feature 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.subject and every detail field that names a person (requestedBy, erasedCaller, reviewFor, and each element of actors and approvedBy; one list, in fields.rs) are each sealed under the named person’s own key; detail.reason under the actor’s (under the key of the empty name when there is no actor). A sealed value is the string a2a-sealed:v1:<sid>:<base64>: sid is 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 HKDF info and the associated data.
  • What. Every digest sha256:<hex> becomes hmac-sha256:<kid>:<hex>, HMAC-SHA-256 under the operator’s HMAC key of ["a2a-audit-digest/v1", chain, seq, name, digest]. Bound to seq, 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_matches checks 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 (run VACUUM a2a_audit_subject_keys after 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 reason is 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

Source

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 :.

Source

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§

Source§

impl Debug for AuditPrivacy

Source§

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

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more