The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
"""The online face of the transparency log: a READ-ONLY, zero-dependency
|
|
|
|
|
HTTP service exposing CT-style endpoints under a base path (deployed at
|
2026-07-06 17:14:52 +00:00
|
|
|
ltl.zkdefi.org behind a reverse proxy).
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
|
|
|
|
|
Security posture: this process never loads a private key. Tree heads are
|
|
|
|
|
signed OFFLINE by the provider CLI (log-append / log-sth); the service
|
|
|
|
|
serves stored, already-signed material. Compromise of the web process can
|
|
|
|
|
therefore withhold or replay data (which agents detect via pinning and
|
|
|
|
|
freshness policies) but can never forge a signature.
|
|
|
|
|
"""
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
2026-07-06 17:44:06 +00:00
|
|
|
from pathlib import Path
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
from typing import Any
|
|
|
|
|
from urllib.parse import parse_qs, urlparse
|
|
|
|
|
|
|
|
|
|
from .transparency_log import TransparencyLog
|
|
|
|
|
|
|
|
|
|
API_VERSION = "v1"
|
|
|
|
|
|
|
|
|
|
|
2026-07-06 17:44:06 +00:00
|
|
|
def make_handler(log: TransparencyLog, base_path: str, docs_html: str, paper_pdf: bytes | None = None):
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
base = "/" + base_path.strip("/") if base_path.strip("/") else ""
|
|
|
|
|
|
|
|
|
|
class Handler(BaseHTTPRequestHandler):
|
|
|
|
|
server_version = "pacta-log/1"
|
|
|
|
|
|
|
|
|
|
def do_GET(self) -> None: # noqa: N802 (stdlib API)
|
|
|
|
|
try:
|
|
|
|
|
self._route()
|
|
|
|
|
except Exception as exc: # noqa: BLE001 - the service must not die on a bad request
|
|
|
|
|
self._send(500, {"error": f"internal error: {type(exc).__name__}"})
|
|
|
|
|
|
|
|
|
|
def _route(self) -> None:
|
|
|
|
|
parsed = urlparse(self.path)
|
|
|
|
|
path = parsed.path.rstrip("/")
|
|
|
|
|
query = {key: values[0] for key, values in parse_qs(parsed.query).items()}
|
|
|
|
|
if not path.startswith(base):
|
|
|
|
|
self._send(404, {"error": "unknown path", "base_path": base or "/"})
|
|
|
|
|
return
|
|
|
|
|
route = path[len(base):] or "/"
|
|
|
|
|
|
|
|
|
|
if route in ("/", "/docs"):
|
|
|
|
|
self._send_html(docs_html)
|
2026-07-06 17:44:06 +00:00
|
|
|
elif route in ("/paper", "/paper/ltl.pdf"):
|
|
|
|
|
if paper_pdf is None:
|
|
|
|
|
self._send(404, {"error": "paper not available on this deployment"})
|
|
|
|
|
return
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
self.send_header("Content-Type", "application/pdf")
|
|
|
|
|
self.send_header("Content-Disposition", 'inline; filename="ltl.pdf"')
|
|
|
|
|
self.send_header("Content-Length", str(len(paper_pdf)))
|
|
|
|
|
self.end_headers()
|
|
|
|
|
self.wfile.write(paper_pdf)
|
paper rigor pass: fix three claims that failed verification; serve the trust anchor
Socratic audit findings, all verified against artifacts:
- 'zero lines between structurally identical forks' was FALSE: risc0 vs
betrusted differ by 27 lines (all annotation, documenting the risc0
fork's black_box trusted-base entry). Corrected to the true number.
- '~64 Lean files per fork' over-rounded anza's 58. Now '58-64'.
- completeness parenthetical now states both hypotheses (a=-1 square, d
non-square), not just d.
- 'key published in two independent locations' was ASPIRATIONAL: the
site served only a fingerprint. New /log-public-key endpoint serves
the key bytes; docs-page artifact-1 row links both copies; test added.
Verified exactly and kept: 215-line parser diff (FromBytesSpec), 121-line
signature-glue diff (SigApexSpec), byte-identical x4 math files incl. the
carry-telescope file, 11-axiom upstream boundary, 16 certs/leaf, 153-line
mirror verifier, leaf fields (toolchain + machine_protection), all 17 refs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 07:28:55 +00:00
|
|
|
elif route == "/log-public-key":
|
|
|
|
|
# TOFU mitigation depends on the key being published in two
|
|
|
|
|
# independent locations; this is the site's copy (the mirror
|
|
|
|
|
# carries the other). Serving only a fingerprint would not do.
|
|
|
|
|
key_path = Path(log.log_dir) / "provider.ed25519.pub"
|
|
|
|
|
if not key_path.is_file():
|
|
|
|
|
self._send(404, {"error": "log public key not present in this log directory"})
|
|
|
|
|
return
|
|
|
|
|
body = key_path.read_bytes()
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
|
|
|
|
self.send_header("Content-Length", str(len(body)))
|
|
|
|
|
self.end_headers()
|
|
|
|
|
self.wfile.write(body)
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
elif route == "/healthz":
|
|
|
|
|
self._send(200, {"ok": True, "tree_size": len(log.entries())})
|
|
|
|
|
elif route == f"/{API_VERSION}/metadata":
|
|
|
|
|
self._send(200, log.metadata())
|
|
|
|
|
elif route == f"/{API_VERSION}/sth":
|
|
|
|
|
history = log.sth_history()
|
|
|
|
|
if history:
|
|
|
|
|
self._send(200, history[-1])
|
|
|
|
|
else:
|
|
|
|
|
from pacta.yamlio import load_data
|
|
|
|
|
|
|
|
|
|
if log.sth_path.exists():
|
|
|
|
|
self._send(200, load_data(log.sth_path))
|
|
|
|
|
else:
|
|
|
|
|
self._send(404, {"error": "no signed tree head yet"})
|
|
|
|
|
elif route == f"/{API_VERSION}/sth-history":
|
|
|
|
|
self._send(200, {"sth_history": log.sth_history()})
|
|
|
|
|
elif route == f"/{API_VERSION}/sth-consistency":
|
|
|
|
|
first = int(query.get("first", "-1"))
|
|
|
|
|
if first < 0:
|
|
|
|
|
self._send(400, {"error": "missing or invalid ?first=<old tree size>"})
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
self._send(200, log.consistency_from(first))
|
|
|
|
|
except ValueError as exc:
|
|
|
|
|
self._send(400, {"error": str(exc)})
|
|
|
|
|
elif route == f"/{API_VERSION}/proof":
|
|
|
|
|
leaf_hash = query.get("leaf_hash")
|
|
|
|
|
component = query.get("component")
|
|
|
|
|
if component and not leaf_hash:
|
|
|
|
|
entry = log.newest_entry_for_component(component)
|
|
|
|
|
leaf_hash = entry.leaf_hash if entry else None
|
|
|
|
|
if not leaf_hash:
|
|
|
|
|
self._send(400, {"error": "supply ?leaf_hash=<hex> or ?component=<name>"})
|
|
|
|
|
return
|
|
|
|
|
proof = log.proof_for_leaf_hash(leaf_hash)
|
|
|
|
|
if proof is None:
|
|
|
|
|
self._send(404, {"error": f"no leaf with hash {leaf_hash}"})
|
|
|
|
|
return
|
|
|
|
|
self._send(200, proof)
|
|
|
|
|
elif route == f"/{API_VERSION}/attestation":
|
|
|
|
|
component = query.get("component")
|
|
|
|
|
if not component:
|
|
|
|
|
self._send(400, {"error": "supply ?component=<name>"})
|
|
|
|
|
return
|
|
|
|
|
entry = log.newest_entry_for_component(component)
|
|
|
|
|
if entry is None:
|
|
|
|
|
self._send(404, {"error": f"no attestation for component {component}"})
|
|
|
|
|
return
|
|
|
|
|
self._send(200, {
|
|
|
|
|
"leaf_index": entry.index,
|
|
|
|
|
"leaf_hash": entry.leaf_hash,
|
|
|
|
|
"attestation": entry.leaf.get("attestation"),
|
|
|
|
|
})
|
|
|
|
|
elif route == f"/{API_VERSION}/entries":
|
|
|
|
|
start = int(query.get("start", "0"))
|
|
|
|
|
end = int(query.get("end", str(len(log.entries()))))
|
|
|
|
|
entries = log.entries()[start:end]
|
|
|
|
|
self._send(200, {
|
|
|
|
|
"entries": [
|
|
|
|
|
{"index": entry.index, "leaf_hash": entry.leaf_hash, "leaf": entry.leaf}
|
|
|
|
|
for entry in entries
|
|
|
|
|
]
|
|
|
|
|
})
|
2026-07-07 12:17:39 +00:00
|
|
|
elif self._serve_site_document(route, log):
|
|
|
|
|
pass # operator-dropped document; checked LAST so it can never shadow an API route
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
else:
|
|
|
|
|
self._send(404, {
|
|
|
|
|
"error": "unknown endpoint",
|
|
|
|
|
"endpoints": [
|
|
|
|
|
f"{base}/docs",
|
2026-07-06 17:44:06 +00:00
|
|
|
f"{base}/paper",
|
paper rigor pass: fix three claims that failed verification; serve the trust anchor
Socratic audit findings, all verified against artifacts:
- 'zero lines between structurally identical forks' was FALSE: risc0 vs
betrusted differ by 27 lines (all annotation, documenting the risc0
fork's black_box trusted-base entry). Corrected to the true number.
- '~64 Lean files per fork' over-rounded anza's 58. Now '58-64'.
- completeness parenthetical now states both hypotheses (a=-1 square, d
non-square), not just d.
- 'key published in two independent locations' was ASPIRATIONAL: the
site served only a fingerprint. New /log-public-key endpoint serves
the key bytes; docs-page artifact-1 row links both copies; test added.
Verified exactly and kept: 215-line parser diff (FromBytesSpec), 121-line
signature-glue diff (SigApexSpec), byte-identical x4 math files incl. the
carry-telescope file, 11-axiom upstream boundary, 16 certs/leaf, 153-line
mirror verifier, leaf fields (toolchain + machine_protection), all 17 refs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 07:28:55 +00:00
|
|
|
f"{base}/log-public-key",
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
f"{base}/healthz",
|
|
|
|
|
f"{base}/{API_VERSION}/metadata",
|
|
|
|
|
f"{base}/{API_VERSION}/sth",
|
|
|
|
|
f"{base}/{API_VERSION}/sth-history",
|
|
|
|
|
f"{base}/{API_VERSION}/sth-consistency?first=N",
|
|
|
|
|
f"{base}/{API_VERSION}/proof?component=NAME | ?leaf_hash=HEX",
|
|
|
|
|
f"{base}/{API_VERSION}/attestation?component=NAME",
|
|
|
|
|
f"{base}/{API_VERSION}/entries?start=N&end=M",
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
2026-07-07 12:17:39 +00:00
|
|
|
def _serve_site_document(self, route: str, log_obj: TransparencyLog) -> bool:
|
|
|
|
|
"""Serve operator-dropped PDFs from ``<log>/site/`` by bare name.
|
|
|
|
|
|
|
|
|
|
Deliberately UNLISTED: these documents do not appear in the
|
|
|
|
|
endpoint index or anywhere on the docs page - the operator
|
|
|
|
|
decides who receives a link. The name must be a single plain
|
|
|
|
|
path segment (no traversal); only ``.pdf`` payloads are served.
|
|
|
|
|
Returns True when it handled the request.
|
|
|
|
|
"""
|
|
|
|
|
name = route.lstrip("/")
|
|
|
|
|
if not name or not name.replace("-", "").replace("_", "").isalnum():
|
|
|
|
|
return False
|
|
|
|
|
candidate = (log_obj.log_dir / "site" / f"{name}.pdf").resolve()
|
|
|
|
|
site_dir = (log_obj.log_dir / "site").resolve()
|
|
|
|
|
if site_dir not in candidate.parents or not candidate.is_file():
|
|
|
|
|
return False
|
|
|
|
|
body = candidate.read_bytes()
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
self.send_header("Content-Type", "application/pdf")
|
|
|
|
|
self.send_header("Content-Disposition", f'inline; filename="{name}.pdf"')
|
|
|
|
|
self.send_header("Content-Length", str(len(body)))
|
|
|
|
|
self.send_header("X-Robots-Tag", "noindex, nofollow")
|
|
|
|
|
self.end_headers()
|
|
|
|
|
self.wfile.write(body)
|
|
|
|
|
return True
|
|
|
|
|
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
def _send(self, code: int, payload: dict[str, Any], code_if_error: int | None = None) -> None:
|
|
|
|
|
if code_if_error and "error" in payload:
|
|
|
|
|
code = code_if_error
|
|
|
|
|
body = json.dumps(payload, indent=2, sort_keys=True).encode("utf-8")
|
|
|
|
|
self.send_response(code)
|
|
|
|
|
self.send_header("Content-Type", "application/json; charset=utf-8")
|
|
|
|
|
self.send_header("Content-Length", str(len(body)))
|
|
|
|
|
self.send_header("Cache-Control", "no-store")
|
|
|
|
|
self.end_headers()
|
|
|
|
|
self.wfile.write(body)
|
|
|
|
|
|
|
|
|
|
def _send_html(self, html: str) -> None:
|
|
|
|
|
body = html.encode("utf-8")
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
self.send_header("Content-Type", "text/html; charset=utf-8")
|
|
|
|
|
self.send_header("Content-Length", str(len(body)))
|
|
|
|
|
self.end_headers()
|
|
|
|
|
self.wfile.write(body)
|
|
|
|
|
|
|
|
|
|
def log_message(self, fmt: str, *args: Any) -> None: # quiet by default
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
return Handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def serve(
|
|
|
|
|
log_dir: str,
|
2026-07-06 17:14:52 +00:00
|
|
|
base_path: str = "",
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
host: str = "127.0.0.1",
|
|
|
|
|
port: int = 8461,
|
|
|
|
|
docs_html: str | None = None,
|
|
|
|
|
) -> ThreadingHTTPServer:
|
|
|
|
|
log = TransparencyLog(log_dir)
|
|
|
|
|
log.metadata() # fail fast if the log is not initialized
|
|
|
|
|
if docs_html is None:
|
|
|
|
|
from .webdocs import render_docs
|
|
|
|
|
|
|
|
|
|
docs_html = render_docs(log, base_path)
|
2026-07-06 17:44:06 +00:00
|
|
|
paper_path = Path(__file__).resolve().parents[3] / "paper" / "ltl.pdf"
|
|
|
|
|
paper_pdf = paper_path.read_bytes() if paper_path.is_file() else None
|
|
|
|
|
handler = make_handler(log, base_path, docs_html, paper_pdf)
|
The log goes public: git-published mirror, online service, witnesses
Three synchronized faces of one log - transport orthogonal to trust:
- PUBLISHED GIT MIRROR: log-publish exports the public face (one file
per leaf so git history mirrors log history; the FULL STH history as
the witness channel; per-component attestations + receipts; the
provider public key; a standalone stdlib-only verify.py and customer
README). Live at github.com/saymrwulf/lean-transparency-log (genesis:
8 leaves incl. the honest failed-run entries, dogfood-signed head).
- ONLINE SERVICE (pacta_provider serve): read-only, zero-dependency
HTTP with CT-style endpoints under a base path for
zkdefi.org/lean-transparency-log - /v1/sth, /v1/sth-history,
/v1/sth-consistency?first=N, /v1/proof, /v1/attestation, /v1/entries,
/v1/metadata, /healthz - plus self-contained customer documentation
at /docs (current state, attested components, API, the verify-
without-trusting-this-site path, and the means/does-NOT-mean
boundary). The process never loads private keys: heads are signed
offline; a compromised server can withhold or replay (pinning +
freshness detect both) but never forge. STH history now recorded
append-only by the provider (with a backfill head signed for the
existing log).
- AGENT ONLINE CLIENT: pacta log-fetch (download evidence; explicitly
UNVERIFIED until receipt-verify runs - transport is not trust) and
pacta sth-refresh (fetch head, verify signature, advance the pin via
an online consistency proof from the pinned size; fail closed).
- WITNESSES: pacta witness-audit over a clone of the published mirror
recomputes every prefix root from the public leaves and checks every
historical head + signature - no consistency proofs needed when the
leaves are public. Tampering one published entry trips both the
leaf-hash check and the prefix-root check (tested). verify.py gives
customers the same audit with zero installation.
- DEPLOY.md: the complete server-session checklist for zkdefi.org -
reconstruct the servable log FROM the published mirror (the server
stays in witness trust-position), hardened systemd unit, nginx/Caddy
path routing, Forgejo mirror setup, the provider->world update
cycle, and remote smoke tests.
Validated end-to-end on the REAL log: all 10 endpoints, online-fetched
proof re-verified locally through the dogfood verifier with pinning,
online pin refresh, publish + witness audit green, tamper caught,
standalone verify.py green in the published clone. 54/54 tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 14:05:20 +00:00
|
|
|
return ThreadingHTTPServer((host, port), handler)
|