From f7119530a01d6a2b292b1b45cbca4bce05b21a4b Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:18:25 +0100 Subject: [PATCH 01/21] Create run_record.py --- .../build-reproducible-notebook/run_record.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/build-reproducible-notebook/run_record.py diff --git a/examples/build-reproducible-notebook/run_record.py b/examples/build-reproducible-notebook/run_record.py new file mode 100644 index 0000000..0ca6d3b --- /dev/null +++ b/examples/build-reproducible-notebook/run_record.py @@ -0,0 +1,31 @@ +"""Build a canonical run record: hashes of inputs, code and outputs.""" +import hashlib, json +from pathlib import Path + +VERSION = "nirium-run-record-v1" + +def sha256_file(path, chunk=1 << 20): + h = hashlib.sha256() + with open(path, "rb") as f: # streamed: large files are hashed, never uploaded + while block := f.read(chunk): + h.update(block) + return h.hexdigest() + +def _entries(paths, root): + return {Path(p).as_posix(): sha256_file(Path(root) / p) for p in sorted(paths)} + +def build_record(inputs, code, outputs, root="."): + return {"version": VERSION, + "inputs": _entries(inputs, root), + "code": _entries(code, root), + "outputs": _entries(outputs, root)} + +def canonical(record): + return json.dumps(record, sort_keys=True, separators=(",", ":")) + +def record_hash(record): + return hashlib.sha256(canonical(record).encode()).hexdigest() + +def rebuild(record, root="."): + """Recompute a record from the files named in an existing one.""" + return build_record(record["inputs"], record["code"], record["outputs"], root) From a32886c7406cf255bb64e23506510f20e3878494 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:20:15 +0100 Subject: [PATCH 02/21] Add anchor functionality for run-record hashes Implement functions to sign and anchor a run-record hash through the Nirium Audit Trail. Includes receipt saving functionality. --- .../build-reproducible-notebook/anchor.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/build-reproducible-notebook/anchor.py diff --git a/examples/build-reproducible-notebook/anchor.py b/examples/build-reproducible-notebook/anchor.py new file mode 100644 index 0000000..a323562 --- /dev/null +++ b/examples/build-reproducible-notebook/anchor.py @@ -0,0 +1,33 @@ +"""Sign and anchor a run-record hash through the Nirium Audit Trail (client only).""" +import base64, json, os +from pathlib import Path + +NODE = "https://nirium-agent.fly.dev" # testnet node, POST /api/audit/log +PREFIX = "nirium-audit-v1:" + +def stellar_sign(secret, record_hash): + from stellar_sdk import Keypair # pip install stellar-sdk + kp = Keypair.from_secret(secret) + sig = kp.sign((PREFIX + record_hash).encode()) + return kp.public_key, base64.b64encode(sig).decode() + +def sdk_anchor(payload): + # TODO(check SDK docs): confirm the exact anchor_audit_record signature. + from nirium import anchor_audit_record + return anchor_audit_record(**payload) + +def anchor(record, record_hash, tag, secret=None, signer=stellar_sign, client=sdk_anchor): + if not tag.startswith("wave11-"): + raise ValueError("tag must start with 'wave11-'") + secret = secret or os.environ["STELLAR_TESTNET_SECRET"] # never commit keys + agent, signature = signer(secret, record_hash) + resp = client({"hash": record_hash, "agent": agent, "statement": PREFIX + record_hash, + "signature": signature, "tag": tag, "node": NODE}) + return {"cid": resp["cid"], "hash": record_hash, "agent": agent, "tag": tag, + "anchoredAt": resp.get("anchoredAt"), "record": record} + +def save_receipt(receipt, directory="receipts"): + Path(directory).mkdir(exist_ok=True) + path = Path(directory) / f"{receipt['hash'][:12]}.json" + path.write_text(json.dumps(receipt, indent=2)) + return path From 3acd5f09a0bfa4c1eb2d46c3a7d946e279c36e0d Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:21:23 +0100 Subject: [PATCH 03/21] Add check_run.py for verifying record integrity --- .../build-reproducible-notebook/check_run.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/build-reproducible-notebook/check_run.py diff --git a/examples/build-reproducible-notebook/check_run.py b/examples/build-reproducible-notebook/check_run.py new file mode 100644 index 0000000..2a237fc --- /dev/null +++ b/examples/build-reproducible-notebook/check_run.py @@ -0,0 +1,25 @@ +"""check-run: recompute a record from local files, then run `nirium verify`.""" +import argparse, json, subprocess, sys +from run_record import rebuild, record_hash + +def check(receipt, root=".", verify=True, runner=subprocess.run): + recomputed = record_hash(rebuild(receipt["record"], root)) + if recomputed != receipt["hash"]: + return False, f"FAIL: files changed (expected {receipt['hash']}, got {recomputed})" + if verify: + r = runner(["npx", "nirium-cli", "verify", receipt["cid"], "--hash", receipt["hash"]], + capture_output=True, text=True) + if r.returncode != 0: + return False, "FAIL: nirium verify\n" + (r.stdout or "") + (r.stderr or "") + return True, "OK: record matches files" + (" and passes nirium verify" if verify else "") + +def main(argv=None): + ap = argparse.ArgumentParser() + ap.add_argument("receipt"); ap.add_argument("--root", default=".") + ap.add_argument("--skip-cli", action="store_true") + a = ap.parse_args(argv) + ok, msg = check(json.load(open(a.receipt)), a.root, not a.skip_cli) + print(msg); return 0 if ok else 1 + +if __name__ == "__main__": + sys.exit(main()) From 5c1c752430cabbd4641dc10ee2371af1f9c64ce6 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:22:53 +0100 Subject: [PATCH 04/21] Add run_analysis.py for data analysis and receipt generation Implement analysis function to compute statistics from input file and save results. --- .../run_analysis.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/build-reproducible-notebook/run_analysis.py diff --git a/examples/build-reproducible-notebook/run_analysis.py b/examples/build-reproducible-notebook/run_analysis.py new file mode 100644 index 0000000..e5d8691 --- /dev/null +++ b/examples/build-reproducible-notebook/run_analysis.py @@ -0,0 +1,18 @@ +"""Run the analysis on an input file, write results, anchor a receipt.""" +import argparse, json, statistics +from pathlib import Path +from run_record import build_record, record_hash +from anchor import anchor, save_receipt + +def analyse(inp, out): + nums = [float(x) for x in Path(inp).read_text().split()] + Path(out).write_text(json.dumps({"n": len(nums), "mean": statistics.mean(nums)}, indent=2)) + +if __name__ == "__main__": + ap = argparse.ArgumentParser() + ap.add_argument("input"); ap.add_argument("--out", required=True) + ap.add_argument("--tag", default="wave11-reproducible-notebook") + a = ap.parse_args() + analyse(a.input, a.out) + rec = build_record([a.input], ["run_analysis.py"], [a.out]) + print(save_receipt(anchor(rec, record_hash(rec), a.tag))) From bc325adbc4779727be27a62005ae992fd193bff8 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:23:58 +0100 Subject: [PATCH 05/21] Add README for reproducible run records with Nirium Added README.md for building reproducible run records with Nirium, including usage instructions and receipts table. --- .../build-reproducible-notebook/README.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/build-reproducible-notebook/README.md diff --git a/examples/build-reproducible-notebook/README.md b/examples/build-reproducible-notebook/README.md new file mode 100644 index 0000000..c28a0d5 --- /dev/null +++ b/examples/build-reproducible-notebook/README.md @@ -0,0 +1,29 @@ +# Build with Nirium: reproducible run records + +Hashes a run's input files, code and output files into one run record, signs +`nirium-audit-v1:` with your own Stellar testnet key, and anchors the +hash via the Nirium Audit Trail (testnet). Large files are hashed locally and +never uploaded; only the record hash is public. + +## Usage +```bash +pip install stellar-sdk nirium # nirium = published Python SDK +export STELLAR_TESTNET_SECRET=S... # your own testnet key, never committed +python run_analysis.py data/run1.txt --out results/run1.json +python run_analysis.py data/run2.txt --out results/run2.json +python check_run.py receipts/.json # recompute + nirium verify +python -m unittest tests/test_all.py # offline, HTTP mocked +``` + +## Receipts +| Run | Input | CID | Hash | Verify | +|-----|-------|-----|------|--------| +| 1 | data/run1.txt | _TODO_ | _TODO_ | _paste output_ | +| 2 | data/run2.txt | _TODO_ | _TODO_ | _paste output_ | + +Tampered case (one input changed): _paste failing output_ + +## What a receipt proves, and what it doesn't +Proves: the record has not changed since it was anchored, and which key signed it. +Does not prove: that the content is true or the analysis correct. `anchoredAt` +is the Nirium node's clock, not a ledger time. From 55854bb847d27369d7c5f364e8e7add3fabb14f7 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:25:44 +0100 Subject: [PATCH 06/21] Implement tests for build_record and check functions Add unit tests for record building and verification --- .../tests/test_all.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/build-reproducible-notebook/tests/test_all.py diff --git a/examples/build-reproducible-notebook/tests/test_all.py b/examples/build-reproducible-notebook/tests/test_all.py new file mode 100644 index 0000000..24e4337 --- /dev/null +++ b/examples/build-reproducible-notebook/tests/test_all.py @@ -0,0 +1,33 @@ +import shutil, sys, tempfile, unittest +from pathlib import Path +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) +from run_record import build_record, record_hash +from anchor import anchor +from check_run import check + +fake_signer = lambda s, h: ("GFAKE", "c2ln") +fake_client = lambda p: {"cid": "bafyfake", "anchoredAt": "2026-11-22T00:00:00Z"} + +class T(unittest.TestCase): + def setUp(self): + self.d = Path(tempfile.mkdtemp()) + (self.d / "in.txt").write_text("1 2 3"); (self.d / "code.py").write_text("x") + (self.d / "out.json").write_text("{}") + self.rec = build_record(["in.txt"], ["code.py"], ["out.json"], self.d) + self.rcpt = anchor(self.rec, record_hash(self.rec), "wave11-test", "s", fake_signer, fake_client) + def tearDown(self): shutil.rmtree(self.d) + def test_ok(self): self.assertTrue(check(self.rcpt, self.d, verify=False)[0]) + def test_tampered_input(self): + (self.d / "in.txt").write_text("1 2 4"); self.assertFalse(check(self.rcpt, self.d, verify=False)[0]) + def test_tampered_output(self): + (self.d / "out.json").write_text("{1}"); self.assertFalse(check(self.rcpt, self.d, verify=False)[0]) + def test_different_inputs_different_hash(self): + (self.d / "in.txt").write_text("9"); r2 = build_record(["in.txt"], ["code.py"], ["out.json"], self.d) + self.assertNotEqual(record_hash(r2), self.rcpt["hash"]) + def test_tag_enforced(self): + with self.assertRaises(ValueError): anchor(self.rec, "h", "bad", "s", fake_signer, fake_client) + def test_cli_failure(self): + class R: returncode, stdout, stderr = 1, "", "bad" + self.assertFalse(check(self.rcpt, self.d, True, lambda *a, **k: R())[0]) + +if __name__ == "__main__": unittest.main() From 13891cf40012e15ce9b7c3564879f71711bb9e8a Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:28:31 +0100 Subject: [PATCH 07/21] Add run1.txt with sample data --- examples/build-reproducible-notebook/data/run1.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/build-reproducible-notebook/data/run1.txt diff --git a/examples/build-reproducible-notebook/data/run1.txt b/examples/build-reproducible-notebook/data/run1.txt new file mode 100644 index 0000000..aacb595 --- /dev/null +++ b/examples/build-reproducible-notebook/data/run1.txt @@ -0,0 +1 @@ +1 2 3 4 5 From a03726dd44742ceecdcbf54a78aae858cb1fb1cc Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Sun, 22 Nov 2026 23:29:38 +0100 Subject: [PATCH 08/21] Add run2.txt with sample data --- examples/build-reproducible-notebook/data/run2.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/build-reproducible-notebook/data/run2.txt diff --git a/examples/build-reproducible-notebook/data/run2.txt b/examples/build-reproducible-notebook/data/run2.txt new file mode 100644 index 0000000..659cfca --- /dev/null +++ b/examples/build-reproducible-notebook/data/run2.txt @@ -0,0 +1 @@ +10 20 30 From 2f6682cac949d833fad3b8103fd2d0a57a3b6abd Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 00:26:02 +0100 Subject: [PATCH 09/21] Refactor sdk_anchor to use asyncio for SDK calls --- examples/build-reproducible-notebook/anchor.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/build-reproducible-notebook/anchor.py b/examples/build-reproducible-notebook/anchor.py index a323562..7ab55da 100644 --- a/examples/build-reproducible-notebook/anchor.py +++ b/examples/build-reproducible-notebook/anchor.py @@ -1,5 +1,5 @@ """Sign and anchor a run-record hash through the Nirium Audit Trail (client only).""" -import base64, json, os +import asyncio, base64, json, os from pathlib import Path NODE = "https://nirium-agent.fly.dev" # testnet node, POST /api/audit/log @@ -11,19 +11,19 @@ def stellar_sign(secret, record_hash): sig = kp.sign((PREFIX + record_hash).encode()) return kp.public_key, base64.b64encode(sig).decode() -def sdk_anchor(payload): - # TODO(check SDK docs): confirm the exact anchor_audit_record signature. - from nirium import anchor_audit_record - return anchor_audit_record(**payload) +def sdk_anchor(kwargs): + """Call the published SDK: Agent(...).anchor_audit_record(hash=, tag=, agent=).""" + from nirium import Agent + return asyncio.run(Agent(api_url=NODE).anchor_audit_record(**kwargs)) def anchor(record, record_hash, tag, secret=None, signer=stellar_sign, client=sdk_anchor): if not tag.startswith("wave11-"): raise ValueError("tag must start with 'wave11-'") secret = secret or os.environ["STELLAR_TESTNET_SECRET"] # never commit keys - agent, signature = signer(secret, record_hash) - resp = client({"hash": record_hash, "agent": agent, "statement": PREFIX + record_hash, - "signature": signature, "tag": tag, "node": NODE}) - return {"cid": resp["cid"], "hash": record_hash, "agent": agent, "tag": tag, + key, signature = signer(secret, record_hash) + resp = client({"hash": record_hash, "tag": tag, + "agent": {"key": key, "signature": signature}}) + return {"cid": resp["cid"], "hash": record_hash, "agent": key, "tag": tag, "anchoredAt": resp.get("anchoredAt"), "record": record} def save_receipt(receipt, directory="receipts"): From 198cf20fe8e883a76d59535b01a0c00f1a7b6867 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:32:15 +0100 Subject: [PATCH 10/21] Add run1.json with results of notebook execution --- examples/build-reproducible-notebook/results/run1.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/build-reproducible-notebook/results/run1.json diff --git a/examples/build-reproducible-notebook/results/run1.json b/examples/build-reproducible-notebook/results/run1.json new file mode 100644 index 0000000..d8bc0be --- /dev/null +++ b/examples/build-reproducible-notebook/results/run1.json @@ -0,0 +1,4 @@ +{ + "n": 5, + "mean": 3.0 +} From 8b1d39b4b1fb3c7ca2e87bb6deb0645125763926 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:33:50 +0100 Subject: [PATCH 11/21] Add run2.json with results data --- examples/build-reproducible-notebook/results/run2.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/build-reproducible-notebook/results/run2.json diff --git a/examples/build-reproducible-notebook/results/run2.json b/examples/build-reproducible-notebook/results/run2.json new file mode 100644 index 0000000..e9a9f71 --- /dev/null +++ b/examples/build-reproducible-notebook/results/run2.json @@ -0,0 +1,4 @@ +{ + "n": 3, + "mean": 20.0 +} From 611f8072cd1146563eacd490d9ac1770af3cdb0f Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:36:11 +0100 Subject: [PATCH 12/21] Add reproducible notebook JSON configuration --- .../463b7d604aab.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/build-reproducible-notebook/463b7d604aab.json diff --git a/examples/build-reproducible-notebook/463b7d604aab.json b/examples/build-reproducible-notebook/463b7d604aab.json new file mode 100644 index 0000000..f0db69b --- /dev/null +++ b/examples/build-reproducible-notebook/463b7d604aab.json @@ -0,0 +1,19 @@ +{ + "cid": "Qmasm9GgAoyrQGEcHKnEw4XyV8fYZbr4j7pBYiCXcaVfdo", + "hash": "463b7d604aabecfd86b52863515a1b9fe00ac8846ccf17de6befd1017744f0da", + "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", + "tag": "wave11-reproducible-notebook", + "anchoredAt": "2026-11-23T00:15:57.562Z", + "record": { + "version": "nirium-run-record-v1", + "inputs": { + "data/run1.txt": "e7464530ec48c7398faea385c2e737c855ca15a7f9bb30f0cdc363b5d0f2e3d4" + }, + "code": { + "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" + }, + "outputs": { + "results/run1.json": "dad2c0fa489949bdd42cd767c7899efc11fedb2f07ef719090e16e6a8b6bb175" + } + } +} From c50ed929de5be04888fd11c30fa641df5e9dab68 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:37:02 +0100 Subject: [PATCH 13/21] Delete examples/build-reproducible-notebook/463b7d604aab.json --- .../463b7d604aab.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 examples/build-reproducible-notebook/463b7d604aab.json diff --git a/examples/build-reproducible-notebook/463b7d604aab.json b/examples/build-reproducible-notebook/463b7d604aab.json deleted file mode 100644 index f0db69b..0000000 --- a/examples/build-reproducible-notebook/463b7d604aab.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "cid": "Qmasm9GgAoyrQGEcHKnEw4XyV8fYZbr4j7pBYiCXcaVfdo", - "hash": "463b7d604aabecfd86b52863515a1b9fe00ac8846ccf17de6befd1017744f0da", - "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", - "tag": "wave11-reproducible-notebook", - "anchoredAt": "2026-11-23T00:15:57.562Z", - "record": { - "version": "nirium-run-record-v1", - "inputs": { - "data/run1.txt": "e7464530ec48c7398faea385c2e737c855ca15a7f9bb30f0cdc363b5d0f2e3d4" - }, - "code": { - "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" - }, - "outputs": { - "results/run1.json": "dad2c0fa489949bdd42cd767c7899efc11fedb2f07ef719090e16e6a8b6bb175" - } - } -} From f3ca48537f537d0ef2b5773249c8fa92ef35969c Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:39:01 +0100 Subject: [PATCH 14/21] Add JSON receipt for reproducible notebook --- .../receipts/463b7d604aab.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/build-reproducible-notebook/receipts/463b7d604aab.json diff --git a/examples/build-reproducible-notebook/receipts/463b7d604aab.json b/examples/build-reproducible-notebook/receipts/463b7d604aab.json new file mode 100644 index 0000000..f0db69b --- /dev/null +++ b/examples/build-reproducible-notebook/receipts/463b7d604aab.json @@ -0,0 +1,19 @@ +{ + "cid": "Qmasm9GgAoyrQGEcHKnEw4XyV8fYZbr4j7pBYiCXcaVfdo", + "hash": "463b7d604aabecfd86b52863515a1b9fe00ac8846ccf17de6befd1017744f0da", + "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", + "tag": "wave11-reproducible-notebook", + "anchoredAt": "2026-11-23T00:15:57.562Z", + "record": { + "version": "nirium-run-record-v1", + "inputs": { + "data/run1.txt": "e7464530ec48c7398faea385c2e737c855ca15a7f9bb30f0cdc363b5d0f2e3d4" + }, + "code": { + "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" + }, + "outputs": { + "results/run1.json": "dad2c0fa489949bdd42cd767c7899efc11fedb2f07ef719090e16e6a8b6bb175" + } + } +} From d2714bcf3d2c41d032ed8410cbd5ac07ad1e8d8a Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:39:55 +0100 Subject: [PATCH 15/21] Add JSON receipt for reproducible notebook --- .../receipts/8fb6bf393c1e.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json diff --git a/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json b/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json new file mode 100644 index 0000000..e61c410 --- /dev/null +++ b/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json @@ -0,0 +1,19 @@ +{ + "cid": "QmWRJetpVMX8DtwgMFK3GqL6YKzs6oJ3GhCeKtkWJbcRTz", + "hash": "8fb6bf393c1e9d552e8a81b0858204d6b4877c82224c6c9b5d2d5658b2ef13bd", + "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", + "tag": "wave11-reproducible-notebook", + "anchoredAt": "2026-11-23T00:19:33.802Z", + "record": { + "version": "nirium-run-record-v1", + "inputs": { + "data/run2.txt": "0b2a04baf2fb45f9efd2e31510ab7e39fb025c310306add1783aa174e9e2881d" + }, + "code": { + "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" + }, + "outputs": { + "results/run2.json": "1219930bcd9070f673ceca33956c294aba64f36968ab2bb320896af9cb85a044" + } + } +} From 6400c3d9227f665065b1959c2da3ca60319f12df Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:47:03 +0100 Subject: [PATCH 16/21] Modify output format in run_analysis.py Add a newline at the end of the output JSON file. --- examples/build-reproducible-notebook/run_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/build-reproducible-notebook/run_analysis.py b/examples/build-reproducible-notebook/run_analysis.py index e5d8691..701fbb7 100644 --- a/examples/build-reproducible-notebook/run_analysis.py +++ b/examples/build-reproducible-notebook/run_analysis.py @@ -6,7 +6,8 @@ def analyse(inp, out): nums = [float(x) for x in Path(inp).read_text().split()] - Path(out).write_text(json.dumps({"n": len(nums), "mean": statistics.mean(nums)}, indent=2)) + result = {"n": len(nums), "mean": statistics.mean(nums)} + Path(out).write_text(json.dumps(result, indent=2) + "\n") if __name__ == "__main__": ap = argparse.ArgumentParser() From 9c99e839a83acd55406459ae4d9c27bb3c3ecd25 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:50:29 +0100 Subject: [PATCH 17/21] Add JSON receipt for reproducible notebook --- .../receipts/c5f1ee188d91.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/build-reproducible-notebook/receipts/c5f1ee188d91.json diff --git a/examples/build-reproducible-notebook/receipts/c5f1ee188d91.json b/examples/build-reproducible-notebook/receipts/c5f1ee188d91.json new file mode 100644 index 0000000..582afca --- /dev/null +++ b/examples/build-reproducible-notebook/receipts/c5f1ee188d91.json @@ -0,0 +1,19 @@ +{ + "cid": "QmdvnYaQEtqrQQ19hZ7hphbU6GAKknnvS9aMGezq5iMNVK", + "hash": "c5f1ee188d9180c8d63497d29c7f88f8798f722ed8212044264774dbd092809a", + "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", + "tag": "wave11-reproducible-notebook", + "anchoredAt": "2026-11-23T00:48:18.540Z", + "record": { + "version": "nirium-run-record-v1", + "inputs": { + "data/run1.txt": "e7464530ec48c7398faea385c2e737c855ca15a7f9bb30f0cdc363b5d0f2e3d4" + }, + "code": { + "run_analysis.py": "a95d6b47948e2d2b52ef27143131cd4e8b0b10f3a1302ffcc3bb99fdf1576ac3" + }, + "outputs": { + "results/run1.json": "14ca05dda07329f2276571a7ffb8d1d74d190d414eeecc3a0ae7e304d414b26e" + } + } +} From 7fbb3e6a6fbd0f9cd3ab5e2fb3ee9e893da52314 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:51:38 +0100 Subject: [PATCH 18/21] Add JSON receipt for reproducible notebook --- .../receipts/d8428bfa58dd.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/build-reproducible-notebook/receipts/d8428bfa58dd.json diff --git a/examples/build-reproducible-notebook/receipts/d8428bfa58dd.json b/examples/build-reproducible-notebook/receipts/d8428bfa58dd.json new file mode 100644 index 0000000..4443533 --- /dev/null +++ b/examples/build-reproducible-notebook/receipts/d8428bfa58dd.json @@ -0,0 +1,19 @@ +{ + "cid": "QmYgs3Ae89A7jFf9mkZYfk97UEg7gTBPB2E2TcDd5EyaYQ", + "hash": "d8428bfa58dd6b1879472dbf09d1c2577f449fcd949eafab0b3cc31d754334de", + "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", + "tag": "wave11-reproducible-notebook", + "anchoredAt": "2026-11-23T00:48:20.449Z", + "record": { + "version": "nirium-run-record-v1", + "inputs": { + "data/run2.txt": "0b2a04baf2fb45f9efd2e31510ab7e39fb025c310306add1783aa174e9e2881d" + }, + "code": { + "run_analysis.py": "a95d6b47948e2d2b52ef27143131cd4e8b0b10f3a1302ffcc3bb99fdf1576ac3" + }, + "outputs": { + "results/run2.json": "a66e586029dead095414f1feea320dd2a76da2502cce191b2e5aef72effae24c" + } + } +} From 8b5c76992b5af73e88114a2f3ffbfe04479a0816 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:52:38 +0100 Subject: [PATCH 19/21] Delete examples/build-reproducible-notebook/receipts/463b7d604aab.json --- .../receipts/463b7d604aab.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 examples/build-reproducible-notebook/receipts/463b7d604aab.json diff --git a/examples/build-reproducible-notebook/receipts/463b7d604aab.json b/examples/build-reproducible-notebook/receipts/463b7d604aab.json deleted file mode 100644 index f0db69b..0000000 --- a/examples/build-reproducible-notebook/receipts/463b7d604aab.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "cid": "Qmasm9GgAoyrQGEcHKnEw4XyV8fYZbr4j7pBYiCXcaVfdo", - "hash": "463b7d604aabecfd86b52863515a1b9fe00ac8846ccf17de6befd1017744f0da", - "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", - "tag": "wave11-reproducible-notebook", - "anchoredAt": "2026-11-23T00:15:57.562Z", - "record": { - "version": "nirium-run-record-v1", - "inputs": { - "data/run1.txt": "e7464530ec48c7398faea385c2e737c855ca15a7f9bb30f0cdc363b5d0f2e3d4" - }, - "code": { - "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" - }, - "outputs": { - "results/run1.json": "dad2c0fa489949bdd42cd767c7899efc11fedb2f07ef719090e16e6a8b6bb175" - } - } -} From 7b371b015834d948c11e192c2a76d61133c0afbc Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 01:53:54 +0100 Subject: [PATCH 20/21] Delete examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json --- .../receipts/8fb6bf393c1e.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json diff --git a/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json b/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json deleted file mode 100644 index e61c410..0000000 --- a/examples/build-reproducible-notebook/receipts/8fb6bf393c1e.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "cid": "QmWRJetpVMX8DtwgMFK3GqL6YKzs6oJ3GhCeKtkWJbcRTz", - "hash": "8fb6bf393c1e9d552e8a81b0858204d6b4877c82224c6c9b5d2d5658b2ef13bd", - "agent": "GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT", - "tag": "wave11-reproducible-notebook", - "anchoredAt": "2026-11-23T00:19:33.802Z", - "record": { - "version": "nirium-run-record-v1", - "inputs": { - "data/run2.txt": "0b2a04baf2fb45f9efd2e31510ab7e39fb025c310306add1783aa174e9e2881d" - }, - "code": { - "run_analysis.py": "cc28ac12ac4ac2f24e26ff0878f743487b440700807f472972254eaa9aaa2f86" - }, - "outputs": { - "results/run2.json": "1219930bcd9070f673ceca33956c294aba64f36968ab2bb320896af9cb85a044" - } - } -} From 4d21901525334fd9b212bb9325c94a64ce8b39c8 Mon Sep 17 00:00:00 2001 From: Nuruddeen Abubakar Abubakar Date: Mon, 23 Nov 2026 02:01:18 +0100 Subject: [PATCH 21/21] Revise README for usage and verification clarity Updated usage instructions and added verification details in README. --- .../build-reproducible-notebook/README.md | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/examples/build-reproducible-notebook/README.md b/examples/build-reproducible-notebook/README.md index c28a0d5..da0c5e5 100644 --- a/examples/build-reproducible-notebook/README.md +++ b/examples/build-reproducible-notebook/README.md @@ -7,23 +7,50 @@ never uploaded; only the record hash is public. ## Usage ```bash -pip install stellar-sdk nirium # nirium = published Python SDK -export STELLAR_TESTNET_SECRET=S... # your own testnet key, never committed +pip install stellar-sdk nirium +export STELLAR_TESTNET_SECRET=S... # your own testnet key, never committed +cd examples/build-reproducible-notebook python run_analysis.py data/run1.txt --out results/run1.json python run_analysis.py data/run2.txt --out results/run2.json -python check_run.py receipts/.json # recompute + nirium verify -python -m unittest tests/test_all.py # offline, HTTP mocked +python check_run.py receipts/.json # recompute + nirium verify +python tests/test_all.py # offline, HTTP mocked ``` +`check_run.py` recomputes the record from the files, compares its hash with the +receipt, then runs `npx nirium-cli verify --hash `. + ## Receipts -| Run | Input | CID | Hash | Verify | -|-----|-------|-----|------|--------| -| 1 | data/run1.txt | _TODO_ | _TODO_ | _paste output_ | -| 2 | data/run2.txt | _TODO_ | _TODO_ | _paste output_ | +Signed by testnet key `GC3ADSZYQZWOQASTNZQ4PWA7GR6FAETSQBS4Q4EGZZXNZQYST3JXH5XT`, +tag `wave11-reproducible-notebook`. + +| Run | Input | CID | Record hash | +|-----|-------|-----|-------------| +| 1 | data/run1.txt | `QmdvnYaQEtqrQQ19hZ7hphbU6GAKknnvS9aMGezq5iMNVK` | `c5f1ee188d9180c8d63497d29c7f88f8798f722ed8212044264774dbd092809a` | +| 2 | data/run2.txt | `QmYgs3Ae89A7jFf9mkZYfk97UEg7gTBPB2E2TcDd5EyaYQ` | `d8428bfa58dd6b1879472dbf09d1c2577f449fcd949eafab0b3cc31d754334de` | + +Receipt files: `receipts/c5f1ee188d91.json`, `receipts/d8428bfa58dd.json`. -Tampered case (one input changed): _paste failing output_ +### Verify output (fresh clone) +``` +--- RUN 1 --- +OK: record matches files and passes nirium verify +--- RUN 2 --- +OK: record matches files and passes nirium verify +``` + +### Tampered cases +Appending a line to `data/run1.txt`: +``` +FAIL: files changed (expected c5f1ee188d9180c8d63497d29c7f88f8798f722ed8212044264774dbd092809a, got bfeab19880fb8c89cd13f7021203ae468abbd5684cadaf13e6ead4fadb248c3b) +``` +Appending a line to `results/run2.json`: +``` +FAIL: files changed (expected d8428bfa58dd6b1879472dbf09d1c2577f449fcd949eafab0b3cc31d754334de, got fab65ab10426f471132c0820f4eca4d16275efc460af561c4273242a1349a2b9) +``` ## What a receipt proves, and what it doesn't Proves: the record has not changed since it was anchored, and which key signed it. Does not prove: that the content is true or the analysis correct. `anchoredAt` is the Nirium node's clock, not a ledger time. + +Do not edit `run_analysis.py` after anchoring: its hash is part of each record.