@brightchain/brightchain-lib 0.29.21 → 0.29.22

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/lib/errors/ledgerError.d.ts +4 -1
  3. package/src/lib/errors/ledgerError.d.ts.map +1 -1
  4. package/src/lib/errors/ledgerError.js +3 -0
  5. package/src/lib/errors/ledgerError.js.map +1 -1
  6. package/src/lib/interfaces/ledger/consistencyProof.d.ts +22 -0
  7. package/src/lib/interfaces/ledger/consistencyProof.d.ts.map +1 -0
  8. package/src/lib/interfaces/ledger/consistencyProof.js +12 -0
  9. package/src/lib/interfaces/ledger/consistencyProof.js.map +1 -0
  10. package/src/lib/interfaces/ledger/index.d.ts +4 -0
  11. package/src/lib/interfaces/ledger/index.d.ts.map +1 -1
  12. package/src/lib/interfaces/ledger/index.js +4 -1
  13. package/src/lib/interfaces/ledger/index.js.map +1 -1
  14. package/src/lib/interfaces/ledger/merkleProof.d.ts +42 -0
  15. package/src/lib/interfaces/ledger/merkleProof.d.ts.map +1 -0
  16. package/src/lib/interfaces/ledger/merkleProof.js +23 -0
  17. package/src/lib/interfaces/ledger/merkleProof.js.map +1 -0
  18. package/src/lib/interfaces/ledger/proofVerificationResult.d.ts +19 -0
  19. package/src/lib/interfaces/ledger/proofVerificationResult.d.ts.map +1 -0
  20. package/src/lib/interfaces/ledger/proofVerificationResult.js +12 -0
  21. package/src/lib/interfaces/ledger/proofVerificationResult.js.map +1 -0
  22. package/src/lib/interfaces/ledger/validationResult.d.ts +1 -1
  23. package/src/lib/interfaces/ledger/validationResult.d.ts.map +1 -1
  24. package/src/lib/ledger/incrementalMerkleTree.d.ts +179 -0
  25. package/src/lib/ledger/incrementalMerkleTree.d.ts.map +1 -0
  26. package/src/lib/ledger/incrementalMerkleTree.js +372 -0
  27. package/src/lib/ledger/incrementalMerkleTree.js.map +1 -0
  28. package/src/lib/ledger/ledger.d.ts +91 -1
  29. package/src/lib/ledger/ledger.d.ts.map +1 -1
  30. package/src/lib/ledger/ledger.js +363 -10
  31. package/src/lib/ledger/ledger.js.map +1 -1
  32. package/src/lib/ledger/ledgerChainValidator.d.ts +48 -2
  33. package/src/lib/ledger/ledgerChainValidator.d.ts.map +1 -1
  34. package/src/lib/ledger/ledgerChainValidator.js +145 -2
  35. package/src/lib/ledger/ledgerChainValidator.js.map +1 -1
  36. package/src/lib/ledger/proofSerializer.d.ts +60 -0
  37. package/src/lib/ledger/proofSerializer.d.ts.map +1 -0
  38. package/src/lib/ledger/proofSerializer.js +206 -0
  39. package/src/lib/ledger/proofSerializer.js.map +1 -0
