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