pub struct ScopedEncryptionKeyBundle { /* private fields */ }Expand description
Scoped secrets delivered together for one approval, outside its grant JWS.
The wire format is { "version": "v1", "keys": [...] }. Unsupported
versions and inconsistent overlapping keys are rejected on deserialization.
JSON secrets are unpadded base64url strings; binary secrets are 32 raw bytes.
Empty bundles and identical duplicate entries are valid. Entry order is
preserved, and debug output redacts every secret.
Serialization is plaintext and needs an encrypted, authenticated envelope. Decoding validates canonical paths, 32-byte secrets, and consistent overlaps. Disjoint scopes cannot be checked against each other without an ancestor key. Approval and identity checks belong to the auth flow. Secret storage is zeroized on drop; serialized copies need their own secret handling.
Implementations§
Source§impl ScopedEncryptionKeyBundle
impl ScopedEncryptionKeyBundle
Sourcepub fn from_identity_secret<'a>(
identity_secret: &[u8; 32],
scopes: impl IntoIterator<Item = &'a StoragePath>,
) -> Self
pub fn from_identity_secret<'a>( identity_secret: &[u8; 32], scopes: impl IntoIterator<Item = &'a StoragePath>, ) -> Self
Derive an approval bundle from the signer’s high-entropy identity secret.
Use the canonical 32-byte secret returned by Keypair::secret(), not a
password or an encoded key string. Only approved scopes are retained;
the temporary root seed is zeroized on return.
Entries preserve request order, including overlapping or repeated scopes.
The caller must limit the scopes to those approved by the user.
Sourcepub fn scopes(&self) -> impl ExactSizeIterator<Item = &StoragePath>
pub fn scopes(&self) -> impl ExactSizeIterator<Item = &StoragePath>
Borrow approved scopes in delivery order, without exposing their entries.
Sourcepub fn derive_for_path(
&self,
path: &StoragePath,
) -> Result<Zeroizing<[u8; 32]>, KeyDerivationError>
pub fn derive_for_path( &self, path: &StoragePath, ) -> Result<Zeroizing<[u8; 32]>, KeyDerivationError>
Derive an owned file content key using the first covering key.
Directory paths, including /, are rejected. Directory seeds remain
internal to the bundle. Returned bytes are zeroized on drop. Do not log
them or put them in public metadata.
Overlapping entries agree, so entry order cannot change the result. File entries cannot cover descendants or directories.
§Errors
Returns KeyDerivationError::DirectoryPath for directory paths and
KeyDerivationError::OutsideScope if no bundled key covers the file,
including when the bundle is empty.