@mikeargento/bitgraph-verify 1.25.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * bitgraph-epoch-genesis/1: the record an epoch's first BitGraph binds when the epoch opens with a Base write.
3
+ *
4
+ * cd packages/verify && npx tsc -p . && node --test dist/__tests__/epoch-genesis.test.js
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=epoch-genesis.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch-genesis.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/epoch-genesis.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * bitgraph-epoch-genesis/1: the record an epoch's first BitGraph binds when the epoch opens with a Base write.
3
+ *
4
+ * cd packages/verify && npx tsc -p . && node --test dist/__tests__/epoch-genesis.test.js
5
+ */
6
+ import { test } from "node:test";
7
+ import { strict as assert } from "node:assert";
8
+ import { sha256 } from "@noble/hashes/sha256";
9
+ import { EPOCH_GENESIS_FORMAT, checkEpochGenesis, epochGenesisCalldata, epochGenesisCalldataHex, epochGenesisFileText, epochIdOfCalldata, parseEpochGenesisFile, } from "../epoch-genesis.js";
10
+ const epochId = Buffer.from(Array.from({ length: 32 }, (_, i) => (i * 7 + 3) & 0xff)).toString("base64");
11
+ const writer = "0x" + "ab".repeat(20);
12
+ const txHash = "0x" + "cd".repeat(32);
13
+ const blockHash = "0x" + "ef".repeat(32);
14
+ const file = epochGenesisFileText({ epochId, chainId: 8453, writer, txHash, blockNumber: 52_000_000, blockHash, blockTimestamp: 1_790_000_000 });
15
+ function proofFor(text, over = {}) {
16
+ return {
17
+ version: "bitgraph/1",
18
+ artifact: { hashAlg: "sha256", digestB64: Buffer.from(sha256(new TextEncoder().encode(text))).toString("base64") },
19
+ commit: { nonceB64: "x", counter: "2", slotCounter: "1", epochId, atomic: true, ...over },
20
+ signer: { publicKeyB64: "k", signatureB64: "s" },
21
+ environment: { enforcement: "measured-tee", measurement: "m" },
22
+ };
23
+ }
24
+ test("calldata is the magic and the epoch id, and reads back", () => {
25
+ const data = epochGenesisCalldata(epochId);
26
+ assert.equal(data.length, 36);
27
+ assert.equal(Buffer.from(data.slice(0, 4)).toString(), "BGE1");
28
+ assert.equal(epochIdOfCalldata(data), epochId);
29
+ assert.equal(epochIdOfCalldata(epochGenesisCalldataHex(epochId)), epochId);
30
+ assert.equal(epochIdOfCalldata("0x"), null);
31
+ assert.equal(epochIdOfCalldata("0x" + "00".repeat(36)), null);
32
+ assert.throws(() => epochGenesisCalldata("short"));
33
+ });
34
+ test("the file round-trips and is strict", () => {
35
+ const g = parseEpochGenesisFile(file);
36
+ assert.ok(g);
37
+ assert.equal(g.format, EPOCH_GENESIS_FORMAT);
38
+ assert.equal(g.chain, "base-mainnet");
39
+ assert.equal(g.writer, writer);
40
+ assert.match(g.note, /mined in block 52000000/);
41
+ assert.equal(parseEpochGenesisFile(file.replace("base-mainnet", "base-sepolia")), null);
42
+ assert.equal(parseEpochGenesisFile(file.replace(txHash, "0x1234")), null);
43
+ assert.equal(parseEpochGenesisFile("{}"), null);
44
+ assert.equal(parseEpochGenesisFile("not json"), null);
45
+ });
46
+ test("the offline check: file against the epoch's first proof", () => {
47
+ assert.deepEqual(checkEpochGenesis({ file, proof: proofFor(file) }).reasons, []);
48
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file + " ") }).reasons.join(), /does not hash/);
49
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file, { counter: "9", slotCounter: "8" }) }).reasons.join(), /first BitGraph/);
50
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file, { epochId: "other" }) }).reasons.join(), /not of the epoch/);
51
+ });
52
+ test("the online check: the transaction and the block as Base reports them", () => {
53
+ const tx = { from: writer.toUpperCase().replace("0X", "0x"), to: writer, input: epochGenesisCalldataHex(epochId), blockHash, blockNumber: 52_000_000 };
54
+ const block = { hash: blockHash, number: 52_000_000, timestamp: 1_790_000_000 };
55
+ assert.equal(checkEpochGenesis({ file, proof: proofFor(file), tx, block }).ok, true);
56
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, input: "0x00" }, block }).reasons.join(), /carry this epoch/);
57
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, to: "0x" + "11".repeat(20) }, block }).reasons.join(), /self-addressed/);
58
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, blockHash: "0x" + "00".repeat(32) }, block }).reasons.join(), /not in the block/);
59
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx, block: { ...block, timestamp: 1 } }).reasons.join(), /block time/);
60
+ });
61
+ //# sourceMappingURL=epoch-genesis.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch-genesis.test.js","sourceRoot":"","sources":["../../src/__tests__/epoch-genesis.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,oBAAoB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,EAC5G,iBAAiB,EAAE,qBAAqB,GACzC,MAAM,qBAAqB,CAAC;AAG7B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzG,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,C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AI,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,YAAY,CAAC,CAAC;AACvI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { BitGraphProof } from "./types.js";
2
+ export declare const EPOCH_GENESIS_FORMAT: "bitgraph-epoch-genesis/1";
3
+ export declare const EPOCH_GENESIS_REQUEST_FORMAT: "bitgraph-epoch-genesis-request/1";
4
+ export declare const EPOCH_GENESIS_MAGIC = "BGE1";
5
+ export interface EpochGenesisFile {
6
+ format: typeof EPOCH_GENESIS_FORMAT;
7
+ epochId: string;
8
+ chain: "base-mainnet" | "base-sepolia";
9
+ chainId: 8453 | 84532;
10
+ /** The sending (and receiving) address, lowercase 0x hex: the ceiling writer's. */
11
+ writer: string;
12
+ txHash: string;
13
+ blockNumber: number;
14
+ blockHash: string;
15
+ blockTimestamp: number;
16
+ note: string;
17
+ }
18
+ /** "BGE1" || the 32 raw bytes of the epoch id: what the genesis transaction carries. */
19
+ export declare function epochGenesisCalldata(epochId: string): Uint8Array;
20
+ /** The calldata as 0x hex, as a node reports a transaction's input. */
21
+ export declare function epochGenesisCalldataHex(epochId: string): string;
22
+ /** The epoch id carried by calldata, or null when the bytes are not a genesis. */
23
+ export declare function epochIdOfCalldata(input: string | Uint8Array): string | null;
24
+ /** The file's text, byte for byte, as the writer makes it and the epoch's first BitGraph binds it. */
25
+ export declare function epochGenesisFileText(f: Omit<EpochGenesisFile, "format" | "chain" | "note">): string;
26
+ /** Strict: the format, a 32-byte epoch id, a known chain, hex hashes, integers. Null otherwise. */
27
+ export declare function parseEpochGenesisFile(text: string): EpochGenesisFile | null;
28
+ /** What a node says about the transaction, from eth_getTransactionByHash. */
29
+ export interface EpochGenesisTx {
30
+ from: string;
31
+ to: string | null;
32
+ input: string;
33
+ blockHash: string | null;
34
+ blockNumber: number | null;
35
+ }
36
+ /** What a node says about the block, from eth_getBlockByHash. */
37
+ export interface EpochGenesisBlock {
38
+ hash: string;
39
+ number: number;
40
+ timestamp: number;
41
+ }
42
+ export interface EpochGenesisCheck {
43
+ ok: boolean;
44
+ reasons: string[];
45
+ genesis: EpochGenesisFile | null;
46
+ }
47
+ /**
48
+ * Check a genesis record against the epoch's first BitGraph and, when given, against what Base says.
49
+ *
50
+ * The file must hash to the proof's digest; the proof must be the epoch's first (counts 1 and 2) and name the
51
+ * file's epoch; the transaction, when supplied, must be the writer's self-addressed transaction carrying this
52
+ * epoch's id, mined in the block the file names; the block, when supplied, must be that block with that time.
53
+ * Without `tx` and `block` only the file and the proof are checked (offline).
54
+ */
55
+ export declare function checkEpochGenesis(args: {
56
+ file: string;
57
+ proof: BitGraphProof;
58
+ tx?: EpochGenesisTx | null;
59
+ block?: EpochGenesisBlock | null;
60
+ }): EpochGenesisCheck;
61
+ //# sourceMappingURL=epoch-genesis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch-genesis.d.ts","sourceRoot":"","sources":["../src/epoch-genesis.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAG,0BAAmC,CAAC;AACxE,eAAO,MAAM,4BAA4B,EAAG,kCAA2C,CAAC;AACxF,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,oBAAoB,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,cAAc,GAAG,cAAc,CAAC;IACvC,OAAO,EAAE,IAAI,GAAG,KAAK,CAAC;IACtB,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CA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AAC;IAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAAE,GAAG,iBAAiB,CAwB/J"}
@@ -0,0 +1,171 @@
1
+ // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
+ /**
3
+ * bitgraph-epoch-genesis/1: an epoch opens with a write to Base, not a read of it.
4
+ *
5
+ * A block read bound as an epoch's first BitGraph proves the epoch began after that block, but the host chooses
6
+ * the block, so an old one makes the floor loose, and nothing in the proofs says how old. With a genesis
7
+ * transaction the choice is gone. The host puts the new epoch's id in a Base transaction from the ceiling writer's
8
+ * address, waits for it to be mined, and binds a record of the mined transaction as the epoch's first BitGraph.
9
+ *
10
+ * - The transaction carries the epoch id, which is derived from the epoch's key, so the transaction could not be
11
+ * made before the key existed: the key is older than the block that holds the transaction.
12
+ * - BitGraph 1 binds the mined transaction, so it could not be made before that block: every BitGraph of the
13
+ * epoch is younger than that block.
14
+ *
15
+ * Epochs therefore order by their genesis blocks on Base alone, and the transactions are a public list of every
16
+ * epoch the writer opened. Calldata is "BGE1" followed by the 32 raw bytes of the epoch id. The record is a small
17
+ * JSON file whose SHA-256 BitGraph 1 binds; this module makes, parses and checks it.
18
+ */
19
+ import { sha256 } from "@noble/hashes/sha256";
20
+ export const EPOCH_GENESIS_FORMAT = "bitgraph-epoch-genesis/1";
21
+ export const EPOCH_GENESIS_REQUEST_FORMAT = "bitgraph-epoch-genesis-request/1";
22
+ export const EPOCH_GENESIS_MAGIC = "BGE1";
23
+ const enc = new TextEncoder();
24
+ function b64ToBytes(s) {
25
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(s) || s.length % 4 !== 0)
26
+ return null;
27
+ const bin = typeof atob === "function" ? atob(s) : Buffer.from(s, "base64").toString("binary");
28
+ const out = new Uint8Array(bin.length);
29
+ for (let i = 0; i < bin.length; i++)
30
+ out[i] = bin.charCodeAt(i);
31
+ return out;
32
+ }
33
+ function bytesToB64(u) {
34
+ let bin = "";
35
+ for (const x of u)
36
+ bin += String.fromCharCode(x);
37
+ return typeof btoa === "function" ? btoa(bin) : Buffer.from(bin, "binary").toString("base64");
38
+ }
39
+ const hex = (u) => Array.from(u, (b) => b.toString(16).padStart(2, "0")).join("");
40
+ /** "BGE1" || the 32 raw bytes of the epoch id: what the genesis transaction carries. */
41
+ export function epochGenesisCalldata(epochId) {
42
+ const id = b64ToBytes(epochId);
43
+ if (id === null || id.length !== 32)
44
+ throw new TypeError("an epoch id is 32 bytes in standard base64");
45
+ const out = new Uint8Array(4 + 32);
46
+ out.set(enc.encode(EPOCH_GENESIS_MAGIC), 0);
47
+ out.set(id, 4);
48
+ return out;
49
+ }
50
+ /** The calldata as 0x hex, as a node reports a transaction's input. */
51
+ export function epochGenesisCalldataHex(epochId) {
52
+ return "0x" + hex(epochGenesisCalldata(epochId));
53
+ }
54
+ /** The epoch id carried by calldata, or null when the bytes are not a genesis. */
55
+ export function epochIdOfCalldata(input) {
56
+ let bytes;
57
+ if (typeof input === "string") {
58
+ const h = input.startsWith("0x") ? input.slice(2) : input;
59
+ if (!/^[0-9a-fA-F]*$/.test(h) || h.length % 2 !== 0)
60
+ return null;
61
+ bytes = new Uint8Array(h.length / 2);
62
+ for (let i = 0; i < bytes.length; i++)
63
+ bytes[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
64
+ }
65
+ else
66
+ bytes = input;
67
+ if (bytes.length !== 36)
68
+ return null;
69
+ for (let i = 0; i < 4; i++)
70
+ if (bytes[i] !== EPOCH_GENESIS_MAGIC.charCodeAt(i))
71
+ return null;
72
+ return bytesToB64(bytes.slice(4));
73
+ }
74
+ const CHAIN_NAMES = { 8453: "base-mainnet", 84532: "base-sepolia" };
75
+ /** The file's text, byte for byte, as the writer makes it and the epoch's first BitGraph binds it. */
76
+ export function epochGenesisFileText(f) {
77
+ const chain = CHAIN_NAMES[f.chainId];
78
+ const body = {
79
+ format: EPOCH_GENESIS_FORMAT,
80
+ epochId: f.epochId,
81
+ chain,
82
+ chainId: f.chainId,
83
+ writer: f.writer.toLowerCase(),
84
+ txHash: f.txHash.toLowerCase(),
85
+ blockNumber: f.blockNumber,
86
+ blockHash: f.blockHash.toLowerCase(),
87
+ blockTimestamp: f.blockTimestamp,
88
+ note: `The first BitGraph of this epoch. Base transaction ${f.txHash.toLowerCase()} carries this epoch's id and was mined in block ${f.blockNumber}, so this epoch's key existed before that block and every BitGraph of this epoch was made after it.`,
89
+ };
90
+ return JSON.stringify(body, null, 2) + "\n";
91
+ }
92
+ /** Strict: the format, a 32-byte epoch id, a known chain, hex hashes, integers. Null otherwise. */
93
+ export function parseEpochGenesisFile(text) {
94
+ let o;
95
+ try {
96
+ o = JSON.parse(text);
97
+ }
98
+ catch {
99
+ return null;
100
+ }
101
+ if (!o || typeof o !== "object" || o["format"] !== EPOCH_GENESIS_FORMAT)
102
+ return null;
103
+ const epochId = o["epochId"];
104
+ if (typeof epochId !== "string" || b64ToBytes(epochId)?.length !== 32)
105
+ return null;
106
+ const chainId = o["chainId"];
107
+ if (chainId !== 8453 && chainId !== 84532)
108
+ return null;
109
+ if (o["chain"] !== CHAIN_NAMES[chainId])
110
+ return null;
111
+ const writer = o["writer"], txHash = o["txHash"], blockHash = o["blockHash"];
112
+ if (typeof writer !== "string" || !/^0x[0-9a-f]{40}$/.test(writer))
113
+ return null;
114
+ if (typeof txHash !== "string" || !/^0x[0-9a-f]{64}$/.test(txHash))
115
+ return null;
116
+ if (typeof blockHash !== "string" || !/^0x[0-9a-f]{64}$/.test(blockHash))
117
+ return null;
118
+ const blockNumber = o["blockNumber"], blockTimestamp = o["blockTimestamp"];
119
+ if (!Number.isSafeInteger(blockNumber) || blockNumber < 0)
120
+ return null;
121
+ if (!Number.isSafeInteger(blockTimestamp) || blockTimestamp < 0)
122
+ return null;
123
+ const note = typeof o["note"] === "string" ? o["note"] : "";
124
+ return { format: EPOCH_GENESIS_FORMAT, epochId, chain: CHAIN_NAMES[chainId], chainId, writer, txHash, blockNumber: blockNumber, blockHash, blockTimestamp: blockTimestamp, note };
125
+ }
126
+ /**
127
+ * Check a genesis record against the epoch's first BitGraph and, when given, against what Base says.
128
+ *
129
+ * The file must hash to the proof's digest; the proof must be the epoch's first (counts 1 and 2) and name the
130
+ * file's epoch; the transaction, when supplied, must be the writer's self-addressed transaction carrying this
131
+ * epoch's id, mined in the block the file names; the block, when supplied, must be that block with that time.
132
+ * Without `tx` and `block` only the file and the proof are checked (offline).
133
+ */
134
+ export function checkEpochGenesis(args) {
135
+ const reasons = [];
136
+ const genesis = parseEpochGenesisFile(args.file);
137
+ if (!genesis)
138
+ return { ok: false, reasons: ["the file is not a bitgraph-epoch-genesis/1 record"], genesis: null };
139
+ const digest = bytesToB64(sha256(enc.encode(args.file)));
140
+ if (digest !== args.proof.artifact?.digestB64)
141
+ reasons.push("the file does not hash to the proof's digest");
142
+ const commit = args.proof.commit;
143
+ if (commit.epochId !== genesis.epochId)
144
+ reasons.push("the proof is not of the epoch the file names");
145
+ if (commit.slotCounter !== "1" || commit.counter !== "2")
146
+ reasons.push("the proof is not the epoch's first BitGraph (counts 1 and 2)");
147
+ if (args.tx) {
148
+ const t = args.tx;
149
+ if (t.from.toLowerCase() !== genesis.writer)
150
+ reasons.push("the transaction was not sent by the writer the file names");
151
+ if ((t.to ?? "").toLowerCase() !== genesis.writer)
152
+ reasons.push("the transaction is not self-addressed to the writer");
153
+ if (t.input.toLowerCase() !== epochGenesisCalldataHex(genesis.epochId))
154
+ reasons.push("the transaction does not carry this epoch's id");
155
+ if ((t.blockHash ?? "").toLowerCase() !== genesis.blockHash)
156
+ reasons.push("the transaction is not in the block the file names");
157
+ if (t.blockNumber !== null && t.blockNumber !== genesis.blockNumber)
158
+ reasons.push("the transaction's block number is not the one the file names");
159
+ }
160
+ if (args.block) {
161
+ const b = args.block;
162
+ if (b.hash.toLowerCase() !== genesis.blockHash)
163
+ reasons.push("Base's block hash differs from the file's");
164
+ if (b.number !== genesis.blockNumber)
165
+ reasons.push("Base's block number differs from the file's");
166
+ if (b.timestamp !== genesis.blockTimestamp)
167
+ reasons.push("Base's block time differs from the file's");
168
+ }
169
+ return { ok: reasons.length === 0, reasons, genesis };
170
+ }
171
+ //# sourceMappingURL=epoch-genesis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch-genesis.js","sourceRoot":"","sources":["../src/epoch-genesis.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAAmC,CAAC;AACxE,MAAM,CAAC,MAAM,4BAA4B,GAAG,kCAA2C,CAAC;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAgB1C,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAE9B,SAAS,UAAU,CAAC,CAAS;IAC3B,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,MAAM,GAAG,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/F,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,CAAa;IAC/B,IAAI,GAAG,GAAG,EAAE,CAAC;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C,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,uBAAuB,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QACvI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QAChI,IAAI,CAAC,CAAC,WAAW,KAAK,IAAI,IAAI,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IACpJ,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACrB,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1G,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAClG,IAAI,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC,cAAc;YAAE,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACxD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -67,4 +67,6 @@ export type { RpcBlockHeader } from "./ceiling.js";
67
67
  export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
68
68
  export type { PublishedMeasurement } from "./measurements.js";
69
69
  export type { BitGraphExport, ExportClaim, ExportClaimResult, ExportLookups, ExportVerifyOptions, ExportVerifyResult } from "./export.js";
70
+ export { EPOCH_GENESIS_FORMAT, EPOCH_GENESIS_REQUEST_FORMAT, EPOCH_GENESIS_MAGIC, epochGenesisCalldata, epochGenesisCalldataHex, epochIdOfCalldata, epochGenesisFileText, parseEpochGenesisFile, checkEpochGenesis } from "./epoch-genesis.js";
71
+ export type { EpochGenesisFile, EpochGenesisTx, EpochGenesisBlock, EpochGenesisCheck } from "./epoch-genesis.js";
70
72
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7G,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAA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AAe,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG/H,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACxJ,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1I,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/O,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -65,4 +65,6 @@ export { baseTimeIsBound, BASE_STAMP_TOLERANCE_SECONDS } from "./ceiling.js";
65
65
  export { checkFloorHeader, floorTimeIsBound, onBaseSchedule, headerRlpFromRpc, BASE_MAINNET_GENESIS_TIME, BASE_BLOCK_TIME_SECONDS } from "./ceiling.js";
66
66
  /* The enclave images BitGraph has published: the default measurement policy (SPEC section 16). */
67
67
  export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
68
+ /* bitgraph-epoch-genesis/1 (2026-10-23): an epoch opens with a Base write carrying its id; the epoch's first BitGraph binds the mined transaction's record. */
69
+ export { EPOCH_GENESIS_FORMAT, EPOCH_GENESIS_REQUEST_FORMAT, EPOCH_GENESIS_MAGIC, epochGenesisCalldata, epochGenesisCalldataHex, epochIdOfCalldata, epochGenesisFileText, parseEpochGenesisFile, checkEpochGenesis } from "./epoch-genesis.js";
68
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,GAGd,MAAM,aAAa,CAAC;AAiBrB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG7G,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvF,qEAAqE;AACrE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5D,iHAAiH;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,6GAA6G;AAC7G,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,iBAAiB,EAAwB,MAAM,kBAAkB,CAAC;AAInM,gFAAgF;AAChF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB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AC7F,iBAAiB,EAAE,WAAW,EAAE,0BAA0B,GAC3D,MAAM,kBAAkB,CAAC;AAG1B,yHAAyH;AACzH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC7E,qFAAqF;AACrF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAExJ,kGAAkG;AAClG,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG1G,+JAA+J;AAC/J,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeargento/bitgraph-verify",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "description": "Offline verification of BitGraph proofs: the enclave signature, its attestation and the two counts. Permissionless by design.",
5
5
  "keywords": [
6
6
  "bitgraph",
@@ -0,0 +1,71 @@
1
+ /**
2
+ * bitgraph-epoch-genesis/1: the record an epoch's first BitGraph binds when the epoch opens with a Base write.
3
+ *
4
+ * cd packages/verify && npx tsc -p . && node --test dist/__tests__/epoch-genesis.test.js
5
+ */
6
+
7
+ import { test } from "node:test";
8
+ import { strict as assert } from "node:assert";
9
+ import { sha256 } from "@noble/hashes/sha256";
10
+ import {
11
+ EPOCH_GENESIS_FORMAT, checkEpochGenesis, epochGenesisCalldata, epochGenesisCalldataHex, epochGenesisFileText,
12
+ epochIdOfCalldata, parseEpochGenesisFile,
13
+ } from "../epoch-genesis.js";
14
+ import type { BitGraphProof } from "../types.js";
15
+
16
+ const epochId = Buffer.from(Array.from({ length: 32 }, (_, i) => (i * 7 + 3) & 0xff)).toString("base64");
17
+ const writer = "0x" + "ab".repeat(20);
18
+ const txHash = "0x" + "cd".repeat(32);
19
+ const blockHash = "0x" + "ef".repeat(32);
20
+ const file = epochGenesisFileText({ epochId, chainId: 8453, writer, txHash, blockNumber: 52_000_000, blockHash, blockTimestamp: 1_790_000_000 });
21
+
22
+ function proofFor(text: string, over: Partial<{ counter: string; slotCounter: string; epochId: string }> = {}): BitGraphProof {
23
+ return {
24
+ version: "bitgraph/1",
25
+ artifact: { hashAlg: "sha256", digestB64: Buffer.from(sha256(new TextEncoder().encode(text))).toString("base64") },
26
+ commit: { nonceB64: "x", counter: "2", slotCounter: "1", epochId, atomic: true, ...over },
27
+ signer: { publicKeyB64: "k", signatureB64: "s" },
28
+ environment: { enforcement: "measured-tee", measurement: "m" },
29
+ } as unknown as BitGraphProof;
30
+ }
31
+
32
+ test("calldata is the magic and the epoch id, and reads back", () => {
33
+ const data = epochGenesisCalldata(epochId);
34
+ assert.equal(data.length, 36);
35
+ assert.equal(Buffer.from(data.slice(0, 4)).toString(), "BGE1");
36
+ assert.equal(epochIdOfCalldata(data), epochId);
37
+ assert.equal(epochIdOfCalldata(epochGenesisCalldataHex(epochId)), epochId);
38
+ assert.equal(epochIdOfCalldata("0x"), null);
39
+ assert.equal(epochIdOfCalldata("0x" + "00".repeat(36)), null);
40
+ assert.throws(() => epochGenesisCalldata("short"));
41
+ });
42
+
43
+ test("the file round-trips and is strict", () => {
44
+ const g = parseEpochGenesisFile(file);
45
+ assert.ok(g);
46
+ assert.equal(g.format, EPOCH_GENESIS_FORMAT);
47
+ assert.equal(g.chain, "base-mainnet");
48
+ assert.equal(g.writer, writer);
49
+ assert.match(g.note, /mined in block 52000000/);
50
+ assert.equal(parseEpochGenesisFile(file.replace("base-mainnet", "base-sepolia")), null);
51
+ assert.equal(parseEpochGenesisFile(file.replace(txHash, "0x1234")), null);
52
+ assert.equal(parseEpochGenesisFile("{}"), null);
53
+ assert.equal(parseEpochGenesisFile("not json"), null);
54
+ });
55
+
56
+ test("the offline check: file against the epoch's first proof", () => {
57
+ assert.deepEqual(checkEpochGenesis({ file, proof: proofFor(file) }).reasons, []);
58
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file + " ") }).reasons.join(), /does not hash/);
59
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file, { counter: "9", slotCounter: "8" }) }).reasons.join(), /first BitGraph/);
60
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file, { epochId: "other" }) }).reasons.join(), /not of the epoch/);
61
+ });
62
+
63
+ test("the online check: the transaction and the block as Base reports them", () => {
64
+ const tx = { from: writer.toUpperCase().replace("0X", "0x"), to: writer, input: epochGenesisCalldataHex(epochId), blockHash, blockNumber: 52_000_000 };
65
+ const block = { hash: blockHash, number: 52_000_000, timestamp: 1_790_000_000 };
66
+ assert.equal(checkEpochGenesis({ file, proof: proofFor(file), tx, block }).ok, true);
67
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, input: "0x00" }, block }).reasons.join(), /carry this epoch/);
68
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, to: "0x" + "11".repeat(20) }, block }).reasons.join(), /self-addressed/);
69
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx: { ...tx, blockHash: "0x" + "00".repeat(32) }, block }).reasons.join(), /not in the block/);
70
+ assert.match(checkEpochGenesis({ file, proof: proofFor(file), tx, block: { ...block, timestamp: 1 } }).reasons.join(), /block time/);
71
+ });
@@ -0,0 +1,184 @@
1
+ // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
+
3
+ /**
4
+ * bitgraph-epoch-genesis/1: an epoch opens with a write to Base, not a read of it.
5
+ *
6
+ * A block read bound as an epoch's first BitGraph proves the epoch began after that block, but the host chooses
7
+ * the block, so an old one makes the floor loose, and nothing in the proofs says how old. With a genesis
8
+ * transaction the choice is gone. The host puts the new epoch's id in a Base transaction from the ceiling writer's
9
+ * address, waits for it to be mined, and binds a record of the mined transaction as the epoch's first BitGraph.
10
+ *
11
+ * - The transaction carries the epoch id, which is derived from the epoch's key, so the transaction could not be
12
+ * made before the key existed: the key is older than the block that holds the transaction.
13
+ * - BitGraph 1 binds the mined transaction, so it could not be made before that block: every BitGraph of the
14
+ * epoch is younger than that block.
15
+ *
16
+ * Epochs therefore order by their genesis blocks on Base alone, and the transactions are a public list of every
17
+ * epoch the writer opened. Calldata is "BGE1" followed by the 32 raw bytes of the epoch id. The record is a small
18
+ * JSON file whose SHA-256 BitGraph 1 binds; this module makes, parses and checks it.
19
+ */
20
+
21
+ import { sha256 } from "@noble/hashes/sha256";
22
+ import type { BitGraphProof } from "./types.js";
23
+
24
+ export const EPOCH_GENESIS_FORMAT = "bitgraph-epoch-genesis/1" as const;
25
+ export const EPOCH_GENESIS_REQUEST_FORMAT = "bitgraph-epoch-genesis-request/1" as const;
26
+ export const EPOCH_GENESIS_MAGIC = "BGE1";
27
+
28
+ export interface EpochGenesisFile {
29
+ format: typeof EPOCH_GENESIS_FORMAT;
30
+ epochId: string;
31
+ chain: "base-mainnet" | "base-sepolia";
32
+ chainId: 8453 | 84532;
33
+ /** The sending (and receiving) address, lowercase 0x hex: the ceiling writer's. */
34
+ writer: string;
35
+ txHash: string;
36
+ blockNumber: number;
37
+ blockHash: string;
38
+ blockTimestamp: number;
39
+ note: string;
40
+ }
41
+
42
+ const enc = new TextEncoder();
43
+
44
+ function b64ToBytes(s: string): Uint8Array | null {
45
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(s) || s.length % 4 !== 0) return null;
46
+ const bin = typeof atob === "function" ? atob(s) : Buffer.from(s, "base64").toString("binary");
47
+ const out = new Uint8Array(bin.length);
48
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
49
+ return out;
50
+ }
51
+
52
+ function bytesToB64(u: Uint8Array): string {
53
+ let bin = "";
54
+ for (const x of u) bin += String.fromCharCode(x);
55
+ return typeof btoa === "function" ? btoa(bin) : Buffer.from(bin, "binary").toString("base64");
56
+ }
57
+
58
+ const hex = (u: Uint8Array): string => Array.from(u, (b) => b.toString(16).padStart(2, "0")).join("");
59
+
60
+ /** "BGE1" || the 32 raw bytes of the epoch id: what the genesis transaction carries. */
61
+ export function epochGenesisCalldata(epochId: string): Uint8Array {
62
+ const id = b64ToBytes(epochId);
63
+ if (id === null || id.length !== 32) throw new TypeError("an epoch id is 32 bytes in standard base64");
64
+ const out = new Uint8Array(4 + 32);
65
+ out.set(enc.encode(EPOCH_GENESIS_MAGIC), 0);
66
+ out.set(id, 4);
67
+ return out;
68
+ }
69
+
70
+ /** The calldata as 0x hex, as a node reports a transaction's input. */
71
+ export function epochGenesisCalldataHex(epochId: string): string {
72
+ return "0x" + hex(epochGenesisCalldata(epochId));
73
+ }
74
+
75
+ /** The epoch id carried by calldata, or null when the bytes are not a genesis. */
76
+ export function epochIdOfCalldata(input: string | Uint8Array): string | null {
77
+ let bytes: Uint8Array;
78
+ if (typeof input === "string") {
79
+ const h = input.startsWith("0x") ? input.slice(2) : input;
80
+ if (!/^[0-9a-fA-F]*$/.test(h) || h.length % 2 !== 0) return null;
81
+ bytes = new Uint8Array(h.length / 2);
82
+ for (let i = 0; i < bytes.length; i++) bytes[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
83
+ } else bytes = input;
84
+ if (bytes.length !== 36) return null;
85
+ for (let i = 0; i < 4; i++) if (bytes[i] !== EPOCH_GENESIS_MAGIC.charCodeAt(i)) return null;
86
+ return bytesToB64(bytes.slice(4));
87
+ }
88
+
89
+ const CHAIN_NAMES = { 8453: "base-mainnet", 84532: "base-sepolia" } as const;
90
+
91
+ /** The file's text, byte for byte, as the writer makes it and the epoch's first BitGraph binds it. */
92
+ export function epochGenesisFileText(f: Omit<EpochGenesisFile, "format" | "chain" | "note">): string {
93
+ const chain = CHAIN_NAMES[f.chainId];
94
+ const body: EpochGenesisFile = {
95
+ format: EPOCH_GENESIS_FORMAT,
96
+ epochId: f.epochId,
97
+ chain,
98
+ chainId: f.chainId,
99
+ writer: f.writer.toLowerCase(),
100
+ txHash: f.txHash.toLowerCase(),
101
+ blockNumber: f.blockNumber,
102
+ blockHash: f.blockHash.toLowerCase(),
103
+ blockTimestamp: f.blockTimestamp,
104
+ note: `The first BitGraph of this epoch. Base transaction ${f.txHash.toLowerCase()} carries this epoch's id and was mined in block ${f.blockNumber}, so this epoch's key existed before that block and every BitGraph of this epoch was made after it.`,
105
+ };
106
+ return JSON.stringify(body, null, 2) + "\n";
107
+ }
108
+
109
+ /** Strict: the format, a 32-byte epoch id, a known chain, hex hashes, integers. Null otherwise. */
110
+ export function parseEpochGenesisFile(text: string): EpochGenesisFile | null {
111
+ let o: Record<string, unknown>;
112
+ try { o = JSON.parse(text) as Record<string, unknown>; } catch { return null; }
113
+ if (!o || typeof o !== "object" || o["format"] !== EPOCH_GENESIS_FORMAT) return null;
114
+ const epochId = o["epochId"];
115
+ if (typeof epochId !== "string" || b64ToBytes(epochId)?.length !== 32) return null;
116
+ const chainId = o["chainId"];
117
+ if (chainId !== 8453 && chainId !== 84532) return null;
118
+ if (o["chain"] !== CHAIN_NAMES[chainId]) return null;
119
+ const writer = o["writer"], txHash = o["txHash"], blockHash = o["blockHash"];
120
+ if (typeof writer !== "string" || !/^0x[0-9a-f]{40}$/.test(writer)) return null;
121
+ if (typeof txHash !== "string" || !/^0x[0-9a-f]{64}$/.test(txHash)) return null;
122
+ if (typeof blockHash !== "string" || !/^0x[0-9a-f]{64}$/.test(blockHash)) return null;
123
+ const blockNumber = o["blockNumber"], blockTimestamp = o["blockTimestamp"];
124
+ if (!Number.isSafeInteger(blockNumber) || (blockNumber as number) < 0) return null;
125
+ if (!Number.isSafeInteger(blockTimestamp) || (blockTimestamp as number) < 0) return null;
126
+ const note = typeof o["note"] === "string" ? o["note"] : "";
127
+ return { format: EPOCH_GENESIS_FORMAT, epochId, chain: CHAIN_NAMES[chainId], chainId, writer, txHash, blockNumber: blockNumber as number, blockHash, blockTimestamp: blockTimestamp as number, note };
128
+ }
129
+
130
+ /** What a node says about the transaction, from eth_getTransactionByHash. */
131
+ export interface EpochGenesisTx {
132
+ from: string;
133
+ to: string | null;
134
+ input: string;
135
+ blockHash: string | null;
136
+ blockNumber: number | null;
137
+ }
138
+
139
+ /** What a node says about the block, from eth_getBlockByHash. */
140
+ export interface EpochGenesisBlock {
141
+ hash: string;
142
+ number: number;
143
+ timestamp: number;
144
+ }
145
+
146
+ export interface EpochGenesisCheck {
147
+ ok: boolean;
148
+ reasons: string[];
149
+ genesis: EpochGenesisFile | null;
150
+ }
151
+
152
+ /**
153
+ * Check a genesis record against the epoch's first BitGraph and, when given, against what Base says.
154
+ *
155
+ * The file must hash to the proof's digest; the proof must be the epoch's first (counts 1 and 2) and name the
156
+ * file's epoch; the transaction, when supplied, must be the writer's self-addressed transaction carrying this
157
+ * epoch's id, mined in the block the file names; the block, when supplied, must be that block with that time.
158
+ * Without `tx` and `block` only the file and the proof are checked (offline).
159
+ */
160
+ export function checkEpochGenesis(args: { file: string; proof: BitGraphProof; tx?: EpochGenesisTx | null; block?: EpochGenesisBlock | null }): EpochGenesisCheck {
161
+ const reasons: string[] = [];
162
+ const genesis = parseEpochGenesisFile(args.file);
163
+ if (!genesis) return { ok: false, reasons: ["the file is not a bitgraph-epoch-genesis/1 record"], genesis: null };
164
+ const digest = bytesToB64(sha256(enc.encode(args.file)));
165
+ if (digest !== args.proof.artifact?.digestB64) reasons.push("the file does not hash to the proof's digest");
166
+ const commit = args.proof.commit as { counter?: string; slotCounter?: string; epochId?: string };
167
+ if (commit.epochId !== genesis.epochId) reasons.push("the proof is not of the epoch the file names");
168
+ if (commit.slotCounter !== "1" || commit.counter !== "2") reasons.push("the proof is not the epoch's first BitGraph (counts 1 and 2)");
169
+ if (args.tx) {
170
+ const t = args.tx;
171
+ if (t.from.toLowerCase() !== genesis.writer) reasons.push("the transaction was not sent by the writer the file names");
172
+ if ((t.to ?? "").toLowerCase() !== genesis.writer) reasons.push("the transaction is not self-addressed to the writer");
173
+ if (t.input.toLowerCase() !== epochGenesisCalldataHex(genesis.epochId)) reasons.push("the transaction does not carry this epoch's id");
174
+ if ((t.blockHash ?? "").toLowerCase() !== genesis.blockHash) reasons.push("the transaction is not in the block the file names");
175
+ if (t.blockNumber !== null && t.blockNumber !== genesis.blockNumber) reasons.push("the transaction's block number is not the one the file names");
176
+ }
177
+ if (args.block) {
178
+ const b = args.block;
179
+ if (b.hash.toLowerCase() !== genesis.blockHash) reasons.push("Base's block hash differs from the file's");
180
+ if (b.number !== genesis.blockNumber) reasons.push("Base's block number differs from the file's");
181
+ if (b.timestamp !== genesis.blockTimestamp) reasons.push("Base's block time differs from the file's");
182
+ }
183
+ return { ok: reasons.length === 0, reasons, genesis };
184
+ }
package/src/index.ts CHANGED
@@ -207,3 +207,6 @@ export type { RpcBlockHeader } from "./ceiling.js";
207
207
  export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
208
208
  export type { PublishedMeasurement } from "./measurements.js";
209
209
  export type { BitGraphExport, ExportClaim, ExportClaimResult, ExportLookups, ExportVerifyOptions, ExportVerifyResult } from "./export.js";
210
+ /* bitgraph-epoch-genesis/1 (2026-10-23): an epoch opens with a Base write carrying its id; the epoch's first BitGraph binds the mined transaction's record. */
211
+ export { EPOCH_GENESIS_FORMAT, EPOCH_GENESIS_REQUEST_FORMAT, EPOCH_GENESIS_MAGIC, epochGenesisCalldata, epochGenesisCalldataHex, epochIdOfCalldata, epochGenesisFileText, parseEpochGenesisFile, checkEpochGenesis } from "./epoch-genesis.js";
212
+ export type { EpochGenesisFile, EpochGenesisTx, EpochGenesisBlock, EpochGenesisCheck } from "./epoch-genesis.js";