pub fn encrypt_log_record(
key: &SecretKey,
epoch: u32,
lineage: &[u8],
log_version: u64,
t: u64,
plaintext: &[u8],
) -> Result<Vec<u8>, CryptError>Expand description
Encrypts one transaction-log record payload.
The AAD binds the database lineage, the log’s lease version, the transaction number, and the key epoch, so a record can neither be replayed at another basis nor moved between the per-lease-version log files that takeover fencing relies on.
Unlike blobs, log records are not content addressed and nothing requires
re-encoding a record to the same bytes, so this uses one-pass AES-256-GCM
with a fresh random nonce rather than a nonce derived from
(log_version, t). A derived nonce would be reused whenever a transaction
number is re-issued with different content — which happens whenever an
append is torn by a crash before it is acknowledged, and truncated away on
recovery. Key/nonce reuse is fatal under GCM; storing 12 bytes is not.
§Errors
Returns a CryptError when randomness is unavailable or encryption
fails.