@mikeargento/bitgraph-verify 1.15.2 → 1.17.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 +24 -3
- package/dist/__tests__/carrier2.test.js +62 -3
- package/dist/__tests__/carrier2.test.js.map +1 -1
- package/dist/__tests__/ceiling.test.js +11 -4
- package/dist/__tests__/ceiling.test.js.map +1 -1
- package/dist/carrier-assemble.d.ts +12 -2
- package/dist/carrier-assemble.d.ts.map +1 -1
- package/dist/carrier-assemble.js +14 -3
- package/dist/carrier-assemble.js.map +1 -1
- package/dist/carrier-verify.d.ts +15 -4
- package/dist/carrier-verify.d.ts.map +1 -1
- package/dist/carrier-verify.js +201 -59
- package/dist/carrier-verify.js.map +1 -1
- package/dist/carrier.d.ts +48 -13
- package/dist/carrier.d.ts.map +1 -1
- package/dist/carrier.js +74 -16
- package/dist/carrier.js.map +1 -1
- package/dist/ceiling.d.ts +115 -6
- package/dist/ceiling.d.ts.map +1 -1
- package/dist/ceiling.js +189 -23
- package/dist/ceiling.js.map +1 -1
- package/dist/export.d.ts +122 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +510 -0
- package/dist/export.js.map +1 -0
- package/dist/fuse.d.ts +45 -11
- package/dist/fuse.d.ts.map +1 -1
- package/dist/fuse.js +100 -18
- package/dist/fuse.js.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/measurements.d.ts +30 -0
- package/dist/measurements.d.ts.map +1 -0
- package/dist/measurements.js +22 -0
- package/dist/measurements.js.map +1 -0
- package/dist/output-root.d.ts +88 -0
- package/dist/output-root.d.ts.map +1 -0
- package/dist/output-root.js +260 -0
- package/dist/output-root.js.map +1 -0
- package/dist/stream.d.ts +46 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +290 -0
- package/dist/stream.js.map +1 -0
- package/dist/tree.d.ts +167 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +485 -0
- package/dist/tree.js.map +1 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/carrier2.test.ts +65 -3
- package/src/__tests__/ceiling.test.ts +12 -4
- package/src/carrier-assemble.ts +21 -3
- package/src/carrier-verify.ts +204 -61
- package/src/carrier.ts +95 -27
- package/src/ceiling.ts +217 -28
- package/src/export.ts +592 -0
- package/src/fuse.ts +126 -23
- package/src/index.ts +47 -1
- package/src/measurements.ts +49 -0
- package/src/output-root.ts +301 -0
- package/src/stream.ts +291 -0
- package/src/tree.ts +580 -0
- package/src/types.ts +22 -0
package/dist/index.js
CHANGED
|
@@ -11,7 +11,10 @@ export { verify, verifyProofIntegrity, resetEpochLinkState, createVerificationCo
|
|
|
11
11
|
export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyHash } from "./proof-hash.js";
|
|
12
12
|
export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
|
|
13
13
|
// BitGraph Fuse (profile bitgraph-fuse/1): construction, parsing, verification.
|
|
14
|
-
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, SET_PLACEMENT_ID, SET_METADATA_KEY, buildSetManifest, parseSetManifest, readSetMetadata, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, FUSE2_PROFILE, FUSE2_DOMAIN, FUSE2_ATTRIBUTION_NAME, fuseVersionOfName, isFuseMarkerName, slotCommitment2Preimage, computeSlotCommitment2, commitmentForProof, producerCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
14
|
+
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, SET_PLACEMENT_ID, SET_METADATA_KEY, buildSetManifest, parseSetManifest, readSetMetadata, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, FUSE2_PROFILE, FUSE2_DOMAIN, FUSE2_ATTRIBUTION_NAME, FUSE3_PROFILE, FUSE3_DOMAIN, FUSE3_ATTRIBUTION_NAME, fuseNameOfVersion, signedFloorOf, slotCommitment3Preimage, computeSlotCommitment3, fuseVersionOfName, isFuseMarkerName, slotCommitment2Preimage, computeSlotCommitment2, commitmentForProof, producerCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
15
|
+
export { MAX_CONTAINER_ENTRY_BYTES } from "./fuse.js";
|
|
16
|
+
/* Streaming checks: a file of any size against its leaf, in constant memory. */
|
|
17
|
+
export { bytesSource, blobSource, streamDigest, streamLeafCheck } from "./stream.js";
|
|
15
18
|
export { verifyFuse, assembledAfterCommit } from "./fuse-verify.js";
|
|
16
19
|
export { verifyFuseMember } from "./fuse-member.js";
|
|
17
20
|
export { SET2_PLACEMENT_ID, SET_MEMBER_METADATA_KEY, MAX_SET2_MEMBERS, canonicalSetRow, setLeaf, sortSetMembers, buildSetTree, setMemberPath, buildSetRoot, parseSetRoot, buildSetMemberProof, parseSetMemberProof, setRootFromMember } from "./fuse.js";
|
|
@@ -27,6 +30,9 @@ export { verifyCarrier, verifyCarrierPayload, BITGRAPH_CEILING_WRITER, BASE_MAIN
|
|
|
27
30
|
/* bitgraph-carrier/2 (2026-09-30): the ceiling in time, its settlement, the attestation witness and the declared pins, in the same block. */
|
|
28
31
|
export { CARRIER_VERSION_2, CEILING_SIDECAR_VERSION, SETTLEMENT_POINTER_VERSION, ATTESTATION_WITNESS_VERSION, carrierVersionOf, completeCarrierInTime, completeCarrierSettlement, settlementFromSidecar, } from "./carrier.js";
|
|
29
32
|
export { assembleCarrierV2Payload, carrierBlockSize, CARRIER_BLOCK_ZIP_LIMIT } from "./carrier-assemble.js";
|
|
33
|
+
/* bitgraph-carrier/3 (2026-10-06, enclave v10): the floor is the Base header the proof signs; no ceiling in position exists. */
|
|
34
|
+
export { CARRIER_VERSION_3, baseHeaderFields } from "./carrier.js";
|
|
35
|
+
export { assembleCarrierV3Payload } from "./carrier-assemble.js";
|
|
30
36
|
/* AWS Nitro attestation: decode, verify (chain to the AWS root, validity at the document's instant), and the openssl-checkable witness. */
|
|
31
37
|
export { AWS_NITRO_ROOT_CA_PEM, awsNitroRootDer, awsNitroRootSha256, decodeNitroAttestation, verifyNitroAttestation, attestationWitness, witnessMatchesAttestation, encodeSigStructure, rawEcdsaSigToDer, derToPem, pemToDer, ATTESTATION_WITNESS_FORMAT, } from "./nitro.js";
|
|
32
38
|
/* Settlement of a Base ceiling on Ethereum: L1 data inclusion (bitgraph-settlement/1). The pointer layer is here; the blob layer is bitgraph-audit's. */
|
|
@@ -35,4 +41,15 @@ export * from "./settlement.js";
|
|
|
35
41
|
export { CEILING_VERSION, CEILING_MAGIC, CEILING_PAYLOAD_BYTES, encodeCeilingPayload, decodeCeilingPayload, ceilingPayloadHash, ceilingLeaf, ceilingLabel, verifyCeiling, checkCeilingOnline, } from "./ceiling.js";
|
|
36
42
|
export { rlpEncode, rlpDecode, decodeHeader, decodeEip1559, mptVerify, txTrieKey, keccak256, hexToBytes as evmHexToBytes, bytesToHex as evmBytesToHex } from "./ceiling-evm.js";
|
|
37
43
|
export { txTrieProof } from "./ceiling-trie.js";
|
|
44
|
+
/* tree/1 (2026-10-03): every BitGraph is a Merkle tree under one position; a single file is a tree of one. */
|
|
45
|
+
export { TREE_PLACEMENT_ID, TREE_PROFILE, TREE_DOMAIN, TREE_LEAF_BYTES, TREE_ROOT_DOCUMENT_BYTES, MAX_TREE_LEAVES, TREE_METADATA_KEY, KNOWN_TREE_SPEC_HASHES, TREE_SPEC_V1_HASH, TREE_SPEC_V2_HASH, LEAF_AS_IS, LEAF_PLACEMENTS, TREE_MEMBER_CATEGORIES, leafCodeOf, encodeTreeLeaf, decodeTreeLeaf, treeLeafHash, sortTreeLeaves, buildTree, buildTreeRootDocument, parseTreeRootDocument, readTreeMetadata, treeAttribution, currentTreeSpecHash, isTreeProof, buildTreeMemberEvidence, parseTreeMemberEvidence, treeRootFromMember, encodeTreeLeaves, decodeTreeLeaves, verifyTreeLeaves, committedBytesFor, leafFor, verifyTreeMember, } from "./tree.js";
|
|
46
|
+
/* bitgraph-output-root/1: a Base ceiling settled on Ethereum through Base's output root, without blobs. */
|
|
47
|
+
export { OUTPUT_ROOT_VERSION, HISTORY_STORAGE_ADDRESS, HISTORY_SERVE_WINDOW, BASE_DISPUTE_GAME_FACTORY, computeOutputRoot, historySlot, verifyOutputRootSettlement, } from "./output-root.js";
|
|
48
|
+
/* bitgraph-export/1: one JSON file that, with the file, checks a tree/1 BitGraph with nothing of BitGraph's required. */
|
|
49
|
+
export { EXPORT_FORMAT, parseExport, verifyExport, buildExport } from "./export.js";
|
|
50
|
+
export { baseTimeIsBound, BASE_STAMP_TOLERANCE_SECONDS } from "./ceiling.js";
|
|
51
|
+
/* The floor block's header, on either chain (enclave v10 floors are Base blocks). */
|
|
52
|
+
export { checkFloorHeader, floorTimeIsBound, onBaseSchedule, headerRlpFromRpc, BASE_MAINNET_GENESIS_TIME, BASE_BLOCK_TIME_SECONDS } from "./ceiling.js";
|
|
53
|
+
/* The enclave images BitGraph has published: the default measurement policy (SPEC section 16). */
|
|
54
|
+
export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
|
|
38
55
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@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(SPEC.md section 16), oldest
|
|
3
|
+
* first: every PCR0 a real BitGraph proof can carry.
|
|
4
|
+
*
|
|
5
|
+
* An attestation that chains to the AWS Nitro root shows that SOME Nitro
|
|
6
|
+
* enclave signed; anyone can run one. Which image is BitGraph's is a
|
|
7
|
+
* measurement policy, and this list is that policy by default:
|
|
8
|
+
* verifyExport and verifyCarrier judge `attestation.pins` against it when
|
|
9
|
+
* the caller names no list of their own, and a proof from any other image is
|
|
10
|
+
* not a BitGraph. A caller who rebuilt an image from its tagged source and
|
|
11
|
+
* wants to accept exactly that passes their own list instead.
|
|
12
|
+
*
|
|
13
|
+
* Keep in step with SPEC.md section 16, the site's
|
|
14
|
+
* website/src/lib/enclave-measurements.ts and the player's
|
|
15
|
+
* KNOWN_ENCLAVE_MEASUREMENTS; a root test checks all of them against this.
|
|
16
|
+
*/
|
|
17
|
+
export interface PublishedMeasurement {
|
|
18
|
+
/** The image's name in BitGraph's history: "genesis", "v2", ... */
|
|
19
|
+
version: string;
|
|
20
|
+
/** The UTC day it went live (YYYY-MM-DD). */
|
|
21
|
+
since: string;
|
|
22
|
+
/** PCR0, 96 lowercase hex characters. */
|
|
23
|
+
pcr0: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const PUBLISHED_ENCLAVE_MEASUREMENTS: readonly PublishedMeasurement[];
|
|
26
|
+
/** PUBLISHED_ENCLAVE_MEASUREMENTS as the bare PCR0 list a verifier's pins take. */
|
|
27
|
+
export declare const PUBLISHED_PCR0S: readonly string[];
|
|
28
|
+
/** The published image a PCR0 names, or null when it is not one of BitGraph's. Case-insensitive. */
|
|
29
|
+
export declare function publishedMeasurement(pcr0: unknown): PublishedMeasurement | null;
|
|
30
|
+
//# sourceMappingURL=measurements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../src/measurements.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,8BAA8B,EAAE,SAAS,oBAAoB,EAU3C,CAAC;AAEhC,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAqE,CAAC;AAEnH,oGAAoG;AACpG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAI/E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
export const PUBLISHED_ENCLAVE_MEASUREMENTS = Object.freeze([
|
|
3
|
+
{ version: "genesis", since: "2026-05-15", pcr0: "8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92" },
|
|
4
|
+
{ version: "v2", since: "2026-06-27", pcr0: "bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a" },
|
|
5
|
+
{ version: "v4", since: "2026-07-05", pcr0: "e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb" },
|
|
6
|
+
{ version: "v5", since: "2026-07-29", pcr0: "6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f" },
|
|
7
|
+
{ version: "v6", since: "2026-09-05", pcr0: "cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf" },
|
|
8
|
+
{ version: "v7", since: "2026-09-06", pcr0: "394c3cf515651dc27187d85e4716c12dfeb99c1227f1fe0eacfaa427d80018e1a28ebba9469e99c7936601f901d74e1d" },
|
|
9
|
+
{ version: "v8", since: "2026-09-07", pcr0: "eccfc1c78006f4b74f929c992785575c908a0f60eca08ff638cd6c0842f993f182ebb002457b8ef3e732a6a10805c72b" },
|
|
10
|
+
{ version: "v9", since: "2026-09-30", pcr0: "934feb8bb6f4f7e2d2f85d902a7d5edd0981f706d9d2385638988ac096a05ea0583c3d00eef2a7947865ec66efc1fcf8" },
|
|
11
|
+
{ version: "v10", since: "2026-10-08", pcr0: "5a947cc66095adcceefa9e5ece5d1416dfe08c3470df1bcaa5b2bc5267b0480e6cdc172fe077cd06b0afb07614307973" },
|
|
12
|
+
].map((m) => Object.freeze(m)));
|
|
13
|
+
/** PUBLISHED_ENCLAVE_MEASUREMENTS as the bare PCR0 list a verifier's pins take. */
|
|
14
|
+
export const PUBLISHED_PCR0S = Object.freeze(PUBLISHED_ENCLAVE_MEASUREMENTS.map((m) => m.pcr0));
|
|
15
|
+
/** The published image a PCR0 names, or null when it is not one of BitGraph's. Case-insensitive. */
|
|
16
|
+
export function publishedMeasurement(pcr0) {
|
|
17
|
+
if (typeof pcr0 !== "string")
|
|
18
|
+
return null;
|
|
19
|
+
const want = pcr0.toLowerCase();
|
|
20
|
+
return PUBLISHED_ENCLAVE_MEASUREMENTS.find((m) => m.pcr0 === want) ?? null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=measurements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurements.js","sourceRoot":"","sources":["../src/measurements.ts"],"names":[],"mappings":"AAAA,8FAA8F;AA4B9F,MAAM,CAAC,MAAM,8BAA8B,GAAoC,MAAM,CAAC,MAAM,CAAC;IAC3F,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,kGAAkG,EAAE;IACrJ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,kGAAkG,EAAE;IAChJ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,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
2
|
+
/** EIP-2935 history storage contract (the same address on Ethereum and on OP Stack chains). */
|
|
3
|
+
export declare const HISTORY_STORAGE_ADDRESS: "0x0000f90827f1c53a10cb7a02335b175320002935";
|
|
4
|
+
/** EIP-2935 ring buffer size: the contract keeps the previous 8,191 block hashes. */
|
|
5
|
+
export declare const HISTORY_SERVE_WINDOW = 8191;
|
|
6
|
+
/** Base mainnet's dispute game factory on Ethereum (OptimismPortal 0x49048044D57e1C92A77f79988d21Fa8fAF74E97e). Informational. */
|
|
7
|
+
export declare const BASE_DISPUTE_GAME_FACTORY: "0x43edb88c4b80fdd2adff2412a7bebf9df42cb40e";
|
|
8
|
+
export interface OutputRootSettlement {
|
|
9
|
+
version: typeof OUTPUT_ROOT_VERSION;
|
|
10
|
+
/** The ceiling's Base block: number and hash (the hash is also the ceiling sidecar's). */
|
|
11
|
+
base: {
|
|
12
|
+
chainId: number;
|
|
13
|
+
blockNumber: number;
|
|
14
|
+
blockHash: string;
|
|
15
|
+
};
|
|
16
|
+
/** The output-root preimage for Base block P. */
|
|
17
|
+
outputRoot: {
|
|
18
|
+
blockNumber: number;
|
|
19
|
+
/** 32 bytes, all zero for output-root version 0. */
|
|
20
|
+
version: string;
|
|
21
|
+
stateRoot: string;
|
|
22
|
+
messagePasserStorageRoot: string;
|
|
23
|
+
blockHash: string;
|
|
24
|
+
};
|
|
25
|
+
/** B's hash in P's state. Null exactly when B = P. */
|
|
26
|
+
history: {
|
|
27
|
+
address: string;
|
|
28
|
+
/** uint256(B mod 8191), 32 bytes. */
|
|
29
|
+
slot: string;
|
|
30
|
+
accountProof: string[];
|
|
31
|
+
storageProof: string[];
|
|
32
|
+
} | null;
|
|
33
|
+
/** The Ethereum transaction that carries the output root, and its block. */
|
|
34
|
+
ethereum: {
|
|
35
|
+
chainId: number;
|
|
36
|
+
blockNumber: number;
|
|
37
|
+
blockHash: string;
|
|
38
|
+
blockTimestamp: number;
|
|
39
|
+
header: string;
|
|
40
|
+
txHash: string;
|
|
41
|
+
txIndex: number;
|
|
42
|
+
rawTx: string;
|
|
43
|
+
txInclusionProof: string[];
|
|
44
|
+
};
|
|
45
|
+
/** Informational, never verified: which dispute game this was. */
|
|
46
|
+
game?: {
|
|
47
|
+
factory: string;
|
|
48
|
+
gameType: number;
|
|
49
|
+
index: number;
|
|
50
|
+
proxy: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface OutputRootCheck {
|
|
54
|
+
name: string;
|
|
55
|
+
ok: boolean;
|
|
56
|
+
detail?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface OutputRootVerifyResult {
|
|
59
|
+
ok: boolean;
|
|
60
|
+
reason?: string;
|
|
61
|
+
checks: OutputRootCheck[];
|
|
62
|
+
/** On success: the ceiling transaction existed by this Ethereum block. Canonicality of the block is not checked here. */
|
|
63
|
+
existedBy?: {
|
|
64
|
+
chainId: number;
|
|
65
|
+
blockNumber: number;
|
|
66
|
+
blockHash: string;
|
|
67
|
+
blockTimestamp: number;
|
|
68
|
+
};
|
|
69
|
+
/** The output root that was recomputed (0x hex). */
|
|
70
|
+
outputRootHex?: string;
|
|
71
|
+
}
|
|
72
|
+
/** keccak256(version || stateRoot || messagePasserStorageRoot || blockHash). */
|
|
73
|
+
export declare function computeOutputRoot(o: OutputRootSettlement["outputRoot"]): Uint8Array;
|
|
74
|
+
/** The EIP-2935 storage slot holding block n's hash: uint256(n mod 8191), big-endian. */
|
|
75
|
+
export declare function historySlot(blockNumber: number): Uint8Array;
|
|
76
|
+
/**
|
|
77
|
+
* Verify an output-root settlement, offline. Every link is recomputed from
|
|
78
|
+
* bytes; the result names the Ethereum block whose canonicality is the one
|
|
79
|
+
* remaining lookup.
|
|
80
|
+
*/
|
|
81
|
+
export interface OutputRootVerifyOptions {
|
|
82
|
+
/** The chain the ceiling is on. Default Base mainnet, 8453. */
|
|
83
|
+
baseChainId?: number;
|
|
84
|
+
/** The chain the settlement is on. Default Ethereum mainnet, 1. */
|
|
85
|
+
ethereumChainId?: number;
|
|
86
|
+
}
|
|
87
|
+
export declare function verifyOutputRootSettlement(s: OutputRootSettlement, opts?: OutputRootVerifyOptions): OutputRootVerifyResult;
|
|
88
|
+
//# sourceMappingURL=output-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-root.d.ts","sourceRoot":"","sources":["../src/output-root.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,mBAAmB,EAAG,wBAAiC,CAAC;AACrE,+FAA+F;AAC/F,eAAO,MAAM,uBAAuB,EAAG,4CAAqD,CAAC;AAC7F,qFAAqF;AACrF,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,kIAAkI;AAClI,eAAO,MAAM,yBAAyB,EAAG,4CAAqD,CAAC;AAE/F,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,mBAAmB,CAAC;IACpC,0FAA0F;IAC1F,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,iDAAiD;IACjD,UAAU,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,oDAAoD;QACpD,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,MAAM,CAAC;QACjC,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,sDAAsD;IACtD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,qCAAqC;QACrC,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB,GAAG,IAAI,CAAC;IACT,4EAA4E;IAC5E,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;Q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A4B,GAAG,sBAAsB,CAY9H"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* bitgraph-output-root/1: settling a Base ceiling on Ethereum without blobs
|
|
4
|
+
* (2026-10-03).
|
|
5
|
+
*
|
|
6
|
+
* A Base ceiling is a transaction in Base block B. Base posts an OUTPUT ROOT
|
|
7
|
+
* for one of its blocks P to Ethereum about every 600 Base blocks, as the
|
|
8
|
+
* rootClaim of a dispute game:
|
|
9
|
+
*
|
|
10
|
+
* outputRoot = keccak256(version (32 zero bytes) || stateRoot_P || messagePasserStorageRoot_P || blockHash_P)
|
|
11
|
+
*
|
|
12
|
+
* Base runs the EIP-2935 history contract, which keeps the hashes of the
|
|
13
|
+
* previous 8,191 blocks in its storage, so B's hash is provable from P's state
|
|
14
|
+
* when 1 <= P - B <= 8,191 (the contract holds earlier blocks only). When
|
|
15
|
+
* B = P the output root names P's hash directly.
|
|
16
|
+
*
|
|
17
|
+
* The chain this module checks, every link by hash:
|
|
18
|
+
* Ethereum tx in block H carries outputRoot
|
|
19
|
+
* -> outputRoot preimage (stateRoot_P, blockHash_P)
|
|
20
|
+
* -> B's hash (from P's state by storage proof, or blockHash_P when B = P)
|
|
21
|
+
* -> B's header (checked by the ceiling sidecar)
|
|
22
|
+
*
|
|
23
|
+
* What it proves: the ceiling transaction, and so the root it carries, existed
|
|
24
|
+
* by Ethereum block H. Any Ethereum transaction whose bytes commit to the
|
|
25
|
+
* output root by hash proves that, whoever sent it and whether or not Base's
|
|
26
|
+
* claim is ever upheld; so the sender and the game's outcome are not checked.
|
|
27
|
+
* What it does NOT prove: that B is canonical on Base, or B's timestamp. Those
|
|
28
|
+
* need Base itself (checkCeilingOnline). Whether H is canonical is the one
|
|
29
|
+
* outside lookup this leaves.
|
|
30
|
+
*/
|
|
31
|
+
import { bytesEqual, decodeHeader, hexToBytes, bytesToHex, keccak256, mptVerify, rlpDecode, txTrieKey } from "./ceiling-evm.js";
|
|
32
|
+
export const OUTPUT_ROOT_VERSION = "bitgraph-output-root/1";
|
|
33
|
+
/** EIP-2935 history storage contract (the same address on Ethereum and on OP Stack chains). */
|
|
34
|
+
export const HISTORY_STORAGE_ADDRESS = "0x0000f90827f1c53a10cb7a02335b175320002935";
|
|
35
|
+
/** EIP-2935 ring buffer size: the contract keeps the previous 8,191 block hashes. */
|
|
36
|
+
export const HISTORY_SERVE_WINDOW = 8191;
|
|
37
|
+
/** Base mainnet's dispute game factory on Ethereum (OptimismPortal 0x49048044D57e1C92A77f79988d21Fa8fAF74E97e). Informational. */
|
|
38
|
+
export const BASE_DISPUTE_GAME_FACTORY = "0x43edb88c4b80fdd2adff2412a7bebf9df42cb40e";
|
|
39
|
+
const ZERO32 = new Uint8Array(32);
|
|
40
|
+
function b32(hex, name) {
|
|
41
|
+
const b = hexToBytes(hex);
|
|
42
|
+
if (b.length !== 32)
|
|
43
|
+
throw new TypeError(`${name} must be 32 bytes`);
|
|
44
|
+
return b;
|
|
45
|
+
}
|
|
46
|
+
/** keccak256(version || stateRoot || messagePasserStorageRoot || blockHash). */
|
|
47
|
+
export function computeOutputRoot(o) {
|
|
48
|
+
const parts = [b32(o.version, "outputRoot.version"), b32(o.stateRoot, "outputRoot.stateRoot"), b32(o.messagePasserStorageRoot, "outputRoot.messagePasserStorageRoot"), b32(o.blockHash, "outputRoot.blockHash")];
|
|
49
|
+
const pre = new Uint8Array(128);
|
|
50
|
+
parts.forEach((p, i) => pre.set(p, i * 32));
|
|
51
|
+
return keccak256(pre);
|
|
52
|
+
}
|
|
53
|
+
/** The EIP-2935 storage slot holding block n's hash: uint256(n mod 8191), big-endian. */
|
|
54
|
+
export function historySlot(blockNumber) {
|
|
55
|
+
const slot = new Uint8Array(32);
|
|
56
|
+
let v = blockNumber % HISTORY_SERVE_WINDOW;
|
|
57
|
+
for (let i = 31; i >= 0 && v > 0; i--) {
|
|
58
|
+
slot[i] = v & 0xff;
|
|
59
|
+
v = Math.floor(v / 256);
|
|
60
|
+
}
|
|
61
|
+
return slot;
|
|
62
|
+
}
|
|
63
|
+
function indexOfBytes(hay, needle) {
|
|
64
|
+
outer: for (let i = 0; i + needle.length <= hay.length; i++) {
|
|
65
|
+
for (let j = 0; j < needle.length; j++)
|
|
66
|
+
if (hay[i + j] !== needle[j])
|
|
67
|
+
continue outer;
|
|
68
|
+
return i;
|
|
69
|
+
}
|
|
70
|
+
return -1;
|
|
71
|
+
}
|
|
72
|
+
/** RLP bytes as an unsigned integer value padded to 32 bytes (storage values are RLP of the minimal big-endian bytes). */
|
|
73
|
+
function storageWord(item) {
|
|
74
|
+
if (!(item instanceof Uint8Array) || item.length > 32)
|
|
75
|
+
return null;
|
|
76
|
+
const out = new Uint8Array(32);
|
|
77
|
+
out.set(item, 32 - item.length);
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/** The chain a raw Ethereum transaction is signed for: field 0 of a typed transaction, or EIP-155's v. Null when it names none. */
|
|
81
|
+
function transactionChainId(raw) {
|
|
82
|
+
if (raw.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
const big = (b) => b.reduce((n, x) => (n << 8n) | BigInt(x), 0n);
|
|
85
|
+
try {
|
|
86
|
+
if (raw[0] <= 0x7f) {
|
|
87
|
+
const item = rlpDecode(raw.subarray(1));
|
|
88
|
+
return Array.isArray(item) && item[0] instanceof Uint8Array ? big(item[0]) : null;
|
|
89
|
+
}
|
|
90
|
+
const item = rlpDecode(raw);
|
|
91
|
+
if (!Array.isArray(item) || item.length !== 9 || !(item[6] instanceof Uint8Array))
|
|
92
|
+
return null;
|
|
93
|
+
const v = big(item[6]);
|
|
94
|
+
return v >= 35n ? (v - 35n) / 2n : null;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function verifyOutputRootSettlement(s, opts = {}) {
|
|
101
|
+
const checks = [];
|
|
102
|
+
const fail = (name, detail) => {
|
|
103
|
+
checks.push({ name, ok: false, detail });
|
|
104
|
+
return { ok: false, reason: `${name}: ${detail}`, checks };
|
|
105
|
+
};
|
|
106
|
+
// A malformed field anywhere is a failed check, never an exception.
|
|
107
|
+
try {
|
|
108
|
+
return verifyOutputRootChecks(s, opts, checks, fail);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return fail("malformed", `a field of the settlement is malformed: ${e instanceof Error ? e.message : String(e)}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function verifyOutputRootChecks(s, opts, checks, fail) {
|
|
115
|
+
const pass = (name, detail) => checks.push(detail === undefined ? { name, ok: true } : { name, ok: true, detail });
|
|
116
|
+
if (s?.version !== OUTPUT_ROOT_VERSION)
|
|
117
|
+
return fail("format", `not a ${OUTPUT_ROOT_VERSION} settlement`);
|
|
118
|
+
// 0. The chains: the labels are part of what the result reports, so they are checked, never echoed.
|
|
119
|
+
const baseChain = opts.baseChainId ?? 8453;
|
|
120
|
+
const l1Chain = opts.ethereumChainId ?? 1;
|
|
121
|
+
if (s.base?.chainId !== baseChain)
|
|
122
|
+
return fail("chain", `the settlement is for chain ${String(s.base?.chainId)}; this verifier settles Base ${baseChain}`);
|
|
123
|
+
if (s.ethereum?.chainId !== l1Chain)
|
|
124
|
+
return fail("chain", `the settlement names chain ${String(s.ethereum?.chainId)}; this verifier settles on Ethereum ${l1Chain}`);
|
|
125
|
+
// 1. The output root from its preimage.
|
|
126
|
+
let outputRoot;
|
|
127
|
+
try {
|
|
128
|
+
if (!bytesEqual(b32(s.outputRoot.version, "outputRoot.version"), ZERO32))
|
|
129
|
+
return fail("output-root", "only output-root version 0 (32 zero bytes) is defined");
|
|
130
|
+
outputRoot = computeOutputRoot(s.outputRoot);
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
return fail("output-root", e.message);
|
|
134
|
+
}
|
|
135
|
+
pass("output-root", `${bytesToHex(outputRoot)} for Base block ${s.outputRoot.blockNumber}`);
|
|
136
|
+
// 2. B's hash from P: directly when B = P, else by EIP-2935 storage proof.
|
|
137
|
+
const B = s.base.blockNumber;
|
|
138
|
+
const P = s.outputRoot.blockNumber;
|
|
139
|
+
let bHash;
|
|
140
|
+
try {
|
|
141
|
+
bHash = b32(s.base.blockHash, "base.blockHash");
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
return fail("base", e.message);
|
|
145
|
+
}
|
|
146
|
+
if (!Number.isInteger(B) || !Number.isInteger(P) || B < 0)
|
|
147
|
+
return fail("base", "block numbers must be non-negative integers");
|
|
148
|
+
if (B === P) {
|
|
149
|
+
if (s.history !== null)
|
|
150
|
+
return fail("history", "B = P needs no history proof, and one was given");
|
|
151
|
+
if (!bytesEqual(b32(s.outputRoot.blockHash, "outputRoot.blockHash"), bHash))
|
|
152
|
+
return fail("history", "B = P, but the output root names a different block hash");
|
|
153
|
+
pass("history", `B = P: the output root names block ${B}'s hash directly`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const d = P - B;
|
|
157
|
+
if (d < 1 || d > HISTORY_SERVE_WINDOW)
|
|
158
|
+
return fail("history", `P - B is ${d}; the history contract holds blocks 1 to ${HISTORY_SERVE_WINDOW} before P`);
|
|
159
|
+
const h = s.history;
|
|
160
|
+
if (!h)
|
|
161
|
+
return fail("history", "B < P needs a history storage proof");
|
|
162
|
+
if (h.address.toLowerCase() !== HISTORY_STORAGE_ADDRESS)
|
|
163
|
+
return fail("history", `the proof is for ${h.address}, not the EIP-2935 contract`);
|
|
164
|
+
let slot;
|
|
165
|
+
try {
|
|
166
|
+
slot = b32(h.slot, "history.slot");
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
return fail("history", e.message);
|
|
170
|
+
}
|
|
171
|
+
if (!bytesEqual(slot, historySlot(B)))
|
|
172
|
+
return fail("history", `the slot is not B mod ${HISTORY_SERVE_WINDOW}`);
|
|
173
|
+
let account;
|
|
174
|
+
try {
|
|
175
|
+
account = mptVerify(b32(s.outputRoot.stateRoot, "outputRoot.stateRoot"), keccak256(hexToBytes(HISTORY_STORAGE_ADDRESS)), h.accountProof.map(hexToBytes));
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
account = null;
|
|
179
|
+
}
|
|
180
|
+
if (!account)
|
|
181
|
+
return fail("history", "the account proof does not reach P's state root");
|
|
182
|
+
let storageRoot;
|
|
183
|
+
try {
|
|
184
|
+
const fields = rlpDecode(account);
|
|
185
|
+
if (!Array.isArray(fields) || fields.length !== 4 || !(fields[2] instanceof Uint8Array) || fields[2].length !== 32)
|
|
186
|
+
throw new TypeError("account");
|
|
187
|
+
storageRoot = fields[2];
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return fail("history", "the account record is not [nonce, balance, storageRoot, codeHash]");
|
|
191
|
+
}
|
|
192
|
+
let raw;
|
|
193
|
+
try {
|
|
194
|
+
raw = mptVerify(storageRoot, keccak256(slot), h.storageProof.map(hexToBytes));
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
raw = null;
|
|
198
|
+
}
|
|
199
|
+
if (!raw)
|
|
200
|
+
return fail("history", "the storage proof does not reach the contract's storage root");
|
|
201
|
+
let word;
|
|
202
|
+
try {
|
|
203
|
+
word = storageWord(rlpDecode(raw));
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
word = null;
|
|
207
|
+
}
|
|
208
|
+
if (!word || !bytesEqual(word, bHash))
|
|
209
|
+
return fail("history", `P's state does not hold block ${B}'s hash at that slot`);
|
|
210
|
+
pass("history", `block ${B}'s hash is in block ${P}'s state (${d} blocks back)`);
|
|
211
|
+
}
|
|
212
|
+
// 3. The Ethereum transaction carries the output root, and is in block H.
|
|
213
|
+
const e = s.ethereum;
|
|
214
|
+
let header;
|
|
215
|
+
try {
|
|
216
|
+
header = decodeHeader(hexToBytes(e.header));
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
return fail("ethereum", `header: ${err.message}`);
|
|
220
|
+
}
|
|
221
|
+
if (header.hash !== e.blockHash.toLowerCase())
|
|
222
|
+
return fail("ethereum", "the header does not hash to blockHash");
|
|
223
|
+
if (header.number !== e.blockNumber)
|
|
224
|
+
return fail("ethereum", `the header is block ${header.number}, the settlement says ${e.blockNumber}`);
|
|
225
|
+
if (header.timestamp !== e.blockTimestamp)
|
|
226
|
+
return fail("ethereum", `the header's timestamp is ${header.timestamp}, the settlement says ${e.blockTimestamp}`);
|
|
227
|
+
let rawTx;
|
|
228
|
+
try {
|
|
229
|
+
rawTx = hexToBytes(e.rawTx);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return fail("ethereum", "rawTx is not hex");
|
|
233
|
+
}
|
|
234
|
+
if (bytesToHex(keccak256(rawTx)) !== e.txHash.toLowerCase())
|
|
235
|
+
return fail("ethereum", "the raw transaction does not hash to txHash");
|
|
236
|
+
const txChain = transactionChainId(rawTx);
|
|
237
|
+
if (txChain === null)
|
|
238
|
+
return fail("ethereum", "the transaction names no chain (a legacy transaction without EIP-155)");
|
|
239
|
+
if (txChain !== BigInt(l1Chain))
|
|
240
|
+
return fail("ethereum", `the transaction is signed for chain ${txChain}, not Ethereum ${l1Chain}`);
|
|
241
|
+
let inBlock;
|
|
242
|
+
try {
|
|
243
|
+
inBlock = mptVerify(hexToBytes(header.transactionsRoot), txTrieKey(e.txIndex), e.txInclusionProof.map(hexToBytes));
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
inBlock = null;
|
|
247
|
+
}
|
|
248
|
+
if (!inBlock || !bytesEqual(inBlock, rawTx))
|
|
249
|
+
return fail("ethereum", "the transaction is not in this block");
|
|
250
|
+
if (indexOfBytes(rawTx, outputRoot) < 0)
|
|
251
|
+
return fail("ethereum", "the transaction's bytes do not contain the output root");
|
|
252
|
+
pass("ethereum", `transaction ${e.txIndex} of Ethereum block ${header.number} carries the output root`);
|
|
253
|
+
return {
|
|
254
|
+
ok: true,
|
|
255
|
+
checks,
|
|
256
|
+
existedBy: { chainId: e.chainId, blockNumber: header.number, blockHash: header.hash, blockTimestamp: header.timestamp },
|
|
257
|
+
outputRootHex: bytesToHex(outputRoot),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=output-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-root.js","sourceRoot":"","sources":["../src/output-root.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAgB,MAAM,kBAAkB,CAAC;AAE9I,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAiC,CAAC;AACrE,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,4CAAqD,CAAC;AAC7F,qFAAqF;AACrF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,kIAAkI;AAClI,MAAM,CAAC,MAAM,yBAAyB,GAAG,4CAAqD,CAAC;AAmD/F,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAElC,SAAS,GAAG,CAAC,GAAW,EAAE,IAAY;IACpC,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,mBAAmB,CAAC,CAAC;IACrE,OAAO,CAAC,CAAC;AACX,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,CAAqC;IACrE,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,sBA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IAAI,OAA0B,CAAC;IAC/B,IAAI,CAAC;QACH,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IACrH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,UAAU,EAAE,sCAAsC,CAAC,CAAC;IAC7G,IAAI,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,UAAU,EAAE,wDAAwD,CAAC,CAAC;IAC3H,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,OAAO,sBAAsB,MAAM,CAAC,MAAM,0BAA0B,CAAC,CAAC;IAExG,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM;QACN,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE;QACvH,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC;KACtC,CAAC;AACJ,CAAC"}
|
package/dist/stream.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Bytes that can be read as chunks, more than once. A File, a Blob, or a path opened each time. */
|
|
2
|
+
export interface ByteSource {
|
|
3
|
+
size: number;
|
|
4
|
+
stream(): AsyncIterable<Uint8Array>;
|
|
5
|
+
}
|
|
6
|
+
export declare function bytesSource(bytes: Uint8Array): ByteSource;
|
|
7
|
+
/** A Blob or File (browser or Node) as a source. */
|
|
8
|
+
export declare function blobSource(blob: {
|
|
9
|
+
size: number;
|
|
10
|
+
stream(): ReadableStream<Uint8Array>;
|
|
11
|
+
}): ByteSource;
|
|
12
|
+
export type StreamPlacement = "trailer/1" | "container/1" | "container/2";
|
|
13
|
+
export interface StreamLeafCheck {
|
|
14
|
+
/** Bytes streamed; the source's size must agree. */
|
|
15
|
+
size: number;
|
|
16
|
+
/** SHA-256 of every byte. */
|
|
17
|
+
digest: Uint8Array;
|
|
18
|
+
/** The first 64 bytes (or fewer): what a placement choice reads. */
|
|
19
|
+
head: Uint8Array;
|
|
20
|
+
/** The origin hypothesis: SHA-256 of the placement's frame around these bytes. Null when no placement was asked, or container/1 was asked without an origin (its prefix carries it). */
|
|
21
|
+
fusedFromOrigin: Uint8Array | null;
|
|
22
|
+
/** The committed-bytes hypothesis for the placement asked: the layout held and the original inside hashes to embeddedOrigin, or why not. Null when no placement was asked. */
|
|
23
|
+
direct: {
|
|
24
|
+
ok: true;
|
|
25
|
+
embeddedOrigin: Uint8Array;
|
|
26
|
+
originalSize: number;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
reason: string;
|
|
30
|
+
} | null;
|
|
31
|
+
/** True when the bytes carry this commitment under some placement: a trailer at their end, or a container whose manifest names it and whose original inside hashes to the origin it names. */
|
|
32
|
+
carriesCommitment: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** SHA-256 of a source, streamed. */
|
|
35
|
+
export declare function streamDigest(source: ByteSource): Promise<Uint8Array>;
|
|
36
|
+
/**
|
|
37
|
+
* One pass over a source for the hypotheses above. `origin` is the leaf's
|
|
38
|
+
* origin when a leaf is in hand (the origin a producer wrote into a
|
|
39
|
+
* container's manifest); null when only the bytes' own digest will do.
|
|
40
|
+
*/
|
|
41
|
+
export declare function streamLeafCheck(source: ByteSource, opts: {
|
|
42
|
+
placement: StreamPlacement | null;
|
|
43
|
+
commitment: Uint8Array;
|
|
44
|
+
origin: Uint8Array | null;
|
|
45
|
+
}): Promise<StreamLeafCheck>;
|
|
46
|
+
//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