Skip to main content

verify_derivative

Function verify_derivative 

Source
pub fn verify_derivative(
    manifest: &DerivativeManifest,
    asset_id: Uuid,
    directory: &DeviceDirectory,
    authority: &dyn AlbumAuthority,
    role_head: Option<Hash32>,
) -> VerifyOutcome
Expand description

Verify a received derivative manifest for the asset asset_id.

  • directory is the published directory of the account whose device generated the derivative; generated_by_device is resolved in it.
  • role_head is the link_hash of the manifest this receiver already trusts as the head of (asset_id, role), or None when it trusts none yet. A manifest whose prior_provenance_hash is None starts the role’s chain and is only placed when there is no head; any other must name the head exactly.

The derivative’s ciphertext is not an argument: its content address is checked where the bytes arrive (the blob fetch recomputes it against the address the manifest names), and a manifest is verified before any byte is fetched.

Steps, in order — the first that fails decides the RejectReason:

  1. the authority’s admin chain verifies (RejectReason::UntrustedAuthority);
  2. version is derivative-manifest/v1, and the two fields that are wire-optional only on pre-binding fixtures — amk_version and protocol_version — are present (RejectReason::Structural): without amk_version there is no key to check write_sig under;
  3. crypto_suite_id is implemented by this build (RejectReason::SuiteDowngrade);
  4. source_asset_id is asset_id (RejectReason::WrongAsset);
  5. generated_by_device is in directory (RejectReason::UnknownDevice) and was added no later than generated_at (RejectReason::DeviceAddedAfter / RejectReason::BadTimestamp);
  6. device_sig verifies under that entry’s key and declared algorithm (RejectReason::BadDeviceSig);
  7. the epoch is within the attested ceiling and write_sig verifies under its write-tier key (RejectReason::WrongEpoch / RejectReason::BadWriteSig);
  8. chain placement against role_head (RejectReason::Replayed for a chain start when a head exists, RejectReason::ForgedChain for any other mismatch);
  9. accept iff the epoch’s AMK is held locally, else VerifyOutcome::Pending(PendingReason::AmkNotYetLocal).