PROOF OF RECORD // VERIFY

Verify a Seraphix Receipt

We prove what the published record says and when; we do not certify that the record is true.

The check runs in your browser: it re-hashes the record you paste, checks its inclusion proof against the day's signed tree head and checks the Ed25519 signature. The verifier is /verify.js, under 80 lines, no dependencies. How a receipt is made · The Record Ledger

VERIFY 01 // IN THE BROWSER

Check a record

VERIFY 02 // OFFLINE

Check it yourself in Python

Save a record, its proof (/ledger/<day>/proof/<receipt>.json) and the day's entry (/ledger/<day>.json), then run pip install cryptography and python3 verify_min.py record.json proof.json entry.json <public key hex>. Download: /verify_min.py.

#!/usr/bin/env python3
# Seraphix Receipt verifier. usage: verify_min.py record.json proof.json entry.json PUBKEY_HEX   (pip install cryptography)
import hashlib as H, json, sys
from decimal import Decimal
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
def num(x):
    if isinstance(x, int) or (x.is_integer() and abs(x) < 2 ** 53): return str(int(x))
    if x.is_integer() and abs(x) < 1e21: return format(Decimal(repr(x)), "f")
    m, _, e = repr(x).partition("e")
    return m if not e else format(Decimal(repr(x)), "f") if -7 < int(e) < 21 else m + "e" + ("+" if int(e) > 0 else "-") + str(abs(int(e)))
def jcs(v):  # RFC 8785
    if isinstance(v, dict): return "{" + ",".join(json.dumps(k, ensure_ascii=False) + ":" + jcs(v[k]) for k in sorted(v, key=lambda k: k.encode("utf-16-be"))) + "}"
    if isinstance(v, list): return "[" + ",".join(map(jcs, v)) + "]"
    return json.dumps(v, ensure_ascii=False) if v is None or isinstance(v, (bool, str)) else num(v)
sha = lambda b: H.sha256(b).digest()
def need(ok, why): ok or sys.exit("FAIL " + why)
rec, prf, ent, pub = [json.load(open(a, encoding="utf-8")) for a in sys.argv[1:4]] + [sys.argv[4]]
body = {k: v for k, v in ent.items() if k != "signature"}
Ed25519PublicKey.from_public_bytes(bytes.fromhex(pub)).verify(bytes.fromhex(ent["signature"]["sig"]), jcs(body).encode())
r = H.sha256(jcs(rec).encode()).hexdigest(); need(r == prf["receipt"] and prf["entry_sha256"] == H.sha256(jcs(body).encode()).hexdigest(), "receipt/entry mismatch")
need(ent["signature"]["key_id"] == ent.get("key_id") == H.sha256(bytes.fromhex(pub)).hexdigest()[:16], "key id mismatch")
p = prf["proofs"]["state"]; fn, sn, h = p["index"], p["size"] - 1, sha(b"\0" + bytes.fromhex(r))
need(p["size"] == ent["state"]["count"] and 0 <= fn <= sn, "proof size/index does not match the signed tree")
for s in map(bytes.fromhex, p["path"]):  # RFC 9162 2.1.3.2
    need(sn, "proof too long")
    if fn & 1 or fn == sn:
        h = sha(b"\1" + s + h)
        while fn and not fn & 1: fn, sn = fn >> 1, sn >> 1
    else: h = sha(b"\1" + h + s)
    fn, sn = fn >> 1, sn >> 1
need(sn == 0 and h.hex() == p["root"] == ent["state"]["root"], "inclusion proof fails")
print(f"OK receipt {r} is in the Record Ledger state of {ent['date']} (signed, root {p['root']})")

The receipt is sha256 of the record in RFC 8785 canonical JSON (keys sorted, no whitespace, UTF-8). The tree is the RFC 9162 Merkle tree over the day's sorted receipts.

PROOF OF RECORD // KEY

Signing key

Ed25519 public key
4de0c75147e55c8dca81977ba49e97290825a48fa6363d85b036418eaffd1915
Also published
/ledger/pubkey.json and DNS TXT _seraphix-ledger.seraphixsystems.com. Check that the two agree before you rely on a signature.