pub struct PayloadAad { /* private fields */ }Expand description
The associated data bound into a payload seal.
Binding the payload to its location — (execution_id, step_id, entry_kind, idem_key) — is what
makes a sealed blob un-relocatable. Moving a StepResult blob to a different step_id, or
replaying it under a different execution_id, changes the AAD and makes
PayloadCipher::open fail authentication (fail-closed). The fields are private; construct via
PayloadAad::new and read the bound encoding via PayloadAad::canonical_bytes.
§Security
The bound idem_key and the plaintext payload MUST be derived from non-secret descriptors only
(INV-6): resolved secret material is referenced by vault key name, never embedded here or in the
IdempotencyKey fingerprint. The AAD is authenticated but not encrypted, so it must never
carry a secret value.
§Examples
use zeph_durable::{ExecutionId, IdempotencyKey, StepId};
use zeph_durable::cipher::{EntryKindTag, PayloadAad};
let exec = ExecutionId::new();
let key = IdempotencyKey::derive(exec, StepId::new(0), b"tool:transfer");
let with_key = PayloadAad::new(exec, StepId::new(0), EntryKindTag::StepResult, Some(key));
let without_key = PayloadAad::new(exec, StepId::new(0), EntryKindTag::StepResult, None);
// The optional idempotency key is part of the binding.
assert_ne!(with_key.canonical_bytes(), without_key.canonical_bytes());Implementations§
Source§impl PayloadAad
impl PayloadAad
Sourcepub fn new(
execution_id: ExecutionId,
step_id: StepId,
entry_kind: EntryKindTag,
idem_key: Option<IdempotencyKey>,
) -> Self
pub fn new( execution_id: ExecutionId, step_id: StepId, entry_kind: EntryKindTag, idem_key: Option<IdempotencyKey>, ) -> Self
Construct the associated data for a payload at a known journal location.
Sourcepub fn canonical_bytes(&self) -> Vec<u8> ⓘ
pub fn canonical_bytes(&self) -> Vec<u8> ⓘ
Encode the AAD as deterministic, injective bytes for the AEAD associated-data channel.
Layout (fixed positions, so the encoding is injective without per-field length prefixes):
version(1) || execution_id(16) || step_id_le(4) || entry_kind(1) || idem_present(1) || [idem_key(32) when present]. Every concrete PayloadCipher feeds these exact bytes to its
AEAD so seal and open agree on the binding.
§Examples
use zeph_durable::{ExecutionId, StepId};
use zeph_durable::cipher::{EntryKindTag, PayloadAad};
let aad = PayloadAad::new(ExecutionId::new(), StepId::new(1), EntryKindTag::Checkpoint, None);
// version + 16 + 4 + 1 + 1 = 23 bytes when no idempotency key is bound.
assert_eq!(aad.canonical_bytes().len(), 23);Trait Implementations§
Source§impl Clone for PayloadAad
impl Clone for PayloadAad
Source§fn clone(&self) -> PayloadAad
fn clone(&self) -> PayloadAad
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PayloadAad
impl Debug for PayloadAad
impl Eq for PayloadAad
Source§impl PartialEq for PayloadAad
impl PartialEq for PayloadAad
impl StructuralPartialEq for PayloadAad
Auto Trait Implementations§
impl Freeze for PayloadAad
impl RefUnwindSafe for PayloadAad
impl Send for PayloadAad
impl Sync for PayloadAad
impl Unpin for PayloadAad
impl UnsafeUnpin for PayloadAad
impl UnwindSafe for PayloadAad
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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