dig-capsule 0.5.0

The DIG Network .dig capsule data plane โ€” one crate over the DIGS format, capsule read-crypto, compiler, staging, and the guest/host serve triad.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! AES-256-GCM-SIV chunk seal (paper ยง11.2).
//!
//! The implementation now lives in [`crate::imp::core::crypto`] โ€” the single source
//! of truth shared with the producer and the browser verifier. This module
//! re-exports `encrypt_chunk` unchanged and wraps `decrypt_chunk` to keep the
//! host-facing typed [`TamperError`] (so existing host call-sites are unchanged).
//! See `crate::imp::core::crypto::FIXED_NONCE` for the fixed-nonce / determinism
//! rationale.

use crate::imp::crypto::error::TamperError;

pub use crate::imp::core::crypto::encrypt_chunk;

/// Decrypt and authenticate a chunk. A failed tag check is a [`TamperError`].
pub fn decrypt_chunk(key: &[u8; 32], ciphertext: &[u8]) -> Result<Vec<u8>, TamperError> {
    crate::imp::core::crypto::decrypt_chunk(key, ciphertext).map_err(|()| TamperError)
}