Recomputes every entry hash and confirms each matches the stored value,
and that each prev_hash matches its predecessor's entry_hash. Any
discrepancy indicates tampering or corruption.
Value
A list (invisibly) with components:
intactLogical.
TRUEif the chain is unbroken.n_entriesInteger. Number of data entries verified (genesis excluded).
first_brokenInteger or
NA.entry_idof the first invalid entry.errorsCharacter vector of error descriptions.
Details
Verification algorithm
For each entry i (excluding the genesis record):
Reconstruct
hash_inputfrom the stored fields in canonical order.Recompute
digest(hash_input, algo = hash_algo).Assert
computed == entry$entry_hash(content integrity).Assert
entry$prev_hash == entry[i-1]$entry_hash(chain continuity).
Step 3 failure: the entry's content was modified after writing. Step 4 failure: entries were inserted, deleted, or reordered.
Examples
log <- regulog_init(app = "my-app", user = "jsmith")
log_action(log,
action = "approved",
object = "file.csv",
reason = "Review complete"
)
#> regulog: logged action 'approved' on 'file.csv'
verify_log(log)
#> regulog: Log intact: 1 entry, chain unbroken
#> regulog: Log intact: 1 entry, chain unbroken
