Skip to main content

restore_attestation_key_pins

Function restore_attestation_key_pins 

Source
pub fn restore_attestation_key_pins(
    root: &Path,
    carried: &[u8],
) -> Result<KeyPinRestoreOutcome, KeyPinError>
Expand description

Fold the pin file a backup carried into this library’s pin.

A library with no pin takes the carried file byte for byte (KeyPinRestoreOutcome::Restored). Otherwise each origin is merged by the rule a fetch obeys: an origin this library never contacted is pinned as carried; one whose pinned history holds every carried key is kept as it is; one whose pinned keys are all carried, plus more, is extended by the carried keys it lacks, in carried order. An origin where each side holds a key the other lacks is KeyPinError::HistoriesDiverge. Every origin is checked before anything is written, so a refusal — that one, or a carried file that does not decode — leaves the library’s pin exactly as it was.

A carried file stamped with a schema newer than this build reads is not refused: it is skipped with a warning (KeyPinRestoreOutcome::SkippedNewerSchema), so a backup from a newer build still restores here. A pin is never worth more than the assets it travels with. Any other version, and anything that does not decode, is refused.