pub trait DerivativeSealer {
// Required method
fn seal(&self, plaintext: &[u8]) -> Result<SealedDerivative, MediaError>;
}Expand description
The encryption seam between media and lifecycle.
media owns pixels and knows nothing about album keys; lifecycle owns the AMK and must
not own codecs. A derivative’s manifest cannot be signed until its ciphertext exists — the
hash is of the ciphertext — so the encryption has to happen inside generation, and this is
the narrowest thing that lets it: one method, no key material in any media signature.
Each call must draw a fresh nonce prefix, so two derivatives of one asset get distinct keys and distinct ciphertexts even when their plaintext is identical.
Required Methods§
Sourcefn seal(&self, plaintext: &[u8]) -> Result<SealedDerivative, MediaError>
fn seal(&self, plaintext: &[u8]) -> Result<SealedDerivative, MediaError>
Encrypt plaintext under the source asset’s identity and epoch, returning what the
manifest commits to. The ciphertext itself is discarded: clients keep the plaintext
derivative locally and re-derive the ciphertext at push time from the recorded prefix,
exactly as they do for the original.
§Errors
MediaError::Sign, and only that variant. Two things can go wrong: the underlying
encryption refuses, or no unused nonce prefix can be drawn for this file_id inside the
implementation’s retry budget. Both are workspace faults rather than pixel ones — a
broken signer or a broken CSPRNG, not a photo this build cannot render — so the import
path propagates them instead of degrading to a missing thumbnail. An implementation must
therefore not report either as MediaError::Encode, which means a codec refused a
frame and nothing else.
replaces plays no part here: a derivative supersedes nothing, so the production
implementation passes None and enforces non-reuse against the set of prefixes already
spent on this file_id instead.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".