# Verify a Reassigned certificate yourself

Two standalone scripts, same behaviour, no dependencies: `reassigned-verify.mjs` (Node 20+) and
`reassigned_verify.py` (Python 3.9+, standard library). MIT licensed. Read them first: they are short.

## What a check proves

- **Inclusion.** The certificate's public record, byte for byte, is a leaf of that day's ledger.
  `leaf = sha256(0x00 || utf8(record))`, `node = sha256(0x01 || left || right)`, an odd node is
  promoted unchanged (RFC 6962 style). The script rebuilds the root from the record and the path and
  compares it with the root that was submitted to OpenTimestamps (or the day's root, before that).
  Change one character of the record and the root no longer matches.
- **Time.** With the day's `.ots` proof, the script replays the OpenTimestamps operations from the
  root to a Bitcoin attestation and checks that block's Merkle root on a public explorer
  (mempool.space, then blockstream.info). If it matches, the root, and so the record, existed by
  the time that block was mined. A proof still pending (the first few hours) is reported as such.

## What it does not prove

- **Fairness.** A hash shows what was filed and when. It says nothing about whether the ruling was
  fair, or about certificates that were never filed.
- That the site shows every certificate: only the inclusion of the one you check.

Every run ends with a list of what was checked (PASS / FAIL) and what was not (SKIP).
Exit code: `0` all checks passed, `1` a check failed or the proof was unreadable, `2` bad usage.

## Usage

    node reassigned-verify.mjs x7k2m9qa
    node reassigned-verify.mjs https://reassigned.app/c/x7k2m9qa
    python3 reassigned_verify.py x7k2m9qa

This fetches `https://reassigned.app/api/proof/<id>` and, if the day is anchored,
`/ledger/<day>/ots` and the Bitcoin block headers. Options:

    --site URL       another copy of the site (default https://reassigned.app)
    --ots FILE       use a local .ots file instead of downloading it
    --explorer URL   your own Esplora-style API (e.g. your node's mempool), repeatable

## Offline

On a certificate page, "Download this proof (JSON)" saves `reassigned-proof-<id>.json`. Then:

    node reassigned-verify.mjs --file reassigned-proof-x7k2m9qa.json
    python3 reassigned_verify.py --file reassigned-proof-x7k2m9qa.json --ots reassigned-ledger-2026-10-17.ots

With `--file` nothing goes over the network: inclusion is fully checked, and a local `.ots` is
replayed up to its Bitcoin attestation; the script prints the Merkle root that block must have,
for you to compare with any explorer or your own node. Add `--online` to let it check the block.
The `.ots` file is a standard OpenTimestamps proof: the official tools (`ots`, opentimestamps.org) read it too.

## Test vectors

`test-vectors.json` holds proofs generated with the site's own code (single leaf, odd-sized trees,
a version-2 record with non-ASCII text). Both scripts accept it directly:

    node reassigned-verify.mjs --file test-vectors.json
    python3 reassigned_verify.py --file test-vectors.json
