@mikeargento/bitgraph 1.10.1 → 1.12.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 +42 -32
- package/dist/export.d.ts +98 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +366 -0
- package/dist/export.js.map +1 -0
- package/dist/fuse.d.ts +156 -11
- package/dist/fuse.d.ts.map +1 -1
- package/dist/fuse.js +380 -8
- package/dist/fuse.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/recovery-write.d.ts +58 -0
- package/dist/recovery-write.d.ts.map +1 -0
- package/dist/recovery-write.js +265 -0
- package/dist/recovery-write.js.map +1 -0
- package/dist/recovery.d.ts +490 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +1124 -0
- package/dist/recovery.js.map +1 -0
- package/package.json +3 -3
- package/src/export.ts +435 -0
- package/src/fuse.ts +521 -19
- package/src/index.ts +28 -3
- package/src/recovery-write.ts +334 -0
- package/src/recovery.ts +1261 -0
package/dist/export.js
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
// Copyright (c) Argento Computing Inc. All rights reserved. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* bitgraph-export/1 from the producer's side (2026-10-03): the JSON file
|
|
4
|
+
* that, with the file it is about, checks a tree/1 BitGraph with nothing of
|
|
5
|
+
* BitGraph's required. The verify package defines the format (buildExport,
|
|
6
|
+
* parseExport, verifyExport); this module builds one from what fuseTree
|
|
7
|
+
* returned and completes one later from public, read-only GETs.
|
|
8
|
+
*
|
|
9
|
+
* Two kinds, one format:
|
|
10
|
+
* a member's export tree.member: one leaf, its index and its path. It
|
|
11
|
+
* shows nothing of the other files but sibling hashes.
|
|
12
|
+
* the owner's export tree.leaves: every leaf (count x 65 bytes, base64)
|
|
13
|
+
* and tree.names beside them. Any member's evidence is
|
|
14
|
+
* rebuilt from it, and it lists every file, so it is
|
|
15
|
+
* the owner's to keep.
|
|
16
|
+
*
|
|
17
|
+
* At make time the floor header can be in hand (the site's witness route for
|
|
18
|
+
* an Ethereum floor; for a Base floor, enclave v10, a Base node's block at the
|
|
19
|
+
* signed height);
|
|
20
|
+
* the ceiling (a Base block, seconds after the commit) and the settlement
|
|
21
|
+
* (Base's output root on Ethereum, much later) cannot, so they start as
|
|
22
|
+
* { status: "pending" }. completeExport fetches all three. Nothing fetched is
|
|
23
|
+
* embedded before it verifies here: the floor header must hash to the floor
|
|
24
|
+
* block the proof signs, the ceiling must pass verifyCeiling for this proof,
|
|
25
|
+
* and the settlement must pass verifyOutputRootSettlement for the ceiling's
|
|
26
|
+
* own Base block. Nothing already in an export is ever overwritten.
|
|
27
|
+
*/
|
|
28
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
29
|
+
import { base64ToBytes, BASE_MAINNET_CHAIN_ID, BITGRAPH_CEILING_WRITER, buildExport, buildTreeMemberEvidence, bytesEqual, bytesToBase64, bytesToHex, checkFloorHeader, computeProofHash, encodeTreeLeaves, evmHexToBytes, MerkleTree, OUTPUT_ROOT_VERSION, parseExport, parseTreeRootDocument, treeLeafHash, treeRootFromMember, verifyCeiling, verifyOutputRootSettlement, verifyTreeLeaves, CEILING_VERSION, headerRlpFromRpc, signedFloorOf, evmBytesToHex, } from "@mikeargento/bitgraph-verify";
|
|
30
|
+
/** Throws unless the root document is the one the proof signs and states this many leaves; returns its parse. */
|
|
31
|
+
function boundDocument(source) {
|
|
32
|
+
const doc = parseTreeRootDocument(source.rootDocument);
|
|
33
|
+
if (doc === null)
|
|
34
|
+
throw new TypeError("the root document is not 84 bytes of tree/1");
|
|
35
|
+
const signed = base64ToBytes(source.proof.artifact?.digestB64 ?? "");
|
|
36
|
+
if (signed === null || !bytesEqual(sha256(source.rootDocument), signed))
|
|
37
|
+
throw new TypeError("the root document does not hash to the proof's signed artifact digest");
|
|
38
|
+
if (doc.count !== source.leaves.length)
|
|
39
|
+
throw new TypeError(`the root document states ${doc.count} leaves; ${source.leaves.length} were given`);
|
|
40
|
+
return doc;
|
|
41
|
+
}
|
|
42
|
+
function parts(p) {
|
|
43
|
+
return {
|
|
44
|
+
floor: p.floor ?? null,
|
|
45
|
+
ceiling: p.ceiling === undefined ? { status: "pending" } : p.ceiling,
|
|
46
|
+
settlement: p.settlement === undefined ? { status: "pending" } : p.settlement,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One member's export: its leaf, its index and its path, and nothing of the
|
|
51
|
+
* other files but sibling hashes. The path is checked against the committed
|
|
52
|
+
* root before the export is built, so no export contradicts itself.
|
|
53
|
+
*/
|
|
54
|
+
export function buildMemberExport(source, leafIndex, extras = {}) {
|
|
55
|
+
const doc = boundDocument(source);
|
|
56
|
+
if (!Number.isInteger(leafIndex) || leafIndex < 0 || leafIndex >= source.leaves.length)
|
|
57
|
+
throw new RangeError(`leaf ${leafIndex} is not in a tree of ${source.leaves.length}`);
|
|
58
|
+
const tree = source.tree ?? new MerkleTree(source.leaves.map(treeLeafHash));
|
|
59
|
+
const leaf = source.leaves[leafIndex];
|
|
60
|
+
const path = tree.path(leafIndex);
|
|
61
|
+
const reached = treeRootFromMember(leaf, leafIndex, doc.count, path);
|
|
62
|
+
if (reached === null || !bytesEqual(reached, doc.root))
|
|
63
|
+
throw new TypeError(`leaf ${leafIndex}'s path does not recompute the committed root`);
|
|
64
|
+
return buildExport({
|
|
65
|
+
proof: source.proof,
|
|
66
|
+
tree: { rootDocument: bytesToHex(source.rootDocument), member: buildTreeMemberEvidence(leaf, leafIndex, doc.count, path) },
|
|
67
|
+
...parts(extras),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The owner's export: every leaf in tree order and, when given, a name per
|
|
72
|
+
* leaf (unsigned, informational). The whole list is checked against the
|
|
73
|
+
* committed root first: sorted, without duplicates, rebuilding the root.
|
|
74
|
+
*/
|
|
75
|
+
export function buildOwnerExport(source, extras = {}) {
|
|
76
|
+
boundDocument(source);
|
|
77
|
+
const list = encodeTreeLeaves(source.leaves);
|
|
78
|
+
const check = verifyTreeLeaves(source.rootDocument, list);
|
|
79
|
+
if (!check.ok)
|
|
80
|
+
throw new TypeError(`the leaves do not make the committed tree: ${check.reason ?? "invalid"}`);
|
|
81
|
+
const names = extras.names;
|
|
82
|
+
if (names !== undefined && (names.length !== source.leaves.length || names.some((n) => typeof n !== "string"))) {
|
|
83
|
+
throw new TypeError(`names must be one string per leaf (${source.leaves.length})`);
|
|
84
|
+
}
|
|
85
|
+
return buildExport({
|
|
86
|
+
proof: source.proof,
|
|
87
|
+
tree: { rootDocument: bytesToHex(source.rootDocument), leaves: bytesToBase64(list), ...(names !== undefined ? { names: [...names] } : {}) },
|
|
88
|
+
...parts(extras),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** A name per leaf, in tree order, from a tree's members ("" for a member made without one). */
|
|
92
|
+
export function namesByLeaf(result) {
|
|
93
|
+
const names = new Array(result.count).fill("");
|
|
94
|
+
for (const m of result.members)
|
|
95
|
+
names[m.leafIndex] = m.name ?? "";
|
|
96
|
+
return names;
|
|
97
|
+
}
|
|
98
|
+
/** The floor a proof signs, or null when it signs none or is ambiguous (two floors). */
|
|
99
|
+
function signedFloor(proof) {
|
|
100
|
+
try {
|
|
101
|
+
return signedFloorOf(proof);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The floor for an export from a block header, or null unless the header
|
|
109
|
+
* decodes and hashes to the block the proof signs as its floor, at that
|
|
110
|
+
* height (for a Base floor, also at the signed time, on Base mainnet's
|
|
111
|
+
* schedule). The header is never trusted for anything it does not hash to.
|
|
112
|
+
*/
|
|
113
|
+
export function floorFromHeader(proof, headerHex) {
|
|
114
|
+
const signed = signedFloor(proof);
|
|
115
|
+
if (!signed || typeof headerHex !== "string")
|
|
116
|
+
return null;
|
|
117
|
+
try {
|
|
118
|
+
const r = checkFloorHeader(signed, evmHexToBytes(headerHex), signed.chain);
|
|
119
|
+
if (!r.ok)
|
|
120
|
+
return null;
|
|
121
|
+
const hex = headerHex.toLowerCase();
|
|
122
|
+
const header = hex.startsWith("0x") ? hex : `0x${hex}`;
|
|
123
|
+
return signed.chain === "base"
|
|
124
|
+
? { chain: "base", blockNumber: r.header.number, blockHash: r.header.hash, header }
|
|
125
|
+
: { blockNumber: r.header.number, blockHash: r.header.hash, header };
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const DEFAULT_SITE = "https://bitgraph.ing";
|
|
132
|
+
const DEFAULT_BASE_RPC = "https://mainnet.base.org";
|
|
133
|
+
function siteOf(opts) {
|
|
134
|
+
return (opts.baseUrl ?? DEFAULT_SITE).replace(/\/+$/, "");
|
|
135
|
+
}
|
|
136
|
+
/** One read-only GET: status and parsed JSON, or the reason it failed. Never throws. */
|
|
137
|
+
async function getJson(fetcher, url, timeoutMs) {
|
|
138
|
+
try {
|
|
139
|
+
const res = await fetcher(url, { method: "GET", headers: { accept: "application/json" }, redirect: "error", signal: AbortSignal.timeout(timeoutMs) });
|
|
140
|
+
let json = null;
|
|
141
|
+
try {
|
|
142
|
+
json = await res.json();
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
json = null;
|
|
146
|
+
}
|
|
147
|
+
return { status: res.status, json };
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The floor header for a proof, checked against the floor the proof signs:
|
|
155
|
+
* for an Ethereum floor, from the site's witness route
|
|
156
|
+
* (GET /api/proofs/witness?block=N&hash=0x...); for a Base floor, the site's
|
|
157
|
+
* saved copy (GET /api/proofs/floor-header?chain=base&block=N&hash=0x...)
|
|
158
|
+
* when opts.baseUrl names the site, else the Base node's block at the signed
|
|
159
|
+
* height (eth_getBlockByNumber), its header rebuilt from the node's JSON;
|
|
160
|
+
* either kept only when it hashes to the signed block hash.
|
|
161
|
+
* Null when the proof signs no floor, nothing answered with a header, or the
|
|
162
|
+
* header is not that block's.
|
|
163
|
+
*/
|
|
164
|
+
export async function fetchFloorHeader(proof, fetcher = fetch, opts = {}) {
|
|
165
|
+
const r = await floorHeaderLookup(proof, fetcher, opts);
|
|
166
|
+
return "floor" in r ? r.floor : null;
|
|
167
|
+
}
|
|
168
|
+
/** One floor-header lookup on the floor's own chain: the floor, or why there is none. Never throws. */
|
|
169
|
+
async function floorHeaderLookup(proof, fetcher, opts) {
|
|
170
|
+
const signed = signedFloor(proof);
|
|
171
|
+
if (!signed)
|
|
172
|
+
return { none: true };
|
|
173
|
+
const timeoutMs = opts.timeoutMs ?? 20_000;
|
|
174
|
+
if (signed.chain === "base") {
|
|
175
|
+
// The site's saved copy first, when the caller names its site (the parent
|
|
176
|
+
// saves each floor header before a proof stands on it), then a Base node
|
|
177
|
+
// by height. Either is kept only when it hashes to the signed block; a
|
|
178
|
+
// site that has no copy, or answers anything else, falls through.
|
|
179
|
+
if (opts.baseUrl !== undefined) {
|
|
180
|
+
const saved = await getJson(fetcher, `${siteOf(opts)}/api/proofs/floor-header?chain=base&block=${signed.blockNumber}&hash=${encodeURIComponent(signed.blockHash)}`, timeoutMs);
|
|
181
|
+
if (!("error" in saved) && saved.status === 200) {
|
|
182
|
+
const header = saved.json?.header;
|
|
183
|
+
const f = typeof header === "string" ? floorFromHeader(proof, header) : null;
|
|
184
|
+
if (f !== null)
|
|
185
|
+
return { floor: f };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const url = opts.baseRpcUrl ?? DEFAULT_BASE_RPC;
|
|
189
|
+
const r = await postJson(fetcher, url, { jsonrpc: "2.0", id: 1, method: "eth_getBlockByNumber", params: [`0x${signed.blockNumber.toString(16)}`, false] }, timeoutMs);
|
|
190
|
+
if ("error" in r)
|
|
191
|
+
return { note: `floor header: ${r.error}` };
|
|
192
|
+
if (r.status !== 200)
|
|
193
|
+
return { note: `floor header: the Base node answered ${r.status}` };
|
|
194
|
+
const block = r.json?.result ?? null;
|
|
195
|
+
if (block === null)
|
|
196
|
+
return { note: `floor header: the Base node has no block ${signed.blockNumber}` };
|
|
197
|
+
const rlp = headerRlpFromRpc(block, signed.blockHash);
|
|
198
|
+
const f = rlp === null ? null : floorFromHeader(proof, evmBytesToHex(rlp));
|
|
199
|
+
return f !== null ? { floor: f } : { note: `floor header: the Base node's block ${signed.blockNumber} is not the floor block the proof signs; not embedded` };
|
|
200
|
+
}
|
|
201
|
+
const r = await getJson(fetcher, `${siteOf(opts)}/api/proofs/witness?block=${signed.blockNumber}&hash=${encodeURIComponent(signed.blockHash)}`, timeoutMs);
|
|
202
|
+
if ("error" in r)
|
|
203
|
+
return { note: `floor header: ${r.error}` };
|
|
204
|
+
if (r.status !== 200)
|
|
205
|
+
return { note: `floor header: the witness route answered ${r.status}` };
|
|
206
|
+
const f = floorFromHeader(proof, witnessHeader(r.json) ?? "");
|
|
207
|
+
return f !== null ? { floor: f } : { note: "floor header: the witness route answered a header that is not the floor block the proof signs; not embedded" };
|
|
208
|
+
}
|
|
209
|
+
/** One JSON-RPC POST: status and parsed JSON, or the reason it failed. Never throws. */
|
|
210
|
+
async function postJson(fetcher, url, body, timeoutMs) {
|
|
211
|
+
try {
|
|
212
|
+
const res = await fetcher(url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json" }, body: JSON.stringify(body), redirect: "error", signal: AbortSignal.timeout(timeoutMs) });
|
|
213
|
+
let json = null;
|
|
214
|
+
try {
|
|
215
|
+
json = await res.json();
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
json = null;
|
|
219
|
+
}
|
|
220
|
+
return { status: res.status, json };
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** The header in a witness answer: the bitgraph-anchor-witness/1 object, or the same inside a { witness } envelope. */
|
|
227
|
+
function witnessHeader(json) {
|
|
228
|
+
const j = json;
|
|
229
|
+
const h = j?.headerRlpHex ?? j?.witness?.headerRlpHex;
|
|
230
|
+
return typeof h === "string" ? h : null;
|
|
231
|
+
}
|
|
232
|
+
function isCeiling(c) {
|
|
233
|
+
return c !== null && typeof c === "object" && c.version === CEILING_VERSION && c.anchor != null;
|
|
234
|
+
}
|
|
235
|
+
function isSettlement(s) {
|
|
236
|
+
return s !== null && typeof s === "object" && s.version === OUTPUT_ROOT_VERSION;
|
|
237
|
+
}
|
|
238
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
239
|
+
/**
|
|
240
|
+
* Fill what an export is waiting for, from read-only GETs on the site:
|
|
241
|
+
* floor GET /api/proofs/witness?block=N&hash=0x... for an Ethereum floor; a Base floor is
|
|
242
|
+
* GET /api/proofs/floor-header?chain=base&block=N&hash=0x..., else the Base node's
|
|
243
|
+
* block N (opts.baseRpcUrl); or the ceiling sidecar's own floor header
|
|
244
|
+
* ceiling GET /api/ceilings/<proofHash, URL-safe> 404: still pending
|
|
245
|
+
* settlement GET /api/ceilings/settlement/<Base block> 404: still pending
|
|
246
|
+
* Each is verified here before it is embedded, and nothing already present is
|
|
247
|
+
* overwritten. The fetcher is injectable; it defaults to the global fetch.
|
|
248
|
+
*/
|
|
249
|
+
export async function completeExport(input, fetcher = fetch, opts = {}) {
|
|
250
|
+
const exp = parseExport(input);
|
|
251
|
+
if (exp === null)
|
|
252
|
+
throw new TypeError("not a bitgraph-export/1 document");
|
|
253
|
+
const site = siteOf(opts);
|
|
254
|
+
const timeoutMs = opts.timeoutMs ?? 20_000;
|
|
255
|
+
const writerAddress = opts.writerAddress ?? BITGRAPH_CEILING_WRITER;
|
|
256
|
+
const chainId = opts.baseChainId ?? BASE_MAINNET_CHAIN_ID;
|
|
257
|
+
const proof = exp.proof;
|
|
258
|
+
const notes = new Set();
|
|
259
|
+
let floor = exp.floor ?? null;
|
|
260
|
+
let ceiling = exp.ceiling ?? null;
|
|
261
|
+
let settlement = exp.settlement ?? null;
|
|
262
|
+
let changed = false;
|
|
263
|
+
const deadline = Date.now() + (opts.waitMs ?? 0);
|
|
264
|
+
for (;;) {
|
|
265
|
+
// 1. The floor header, on the floor's own chain, checked against the signed floor.
|
|
266
|
+
if (floor === null) {
|
|
267
|
+
const r = await floorHeaderLookup(proof, fetcher, opts);
|
|
268
|
+
if ("floor" in r) {
|
|
269
|
+
floor = r.floor;
|
|
270
|
+
changed = true;
|
|
271
|
+
}
|
|
272
|
+
else if ("note" in r)
|
|
273
|
+
notes.add(r.note);
|
|
274
|
+
}
|
|
275
|
+
// 2. The ceiling on Base: the sidecar, verified for this proof and writer.
|
|
276
|
+
if (!isCeiling(ceiling)) {
|
|
277
|
+
const r = await getJson(fetcher, `${site}/api/ceilings/${encodeURIComponent(urlSafe(computeProofHash(proof)))}`, timeoutMs);
|
|
278
|
+
if ("error" in r)
|
|
279
|
+
notes.add(`ceiling: ${r.error}`);
|
|
280
|
+
else if (r.status === 404) {
|
|
281
|
+
if (ceiling === null) {
|
|
282
|
+
ceiling = { status: "pending" };
|
|
283
|
+
changed = true;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else if (r.status !== 200)
|
|
287
|
+
notes.add(`ceiling: the ceiling route answered ${r.status}`);
|
|
288
|
+
else {
|
|
289
|
+
const sidecar = r.json;
|
|
290
|
+
const v = await verifyCeiling(proof, sidecar, { writerAddress, chainId });
|
|
291
|
+
if (v.ok) {
|
|
292
|
+
ceiling = sidecar;
|
|
293
|
+
changed = true;
|
|
294
|
+
// The sidecar can carry the floor header too; it is checked the same way.
|
|
295
|
+
if (floor === null && typeof sidecar.floor?.blockHeader === "string") {
|
|
296
|
+
const f = floorFromHeader(proof, sidecar.floor.blockHeader);
|
|
297
|
+
if (f !== null)
|
|
298
|
+
floor = f;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else if (v.status === "pending") {
|
|
302
|
+
if (ceiling === null) {
|
|
303
|
+
ceiling = { status: "pending" };
|
|
304
|
+
changed = true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else
|
|
308
|
+
notes.add(`ceiling: the sidecar the site served does not verify (${v.reason ?? "invalid"}); not embedded`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// 3. The settlement on Ethereum, for the ceiling's own Base block.
|
|
312
|
+
if (!isSettlement(settlement)) {
|
|
313
|
+
if (isCeiling(ceiling)) {
|
|
314
|
+
const base = ceiling.anchor;
|
|
315
|
+
const pending = { status: "pending", baseBlock: base.blockNumber };
|
|
316
|
+
const r = await getJson(fetcher, `${site}/api/ceilings/settlement/${base.blockNumber}`, timeoutMs);
|
|
317
|
+
const answer = "error" in r ? null : r.json;
|
|
318
|
+
const s = (answer !== null && typeof answer === "object" && answer.settlement !== undefined ? answer.settlement : answer);
|
|
319
|
+
if ("error" in r)
|
|
320
|
+
notes.add(`settlement: ${r.error}`);
|
|
321
|
+
else if (r.status === 404 || (r.status === 200 && s?.status === "pending")) {
|
|
322
|
+
if (!samePending(settlement, pending)) {
|
|
323
|
+
settlement = pending;
|
|
324
|
+
changed = true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
else if (r.status !== 200)
|
|
328
|
+
notes.add(`settlement: the settlement route answered ${r.status}`);
|
|
329
|
+
else {
|
|
330
|
+
const so = s;
|
|
331
|
+
const v = verifyOutputRootSettlement(so, { baseChainId: chainId, ethereumChainId: opts.ethereumChainId ?? 1 });
|
|
332
|
+
const linked = so?.base?.blockNumber === base.blockNumber && typeof so.base.blockHash === "string" && so.base.blockHash.toLowerCase() === base.blockHash.toLowerCase();
|
|
333
|
+
if (v.ok && linked) {
|
|
334
|
+
settlement = so;
|
|
335
|
+
changed = true;
|
|
336
|
+
}
|
|
337
|
+
else
|
|
338
|
+
notes.add(`settlement: ${v.ok ? "it settles a different Base block than the ceiling's" : `it does not verify (${v.reason ?? "invalid"})`}; not embedded`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (settlement === null) {
|
|
342
|
+
settlement = { status: "pending" };
|
|
343
|
+
changed = true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const complete = floor !== null && isCeiling(ceiling) && isSettlement(settlement);
|
|
347
|
+
if (complete || Date.now() + 2_000 > deadline)
|
|
348
|
+
break;
|
|
349
|
+
await sleep(2_000);
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
export: buildExport({ proof, tree: exp.tree, floor, ceiling, settlement }),
|
|
353
|
+
changed,
|
|
354
|
+
floor: floor !== null ? "present" : "absent",
|
|
355
|
+
ceiling: isCeiling(ceiling) ? "present" : "pending",
|
|
356
|
+
settlement: isSettlement(settlement) ? "present" : "pending",
|
|
357
|
+
notes: [...notes],
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function samePending(s, p) {
|
|
361
|
+
return s !== null && s.status === "pending" && s.baseBlock === p.baseBlock;
|
|
362
|
+
}
|
|
363
|
+
function urlSafe(b64) {
|
|
364
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,WAAW,EACX,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,UAAU,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AC;IAED,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;QAC1E,OAAO;QACP,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;QAC5C,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACnD,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC5D,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC;KAClB,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,CAA+B,EAAE,CAA2C;IAC/F,OAAO,CAAC,KAAK,IAAI,IAAK,CAA0B,CAAC,MAAM,KAAK,SAAS,IAAK,CAA6B,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAAC;AACpI,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/fuse.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BitGraphProof, FuseFrame, FuseMemberResult, FuseVerifyResult, PlacementId, SetManifest, SetMemberProof, SetRoot, SlotAllocation } from "@mikeargento/bitgraph-verify";
|
|
1
|
+
import type { BitGraphProof, FuseFrame, FuseMemberResult, FuseVerifyResult, MerkleTree, PlacementId, SetManifest, SetMemberProof, SetRoot, SlotAllocation, TreeLeaf, TreeMemberEvidence, TreeVerifyResult } from "@mikeargento/bitgraph-verify";
|
|
2
2
|
/**
|
|
3
3
|
* SHA-256 over bytes: the platform's native hasher when one is present
|
|
4
4
|
* (WebCrypto, in browsers and in Node), else the JavaScript library. The
|
|
@@ -14,15 +14,26 @@ export interface AnchorMark {
|
|
|
14
14
|
blockNumber: number;
|
|
15
15
|
blockHash: string;
|
|
16
16
|
}
|
|
17
|
+
/** The Base floor an enclave v10 allocation hands back: the one it signs at commit as commit.slotFloor. */
|
|
18
|
+
export interface BaseFloorMark {
|
|
19
|
+
chain: "base";
|
|
20
|
+
evmChainId: 8453;
|
|
21
|
+
blockNumber: number;
|
|
22
|
+
blockHash: string;
|
|
23
|
+
blockTimestamp: number;
|
|
24
|
+
}
|
|
25
|
+
/** Either floor an allocation can return. A Base floor makes a fuse/3 commitment, an Ethereum anchor a fuse/2 one. */
|
|
26
|
+
export type FloorMark = AnchorMark | BaseFloorMark;
|
|
27
|
+
export declare function isBaseFloorMark(x: unknown): x is BaseFloorMark;
|
|
17
28
|
/** What the builder receives. The raw nonce is deliberately absent. */
|
|
18
29
|
export interface BuilderInput {
|
|
19
|
-
/** 32-byte commitment to the signed slot record (
|
|
30
|
+
/** 32-byte commitment to the signed slot record (fuse/2 and fuse/3 also bind the floor block). Write this into the artifact. */
|
|
20
31
|
commitment: Uint8Array;
|
|
21
32
|
commitmentHex: string;
|
|
22
|
-
/** Which commitment this is:
|
|
23
|
-
fuseVersion: 1 | 2;
|
|
24
|
-
/** The floor bound into
|
|
25
|
-
floor?:
|
|
33
|
+
/** Which commitment this is: 3 for a Base floor (enclave v10), 2 for an Ethereum floor anchor (v9), else 1. */
|
|
34
|
+
fuseVersion: 1 | 2 | 3;
|
|
35
|
+
/** The floor bound into the commitment, when there is one. */
|
|
36
|
+
floor?: FloorMark;
|
|
26
37
|
/** The origin digest, when the fused artifact names a source. */
|
|
27
38
|
originDigest?: Uint8Array;
|
|
28
39
|
/** The signed slot record, for producers that want to embed its fields. Contains the nonce: do not copy it into the artifact. */
|
|
@@ -74,7 +85,9 @@ export interface FuseResult {
|
|
|
74
85
|
/** The local verification of the returned proof against the fused bytes. Always FUSED_DIRECT on success. */
|
|
75
86
|
verification: FuseVerifyResult;
|
|
76
87
|
}
|
|
77
|
-
export type FuseErrorCode = "bad-placement" | "bad-input" | "allocate-failed" | "builder-failed" | "load-failed" | "commitment-missing" | "commit-refused" | "slot-unavailable" | "tee-restarting" | "network" | "slot-mismatch" | "verification-failed" | "transport"
|
|
88
|
+
export type FuseErrorCode = "bad-placement" | "bad-input" | "allocate-failed" | "builder-failed" | "load-failed" | "commitment-missing" | "commit-refused" | "slot-unavailable" | "tee-restarting" | "network" | "slot-mismatch" | "verification-failed" | "transport"
|
|
89
|
+
/** tree/1 only: the allocation returned no floor anchor (a boundary before enclave v9), so no tree/1 commitment can be made. */
|
|
90
|
+
| "floor-missing";
|
|
78
91
|
export declare class FuseError extends Error {
|
|
79
92
|
readonly code: FuseErrorCode;
|
|
80
93
|
readonly status: number | null;
|
|
@@ -107,6 +120,9 @@ export declare function builderFor(placement: PlacementId, original?: Uint8Array
|
|
|
107
120
|
* Allocate, fuse, hash, fill. Returns the Frame with the unchanged proof, or
|
|
108
121
|
* throws a FuseError; it never returns an ordinary recording in place of a
|
|
109
122
|
* fused one.
|
|
123
|
+
*
|
|
124
|
+
* Superseded by fuseTree (tree/1, 2026-10-03): a new BitGraph of one file is
|
|
125
|
+
* a tree of one. Kept so code that imports it keeps working.
|
|
110
126
|
*/
|
|
111
127
|
export declare function fuse(builder: FuseBuilder, options: FuseOptions): Promise<FuseResult>;
|
|
112
128
|
/**
|
|
@@ -123,10 +139,10 @@ export declare const MAX_SET_MEMBERS = 2000;
|
|
|
123
139
|
export type SetMemberPlacement = "trailer/1" | "container/1" | "container/2";
|
|
124
140
|
/** What a hashed member's fused digest is computed for: the held slot and its commitment. */
|
|
125
141
|
export interface FusedDigestInput {
|
|
126
|
-
/** Which commitment this is:
|
|
127
|
-
fuseVersion: 1 | 2;
|
|
128
|
-
/** The floor bound into
|
|
129
|
-
floor?:
|
|
142
|
+
/** Which commitment this is: 3 for a Base floor, 2 for an Ethereum floor anchor, else 1. */
|
|
143
|
+
fuseVersion: 1 | 2 | 3;
|
|
144
|
+
/** The floor bound into the commitment, when there is one. */
|
|
145
|
+
floor?: FloorMark;
|
|
130
146
|
commitment: Uint8Array;
|
|
131
147
|
commitmentHex: string;
|
|
132
148
|
slot: SlotAllocation;
|
|
@@ -278,8 +294,137 @@ export interface FuseSetResult {
|
|
|
278
294
|
* allocates a second slot. Members may be given as bytes, as a loader read
|
|
279
295
|
* one at a time after the slot is held, or as a digest the caller finishes
|
|
280
296
|
* itself; one set may mix them.
|
|
297
|
+
*
|
|
298
|
+
* Superseded by fuseTree (tree/1, 2026-10-03): N files are one tree under one
|
|
299
|
+
* position. Kept so code that imports it keeps working.
|
|
281
300
|
*/
|
|
282
301
|
export declare function fuseSet(members: readonly FuseSetMember[], options?: FuseSetOptions): Promise<FuseSetResult>;
|
|
302
|
+
/** How a file goes into a tree: as is (0x00), or placed into committed bytes that carry the commitment. */
|
|
303
|
+
export type TreeMemberPlacement = "as-is" | SetMemberPlacement;
|
|
304
|
+
/**
|
|
305
|
+
* The placement a file takes in a tree, from its size and its first bytes
|
|
306
|
+
* (every magic number placementForBytes reads sits in the first 16): trailer/1
|
|
307
|
+
* for the formats that ignore trailing bytes, container/2 for everything else,
|
|
308
|
+
* except that a file too large for a ustar entry (MAX_CONTAINER_ENTRY_BYTES,
|
|
309
|
+
* 8 GiB - 1, SPEC 7.3) takes trailer/1 whatever its bytes: the committed
|
|
310
|
+
* bytes are virtual, so a trailer costs the file nothing. Never as is: that
|
|
311
|
+
* is the user's choice, and no producer decides it by size (SPEC 7.5, 8.1).
|
|
312
|
+
*/
|
|
313
|
+
export declare function treePlacementFor(size: number, head: Uint8Array): "trailer/1" | "container/2";
|
|
314
|
+
/** A tree member given as bytes: hashed, placed (unless as is), checked and hashed again by the core. */
|
|
315
|
+
export interface FuseTreeBytesMember {
|
|
316
|
+
original: Uint8Array;
|
|
317
|
+
/** Default: treePlacementFor(original.length, original). As is is asked for by name, never by size. */
|
|
318
|
+
placement?: TreeMemberPlacement;
|
|
319
|
+
/** Unsigned and informational: the owner's export lists it beside the leaf. */
|
|
320
|
+
name?: string;
|
|
321
|
+
/** Placed members only. Default: the placement's own build. The locate and origin guards run regardless. */
|
|
322
|
+
builder?: FuseBuilder;
|
|
323
|
+
}
|
|
324
|
+
/** A placed member read only when it is its turn, after the slot is held, and checked against its named digest. */
|
|
325
|
+
export interface FuseTreeLoadedMember {
|
|
326
|
+
load: () => Promise<Uint8Array> | Uint8Array;
|
|
327
|
+
originDigest: Uint8Array;
|
|
328
|
+
placement: SetMemberPlacement;
|
|
329
|
+
name?: string;
|
|
330
|
+
builder?: FuseBuilder;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* A placed member whose committed digest the caller finishes itself for the
|
|
334
|
+
* held commitment (a scanner's saved hash state finished with the placement's
|
|
335
|
+
* suffix). The core never sees its bytes.
|
|
336
|
+
*/
|
|
337
|
+
export interface FuseTreeHashedMember {
|
|
338
|
+
originDigest: Uint8Array;
|
|
339
|
+
placement: SetMemberPlacement;
|
|
340
|
+
fusedDigest: (input: FusedDigestInput) => Promise<Uint8Array> | Uint8Array;
|
|
341
|
+
name?: string;
|
|
342
|
+
}
|
|
343
|
+
/** A file that goes in as is, given by its digest alone: nothing is read, placed or loaded. */
|
|
344
|
+
export interface FuseTreeAsIsMember {
|
|
345
|
+
originDigest: Uint8Array;
|
|
346
|
+
placement: "as-is";
|
|
347
|
+
name?: string;
|
|
348
|
+
}
|
|
349
|
+
export type FuseTreeMember = FuseTreeBytesMember | FuseTreeLoadedMember | FuseTreeHashedMember | FuseTreeAsIsMember;
|
|
350
|
+
/** Progress, in fuseSet's phases: hash (before any request), fuse (each leaf, after the slot is held), tree, commit, verify (only with verifyMembers). */
|
|
351
|
+
export type FuseTreeProgress = FuseSetProgress;
|
|
352
|
+
export interface FuseTreeOptions {
|
|
353
|
+
/** Return each member's committed bytes (for as is, the original itself) when they passed through the core. Default false: they are virtual, rebuilt from the original and the proof. */
|
|
354
|
+
keepCommitted?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Run verifyTreeMember over every member's committed bytes after the
|
|
357
|
+
* commit and return each verdict. Default false: every member's leaf is
|
|
358
|
+
* bound to the returned proof by its path to the verified root, which
|
|
359
|
+
* reads no bytes. A hashed member, or an as-is member given by its digest,
|
|
360
|
+
* has no bytes here and is refused before any request.
|
|
361
|
+
*/
|
|
362
|
+
verifyMembers?: boolean;
|
|
363
|
+
/** Called as the tree advances. A throw inside it is ignored: a progress hook never changes the outcome. */
|
|
364
|
+
onProgress?: (progress: FuseTreeProgress) => void;
|
|
365
|
+
/** Actor-bound commits: an agency envelope passed through untouched. */
|
|
366
|
+
agency?: unknown;
|
|
367
|
+
transport?: FuseTransport;
|
|
368
|
+
}
|
|
369
|
+
export interface FuseTreeMemberResult {
|
|
370
|
+
/** The caller's index into members. */
|
|
371
|
+
index: number;
|
|
372
|
+
/** The member's leaf in the sorted tree: its evidence's index. */
|
|
373
|
+
leafIndex: number;
|
|
374
|
+
placement: TreeMemberPlacement;
|
|
375
|
+
/** The leaf's placement code: 0x00 as is, 0x01 trailer/1, 0x02 container/1, 0x03 container/2. */
|
|
376
|
+
code: number;
|
|
377
|
+
originDigestB64: string;
|
|
378
|
+
/** SHA-256 of the committed bytes: the leaf's artifact. For as is, the file's own digest. */
|
|
379
|
+
artifactDigestB64: string;
|
|
380
|
+
name: string | null;
|
|
381
|
+
/** Present only with keepCommitted, for a member whose bytes passed through the core (never a hashed member, nor an as-is member given by its digest). */
|
|
382
|
+
committedBytes?: Uint8Array;
|
|
383
|
+
/** Present only with verifyMembers: the verifier's verdict on the committed bytes, TREE_MEMBER_DIRECT (TREE_MEMBER_AS_IS for as is) on success. */
|
|
384
|
+
verification?: TreeVerifyResult;
|
|
385
|
+
}
|
|
386
|
+
export interface FuseTreeResult {
|
|
387
|
+
proof: BitGraphProof;
|
|
388
|
+
/** The committed artifact: the 84-byte root document. Its SHA-256 is the signed digest; every export carries it. */
|
|
389
|
+
rootDocument: Uint8Array;
|
|
390
|
+
/** SHA-256 of rootDocument, standard base64; equals proof.artifact.digestB64. */
|
|
391
|
+
artifactDigestB64: string;
|
|
392
|
+
count: number;
|
|
393
|
+
/** The tree's root, lowercase hex. */
|
|
394
|
+
rootHex: string;
|
|
395
|
+
/** commitment/2 or /3, which every placed member's committed bytes carry. committedBytesFor(member.code, original, commitment) rebuilds them. */
|
|
396
|
+
commitment: Uint8Array;
|
|
397
|
+
/** The floor block the commitment binds, as the proof signs it (commit.slotAnchor or commit.slotFloor). */
|
|
398
|
+
floor: FloorMark;
|
|
399
|
+
/** The spec hash the signed attribution pins, standard base64. */
|
|
400
|
+
specHashB64: string;
|
|
401
|
+
/** Every leaf, in tree order (strictly ascending artifact digest). */
|
|
402
|
+
leaves: TreeLeaf[];
|
|
403
|
+
/** The tree over those leaves: tree.path(k) is leaf k's path. */
|
|
404
|
+
tree: MerkleTree;
|
|
405
|
+
/** In the caller's order. */
|
|
406
|
+
members: FuseTreeMemberResult[];
|
|
407
|
+
/** A member's evidence (TreeMemberEvidence JSON) by the caller's index, built on demand so a large tree holds no path it is not asked for. */
|
|
408
|
+
memberEvidence: (index: number) => TreeMemberEvidence;
|
|
409
|
+
/** True when the commit response was lost and the proof was read back by the root document's digest. */
|
|
410
|
+
recovered: boolean;
|
|
411
|
+
/** True only when the proof's metadata carries this root document. Absent is normal for a boundary that drops metadata; exports carry the document either way. */
|
|
412
|
+
rootDocumentEchoed: boolean;
|
|
413
|
+
/** verifyTreeMember over the proof and the root document: TREE_ROOT_VALID on success. */
|
|
414
|
+
verification: TreeVerifyResult;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Make ONE tree/1 BitGraph of 1 to N files: allocate one slot, take its floor,
|
|
418
|
+
* make every member's leaf under commitment/2, build the tree and its root
|
|
419
|
+
* document, commit the document's digest under the same slot with the spec
|
|
420
|
+
* pinned in the signed attribution, and verify what comes back before
|
|
421
|
+
* returning it. Throws a FuseError otherwise; it never commits a partial
|
|
422
|
+
* tree, never allocates a second slot, and never makes a tree without the
|
|
423
|
+
* floor. Members may be bytes, a loader read after the slot is held, a digest
|
|
424
|
+
* the caller finishes from a saved hash state, or (for as is) a digest alone;
|
|
425
|
+
* one tree may mix them.
|
|
426
|
+
*/
|
|
427
|
+
export declare function fuseTree(members: readonly FuseTreeMember[], options?: FuseTreeOptions): Promise<FuseTreeResult>;
|
|
283
428
|
/** Decode a standard-base64 digest, for callers holding one as text. */
|
|
284
429
|
export declare function digestFromBase64(b64: string): Uint8Array;
|
|
285
430
|
//# sourceMappingURL=fuse.d.ts.map
|
package/dist/fuse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuse.d.ts","sourceRoot":"","sources":["../src/fuse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fuse.d.ts","sourceRoot":"","sources":["../src/fuse.ts"],"names":[],"mappings":"AAyFA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAW,UAAU,EAAa,WAAW,EAAE,WAAW,EAAa,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAE/Q;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAUnE;AAED,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAE3J,6GAA6G;AAC7G,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC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