@@ -0,0 +1,372 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview IncrementalMerkleTree — a frontier-based incremental Merkle tree
4
+ * built over SHA3-512 entry hashes.
5
+ *
6
+ * The tree supports O(log N) appends via a frontier (right-spine hashes) and
7
+ * maintains the full leaf list for proof generation. All binary data uses
8
+ * Uint8Array (no Node.js Buffer) for browser compatibility.
9
+ *
10
+ * @see Design: Merkle Tree Commitment Layer — IncrementalMerkleTree
11
+ * @see Requirements 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.1, 2.2, 14.1, 15.1, 15.2
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.IncrementalMerkleTree = void 0;
15
+ const ledgerError_1 = require("../errors/ledgerError");
16
+ const merkleProof_1 = require("../interfaces/ledger/merkleProof");
17
+ /**
18
+ * Incremental Merkle tree using frontier-based O(log N) appends.
19
+ *
20
+ * Leaves are the entryHash (SHA3-512, 64 bytes) of each ledger entry.
21
+ * Internal nodes are SHA3-512(left_child || right_child).
22
+ * The frontier stores the root hashes of the perfect binary subtrees
23
+ * that compose the current tree.
24
+ */
25
+ class IncrementalMerkleTree {
26
+ checksumService;
27
+ /** All leaf hashes, in order. */
28
+ leaves;
29
+ /** Frontier: right-spine hashes for incremental root computation. */
30
+ frontier;
31
+ /** Cached current root. */
32
+ cachedRoot;
33
+ /**
34
+ * Tracked size, independent of leaves.length.
35
+ * For frontier-only trees (restored via fromFrontier), leaves may be empty
36
+ * while _size reflects the actual number of leaves the frontier represents.
37
+ */
38
+ _size;
39
+ constructor(checksumService) {
40
+ this.checksumService = checksumService;
41
+ this.leaves = [];
42
+ this.frontier = [];
43
+ this.cachedRoot = null;
44
+ this._size = 0;
45
+ }
46
+ /**
47
+ * Current Merkle root. SHA3-512 of empty bytes if tree is empty.
48
+ * Returns the leaf hash when there is a single leaf.
49
+ */
50
+ get root() {
51
+ if (this._size === 0) {
52
+ return this.checksumService.calculateChecksum(new Uint8Array(0));
53
+ }
54
+ if (this._size === 1 && this.leaves.length === 1) {
55
+ return this.leaves[0];
56
+ }
57
+ if (this.cachedRoot !== null) {
58
+ return this.cachedRoot;
59
+ }
60
+ this.cachedRoot = this.computeRootFromFrontier();
61
+ return this.cachedRoot;
62
+ }
63
+ /** Number of leaves in the tree. */
64
+ get size() {
65
+ return this._size;
66
+ }
67
+ /** Current frontier (right-spine hashes). Returns a copy. */
68
+ get currentFrontier() {
69
+ return [...this.frontier];
70
+ }
71
+ /**
72
+ * Append a new leaf hash. Updates frontier and root in O(log N).
73
+ *
74
+ * Algorithm (trailing-ones merge):
75
+ * 1. Push leafHash onto frontier
76
+ * 2. Increment size
77
+ * 3. Count trailing 1-bits in binary(size) = mergeCount
78
+ * 4. For mergeCount iterations: pop right, pop left, push SHA3-512(left || right)
79
+ * 5. Recompute cachedRoot from frontier
80
+ */
81
+ append(leafHash) {
82
+ this.leaves.push(leafHash);
83
+ this.frontier.push(leafHash);
84
+ this._size++;
85
+ const mergeCount = this.trailingZeros(this._size);
86
+ for (let i = 0; i < mergeCount; i++) {
87
+ const right = this.frontier.pop();
88
+ const left = this.frontier.pop();
89
+ this.frontier.push(this.hashPair(left, right));
90
+ }
91
+ this.cachedRoot = this.computeRootFromFrontier();
92
+ }
93
+ /**
94
+ * Generate an inclusion proof for the leaf at the given index.
95
+ *
96
+ * Uses the RFC 6962 recursive decomposition: split the N leaves into
97
+ * a left subtree of size k (largest power of 2 < N) and a right subtree
98
+ * of size N-k. Recurse into whichever subtree contains the target leaf,
99
+ * recording the sibling subtree's hash at each level.
100
+ *
101
+ * This guarantees path length = ceil(log2(N)), or 0 when N = 1.
102
+ *
103
+ * @param leafIndex - Zero-based index of the leaf
104
+ * @returns An IMerkleProof with the authentication path from leaf to root
105
+ * @throws LedgerError(MerkleProofFailed) if leafIndex is out of range
106
+ *
107
+ * @see Requirements 3.1, 3.2, 3.3, 3.4, 14.2
108
+ */
109
+ getInclusionProof(leafIndex) {
110
+ const n = this._size;
111
+ if (n === 0 || leafIndex < 0 || leafIndex >= n || leafIndex >= this.leaves.length) {
112
+ throw new ledgerError_1.LedgerError(ledgerError_1.LedgerErrorType.MerkleProofFailed, `Leaf index ${leafIndex} is out of range [0, ${n})`);
113
+ }
114
+ // Single leaf — proof path is empty
115
+ if (n === 1) {
116
+ return {
117
+ leafHash: this.leaves[0],
118
+ leafIndex: 0,
119
+ treeSize: 1,
120
+ path: [],
121
+ };
122
+ }
123
+ const path = [];
124
+ this.buildInclusionPath(this.leaves, leafIndex, path);
125
+ // buildInclusionPath produces root-to-leaf order; reverse for leaf-to-root
126
+ path.reverse();
127
+ return {
128
+ leafHash: this.leaves[leafIndex],
129
+ leafIndex,
130
+ treeSize: n,
131
+ path,
132
+ };
133
+ }
134
+ /**
135
+ * Generate a consistency proof between an earlier tree size M and the current
136
+ * tree size N.
137
+ *
138
+ * Follows RFC 6962 Section 2.1.2: SUBPROOF(m, D[0:n], b).
139
+ *
140
+ * - M=0 or M=N → empty proof (trivially consistent)
141
+ * - M > N → throw LedgerError(ConsistencyProofFailed)
142
+ * - 0 < M < N → return minimal set of intermediate hashes
143
+ *
144
+ * @param earlierSize - The earlier tree size M
145
+ * @returns An IConsistencyProof with the intermediate hashes
146
+ * @throws LedgerError(ConsistencyProofFailed) if earlierSize > current size
147
+ *
148
+ * @see Requirements 5.1, 5.2, 5.3, 5.4, 14.3
149
+ */
150
+ getConsistencyProof(earlierSize) {
151
+ const n = this._size;
152
+ const m = earlierSize;
153
+ if (m > n) {
154
+ throw new ledgerError_1.LedgerError(ledgerError_1.LedgerErrorType.ConsistencyProofFailed, `Earlier size ${m} exceeds current size ${n}`);
155
+ }
156
+ // M=0 or M=N → trivially consistent, empty proof
157
+ if (m === 0 || m === n) {
158
+ return {
159
+ earlierSize: m,
160
+ laterSize: n,
161
+ hashes: [],
162
+ };
163
+ }
164
+ // Consistency proofs require leaves for hash computation
165
+ if (this.leaves.length === 0) {
166
+ throw new ledgerError_1.LedgerError(ledgerError_1.LedgerErrorType.ConsistencyProofFailed, 'Cannot generate consistency proof from a frontier-only tree (no leaves stored)');
167
+ }
168
+ // RFC 6962 SUBPROOF(m, D[0:n], true)
169
+ const hashes = [];
170
+ this.buildConsistencyProof(m, this.leaves.slice(0, n), true, hashes);
171
+ return {
172
+ earlierSize: m,
173
+ laterSize: n,
174
+ hashes,
175
+ };
176
+ }
177
+ /**
178
+ * Batch-construct a tree from a list of leaf hashes.
179
+ * Produces the same root as appending each leaf one at a time.
180
+ *
181
+ * @param leaves - Array of leaf hashes (SHA3-512 Checksums)
182
+ * @param checksumService - ChecksumService for hashing
183
+ * @returns A fully populated IncrementalMerkleTree
184
+ *
185
+ * @see Requirements 2.3, 2.4, 8.2, 14.5
186
+ */
187
+ static fromLeaves(leaves, checksumService) {
188
+ const tree = new IncrementalMerkleTree(checksumService);
189
+ for (const leaf of leaves) {
190
+ tree.append(leaf);
191
+ }
192
+ return tree;
193
+ }
194
+ /**
195
+ * Restore a tree from a persisted frontier and size.
196
+ * Creates a tree that can compute the root and accept further appends,
197
+ * but cannot generate inclusion or consistency proofs (no leaves stored).
198
+ *
199
+ * @param frontier - The persisted frontier (right-spine hashes)
200
+ * @param size - The number of leaves the frontier represents
201
+ * @param checksumService - ChecksumService for hashing
202
+ * @returns An IncrementalMerkleTree with frontier and size set, but no leaves
203
+ *
204
+ * @see Requirements 2.3, 2.4, 8.2, 14.5
205
+ */
206
+ static fromFrontier(frontier, size, checksumService) {
207
+ const tree = new IncrementalMerkleTree(checksumService);
208
+ tree.frontier = [...frontier];
209
+ tree._size = size;
210
+ tree.cachedRoot = tree.computeRootFromFrontier();
211
+ return tree;
212
+ }
213
+ /**
214
+ * Compute the Merkle root for a given set of leaves without creating
215
+ * a full tree instance. Pure function for verification.
216
+ *
217
+ * @param leaves - Array of leaf hashes (SHA3-512 Checksums)
218
+ * @param checksumService - ChecksumService for hashing
219
+ * @returns The Merkle root Checksum
220
+ *
221
+ * @see Requirements 2.3, 2.4, 8.2, 14.5
222
+ */
223
+ static computeRoot(leaves, checksumService) {
224
+ const tree = IncrementalMerkleTree.fromLeaves(leaves, checksumService);
225
+ return tree.root;
226
+ }
227
+ /**
228
+ * RFC 6962 Section 2.1.2 SUBPROOF(m, leaves, startFromOldRoot).
229
+ *
230
+ * Recursively decomposes the tree to produce the minimal set of hashes
231
+ * needed to prove consistency between tree sizes m and |leaves|.
232
+ *
233
+ * @param m - The earlier tree size within this subtree
234
+ * @param leaves - The leaves of the current subtree
235
+ * @param startFromOldRoot - If true, omit the hash when m == |leaves|
236
+ * (because the verifier can compute it from the earlier root)
237
+ * @param hashes - Accumulator for the proof hashes
238
+ */
239
+ buildConsistencyProof(m, leaves, startFromOldRoot, hashes) {
240
+ const n = leaves.length;
241
+ if (m === n) {
242
+ // When startFromOldRoot is true, the verifier already knows this hash
243
+ // (it's the old root). When false, we must include it.
244
+ if (!startFromOldRoot) {
245
+ hashes.push(this.computeSubtreeHash(leaves));
246
+ }
247
+ return;
248
+ }
249
+ // k = largest power of 2 less than n
250
+ const k = this.largestPowerOf2LessThan(n);
251
+ if (m <= k) {
252
+ // The old tree fits entirely in the left subtree
253
+ this.buildConsistencyProof(m, leaves.slice(0, k), startFromOldRoot, hashes);
254
+ // Include the right subtree hash
255
+ hashes.push(this.computeSubtreeHash(leaves.slice(k)));
256
+ }
257
+ else {
258
+ // The old tree spans both subtrees: left is full (size k), right has m-k
259
+ this.buildConsistencyProof(m - k, leaves.slice(k), false, hashes);
260
+ // Include the left subtree hash
261
+ hashes.push(this.computeSubtreeHash(leaves.slice(0, k)));
262
+ }
263
+ }
264
+ /**
265
+ * Recursively build the inclusion proof path using RFC 6962 decomposition.
266
+ *
267
+ * Split leaves into left (size k = largest power of 2 < n) and right (n-k).
268
+ * Record the sibling subtree hash and recurse into the subtree containing
269
+ * the target leaf.
270
+ */
271
+ buildInclusionPath(leaves, targetIndex, path) {
272
+ const n = leaves.length;
273
+ if (n <= 1) {
274
+ return;
275
+ }
276
+ // k = largest power of 2 less than n
277
+ const k = this.largestPowerOf2LessThan(n);
278
+ if (targetIndex < k) {
279
+ // Target is in the left subtree; sibling is the right subtree hash
280
+ const rightHash = this.computeSubtreeHash(leaves.slice(k));
281
+ path.push({ hash: rightHash, direction: merkleProof_1.MerkleDirection.RIGHT });
282
+ this.buildInclusionPath(leaves.slice(0, k), targetIndex, path);
283
+ }
284
+ else {
285
+ // Target is in the right subtree; sibling is the left subtree hash
286
+ const leftHash = this.computeSubtreeHash(leaves.slice(0, k));
287
+ path.push({ hash: leftHash, direction: merkleProof_1.MerkleDirection.LEFT });
288
+ this.buildInclusionPath(leaves.slice(k), targetIndex - k, path);
289
+ }
290
+ }
291
+ /**
292
+ * Compute the Merkle hash of a subtree given its leaves.
293
+ * Uses the same RFC 6962 recursive decomposition.
294
+ */
295
+ computeSubtreeHash(leaves) {
296
+ const n = leaves.length;
297
+ if (n === 0) {
298
+ return this.checksumService.calculateChecksum(new Uint8Array(0));
299
+ }
300
+ if (n === 1) {
301
+ return leaves[0];
302
+ }
303
+ const k = this.largestPowerOf2LessThan(n);
304
+ const leftHash = this.computeSubtreeHash(leaves.slice(0, k));
305
+ const rightHash = this.computeSubtreeHash(leaves.slice(k));
306
+ return this.hashPair(leftHash, rightHash);
307
+ }
308
+ /**
309
+ * Returns the largest power of 2 that is strictly less than n.
310
+ * For n=2, returns 1. For n=3, returns 2. For n=5, returns 4.
311
+ */
312
+ largestPowerOf2LessThan(n) {
313
+ let k = 1;
314
+ while (k * 2 < n) {
315
+ k *= 2;
316
+ }
317
+ return k;
318
+ }
319
+ /**
320
+ * Compute the root from the frontier by folding right-to-left.
321
+ * SHA3-512(frontier[i] || result) for i from second-to-last down to 0.
322
+ */
323
+ computeRootFromFrontier() {
324
+ if (this.frontier.length === 0) {
325
+ return this.checksumService.calculateChecksum(new Uint8Array(0));
326
+ }
327
+ let result = this.frontier[this.frontier.length - 1];
328
+ for (let i = this.frontier.length - 2; i >= 0; i--) {
329
+ result = this.hashPair(this.frontier[i], result);
330
+ }
331
+ return result;
332
+ }
333
+ /**
334
+ * Hash two child nodes: SHA3-512(left || right).
335
+ * Concatenates the 64-byte left and right hashes, then hashes the 128-byte result.
336
+ */
337
+ hashPair(left, right) {
338
+ const leftBytes = left.toUint8Array();
339
+ const rightBytes = right.toUint8Array();
340
+ const combined = new Uint8Array(leftBytes.length + rightBytes.length);
341
+ combined.set(leftBytes, 0);
342
+ combined.set(rightBytes, leftBytes.length);
343
+ return this.checksumService.calculateChecksum(combined);
344
+ }
345
+ /**
346
+ * Count the number of trailing 1-bits in the binary representation of n.
347
+ */
348
+ trailingOnes(n) {
349
+ let count = 0;
350
+ while ((n & 1) === 1) {
351
+ count++;
352
+ n >>>= 1;
353
+ }
354
+ return count;
355
+ }
356
+ /**
357
+ * Count the number of trailing 0-bits in the binary representation of n.
358
+ * For n=0, returns 0.
359
+ */
360
+ trailingZeros(n) {
361
+ if (n === 0)
362
+ return 0;
363
+ let count = 0;
364
+ while ((n & 1) === 0) {
365
+ count++;
366
+ n >>>= 1;
367
+ }
368
+ return count;
369
+ }
370
+ }
371
+ exports.IncrementalMerkleTree = IncrementalMerkleTree;
372
+ //# sourceMappingURL=incrementalMerkleTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incrementalMerkleTree.js","sourceRoot":"","sources":["../../../../../brightchain-lib/src/lib/ledger/incrementalMerk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I,CAAC,eAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,CAAS;QAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,CAAC,MAAM,CAAC,CAAC;QACX,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,CAAS;QAC7B,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QACtB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,EAAE,CAAC;YACR,CAAC,MAAM,CAAC,CAAC;QACX,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArZD,sDAqZC"}
@@ -25,9 +25,12 @@
25
25
  import { SignatureUint8Array } from '@digitaldefiance/ecies-lib';
