@mikeargento/bitgraph-verify 1.13.1 → 1.15.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.
- package/README.md +1 -1
- package/dist/__tests__/carrier.test.js +19 -0
- package/dist/__tests__/carrier.test.js.map +1 -1
- package/dist/__tests__/carrier2.test.d.ts +2 -0
- package/dist/__tests__/carrier2.test.d.ts.map +1 -0
- package/dist/__tests__/carrier2.test.js +172 -0
- package/dist/__tests__/carrier2.test.js.map +1 -0
- package/dist/__tests__/ceiling.test.d.ts +8 -0
- package/dist/__tests__/ceiling.test.d.ts.map +1 -0
- package/dist/__tests__/ceiling.test.js +247 -0
- package/dist/__tests__/ceiling.test.js.map +1 -0
- package/dist/__tests__/settlement.test.d.ts +12 -0
- package/dist/__tests__/settlement.test.d.ts.map +1 -0
- package/dist/__tests__/settlement.test.js +185 -0
- package/dist/__tests__/settlement.test.js.map +1 -0
- package/dist/carrier-assemble.d.ts +33 -0
- package/dist/carrier-assemble.d.ts.map +1 -0
- package/dist/carrier-assemble.js +57 -0
- package/dist/carrier-assemble.js.map +1 -0
- package/dist/carrier-verify.d.ts +47 -1
- package/dist/carrier-verify.d.ts.map +1 -1
- package/dist/carrier-verify.js +292 -53
- package/dist/carrier-verify.js.map +1 -1
- package/dist/carrier.d.ts +93 -3
- package/dist/carrier.d.ts.map +1 -1
- package/dist/carrier.js +144 -19
- package/dist/carrier.js.map +1 -1
- package/dist/ceiling-evm.d.ts +49 -0
- package/dist/ceiling-evm.d.ts.map +1 -0
- package/dist/ceiling-evm.js +331 -0
- package/dist/ceiling-evm.js.map +1 -0
- package/dist/ceiling-trie.d.ts +9 -0
- package/dist/ceiling-trie.d.ts.map +1 -0
- package/dist/ceiling-trie.js +113 -0
- package/dist/ceiling-trie.js.map +1 -0
- package/dist/ceiling.d.ts +123 -0
- package/dist/ceiling.d.ts.map +1 -0
- package/dist/ceiling.js +247 -0
- package/dist/ceiling.js.map +1 -0
- package/dist/fuse-member.js +2 -2
- package/dist/fuse-member.js.map +1 -1
- package/dist/fuse-verify.js +3 -3
- package/dist/fuse-verify.js.map +1 -1
- package/dist/fuse.d.ts +34 -2
- package/dist/fuse.d.ts.map +1 -1
- package/dist/fuse.js +83 -6
- package/dist/fuse.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/nitro.d.ts +128 -0
- package/dist/nitro.d.ts.map +1 -0
- package/dist/nitro.js +551 -0
- package/dist/nitro.js.map +1 -0
- package/dist/settlement.d.ts +114 -0
- package/dist/settlement.d.ts.map +1 -0
- package/dist/settlement.js +194 -0
- package/dist/settlement.js.map +1 -0
- package/package.json +2 -1
- package/src/__tests__/carrier.test.ts +18 -0
- package/src/__tests__/carrier2.test.ts +193 -0
- package/src/__tests__/ceiling.test.ts +281 -0
- package/src/__tests__/fixtures/carrier2/ceiling-26088459.witness.json +1 -0
- package/src/__tests__/fixtures/carrier2/ceiling-4548.anchor.json +1 -0
- package/src/__tests__/fixtures/carrier2/demo4546.ceiling.json +106 -0
- package/src/__tests__/fixtures/carrier2/demo4546.proof.json +47 -0
- package/src/__tests__/fixtures/carrier2/demo4546.txt +29 -0
- package/src/__tests__/fixtures/carrier2/floor-26088457.witness.json +1 -0
- package/src/__tests__/fixtures/carrier2/floor-4542.anchor.json +1 -0
- package/src/__tests__/fixtures/ceiling/floor-26037892.header.hex +1 -0
- package/src/__tests__/fixtures/settlement/pointer-51979918-tx1.json +39 -0
- package/src/__tests__/fixtures/settlement/pointer-51979918.json +69 -0
- package/src/__tests__/settlement.test.ts +215 -0
- package/src/carrier-assemble.ts +74 -0
- package/src/carrier-verify.ts +328 -47
- package/src/carrier.ts +174 -18
- package/src/ceiling-evm.ts +326 -0
- package/src/ceiling-trie.ts +112 -0
- package/src/ceiling.ts +333 -0
- package/src/fuse-member.ts +2 -2
- package/src/fuse-verify.ts +3 -3
- package/src/fuse.ts +93 -6
- package/src/index.ts +42 -2
- package/src/nitro.ts +602 -0
- package/src/settlement.ts +263 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build a block's transaction trie and the inclusion proof for one
|
|
5
|
+
* transaction. The result is only ever used after its root has been compared
|
|
6
|
+
* with the block header's transactionsRoot, so a construction bug shows up
|
|
7
|
+
* as a refusal to write the proof, never as a wrong proof.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { keccak256, rlpEncode, txTrieKey, type RlpItem } from "./ceiling-evm.js";
|
|
11
|
+
|
|
12
|
+
type Node =
|
|
13
|
+
| { kind: "leaf"; path: number[]; value: Uint8Array }
|
|
14
|
+
| { kind: "ext"; path: number[]; child: Node }
|
|
15
|
+
| { kind: "branch"; children: (Node | null)[]; value: Uint8Array };
|
|
16
|
+
|
|
17
|
+
interface Entry { key: number[]; value: Uint8Array }
|
|
18
|
+
|
|
19
|
+
function nibbles(bytes: Uint8Array): number[] {
|
|
20
|
+
const out: number[] = [];
|
|
21
|
+
for (const b of bytes) out.push(b >> 4, b & 0x0f);
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function hexPrefix(nib: number[], leaf: boolean): Uint8Array {
|
|
26
|
+
const odd = nib.length % 2 === 1;
|
|
27
|
+
const flag = (leaf ? 2 : 0) + (odd ? 1 : 0);
|
|
28
|
+
const all = odd ? [flag, ...nib] : [flag, 0, ...nib];
|
|
29
|
+
const out = new Uint8Array(all.length / 2);
|
|
30
|
+
for (let i = 0; i < out.length; i++) out[i] = (all[2 * i]! << 4) | all[2 * i + 1]!;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildNode(entries: Entry[], depth: number): Node {
|
|
35
|
+
if (entries.length === 1) {
|
|
36
|
+
const e = entries[0]!;
|
|
37
|
+
return { kind: "leaf", path: e.key.slice(depth), value: e.value };
|
|
38
|
+
}
|
|
39
|
+
let common = 0;
|
|
40
|
+
const first = entries[0]!.key;
|
|
41
|
+
outer: while (true) {
|
|
42
|
+
const n = first[depth + common];
|
|
43
|
+
if (n === undefined) break;
|
|
44
|
+
for (const e of entries) if (e.key[depth + common] !== n) break outer;
|
|
45
|
+
common++;
|
|
46
|
+
}
|
|
47
|
+
if (common > 0) {
|
|
48
|
+
return { kind: "ext", path: first.slice(depth, depth + common), child: buildNode(entries, depth + common) };
|
|
49
|
+
}
|
|
50
|
+
const groups: Entry[][] = Array.from({ length: 16 }, () => []);
|
|
51
|
+
let value: Uint8Array = new Uint8Array(0);
|
|
52
|
+
for (const e of entries) {
|
|
53
|
+
if (e.key.length === depth) value = e.value;
|
|
54
|
+
else groups[e.key[depth]!]!.push(e);
|
|
55
|
+
}
|
|
56
|
+
return { kind: "branch", children: groups.map((g) => (g.length ? buildNode(g, depth + 1) : null)), value };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class Encoder {
|
|
60
|
+
private readonly memo = new Map<Node, Uint8Array>();
|
|
61
|
+
rlp(node: Node): Uint8Array {
|
|
62
|
+
const known = this.memo.get(node);
|
|
63
|
+
if (known) return known;
|
|
64
|
+
const enc = rlpEncode(this.item(node));
|
|
65
|
+
this.memo.set(node, enc);
|
|
66
|
+
return enc;
|
|
67
|
+
}
|
|
68
|
+
item(node: Node): RlpItem {
|
|
69
|
+
switch (node.kind) {
|
|
70
|
+
case "leaf": return [hexPrefix(node.path, true), node.value];
|
|
71
|
+
case "ext": return [hexPrefix(node.path, false), this.ref(node.child)];
|
|
72
|
+
case "branch": return [...node.children.map((c) => (c ? this.ref(c) : new Uint8Array(0))), node.value];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** A child as its parent holds it: inline when its RLP is under 32 bytes, else its hash. */
|
|
76
|
+
ref(node: Node): RlpItem {
|
|
77
|
+
const enc = this.rlp(node);
|
|
78
|
+
return enc.length < 32 ? this.item(node) : keccak256(enc);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The trie root over `values` keyed by rlp(index), and the proof for `index`:
|
|
84
|
+
* the root node, then every node on the path its parent references by hash.
|
|
85
|
+
*/
|
|
86
|
+
export function txTrieProof(values: readonly Uint8Array[], index: number): { root: Uint8Array; proof: Uint8Array[] } {
|
|
87
|
+
if (values.length === 0) throw new TypeError("an empty block has no transaction to prove");
|
|
88
|
+
if (index < 0 || index >= values.length) throw new RangeError("transaction index out of range");
|
|
89
|
+
const entries: Entry[] = values.map((v, i) => ({ key: nibbles(txTrieKey(i)), value: v }));
|
|
90
|
+
const root = buildNode(entries, 0);
|
|
91
|
+
const enc = new Encoder();
|
|
92
|
+
const target = nibbles(txTrieKey(index));
|
|
93
|
+
const proof: Uint8Array[] = [enc.rlp(root)];
|
|
94
|
+
let node: Node = root;
|
|
95
|
+
let depth = 0;
|
|
96
|
+
while (node.kind !== "leaf") {
|
|
97
|
+
let next: Node | null;
|
|
98
|
+
if (node.kind === "ext") {
|
|
99
|
+
depth += node.path.length;
|
|
100
|
+
next = node.child;
|
|
101
|
+
} else {
|
|
102
|
+
if (depth === target.length) break;
|
|
103
|
+
next = node.children[target[depth]!] ?? null;
|
|
104
|
+
depth += 1;
|
|
105
|
+
}
|
|
106
|
+
if (!next) throw new Error("target not in trie");
|
|
107
|
+
const r = enc.rlp(next);
|
|
108
|
+
if (r.length >= 32) proof.push(r);
|
|
109
|
+
node = next;
|
|
110
|
+
}
|
|
111
|
+
return { root: keccak256(proof[0]!), proof };
|
|
112
|
+
}
|
package/src/ceiling.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A ceiling in TIME for a BitGraph, carried beside the proof, never inside it.
|
|
5
|
+
*
|
|
6
|
+
* Every BitGraph already has a floor in time (the Ethereum block the enclave
|
|
7
|
+
* fixes at slot allocation and signs at commit, `commit.slotAnchor`) and a ceiling in POSITION (the
|
|
8
|
+
* anchors that follow it in the chain). This adds the one thing a record
|
|
9
|
+
* cannot supply for itself: something outside the operator's control that
|
|
10
|
+
* depends on the record. After a commit, a writer puts a Merkle root over
|
|
11
|
+
* record hashes into a Base transaction. The block that includes it proves
|
|
12
|
+
* every record under that root existed by the block's timestamp.
|
|
13
|
+
*
|
|
14
|
+
* The sidecar (`bitgraph-ceiling/1`) is unsigned and trusted for nothing. Every
|
|
15
|
+
* value it states is recomputed here from bytes bound to a hash:
|
|
16
|
+
*
|
|
17
|
+
* proof ─computeProofHash→ leaf ─merklePath→ root
|
|
18
|
+
* root == payload.root, payload == tx.data, tx signed by the writer
|
|
19
|
+
* tx ─MPT proof→ header.transactionsRoot, keccak(header) == blockHash
|
|
20
|
+
* blockTimestamp read from the header, not from the sidecar's own field
|
|
21
|
+
*
|
|
22
|
+
* What stays OUTSIDE this function, and is reported, not assumed:
|
|
23
|
+
* - whether that header is really a Base block (check it against any Base
|
|
24
|
+
* RPC; see checkCeilingOnline), and
|
|
25
|
+
* - who the writer is (the caller names the address it trusts; BitGraph
|
|
26
|
+
* publishes its own on bitgraph.ing).
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
30
|
+
import { verifyProofIntegrity, createVerificationContext } from "./verifier.js";
|
|
31
|
+
import { computeProofHash } from "./proof-hash.js";
|
|
32
|
+
import { merkleLeafHash, merkleRootFromPath } from "./fuse-merkle.js";
|
|
33
|
+
import { base64ToBytes } from "./fuse.js";
|
|
34
|
+
import {
|
|
35
|
+
bytesEqual, bytesToHex, decodeEip1559, decodeHeader, hexToBytes, keccak256, mptVerify, txTrieKey,
|
|
36
|
+
} from "./ceiling-evm.js";
|
|
37
|
+
import type { BitGraphProof, VerificationPolicy } from "./types.js";
|
|
38
|
+
|
|
39
|
+
export const CEILING_VERSION = "bitgraph-ceiling/1";
|
|
40
|
+
export const CEILING_MAGIC = "BGC1";
|
|
41
|
+
export const CEILING_PAYLOAD_BYTES = 84;
|
|
42
|
+
|
|
43
|
+
export type CeilingStatus = "pending" | "included" | "safe" | "finalized";
|
|
44
|
+
|
|
45
|
+
export interface CeilingSidecar {
|
|
46
|
+
version: typeof CEILING_VERSION;
|
|
47
|
+
/** Standard base64, as the ledger stores it. */
|
|
48
|
+
proofHash: string;
|
|
49
|
+
leafIndex: number;
|
|
50
|
+
/** Tree size. RFC 9162 path checks need it; not in the build prompt's draft. */
|
|
51
|
+
leafCount: number;
|
|
52
|
+
/** Sibling hashes, leaf level up, 0x hex. */
|
|
53
|
+
merklePath: string[];
|
|
54
|
+
root: string;
|
|
55
|
+
anchor: {
|
|
56
|
+
chainId: number;
|
|
57
|
+
writer: string;
|
|
58
|
+
txHash: string;
|
|
59
|
+
rawTx: string;
|
|
60
|
+
payload: string;
|
|
61
|
+
blockNumber: number;
|
|
62
|
+
blockHash: string;
|
|
63
|
+
blockTimestamp: number;
|
|
64
|
+
blockHeader: string;
|
|
65
|
+
txIndex: number;
|
|
66
|
+
/** Trie nodes from transactionsRoot down to this transaction, 0x hex. */
|
|
67
|
+
txInclusionProof: string[];
|
|
68
|
+
} | null;
|
|
69
|
+
status: CeilingStatus;
|
|
70
|
+
statusObserved: { included: string | null; safe: string | null; finalized: string | null };
|
|
71
|
+
/**
|
|
72
|
+
* The floor block's header, so the window reads offline. Optional and
|
|
73
|
+
* unsigned: checked by keccak256 against the proof's SIGNED slotAnchor hash.
|
|
74
|
+
*/
|
|
75
|
+
floor?: { blockNumber: number; blockHash: string; blockTimestamp: number; blockHeader: string } | null;
|
|
76
|
+
/** Reserved for v2: the Ethereum batch that settles this Base block. */
|
|
77
|
+
settlement: null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Payload ────────────────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
export interface CeilingPayload {
|
|
83
|
+
root: Uint8Array;
|
|
84
|
+
prev: Uint8Array;
|
|
85
|
+
firstPos: bigint;
|
|
86
|
+
lastPos: bigint;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function encodeCeilingPayload(p: CeilingPayload): Uint8Array {
|
|
90
|
+
if (p.root.length !== 32 || p.prev.length !== 32) throw new TypeError("root and prev are 32 bytes");
|
|
91
|
+
const out = new Uint8Array(CEILING_PAYLOAD_BYTES);
|
|
92
|
+
out.set(new TextEncoder().encode(CEILING_MAGIC), 0);
|
|
93
|
+
out.set(p.root, 4);
|
|
94
|
+
out.set(p.prev, 36);
|
|
95
|
+
const view = new DataView(out.buffer);
|
|
96
|
+
view.setBigUint64(68, p.firstPos);
|
|
97
|
+
view.setBigUint64(76, p.lastPos);
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function decodeCeilingPayload(bytes: Uint8Array): CeilingPayload {
|
|
102
|
+
if (bytes.length !== CEILING_PAYLOAD_BYTES) throw new TypeError(`payload is ${bytes.length} bytes, expected ${CEILING_PAYLOAD_BYTES}`);
|
|
103
|
+
const magic = new TextDecoder().decode(bytes.slice(0, 4));
|
|
104
|
+
if (magic !== CEILING_MAGIC) throw new TypeError(`payload magic is ${JSON.stringify(magic)}, expected ${CEILING_MAGIC}`);
|
|
105
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
106
|
+
return {
|
|
107
|
+
root: bytes.slice(4, 36),
|
|
108
|
+
prev: bytes.slice(36, 68),
|
|
109
|
+
firstPos: view.getBigUint64(68),
|
|
110
|
+
lastPos: view.getBigUint64(76),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** SHA-256 of a payload: the next payload's `prev`, so the anchors chain. */
|
|
115
|
+
export function ceilingPayloadHash(payload: Uint8Array): Uint8Array {
|
|
116
|
+
return sha256(payload);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The leaf hash of one record: SHA256(0x00 || proofHash bytes). */
|
|
120
|
+
export function ceilingLeaf(proofHashB64: string): Uint8Array {
|
|
121
|
+
const raw = base64ToBytes(proofHashB64);
|
|
122
|
+
if (!raw || raw.length !== 32) throw new TypeError("proofHash must decode to 32 bytes");
|
|
123
|
+
return merkleLeafHash(raw);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ── Verification ───────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
export interface CeilingCheck {
|
|
129
|
+
name: string;
|
|
130
|
+
ok: boolean;
|
|
131
|
+
detail?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface CeilingVerifyResult {
|
|
135
|
+
/** True when every offline check passed. Says nothing about chain canonicality. */
|
|
136
|
+
ok: boolean;
|
|
137
|
+
reason?: string;
|
|
138
|
+
checks: CeilingCheck[];
|
|
139
|
+
status?: CeilingStatus;
|
|
140
|
+
window?: {
|
|
141
|
+
/** Floor: the proof's signed slotAnchor block. Time only if a checked header was carried. */
|
|
142
|
+
floor: { blockNumber: number; blockHash: string; blockTimestamp: number | null };
|
|
143
|
+
/** Ceiling: the Base block, time read from its header. */
|
|
144
|
+
ceiling: { chainId: number; blockNumber: number; blockHash: string; blockTimestamp: number };
|
|
145
|
+
widthSeconds: number | null;
|
|
146
|
+
};
|
|
147
|
+
/** One line for people. */
|
|
148
|
+
label?: string;
|
|
149
|
+
/** Offline, this is always false; checkCeilingOnline sets it. */
|
|
150
|
+
headerCheckedAgainstChain: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface CeilingVerifyOptions {
|
|
154
|
+
/** The declared writer address. A sidecar from any other sender is refused. */
|
|
155
|
+
writerAddress: string;
|
|
156
|
+
/** 8453 Base mainnet, 84532 Base Sepolia. */
|
|
157
|
+
chainId: number;
|
|
158
|
+
/** Skip the proof's own signature check (only when the caller already ran verify()). */
|
|
159
|
+
proofAlreadyVerified?: boolean;
|
|
160
|
+
/** Passed through to the proof's own check (measurement allowlist and so on). */
|
|
161
|
+
trustAnchors?: VerificationPolicy;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function hhmmss(unix: number): string {
|
|
165
|
+
return new Date(unix * 1000).toISOString().slice(11, 19);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function ceilingLabel(status: CeilingStatus, blockNumber: number, blockTimestamp: number): string {
|
|
169
|
+
const at = `Base block ${blockNumber.toLocaleString("en-US")} at ${hhmmss(blockTimestamp)} UTC`;
|
|
170
|
+
if (status === "safe" || status === "finalized") return `Ceiling: ${at}, settled on Ethereum.`;
|
|
171
|
+
return `Ceiling: ${at}. Relies on Base's sequencer until settled on Ethereum.`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Check a ceiling sidecar against its proof, offline. Every check runs and
|
|
176
|
+
* is reported; the first failure is the `reason`.
|
|
177
|
+
*/
|
|
178
|
+
export async function verifyCeiling(
|
|
179
|
+
proof: BitGraphProof,
|
|
180
|
+
sidecar: CeilingSidecar,
|
|
181
|
+
opts: CeilingVerifyOptions,
|
|
182
|
+
): Promise<CeilingVerifyResult> {
|
|
183
|
+
const checks: CeilingCheck[] = [];
|
|
184
|
+
const fail = (name: string, detail: string): CeilingVerifyResult => {
|
|
185
|
+
checks.push({ name, ok: false, detail });
|
|
186
|
+
return { ok: false, reason: `${name}: ${detail}`, checks, headerCheckedAgainstChain: false };
|
|
187
|
+
};
|
|
188
|
+
const pass = (name: string, detail?: string) => checks.push(detail === undefined ? { name, ok: true } : { name, ok: true, detail });
|
|
189
|
+
|
|
190
|
+
if (sidecar?.version !== CEILING_VERSION) return fail("format", `not a ${CEILING_VERSION} sidecar`);
|
|
191
|
+
|
|
192
|
+
// 0. The proof itself. The leaf covers the signed-body SUBSET (proofHash);
|
|
193
|
+
// the signature covers the rest, so an altered actor/policy fails here.
|
|
194
|
+
if (!opts.proofAlreadyVerified) {
|
|
195
|
+
const v = await verifyProofIntegrity({
|
|
196
|
+
proof,
|
|
197
|
+
context: createVerificationContext(),
|
|
198
|
+
...(opts.trustAnchors ? { trustAnchors: opts.trustAnchors } : {}),
|
|
199
|
+
});
|
|
200
|
+
if (!v.valid) return fail("proof", `the proof does not verify (${v.reason ?? "invalid"})`);
|
|
201
|
+
pass("proof", "signature valid");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 1. The record is under the root.
|
|
205
|
+
let proofHash: string;
|
|
206
|
+
try {
|
|
207
|
+
proofHash = computeProofHash(proof);
|
|
208
|
+
} catch (e) {
|
|
209
|
+
return fail("record", `cannot hash the proof (${(e as Error).message})`);
|
|
210
|
+
}
|
|
211
|
+
if (proofHash !== sidecar.proofHash) return fail("record", "this sidecar belongs to a different proof");
|
|
212
|
+
let computedRoot: Uint8Array | null;
|
|
213
|
+
try {
|
|
214
|
+
computedRoot = merkleRootFromPath(
|
|
215
|
+
ceilingLeaf(proofHash),
|
|
216
|
+
sidecar.leafIndex,
|
|
217
|
+
sidecar.leafCount,
|
|
218
|
+
sidecar.merklePath.map(hexToBytes),
|
|
219
|
+
);
|
|
220
|
+
} catch {
|
|
221
|
+
computedRoot = null;
|
|
222
|
+
}
|
|
223
|
+
if (!computedRoot) return fail("merkle", "the path does not fit the leaf index and tree size");
|
|
224
|
+
if (bytesToHex(computedRoot) !== sidecar.root.toLowerCase()) return fail("merkle", "the leaf and path do not reach the root");
|
|
225
|
+
pass("merkle", `leaf ${sidecar.leafIndex} of ${sidecar.leafCount} reaches the root`);
|
|
226
|
+
|
|
227
|
+
if (sidecar.status === "pending" || !sidecar.anchor) {
|
|
228
|
+
return { ok: false, reason: "ceiling pending: no transaction included yet", checks, status: "pending", headerCheckedAgainstChain: false };
|
|
229
|
+
}
|
|
230
|
+
const a = sidecar.anchor;
|
|
231
|
+
|
|
232
|
+
// 2. The payload carries that root.
|
|
233
|
+
let payloadBytes: Uint8Array;
|
|
234
|
+
try {
|
|
235
|
+
payloadBytes = hexToBytes(a.payload);
|
|
236
|
+
const p = decodeCeilingPayload(payloadBytes);
|
|
237
|
+
if (bytesToHex(p.root) !== sidecar.root.toLowerCase()) return fail("payload", "the payload's root is not this sidecar's root");
|
|
238
|
+
pass("payload", `${CEILING_MAGIC}, positions ${p.firstPos}-${p.lastPos}`);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
return fail("payload", (e as Error).message);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 3. The transaction: signed by the writer, to itself, carrying the payload.
|
|
244
|
+
let rawTx: Uint8Array;
|
|
245
|
+
try {
|
|
246
|
+
rawTx = hexToBytes(a.rawTx);
|
|
247
|
+
const tx = decodeEip1559(rawTx);
|
|
248
|
+
const writer = opts.writerAddress.toLowerCase();
|
|
249
|
+
if (tx.from !== writer) return fail("sender", `the transaction was signed by ${tx.from}, not the declared writer ${writer}`);
|
|
250
|
+
if (tx.to !== writer) return fail("sender", `the transaction is addressed to ${tx.to ?? "a contract creation"}, not to the writer`);
|
|
251
|
+
if (tx.chainId !== BigInt(opts.chainId)) return fail("chain", `the transaction is for chain ${tx.chainId}, expected ${opts.chainId}`);
|
|
252
|
+
if (a.chainId !== opts.chainId) return fail("chain", `the sidecar names chain ${a.chainId}, expected ${opts.chainId}`);
|
|
253
|
+
if (!bytesEqual(tx.data, payloadBytes)) return fail("payload", "the transaction's data is not the payload");
|
|
254
|
+
if (tx.hash !== a.txHash.toLowerCase()) return fail("transaction", "the raw transaction does not hash to txHash");
|
|
255
|
+
pass("sender", `signed by ${tx.from}`);
|
|
256
|
+
} catch (e) {
|
|
257
|
+
return fail("transaction", (e as Error).message);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 4. The transaction is in the block, and the block is this header.
|
|
261
|
+
let header;
|
|
262
|
+
try {
|
|
263
|
+
header = decodeHeader(hexToBytes(a.blockHeader));
|
|
264
|
+
} catch (e) {
|
|
265
|
+
return fail("header", (e as Error).message);
|
|
266
|
+
}
|
|
267
|
+
if (header.hash !== a.blockHash.toLowerCase()) return fail("header", "the header does not hash to blockHash");
|
|
268
|
+
if (header.number !== a.blockNumber) return fail("header", `the header is block ${header.number}, the sidecar says ${a.blockNumber}`);
|
|
269
|
+
if (header.timestamp !== a.blockTimestamp) return fail("header", `the header's timestamp is ${header.timestamp}, the sidecar says ${a.blockTimestamp}`);
|
|
270
|
+
const inBlock = mptVerify(hexToBytes(header.transactionsRoot), txTrieKey(a.txIndex), a.txInclusionProof.map(hexToBytes));
|
|
271
|
+
if (!inBlock || !bytesEqual(inBlock, rawTx)) return fail("inclusion", "the transaction is not in this block");
|
|
272
|
+
pass("inclusion", `transaction ${a.txIndex} of block ${header.number}`);
|
|
273
|
+
|
|
274
|
+
// 5. The window. The floor is the proof's own signed slotAnchor.
|
|
275
|
+
const slotAnchor = proof.commit.slotAnchor;
|
|
276
|
+
let floor: { blockNumber: number; blockHash: string; blockTimestamp: number | null } | null = null;
|
|
277
|
+
if (slotAnchor) {
|
|
278
|
+
floor = { blockNumber: slotAnchor.blockNumber, blockHash: slotAnchor.blockHash, blockTimestamp: null };
|
|
279
|
+
const w = sidecar.floor;
|
|
280
|
+
if (w && w.blockHeader) {
|
|
281
|
+
try {
|
|
282
|
+
const fh = decodeHeader(hexToBytes(w.blockHeader));
|
|
283
|
+
if (fh.hash === slotAnchor.blockHash.toLowerCase() && fh.number === slotAnchor.blockNumber) {
|
|
284
|
+
floor.blockTimestamp = fh.timestamp;
|
|
285
|
+
pass("floor", `Ethereum block ${fh.number}, header checked against the signed hash`);
|
|
286
|
+
} else {
|
|
287
|
+
checks.push({ name: "floor", ok: false, detail: "the carried floor header does not match the proof's signed slotAnchor; ignored" });
|
|
288
|
+
}
|
|
289
|
+
} catch {
|
|
290
|
+
checks.push({ name: "floor", ok: false, detail: "the carried floor header does not decode; ignored" });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const width = floor?.blockTimestamp != null ? header.timestamp - floor.blockTimestamp : null;
|
|
295
|
+
const status = sidecar.status;
|
|
296
|
+
return {
|
|
297
|
+
ok: true,
|
|
298
|
+
checks,
|
|
299
|
+
status,
|
|
300
|
+
window: {
|
|
301
|
+
floor: floor ?? { blockNumber: 0, blockHash: "", blockTimestamp: null },
|
|
302
|
+
ceiling: { chainId: a.chainId, blockNumber: header.number, blockHash: header.hash, blockTimestamp: header.timestamp },
|
|
303
|
+
widthSeconds: width,
|
|
304
|
+
},
|
|
305
|
+
label: ceilingLabel(status, header.number, header.timestamp),
|
|
306
|
+
headerCheckedAgainstChain: false,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Ask a Base node whether the sidecar's block is on the chain. Returns a
|
|
312
|
+
* finding, never throws. Online is the only way to learn canonicality.
|
|
313
|
+
*
|
|
314
|
+
* The package makes no network calls of its own (the audit's zero-network
|
|
315
|
+
* guarantee covers it), so the caller supplies the one lookup:
|
|
316
|
+
* `getBlockHash(n)` returns the chain's hash at height n, or null.
|
|
317
|
+
*/
|
|
318
|
+
export async function checkCeilingOnline(
|
|
319
|
+
sidecar: CeilingSidecar,
|
|
320
|
+
getBlockHash: (blockNumber: number) => Promise<string | null>,
|
|
321
|
+
): Promise<{ onChain: boolean | null; detail: string }> {
|
|
322
|
+
if (!sidecar.anchor) return { onChain: null, detail: "no anchor to check" };
|
|
323
|
+
try {
|
|
324
|
+
const hash = (await getBlockHash(sidecar.anchor.blockNumber))?.toLowerCase();
|
|
325
|
+
if (!hash) return { onChain: null, detail: "the RPC did not return that block" };
|
|
326
|
+
if (hash === sidecar.anchor.blockHash.toLowerCase()) return { onChain: true, detail: `block ${sidecar.anchor.blockNumber} matches the chain` };
|
|
327
|
+
return { onChain: false, detail: `the chain's block ${sidecar.anchor.blockNumber} is ${hash}, not this header` };
|
|
328
|
+
} catch (e) {
|
|
329
|
+
return { onChain: null, detail: `header not checked against chain (${(e as Error).message})` };
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export { keccak256 as ceilingKeccak256 };
|
package/src/fuse-member.ts
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
bytesEqual,
|
|
48
48
|
bytesToBase64,
|
|
49
49
|
bytesToHex,
|
|
50
|
-
|
|
50
|
+
commitmentForProof,
|
|
51
51
|
getPlacement,
|
|
52
52
|
PLACEMENTS,
|
|
53
53
|
parseSetManifest,
|
|
@@ -388,7 +388,7 @@ export async function verifyFuseMember(opts: FuseMemberOptions): Promise<FuseMem
|
|
|
388
388
|
}
|
|
389
389
|
let commitment: Uint8Array;
|
|
390
390
|
try {
|
|
391
|
-
commitment =
|
|
391
|
+
commitment = commitmentForProof(proof, slot);
|
|
392
392
|
} catch (err) {
|
|
393
393
|
return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
|
|
394
394
|
}
|
package/src/fuse-verify.ts
CHANGED
|
@@ -30,7 +30,7 @@ import type { BitGraphProof, VerificationPolicy } from "./types.js";
|
|
|
30
30
|
import {
|
|
31
31
|
bytesEqual,
|
|
32
32
|
bytesToBase64,
|
|
33
|
-
|
|
33
|
+
commitmentForProof,
|
|
34
34
|
findCommitment,
|
|
35
35
|
getPlacement,
|
|
36
36
|
isCarryEncoding,
|
|
@@ -233,7 +233,7 @@ export async function verifyFuse(opts: FuseVerifyOptions): Promise<FuseVerifyRes
|
|
|
233
233
|
}
|
|
234
234
|
let expected: Uint8Array;
|
|
235
235
|
try {
|
|
236
|
-
expected =
|
|
236
|
+
expected = commitmentForProof(proof, slot);
|
|
237
237
|
} catch (err) {
|
|
238
238
|
return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
|
|
239
239
|
}
|
|
@@ -314,7 +314,7 @@ export async function verifyFuse(opts: FuseVerifyOptions): Promise<FuseVerifyRes
|
|
|
314
314
|
}
|
|
315
315
|
let commitment: Uint8Array;
|
|
316
316
|
try {
|
|
317
|
-
commitment =
|
|
317
|
+
commitment = commitmentForProof(proof, slot);
|
|
318
318
|
} catch (err) {
|
|
319
319
|
return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
|
|
320
320
|
}
|
package/src/fuse.ts
CHANGED
|
@@ -176,6 +176,90 @@ export function computeSlotCommitment(slot: SlotAllocation): Uint8Array {
|
|
|
176
176
|
return sha256(slotCommitmentPreimage(slot));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
// bitgraph-fuse/2 (2026-09-30): the commitment also binds the floor block.
|
|
181
|
+
//
|
|
182
|
+
// commitment/2 = SHA256(UTF8("bitgraph-fuse/2") || 0x00 || slotRecordHash || nonce || floorBlockHash)
|
|
183
|
+
//
|
|
184
|
+
// floorBlockHash is the 32 raw bytes of the Ethereum block hash the enclave
|
|
185
|
+
// signs into the proof as commit.slotAnchor.blockHash (enclave v9 returns it
|
|
186
|
+
// with the allocation, so a producer knows it before finishing the file). A
|
|
187
|
+
// file carrying commitment/2 could not have been finished before that block
|
|
188
|
+
// existed, by hash alone: the floor under the file's content no longer rests
|
|
189
|
+
// on the enclave's counter. Everything else is fuse/1's: the placements, the
|
|
190
|
+
// payload formats and the set documents carry the 32-byte commitment and do
|
|
191
|
+
// not change. A proof is fuse/2 exactly when its SIGNED attribution name says
|
|
192
|
+
// so; a fuse/1 verifier sees an ordinary proof and says nothing about the file.
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
export const FUSE2_PROFILE = "bitgraph-fuse/2" as const;
|
|
196
|
+
export const FUSE2_ATTRIBUTION_NAME = FUSE2_PROFILE;
|
|
197
|
+
|
|
198
|
+
/** "bitgraph-fuse/2" followed by one zero byte. */
|
|
199
|
+
export const FUSE2_DOMAIN: Uint8Array = (() => {
|
|
200
|
+
const label = new TextEncoder().encode(FUSE2_PROFILE);
|
|
201
|
+
const out = new Uint8Array(label.length + 1);
|
|
202
|
+
out.set(label, 0);
|
|
203
|
+
out[label.length] = 0x00;
|
|
204
|
+
return out;
|
|
205
|
+
})();
|
|
206
|
+
|
|
207
|
+
/** Which commitment a fused proof's signed marker declares: 1, 2, or null when the proof is not fused. */
|
|
208
|
+
export function fuseVersionOfName(name: unknown): 1 | 2 | null {
|
|
209
|
+
return name === FUSE_ATTRIBUTION_NAME ? 1 : name === FUSE2_ATTRIBUTION_NAME ? 2 : null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** True for either fused marker name. Use this, never a string compare against one version. */
|
|
213
|
+
export function isFuseMarkerName(name: unknown): boolean {
|
|
214
|
+
return fuseVersionOfName(name) !== null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function floorHashBytes(floorBlockHash: string | Uint8Array): Uint8Array {
|
|
218
|
+
const b = typeof floorBlockHash === "string" ? hexToBytes(floorBlockHash.toLowerCase().replace(/^0x/, "")) : floorBlockHash;
|
|
219
|
+
if (b === null || b.length !== 32) throw new TypeError("the floor block hash must be 32 bytes");
|
|
220
|
+
return b;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The exact preimage of commitment/2: domain || slotRecordHash || nonce || floorBlockHash. */
|
|
224
|
+
export function slotCommitment2Preimage(slot: SlotAllocation, floorBlockHash: string | Uint8Array): Uint8Array {
|
|
225
|
+
const nonce = base64ToBytes(slot.nonceB64);
|
|
226
|
+
if (nonce === null || nonce.length !== 32) {
|
|
227
|
+
throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");
|
|
228
|
+
}
|
|
229
|
+
return concat(FUSE2_DOMAIN, computeSlotRecordHash(slot), nonce, floorHashBytes(floorBlockHash));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** commitment/2 = SHA256(domain/2 || slotRecordHash || nonce || floorBlockHash). */
|
|
233
|
+
export function computeSlotCommitment2(slot: SlotAllocation, floorBlockHash: string | Uint8Array): Uint8Array {
|
|
234
|
+
return sha256(slotCommitment2Preimage(slot, floorBlockHash));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The commitment a fused proof's bytes must carry, chosen by its signed marker:
|
|
239
|
+
* fuse/2 binds the proof's own signed commit.slotAnchor block, fuse/1 does not.
|
|
240
|
+
* Throws when a fuse/2 proof has no signed floor to bind.
|
|
241
|
+
*/
|
|
242
|
+
export function commitmentForProof(proof: BitGraphProof, slot: SlotAllocation): Uint8Array {
|
|
243
|
+
if (fuseVersionOfName(proof.attribution?.name) === 2) {
|
|
244
|
+
const hash = proof.commit?.slotAnchor?.blockHash;
|
|
245
|
+
if (typeof hash !== "string") throw new TypeError("a bitgraph-fuse/2 proof must carry a signed commit.slotAnchor to bind");
|
|
246
|
+
return computeSlotCommitment2(slot, hash);
|
|
247
|
+
}
|
|
248
|
+
return computeSlotCommitment(slot);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The commitment a PRODUCER writes into new bytes, from what the allocation
|
|
253
|
+
* returned: fuse/2 when the enclave handed back its floor anchor (v9 and
|
|
254
|
+
* later), else fuse/1. The attribution name must be chosen to match; see
|
|
255
|
+
* fuseAttribution's version argument.
|
|
256
|
+
*/
|
|
257
|
+
export function producerCommitment(slot: SlotAllocation, floor?: { blockHash: string } | null): { commitment: Uint8Array; version: 1 | 2 } {
|
|
258
|
+
return floor && typeof floor.blockHash === "string"
|
|
259
|
+
? { commitment: computeSlotCommitment2(slot, floor.blockHash), version: 2 }
|
|
260
|
+
: { commitment: computeSlotCommitment(slot), version: 1 };
|
|
261
|
+
}
|
|
262
|
+
|
|
179
263
|
// ---------------------------------------------------------------------------
|
|
180
264
|
// Form C canonical payload
|
|
181
265
|
// ---------------------------------------------------------------------------
|
|
@@ -907,11 +991,11 @@ export function getPlacement(id: string): Placement | undefined {
|
|
|
907
991
|
* set/1 refuses an origin digest: a set/1 marker carrying one is out of
|
|
908
992
|
* profile and verifyFuseMember refuses it.
|
|
909
993
|
*/
|
|
910
|
-
export function fuseAttribution(placement: PlacementId, originDigest?: Uint8Array): Attribution {
|
|
994
|
+
export function fuseAttribution(placement: PlacementId, originDigest?: Uint8Array, version: 1 | 2 = 1): Attribution {
|
|
911
995
|
if (originDigest !== undefined && originDigest.length !== 32) throw new TypeError("originDigest must be 32 bytes");
|
|
912
996
|
if ((placement === SET_PLACEMENT_ID || placement === SET2_PLACEMENT_ID) && originDigest !== undefined) throw new TypeError(`${placement} has no single origin; a set marker carries no origin digest`);
|
|
913
997
|
return {
|
|
914
|
-
name: FUSE_ATTRIBUTION_NAME,
|
|
998
|
+
name: version === 2 ? FUSE2_ATTRIBUTION_NAME : FUSE_ATTRIBUTION_NAME,
|
|
915
999
|
title: placement,
|
|
916
1000
|
...(originDigest !== undefined ? { message: bytesToBase64(originDigest) } : {}),
|
|
917
1001
|
};
|
|
@@ -933,6 +1017,8 @@ export interface FuseMarker {
|
|
|
933
1017
|
originSource?: MarkerSource;
|
|
934
1018
|
/** "attribution" when the proof's signed attribution marks it fused, else "manifest". */
|
|
935
1019
|
source: MarkerSource;
|
|
1020
|
+
/** Which commitment the signed marker declares; absent on a manifest-only marker, which means 1. */
|
|
1021
|
+
version?: 1 | 2;
|
|
936
1022
|
}
|
|
937
1023
|
|
|
938
1024
|
/** Read the fused marker from a proof's signed attribution, or null when the proof is not marked fused. */
|
|
@@ -983,15 +1069,16 @@ export function findCommitment(bytes: Uint8Array, commitment: Uint8Array, encodi
|
|
|
983
1069
|
}
|
|
984
1070
|
|
|
985
1071
|
/** The attribution a producer sends for an artifact made with the commitment inside it. */
|
|
986
|
-
export function inlineAttribution(): { name: string; title: string } {
|
|
987
|
-
return { name: FUSE_ATTRIBUTION_NAME, title: ENCODING_BASE64URL };
|
|
1072
|
+
export function inlineAttribution(version: 1 | 2 = 1): { name: string; title: string } {
|
|
1073
|
+
return { name: version === 2 ? FUSE2_ATTRIBUTION_NAME : FUSE_ATTRIBUTION_NAME, title: ENCODING_BASE64URL };
|
|
988
1074
|
}
|
|
989
1075
|
|
|
990
1076
|
export function readFuseAttribution(proof: BitGraphProof): FuseMarker | null {
|
|
991
1077
|
const a = proof.attribution;
|
|
992
|
-
|
|
1078
|
+
const version = fuseVersionOfName(a?.name);
|
|
1079
|
+
if (a === undefined || version === null) return null;
|
|
993
1080
|
const declared = typeof a.title === "string" && a.title.length > 0;
|
|
994
|
-
const marker: FuseMarker = { placement: declared ? (a.title as string) : null, placementSource: declared ? "attribution" : null, source: "attribution" };
|
|
1081
|
+
const marker: FuseMarker = { placement: declared ? (a.title as string) : null, placementSource: declared ? "attribution" : null, source: "attribution", version };
|
|
995
1082
|
if (typeof a.message === "string" && a.message.length > 0) {
|
|
996
1083
|
const d = base64ToBytes(a.message);
|
|
997
1084
|
// A message that is not a digest is still a fused marker; the origin is simply undeclared.
|
package/src/index.ts
CHANGED
|
@@ -59,6 +59,15 @@ export {
|
|
|
59
59
|
computeSlotRecordHash,
|
|
60
60
|
slotCommitmentPreimage,
|
|
61
61
|
computeSlotCommitment,
|
|
62
|
+
FUSE2_PROFILE,
|
|
63
|
+
FUSE2_DOMAIN,
|
|
64
|
+
FUSE2_ATTRIBUTION_NAME,
|
|
65
|
+
fuseVersionOfName,
|
|
66
|
+
isFuseMarkerName,
|
|
67
|
+
slotCommitment2Preimage,
|
|
68
|
+
computeSlotCommitment2,
|
|
69
|
+
commitmentForProof,
|
|
70
|
+
producerCommitment,
|
|
62
71
|
buildFusePayload,
|
|
63
72
|
parseFusePayload,
|
|
64
73
|
fuseAttribution,
|
|
@@ -100,5 +109,36 @@ export type {
|
|
|
100
109
|
CarrierWitness, CarrierProof, CarrierFloor, CarrierCeiling, CarrierPayload,
|
|
101
110
|
CarrierParse, WitnessCheck, CarrierBounds,
|
|
102
111
|
} from "./carrier.js";
|
|
103
|
-
export { verifyCarrier } from "./carrier-verify.js";
|
|
104
|
-
export type { CarrierVerifyResult } from "./carrier-verify.js";
|
|
112
|
+
export { verifyCarrier, verifyCarrierPayload, BITGRAPH_CEILING_WRITER, BASE_MAINNET_CHAIN_ID } from "./carrier-verify.js";
|
|
113
|
+
export type { CarrierVerifyResult, CarrierClaim, ClaimResult, CarrierLookups, CarrierVerifyOptions } from "./carrier-verify.js";
|
|
114
|
+
|
|
115
|
+
/* bitgraph-carrier/2 (2026-09-30): the ceiling in time, its settlement, the attestation witness and the declared pins, in the same block. */
|
|
116
|
+
export {
|
|
117
|
+
CARRIER_VERSION_2, CEILING_SIDECAR_VERSION, SETTLEMENT_POINTER_VERSION, ATTESTATION_WITNESS_VERSION,
|
|
118
|
+
carrierVersionOf, completeCarrierInTime, completeCarrierSettlement, settlementFromSidecar,
|
|
119
|
+
} from "./carrier.js";
|
|
120
|
+
export type { CarrierVersion, CarrierCeilingInTime, CarrierSettlement, CarrierPins } from "./carrier.js";
|
|
121
|
+
export { assembleCarrierV2Payload, carrierBlockSize, CARRIER_BLOCK_ZIP_LIMIT } from "./carrier-assemble.js";
|
|
122
|
+
export type { CarrierV2Parts } from "./carrier-assemble.js";
|
|
123
|
+
|
|
124
|
+
/* AWS Nitro attestation: decode, verify (chain to the AWS root, validity at the document's instant), and the openssl-checkable witness. */
|
|
125
|
+
export {
|
|
126
|
+
AWS_NITRO_ROOT_CA_PEM, awsNitroRootDer, awsNitroRootSha256, decodeNitroAttestation, verifyNitroAttestation,
|
|
127
|
+
attestationWitness, witnessMatchesAttestation, encodeSigStructure, rawEcdsaSigToDer, derToPem, pemToDer, ATTESTATION_WITNESS_FORMAT,
|
|
128
|
+
} from "./nitro.js";
|
|
129
|
+
export type { NitroDocument, NitroDecoded, NitroCheck, NitroVerifyOptions, NitroVerifyResult, AttestationWitness } from "./nitro.js";
|
|
130
|
+
|
|
131
|
+
/* Settlement of a Base ceiling on Ethereum: L1 data inclusion (bitgraph-settlement/1). The pointer layer is here; the blob layer is bitgraph-audit's. */
|
|
132
|
+
export * from "./settlement.js";
|
|
133
|
+
|
|
134
|
+
// Ceiling in time on Base (bitgraph-ceiling/1): a sidecar beside the proof, never inside it.
|
|
135
|
+
export {
|
|
136
|
+
CEILING_VERSION, CEILING_MAGIC, CEILING_PAYLOAD_BYTES,
|
|
137
|
+
encodeCeilingPayload, decodeCeilingPayload, ceilingPayloadHash, ceilingLeaf, ceilingLabel,
|
|
138
|
+
verifyCeiling, checkCeilingOnline,
|
|
139
|
+
} from "./ceiling.js";
|
|
140
|
+
export type { CeilingSidecar, CeilingStatus, CeilingPayload, CeilingCheck, CeilingVerifyResult, CeilingVerifyOptions } from "./ceiling.js";
|
|
141
|
+
export { rlpEncode, rlpDecode, decodeHeader, decodeEip1559, mptVerify, txTrieKey, keccak256,
|
|
142
|
+
hexToBytes as evmHexToBytes, bytesToHex as evmBytesToHex } from "./ceiling-evm.js";
|
|
143
|
+
export { txTrieProof } from "./ceiling-trie.js";
|
|
144
|
+
export type { RlpItem, DecodedHeader, DecodedTx } from "./ceiling-evm.js";
|