Skip to main content

CommitReader

Struct CommitReader 

Source
pub struct CommitReader { /* private fields */ }
Expand description

Encapsulates the key derivation chain for reading a commit’s objects.

Created by decrypting a commit blob, which extracts the envelope nonce and derives the content key. The content key is then used to decrypt metadata and shards.

§Security

The content_key is a per-commit derived key, not the root key.

Implementations§

Source§

impl CommitReader

Source

pub fn open( root_key: &[u8; 32], commit_blob: &[u8], ) -> CryptoResult<(Vec<u8>, Self)>

Decrypt a commit blob and create a CommitReader for its child objects.

Requires VD01 envelope format. The content key is derived from the envelope nonce.

§Security

This is one of only two operations that require the root key (the other being seal_commit on KeyVault).

Source

pub fn decrypt_metadata<T>(&self, blob: &[u8]) -> CryptoResult<T>

Decrypt a metadata bundle blob using the content key.

Source

pub fn decrypt_metadata_raw(&self, blob: &[u8]) -> CryptoResult<Vec<u8>>

Decrypt a metadata bundle blob into raw bytes.

Source

pub fn decrypt_shard( &self, blob: &[u8], wrapped_key: Option<&WrappedKey>, ancestor_keys: &[ContentKey], ) -> CryptoResult<Vec<u8>>

Decrypt a shard blob. Handles wrapped keys and ancestor key fallback.

Fallback chain:

  1. If wrapped_key is Some, try unwrapping with content_key, then each ancestor key
  2. Error if all attempts fail
Source

pub fn decrypt_repo_manifest(&self, blob: &[u8]) -> CryptoResult<Vec<u8>>

Decrypt a repo manifest blob (collaboration manifest JSON).

Source

pub fn content_key(&self) -> &ContentKey

Get the content key (derived from envelope nonce).

Source

pub fn from_content_key(content_key: ContentKey) -> Self

Create a CommitReader from a content key directly (for scoped-key clone).

Used when cloning from a published repo with --content-key. The content key is the only key available — no root key exists in scoped mode.

Source

pub fn from_share_key(key: ShareKey) -> Self

Create a reader from a share key (for share-based unseal).

In share-based unseal the derived key serves directly as the content key — there is no commit envelope involved.

Source

pub fn decrypt_envelope_body( &self, blob: &[u8], aad: &[u8], ) -> CryptoResult<(Vec<u8>, KeyNonce)>

Decrypt a VD01 envelope body using the content key.

Validates the VD01 header, extracts the nonce, and decrypts the payload using the content key directly (no key derivation — the content key is already the correct decryption key).

Returns the decrypted plaintext and the envelope nonce.

Used by share-based unseal where the share key IS the content key.

Source

pub fn into_parts(self) -> ContentKey

Consume the reader, returning the content key.

Used by void-core’s CommitReader::open_with_vault() to construct the core-layer reader from a vault-opened crypto-layer reader.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V