26
26
  import { BlockSize } from '../enumerations/blockSize';
27
27
  import { IAuthorizedSigner } from '../interfaces/ledger/authorizedSigner';
28
+ import { IConsistencyProof } from '../interfaces/ledger/consistencyProof';
28
29
  import { IGovernanceAction } from '../interfaces/ledger/governanceAction';
29
30
  import { ILedgerEntry } from '../interfaces/ledger/ledgerEntry';
30
31
  import { ILedgerSigner } from '../interfaces/ledger/ledgerSigner';
32
+ import { IMerkleProof } from '../interfaces/ledger/merkleProof';
33
+ import { IProofVerificationResult } from '../interfaces/ledger/proofVerificationResult';
31
34
  import { IQuorumPolicy } from '../interfaces/ledger/quorumPolicy';
32
35
  import { IBlockStore } from '../interfaces/storage/blockStore';
33
36
  import { Checksum } from '../types/checksum';
@@ -51,6 +54,7 @@ export declare class Ledger {
51
54
  private readonly governanceSerializer?;
52
55
  private readonly index;
53
56
  private readonly checksumService;
57
+ private merkleTree;
54
58
  private _length;
55
59
  private _head;
56
60
  private _headEntryHash;
@@ -62,6 +66,11 @@ export declare class Ledger {
62
66
  get head(): Checksum | null;
63
67
  /** Current quorum policy, or undefined if governance not initialized. */
64
68
  get quorumPolicy(): IQuorumPolicy | undefined;
69
+ /**
70
+ * Current Merkle root, or null if the ledger is empty.
71
+ * @see Requirements 9.1, 7.1
72
+ */
73
+ get merkleRoot(): Checksum | null;
65
74
  /**
66
75
  * Append a new entry to the ledger.
67
76
  * Returns the Checksum of the stored block.
@@ -100,6 +109,26 @@ export declare class Ledger {
100
109
  * Get the most recent entry, or null if empty.
101
110
  */
102
111
  getLatestEntry(): Promise<ILedgerEntry | null>;
112
+ /**
113
+ * Get an inclusion proof for the entry at the given sequence number.
114
+ *
115
+ * @param sequenceNumber - Zero-based sequence number of the entry
116
+ * @returns An IMerkleProof with the authentication path from leaf to root
117
+ * @throws LedgerError(MerkleProofFailed) if sequenceNumber is out of range
118
+ *
119
+ * @see Requirements 9.2, 18.1
120
+ */
121
+ getInclusionProof(sequenceNumber: number): IMerkleProof;
122
+ /**
123
+ * Get a consistency proof between an earlier length and the current length.
124
+ *
125
+ * @param earlierLength - The earlier ledger length M
126
+ * @returns An IConsistencyProof with the intermediate hashes
127
+ * @throws LedgerError(ConsistencyProofFailed) if earlierLength > current length
128
+ *
129
+ * @see Requirements 9.3
130
+ */
131
+ getConsistencyProof(earlierLength: number): IConsistencyProof;
103
132
  /**
104
133
  * Handle the genesis entry for a governance-enabled ledger.
105
134
  * The payload must be a governance genesis payload containing the
@@ -119,7 +148,7 @@ export declare class Ledger {
119
148
  /**
120
149
  * Serialize the current metadata into binary.
121
150
  *
122
- * Format:
151
+ * Format (version 0x0001):
123
152
  * magic 4 bytes 0x4C4D4554 ("LMET")
124
153
  * version 2 bytes 0x0001
125
154
  * ledgerIdLength 4 bytes uint32 BE
@@ -127,13 +156,56 @@ export declare class Ledger {
127
156
  * length 4 bytes uint32 BE
128
157
  * hasHead 1 byte 0x00 or 0x01
129
158
  * headChecksum 0|64 SHA3-512 bytes (block checksum of head)
159
+ * hasMerkleRoot 1 byte 0x00 or 0x01
160
+ * merkleRoot 0|64 SHA3-512 Merkle root
161
+ * frontierCount 2 bytes uint16 BE — number of frontier hashes
162
+ * frontier var frontierCount × 64 bytes SHA3-512 hashes
130
163
  * index entries var seqNum (uint32 BE) + blockChecksum (64 bytes)
164
+ *
165
+ * @see Requirements 7.1, 7.3, 8.1, 8.4
131
166
  */
132
167
  private serializeMetadata;
133
168
  /**
134
169
  * Persist the metadata block to the store under a deterministic key.
135
170
  */
136
171
  private persistMetadata;
172
+ /**
173
+ * Verify an inclusion proof against a Merkle root.
174
+ * Static — no Ledger instance needed. Suitable for light clients.
175
+ *
176
+ * Recomputes hashes from the leaf to the root using the proof path,
177
+ * then compares the result to the provided Merkle root.
178
+ *
179
+ * @param proof - The inclusion proof to verify
180
+ * @param merkleRoot - The expected Merkle root
181
+ * @returns An IProofVerificationResult indicating success or failure
182
+ *
183
+ * @see Requirements 9.4, 4.1, 4.2, 4.3, 4.4, 15.3, 18.3
184
+ */
185
+ static verifyInclusionProof(proof: IMerkleProof, merkleRoot: Checksum): IProofVerificationResult;
186
+ /**
187
+ * Verify a consistency proof between two Merkle roots.
188
+ * Static — no Ledger instance needed.
189
+ *
190
+ * Implements the RFC 6962 Section 2.1.4 consistency proof verification
191
+ * algorithm. The proof hashes are consumed in order to reconstruct both
192
+ * the earlier and later roots.
193
+ *
194
+ * @param proof - The consistency proof to verify
195
+ * @param earlierRoot - The Merkle root at the earlier length
196
+ * @param laterRoot - The Merkle root at the later length
197
+ * @param earlierLength - The earlier ledger length M
198
+ * @param laterLength - The later ledger length N
199
+ * @returns An IProofVerificationResult indicating success or failure
200
+ *
201
+ * @see Requirements 9.5, 6.1, 6.2, 6.3
202
+ */
203
+ static verifyConsistencyProof(proof: IConsistencyProof, earlierRoot: Checksum, laterRoot: Checksum, earlierLength: number, laterLength: number): IProofVerificationResult;
204
+ /**
205
+ * Hash two child nodes: SHA3-512(left || right).
206
+ * Helper for static verification methods.
207
+ */
208
+ private static hashChildren;
137
209
  /**
138
210
  * Load ledger state from the block store.
139
211
  *
@@ -151,8 +223,26 @@ export declare class Ledger {
151
223
  * AuthorizedSignerSet from governance entries.
152
224
  */
153
225
  private replayGovernance;
226
+ /**
227
+ * Restore the Merkle tree during `Ledger.load()`.
228
+ *
229
+ * Strategy:
230
+ * 1. If a Merkle root and frontier are persisted, attempt fast restoration
231
+ * via `IncrementalMerkleTree.fromFrontier()`. Verify the restored root
232
+ * matches the persisted root.
233
+ * 2. On mismatch, fall back to full reconstruction from entry hashes.
234
+ * 3. If no Merkle root in metadata, rebuild from all entry hashes.
235
+ *
236
+ * @see Requirements 7.2, 8.2, 8.3
237
+ */
238
+ private restoreMerkleTree;
154
239
  /**
155
240
  * Parse a metadata block's binary content.
241
+ *
242
+ * Returns the parsed fields including Merkle root and frontier
243
+ * so that `Ledger.load()` can restore the Merkle tree state.
244
+ *
245
+ * @see Requirements 7.2, 7.3, 8.1, 8.4
156
246
  */
157
247
  private static parseMetadata;
158
248
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../../../brightchain-lib/src/lib/ledger/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;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