@mikeargento/bitgraph-verify 1.3.0 → 1.4.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/fuse-verify.d.ts +56 -0
- package/dist/fuse-verify.d.ts.map +1 -0
- package/dist/fuse-verify.js +231 -0
- package/dist/fuse-verify.js.map +1 -0
- package/dist/fuse.d.ts +145 -0
- package/dist/fuse.d.ts.map +1 -0
- package/dist/fuse.js +502 -0
- package/dist/fuse.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/fuse-verify.ts +306 -0
- package/src/fuse.ts +570 -0
- package/src/index.ts +33 -0
package/dist/fuse.js
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* BitGraph Fuse, profile `bitgraph-fuse/1`: construction and parsing.
|
|
4
|
+
*
|
|
5
|
+
* A fused artifact is a file that contains a commitment to a signed slot
|
|
6
|
+
* allocation obtained BEFORE the file was finished. The ordinary bitgraph/1
|
|
7
|
+
* primitive then commits the file's digest exactly as it commits any digest.
|
|
8
|
+
* A valid fused proof therefore bounds the file from below (the slot) and from
|
|
9
|
+
* above (the commit): the exact fused bytes could not feasibly have been
|
|
10
|
+
* finalized before their slot allocation and were committed no later than
|
|
11
|
+
* their commit position.
|
|
12
|
+
*
|
|
13
|
+
* Everything a verifier needs to REBUILD a fused artifact from an original and
|
|
14
|
+
* a proof lives here, which is why it is in the MIT package: the slot record
|
|
15
|
+
* hash (the enclave's own canonical subset), the commitment, and a registry of
|
|
16
|
+
* placements that say byte for byte how the commitment and the origin digest
|
|
17
|
+
* were placed. Nothing here talks to a service.
|
|
18
|
+
*
|
|
19
|
+
* Definitions (spec 3.5):
|
|
20
|
+
* slotRecordHash = SHA256(canonical slot record body) 32 bytes
|
|
21
|
+
* slotCommitment = SHA256(UTF8("bitgraph-fuse/1") || 0x00 || slotRecordHash || nonce)
|
|
22
|
+
* with the nonce as its raw 32 bytes. The raw nonce never enters a fused file;
|
|
23
|
+
* only the commitment does, so a partially written file cannot be used to
|
|
24
|
+
* claim the slot.
|
|
25
|
+
*/
|
|
26
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
27
|
+
import { canonicalize } from "./canonical.js";
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Constants
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
export const FUSE_PROFILE = "bitgraph-fuse/1";
|
|
32
|
+
/** Domain separation prefix: the 15 profile bytes followed by one zero byte. */
|
|
33
|
+
export const FUSE_DOMAIN = (() => {
|
|
34
|
+
const label = new TextEncoder().encode(FUSE_PROFILE);
|
|
35
|
+
const out = new Uint8Array(label.length + 1);
|
|
36
|
+
out.set(label, 0);
|
|
37
|
+
out[label.length] = 0x00;
|
|
38
|
+
return out;
|
|
39
|
+
})();
|
|
40
|
+
/**
|
|
41
|
+
* The signed attribution name that marks a fused proof (spec 6.5): the profile
|
|
42
|
+
* id itself, the stable wire identifier of this construction. A product name
|
|
43
|
+
* may change; the v1 wire identifier does not (ruled 2026-09-03).
|
|
44
|
+
*/
|
|
45
|
+
export const FUSE_ATTRIBUTION_NAME = FUSE_PROFILE;
|
|
46
|
+
/** Trailer placement: 8 ASCII magic bytes, 8 reserved zero bytes, 32 commitment bytes. */
|
|
47
|
+
export const TRAILER_MAGIC = "BGFUSE01";
|
|
48
|
+
export const TRAILER_LENGTH = 48;
|
|
49
|
+
/** Fixed paths inside a container/1 archive. */
|
|
50
|
+
export const CONTAINER_MANIFEST_PATH = "bitgraph-fuse/manifest.json";
|
|
51
|
+
export const CONTAINER_ORIGINAL_PATH = "bitgraph-fuse/original";
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Byte helpers (pure JS, so the module runs in browsers and Node alike)
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
56
|
+
const B64_LOOKUP = {};
|
|
57
|
+
for (let i = 0; i < B64.length; i++)
|
|
58
|
+
B64_LOOKUP[B64[i]] = i;
|
|
59
|
+
export function bytesToBase64(bytes) {
|
|
60
|
+
let out = "";
|
|
61
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
62
|
+
const a = bytes[i];
|
|
63
|
+
const b = i + 1 < bytes.length ? bytes[i + 1] : 0;
|
|
64
|
+
const c = i + 2 < bytes.length ? bytes[i + 2] : 0;
|
|
65
|
+
out += B64[a >> 2] + B64[((a & 3) << 4) | (b >> 4)];
|
|
66
|
+
out += i + 1 < bytes.length ? B64[((b & 15) << 2) | (c >> 6)] : "=";
|
|
67
|
+
out += i + 2 < bytes.length ? B64[c & 63] : "=";
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/** Strict standard base64 (RFC 4648 section 4): no whitespace, no URL-safe alphabet, correct padding. */
|
|
72
|
+
export function base64ToBytes(b64) {
|
|
73
|
+
if (typeof b64 !== "string" || b64.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(b64))
|
|
74
|
+
return null;
|
|
75
|
+
const pad = b64.endsWith("==") ? 2 : b64.endsWith("=") ? 1 : 0;
|
|
76
|
+
const out = new Uint8Array((b64.length / 4) * 3 - pad);
|
|
77
|
+
let o = 0;
|
|
78
|
+
for (let i = 0; i < b64.length; i += 4) {
|
|
79
|
+
const n = (B64_LOOKUP[b64[i]] << 18) |
|
|
80
|
+
(B64_LOOKUP[b64[i + 1]] << 12) |
|
|
81
|
+
((b64[i + 2] === "=" ? 0 : B64_LOOKUP[b64[i + 2]]) << 6) |
|
|
82
|
+
(b64[i + 3] === "=" ? 0 : B64_LOOKUP[b64[i + 3]]);
|
|
83
|
+
out[o++] = (n >> 16) & 255;
|
|
84
|
+
if (o < out.length)
|
|
85
|
+
out[o++] = (n >> 8) & 255;
|
|
86
|
+
if (o < out.length)
|
|
87
|
+
out[o++] = n & 255;
|
|
88
|
+
}
|
|
89
|
+
// Reject non-canonical padding bits (e.g. "AQ=" style trailing garbage).
|
|
90
|
+
if (bytesToBase64(out) !== b64)
|
|
91
|
+
return null;
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
export function bytesToHex(bytes) {
|
|
95
|
+
let s = "";
|
|
96
|
+
for (const b of bytes)
|
|
97
|
+
s += (b < 16 ? "0" : "") + b.toString(16);
|
|
98
|
+
return s;
|
|
99
|
+
}
|
|
100
|
+
/** Lowercase hex only; uppercase is rejected so one digest has one spelling. */
|
|
101
|
+
export function hexToBytes(hex) {
|
|
102
|
+
if (typeof hex !== "string" || hex.length % 2 !== 0 || !/^[0-9a-f]*$/.test(hex))
|
|
103
|
+
return null;
|
|
104
|
+
const out = new Uint8Array(hex.length / 2);
|
|
105
|
+
for (let i = 0; i < out.length; i++)
|
|
106
|
+
out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
export function bytesEqual(a, b) {
|
|
110
|
+
if (a.length !== b.length)
|
|
111
|
+
return false;
|
|
112
|
+
let diff = 0;
|
|
113
|
+
for (let i = 0; i < a.length; i++)
|
|
114
|
+
diff |= a[i] ^ b[i];
|
|
115
|
+
return diff === 0;
|
|
116
|
+
}
|
|
117
|
+
function concat(...parts) {
|
|
118
|
+
let n = 0;
|
|
119
|
+
for (const p of parts)
|
|
120
|
+
n += p.length;
|
|
121
|
+
const out = new Uint8Array(n);
|
|
122
|
+
let o = 0;
|
|
123
|
+
for (const p of parts) {
|
|
124
|
+
out.set(p, o);
|
|
125
|
+
o += p.length;
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// Slot record hash and slot commitment
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
/**
|
|
134
|
+
* The enclave's canonical slot body: the signed subset of the slot record,
|
|
135
|
+
* excluding signatureB64, with `time` and `chainId` present only when the
|
|
136
|
+
* record carries them. Identical to the reconstruction in verifier.ts
|
|
137
|
+
* (verifySlotAllocation) and to the enclave's own slotBody. There is exactly
|
|
138
|
+
* one serialization of a slot record; this is it.
|
|
139
|
+
*/
|
|
140
|
+
export function canonicalSlotBody(slot) {
|
|
141
|
+
return {
|
|
142
|
+
version: slot.version,
|
|
143
|
+
nonceB64: slot.nonceB64,
|
|
144
|
+
counter: slot.counter,
|
|
145
|
+
...(slot.time !== undefined ? { time: slot.time } : {}),
|
|
146
|
+
epochId: slot.epochId,
|
|
147
|
+
publicKeyB64: slot.publicKeyB64,
|
|
148
|
+
...(slot.chainId ? { chainId: slot.chainId } : {}),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** SHA-256 of the canonical slot body; equals the proof's commit.slotHashB64. */
|
|
152
|
+
export function computeSlotRecordHash(slot) {
|
|
153
|
+
return sha256(canonicalize(canonicalSlotBody(slot)));
|
|
154
|
+
}
|
|
155
|
+
/** The exact preimage of the commitment, for vectors and audits: domain || slotRecordHash || nonce. */
|
|
156
|
+
export function slotCommitmentPreimage(slot) {
|
|
157
|
+
const nonce = base64ToBytes(slot.nonceB64);
|
|
158
|
+
if (nonce === null || nonce.length !== 32) {
|
|
159
|
+
throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");
|
|
160
|
+
}
|
|
161
|
+
return concat(FUSE_DOMAIN, computeSlotRecordHash(slot), nonce);
|
|
162
|
+
}
|
|
163
|
+
/** slotCommitment = SHA256(domain || slotRecordHash || nonce). */
|
|
164
|
+
export function computeSlotCommitment(slot) {
|
|
165
|
+
return sha256(slotCommitmentPreimage(slot));
|
|
166
|
+
}
|
|
167
|
+
/** Build the canonical Form C payload bytes (spec 6.2). Digests are lowercase hex. */
|
|
168
|
+
export function buildFusePayload(commitment, originDigest) {
|
|
169
|
+
if (commitment.length !== 32)
|
|
170
|
+
throw new TypeError("commitment must be 32 bytes");
|
|
171
|
+
if (originDigest !== undefined && originDigest.length !== 32)
|
|
172
|
+
throw new TypeError("originDigest must be 32 bytes");
|
|
173
|
+
const payload = {
|
|
174
|
+
type: FUSE_PROFILE,
|
|
175
|
+
...(originDigest !== undefined ? { origin: { algorithm: "sha256", digest: bytesToHex(originDigest) } } : {}),
|
|
176
|
+
slotCommitment: { algorithm: "sha256", digest: bytesToHex(commitment) },
|
|
177
|
+
};
|
|
178
|
+
return canonicalize(payload);
|
|
179
|
+
}
|
|
180
|
+
function isPlainObject(x) {
|
|
181
|
+
return x !== null && typeof x === "object" && !Array.isArray(x) && Object.getPrototypeOf(x) === Object.prototype;
|
|
182
|
+
}
|
|
183
|
+
function readDigestField(x) {
|
|
184
|
+
if (!isPlainObject(x))
|
|
185
|
+
return null;
|
|
186
|
+
const keys = Object.keys(x);
|
|
187
|
+
if (keys.length !== 2 || x["algorithm"] !== "sha256" || typeof x["digest"] !== "string")
|
|
188
|
+
return null;
|
|
189
|
+
const bytes = hexToBytes(x["digest"]);
|
|
190
|
+
return bytes !== null && bytes.length === 32 ? bytes : null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Strict parse of Form C bytes. The bytes must be valid UTF-8 JSON, a plain
|
|
194
|
+
* object with exactly the allowed keys, the profile type, lowercase-hex
|
|
195
|
+
* 32-byte digests, and must equal their own re-canonicalization byte for byte
|
|
196
|
+
* (which rejects whitespace, key-order games, and duplicate keys, since a
|
|
197
|
+
* duplicate cannot survive a round trip). Returns null on any deviation.
|
|
198
|
+
*/
|
|
199
|
+
export function parseFusePayload(bytes) {
|
|
200
|
+
let text;
|
|
201
|
+
try {
|
|
202
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
let parsed;
|
|
208
|
+
try {
|
|
209
|
+
parsed = JSON.parse(text);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
if (!isPlainObject(parsed))
|
|
215
|
+
return null;
|
|
216
|
+
const keys = Object.keys(parsed).sort();
|
|
217
|
+
const allowed = keys.length === 2 ? ["slotCommitment", "type"] : keys.length === 3 ? ["origin", "slotCommitment", "type"] : null;
|
|
218
|
+
if (allowed === null || keys.join(",") !== allowed.join(","))
|
|
219
|
+
return null;
|
|
220
|
+
if (parsed["type"] !== FUSE_PROFILE)
|
|
221
|
+
return null;
|
|
222
|
+
const commitment = readDigestField(parsed["slotCommitment"]);
|
|
223
|
+
if (commitment === null)
|
|
224
|
+
return null;
|
|
225
|
+
let originDigest;
|
|
226
|
+
if ("origin" in parsed) {
|
|
227
|
+
const o = readDigestField(parsed["origin"]);
|
|
228
|
+
if (o === null)
|
|
229
|
+
return null;
|
|
230
|
+
originDigest = o;
|
|
231
|
+
}
|
|
232
|
+
if (!bytesEqual(buildFusePayload(commitment, originDigest), bytes))
|
|
233
|
+
return null;
|
|
234
|
+
return originDigest !== undefined ? { commitment, originDigest } : { commitment };
|
|
235
|
+
}
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
// Minimal deterministic ustar (POSIX.1-1988) for container/1
|
|
238
|
+
// ---------------------------------------------------------------------------
|
|
239
|
+
const BLOCK = 512;
|
|
240
|
+
const MAX_ENTRY = 0o77777777777; // 8 GiB - 1, the 11-digit octal size field
|
|
241
|
+
function octal(n, width) {
|
|
242
|
+
const s = n.toString(8).padStart(width - 1, "0") + "\0";
|
|
243
|
+
if (s.length !== width)
|
|
244
|
+
throw new RangeError("field overflow");
|
|
245
|
+
return utf8(s);
|
|
246
|
+
}
|
|
247
|
+
function ustarHeader(name, size) {
|
|
248
|
+
if (size > MAX_ENTRY)
|
|
249
|
+
throw new RangeError("container/1 entries are limited to 8 GiB");
|
|
250
|
+
const h = new Uint8Array(BLOCK);
|
|
251
|
+
const nameBytes = utf8(name);
|
|
252
|
+
if (nameBytes.length > 100)
|
|
253
|
+
throw new RangeError("ustar name too long");
|
|
254
|
+
h.set(nameBytes, 0);
|
|
255
|
+
h.set(utf8("0000644\0"), 100); // mode
|
|
256
|
+
h.set(utf8("0000000\0"), 108); // uid
|
|
257
|
+
h.set(utf8("0000000\0"), 116); // gid
|
|
258
|
+
h.set(octal(size, 12), 124); // size
|
|
259
|
+
h.set(utf8("00000000000\0"), 136); // mtime: 0, the epoch; nothing about a clock enters the bytes
|
|
260
|
+
h.set(utf8(" "), 148); // checksum placeholder
|
|
261
|
+
h[156] = 0x30; // typeflag '0' regular file
|
|
262
|
+
h.set(utf8("ustar\0"), 257); // magic
|
|
263
|
+
h.set(utf8("00"), 263); // version
|
|
264
|
+
// uname, gname, devmajor, devminor, prefix: all zero
|
|
265
|
+
let sum = 0;
|
|
266
|
+
for (const b of h)
|
|
267
|
+
sum += b;
|
|
268
|
+
h.set(utf8(sum.toString(8).padStart(6, "0") + "\0 "), 148);
|
|
269
|
+
return h;
|
|
270
|
+
}
|
|
271
|
+
function padTo(n) {
|
|
272
|
+
return (BLOCK - (n % BLOCK)) % BLOCK;
|
|
273
|
+
}
|
|
274
|
+
/** Build a container/1 archive: manifest entry, then the original, then two zero blocks. */
|
|
275
|
+
function buildContainer(original, manifest) {
|
|
276
|
+
return concat(ustarHeader(CONTAINER_MANIFEST_PATH, manifest.length), manifest, new Uint8Array(padTo(manifest.length)), ustarHeader(CONTAINER_ORIGINAL_PATH, original.length), original, new Uint8Array(padTo(original.length)), new Uint8Array(BLOCK * 2));
|
|
277
|
+
}
|
|
278
|
+
/** Parse a ustar stream into entries; null when malformed. Does not accept extensions. */
|
|
279
|
+
function parseTar(bytes) {
|
|
280
|
+
const entries = [];
|
|
281
|
+
let off = 0;
|
|
282
|
+
while (off + BLOCK <= bytes.length) {
|
|
283
|
+
const h = bytes.subarray(off, off + BLOCK);
|
|
284
|
+
if (h.every((b) => b === 0)) {
|
|
285
|
+
// End marker: two zero blocks, then nothing.
|
|
286
|
+
const rest = bytes.subarray(off);
|
|
287
|
+
if (rest.length !== BLOCK * 2 || !rest.every((b) => b === 0))
|
|
288
|
+
return null;
|
|
289
|
+
return entries;
|
|
290
|
+
}
|
|
291
|
+
const nameEnd = h.indexOf(0, 0);
|
|
292
|
+
const name = new TextDecoder().decode(h.subarray(0, nameEnd < 0 || nameEnd > 100 ? 100 : nameEnd));
|
|
293
|
+
const sizeText = new TextDecoder().decode(h.subarray(124, 135));
|
|
294
|
+
if (!/^[0-7]{11}$/.test(sizeText))
|
|
295
|
+
return null;
|
|
296
|
+
const size = parseInt(sizeText, 8);
|
|
297
|
+
if (off + BLOCK + size > bytes.length)
|
|
298
|
+
return null;
|
|
299
|
+
const data = bytes.subarray(off + BLOCK, off + BLOCK + size);
|
|
300
|
+
entries.push({ name, data, headerBytes: h });
|
|
301
|
+
off += BLOCK + size + padTo(size);
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
const trailer1 = {
|
|
306
|
+
id: "trailer/1",
|
|
307
|
+
form: "A",
|
|
308
|
+
byteExact: true,
|
|
309
|
+
build({ original, commitment }) {
|
|
310
|
+
if (original === undefined)
|
|
311
|
+
throw new TypeError("trailer/1 requires the original bytes");
|
|
312
|
+
if (commitment.length !== 32)
|
|
313
|
+
throw new TypeError("commitment must be 32 bytes");
|
|
314
|
+
return concat(original, utf8(TRAILER_MAGIC), new Uint8Array(8), commitment);
|
|
315
|
+
},
|
|
316
|
+
locate(fused) {
|
|
317
|
+
if (fused.length < TRAILER_LENGTH)
|
|
318
|
+
return null;
|
|
319
|
+
const t = fused.subarray(fused.length - TRAILER_LENGTH);
|
|
320
|
+
if (!bytesEqual(t.subarray(0, 8), utf8(TRAILER_MAGIC)))
|
|
321
|
+
return null;
|
|
322
|
+
if (!t.subarray(8, 16).every((b) => b === 0))
|
|
323
|
+
return null;
|
|
324
|
+
return { commitment: new Uint8Array(t.subarray(16, 48)), originalBytes: fused.subarray(0, fused.length - TRAILER_LENGTH) };
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
const container1 = {
|
|
328
|
+
id: "container/1",
|
|
329
|
+
form: "B",
|
|
330
|
+
byteExact: true,
|
|
331
|
+
build({ original, originDigest, commitment }) {
|
|
332
|
+
if (original === undefined)
|
|
333
|
+
throw new TypeError("container/1 requires the original bytes");
|
|
334
|
+
const digest = originDigest ?? sha256(original);
|
|
335
|
+
return buildContainer(original, buildFusePayload(commitment, digest));
|
|
336
|
+
},
|
|
337
|
+
locate(fused) {
|
|
338
|
+
const entries = parseTar(fused);
|
|
339
|
+
if (entries === null || entries.length !== 2)
|
|
340
|
+
return null;
|
|
341
|
+
const [m, o] = entries;
|
|
342
|
+
if (m.name !== CONTAINER_MANIFEST_PATH || o.name !== CONTAINER_ORIGINAL_PATH)
|
|
343
|
+
return null;
|
|
344
|
+
const payload = parseFusePayload(m.data);
|
|
345
|
+
if (payload === null || payload.originDigest === undefined)
|
|
346
|
+
return null;
|
|
347
|
+
// The archive must be the one this module would build: headers included.
|
|
348
|
+
const rebuilt = buildContainer(o.data, m.data);
|
|
349
|
+
if (!bytesEqual(rebuilt, fused))
|
|
350
|
+
return null;
|
|
351
|
+
return { commitment: payload.commitment, originDigest: payload.originDigest, originalBytes: o.data };
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
const produced1 = {
|
|
355
|
+
id: "produced/1",
|
|
356
|
+
form: "C",
|
|
357
|
+
byteExact: false,
|
|
358
|
+
build({ original, originDigest, commitment }) {
|
|
359
|
+
if (original !== undefined)
|
|
360
|
+
throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");
|
|
361
|
+
return buildFusePayload(commitment, originDigest);
|
|
362
|
+
},
|
|
363
|
+
locate(fused) {
|
|
364
|
+
const payload = parseFusePayload(fused);
|
|
365
|
+
if (payload === null)
|
|
366
|
+
return null;
|
|
367
|
+
return payload.originDigest !== undefined
|
|
368
|
+
? { commitment: payload.commitment, originDigest: payload.originDigest }
|
|
369
|
+
: { commitment: payload.commitment };
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
/** Registered placements in the fixed order a verifier tries them when none is declared. */
|
|
373
|
+
export const PLACEMENTS = Object.freeze([trailer1, container1, produced1]);
|
|
374
|
+
export function getPlacement(id) {
|
|
375
|
+
return PLACEMENTS.find((p) => p.id === id);
|
|
376
|
+
}
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
// Attribution (the signed carrier of placement and origin, spec 6.5)
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
/** attribution.name = "bitgraph-fuse/1" (the profile id), title = placement id, message = origin digest in standard base64. */
|
|
381
|
+
export function fuseAttribution(placement, originDigest) {
|
|
382
|
+
if (originDigest !== undefined && originDigest.length !== 32)
|
|
383
|
+
throw new TypeError("originDigest must be 32 bytes");
|
|
384
|
+
return {
|
|
385
|
+
name: FUSE_ATTRIBUTION_NAME,
|
|
386
|
+
title: placement,
|
|
387
|
+
...(originDigest !== undefined ? { message: bytesToBase64(originDigest) } : {}),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
/** Read the fused marker from a proof's signed attribution, or null when the proof is not marked fused. */
|
|
391
|
+
export function readFuseAttribution(proof) {
|
|
392
|
+
const a = proof.attribution;
|
|
393
|
+
if (a === undefined || a.name !== FUSE_ATTRIBUTION_NAME)
|
|
394
|
+
return null;
|
|
395
|
+
const declared = typeof a.title === "string" && a.title.length > 0;
|
|
396
|
+
const marker = { placement: declared ? a.title : null, placementSource: declared ? "attribution" : null, source: "attribution" };
|
|
397
|
+
if (typeof a.message === "string" && a.message.length > 0) {
|
|
398
|
+
const d = base64ToBytes(a.message);
|
|
399
|
+
// A message that is not a digest is still a fused marker; the origin is simply undeclared.
|
|
400
|
+
if (d !== null && d.length === 32) {
|
|
401
|
+
marker.originDigest = d;
|
|
402
|
+
marker.originSource = "attribution";
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return marker;
|
|
406
|
+
}
|
|
407
|
+
/** Merge the signed marker with a manifest marker: the signature wins wherever it declares. */
|
|
408
|
+
export function mergeMarkers(signed, manifest) {
|
|
409
|
+
if (signed === null)
|
|
410
|
+
return manifest;
|
|
411
|
+
if (manifest === null)
|
|
412
|
+
return signed;
|
|
413
|
+
const out = { ...signed };
|
|
414
|
+
if (out.placement === null && manifest.placement !== null) {
|
|
415
|
+
out.placement = manifest.placement;
|
|
416
|
+
out.placementSource = "manifest";
|
|
417
|
+
}
|
|
418
|
+
if (out.originDigest === undefined && manifest.originDigest !== undefined) {
|
|
419
|
+
out.originDigest = manifest.originDigest;
|
|
420
|
+
out.originSource = "manifest";
|
|
421
|
+
}
|
|
422
|
+
return out;
|
|
423
|
+
}
|
|
424
|
+
export function buildFrame(input) {
|
|
425
|
+
const frame = {
|
|
426
|
+
type: FUSE_PROFILE,
|
|
427
|
+
manifest: {
|
|
428
|
+
placement: input.placement,
|
|
429
|
+
...(input.originDigest !== undefined ? { origin: { algorithm: "sha256", digest: bytesToHex(input.originDigest) } } : {}),
|
|
430
|
+
artifact: { algorithm: "sha256", digest: bytesToHex(input.artifactDigest) },
|
|
431
|
+
fusedFile: input.fusedFile,
|
|
432
|
+
},
|
|
433
|
+
proof: input.proof,
|
|
434
|
+
};
|
|
435
|
+
if (input.fusePayload !== undefined) {
|
|
436
|
+
const parsed = parseFusePayload(input.fusePayload);
|
|
437
|
+
if (parsed === null)
|
|
438
|
+
throw new TypeError("fusePayload is not a canonical bitgraph-fuse/1 payload");
|
|
439
|
+
frame.fusePayload = JSON.parse(new TextDecoder().decode(input.fusePayload));
|
|
440
|
+
}
|
|
441
|
+
return frame;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Structural read of a Frame. The manifest is advisory: nothing here is
|
|
445
|
+
* trusted beyond its shape, and the nested proof is returned exactly as
|
|
446
|
+
* found for the ordinary verifier. Null when this is not a Frame.
|
|
447
|
+
*/
|
|
448
|
+
export function parseFrame(input) {
|
|
449
|
+
const obj = typeof input === "string" ? (() => { try {
|
|
450
|
+
return JSON.parse(input);
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
return null;
|
|
454
|
+
} })() : input;
|
|
455
|
+
if (!isPlainObject(obj) || obj["type"] !== FUSE_PROFILE)
|
|
456
|
+
return null;
|
|
457
|
+
const m = obj["manifest"];
|
|
458
|
+
if (!isPlainObject(m))
|
|
459
|
+
return null;
|
|
460
|
+
if (m["placement"] !== undefined && typeof m["placement"] !== "string")
|
|
461
|
+
return null;
|
|
462
|
+
const artifact = readDigestField(m["artifact"]);
|
|
463
|
+
if (artifact === null)
|
|
464
|
+
return null;
|
|
465
|
+
if (m["origin"] !== undefined && readDigestField(m["origin"]) === null)
|
|
466
|
+
return null;
|
|
467
|
+
if (m["fusedFile"] !== null && typeof m["fusedFile"] !== "string")
|
|
468
|
+
return null;
|
|
469
|
+
const proof = obj["proof"];
|
|
470
|
+
if (!isPlainObject(proof) || proof["version"] !== "bitgraph/1")
|
|
471
|
+
return null;
|
|
472
|
+
const frame = {
|
|
473
|
+
type: FUSE_PROFILE,
|
|
474
|
+
manifest: {
|
|
475
|
+
placement: typeof m["placement"] === "string" ? m["placement"] : "",
|
|
476
|
+
...(m["origin"] !== undefined ? { origin: m["origin"] } : {}),
|
|
477
|
+
artifact: m["artifact"],
|
|
478
|
+
fusedFile: m["fusedFile"],
|
|
479
|
+
},
|
|
480
|
+
proof: proof,
|
|
481
|
+
};
|
|
482
|
+
if (obj["fusePayload"] !== undefined) {
|
|
483
|
+
if (!isPlainObject(obj["fusePayload"]))
|
|
484
|
+
return null;
|
|
485
|
+
frame.fusePayload = obj["fusePayload"];
|
|
486
|
+
}
|
|
487
|
+
return frame;
|
|
488
|
+
}
|
|
489
|
+
/** Marker from a Frame's advisory manifest (unsigned; made self-proving only by reconstruction). */
|
|
490
|
+
export function readFrameMarker(frame) {
|
|
491
|
+
const declared = frame.manifest.placement.length > 0;
|
|
492
|
+
const marker = { placement: declared ? frame.manifest.placement : null, placementSource: declared ? "manifest" : null, source: "manifest" };
|
|
493
|
+
if (frame.manifest.origin !== undefined) {
|
|
494
|
+
const d = hexToBytes(frame.manifest.origin.digest);
|
|
495
|
+
if (d !== null && d.length === 32) {
|
|
496
|
+
marker.originDigest = d;
|
|
497
|
+
marker.originSource = "manifest";
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return marker;
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=fuse.js.map
|
package/dist/fuse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuse.js","sourceRoot":"","sources":["../src/fuse.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,CAAC,MAAM,YAAY,GAAG,iBAA0B,CAAC;AAEvD,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAe,CAAC,GAAG,EAAE;IAC3C,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACzB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,EAAE,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,0F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E,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IACxJ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YAClC,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;YACxB,MAAM,CAAC,YAAY,GAAG,UAAU,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,8 @@ export { verify, verifyProofIntegrity, resetEpochLinkState } from "./verifier.js
|
|
|
10
10
|
export type { VerifyResult, ProofIntegrityResult } from "./verifier.js";
|
|
11
11
|
export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyHash } from "./proof-hash.js";
|
|
12
12
|
export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
|
|
13
|
+
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
14
|
+
export type { PlacementId, Placement, Located, FusePayload, FuseFrame, FuseMarker, MarkerSource } from "./fuse.js";
|
|
15
|
+
export { verifyFuse, assembledAfterCommit } from "./fuse-verify.js";
|
|
16
|
+
export type { FuseCategory, FuseSpan, FuseVerifyResult, FuseVerifyOptions } from "./fuse-verify.js";
|
|
13
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAClF,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAClF,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnH,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,7 @@
|
|
|
2
2
|
export { verify, verifyProofIntegrity, resetEpochLinkState } from "./verifier.js";
|
|
3
3
|
export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyHash } from "./proof-hash.js";
|
|
4
4
|
export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
|
|
5
|
+
// BitGraph Fuse (profile bitgraph-fuse/1): construction, parsing, verification.
|
|
6
|
+
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
7
|
+
export { verifyFuse, assembledAfterCommit } from "./fuse-verify.js";
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAyBrF,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAyBrF,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvF,gFAAgF;AAChF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|