Skip to main content

diagnose_misattributed_signer

Function diagnose_misattributed_signer 

Source
pub fn diagnose_misattributed_signer(
    manifest: &AssetManifest,
    ciphertext_hash: &Hash32,
    directory: &DeviceDirectory,
    authority: &dyn AlbumAuthority,
    local_chain_head: Option<Hash32>,
) -> Option<Uuid>
Expand description

Diagnose a RejectReason::BadDeviceSig as the legacy inherited-device defect (issue #475) rather than a forgery, returning the directory device that actually signed the record.

Before the fix, sign_lifecycle built every continuation (delete, trash-restore, metadata-update) with created_by_user/created_by_device copied from the chain head while signing with the current device. A record written that way from a second device of the same account names a real directory device that did not sign it, so verify_asset step 8 rejects it — the same verdict a forged signature earns. This function separates the two, and returns Some(signer) only when every fact below holds:

  1. verify_asset itself returns TerminalReject(BadDeviceSig) — this never reclassifies any other verdict, and never turns a rejection into an acceptance;
  2. the record is a continuation (not a create): the create paths always named their signer;
  3. device_sig verifies under a different device of the same published directory, under that entry’s declared classical algorithm, and that device was added no later than the record’s timestamp (steps 7–8 hold for the true signer);
  4. steps 9–11 hold unchanged: the epoch is attested, write_sig verifies under its write-tier key, and the record chains to local_chain_head.

So Some means “this record would have been accepted had it named its own signer” — a signature by a device the account’s IK vouches for, carrying album write authority, in the right chain position. A forger holding none of this account’s device keys cannot produce it.

The record is still refused: created_by_device is covered by both signatures, so the misattribution cannot be corrected without re-signing history, and accepting the record would teach the chokepoint to trust a field it cannot verify. The caller quarantines it with the distinct signal this function enables; see provenance.md § Legacy Inherited-Device Records.