@forestrie/merklelog 0.7.0 → 0.7.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"massiffull.d.ts","sourceRoot":"","sources":["../../src/massifs/massiffull.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAWT"}
1
+ {"version":3,"file":"massiffull.d.ts","sourceRoot":"","sources":["../../src/massifs/massiffull.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAYT"}
@@ -13,8 +13,9 @@
13
13
  export function isMassifFull(massifHeight, logEntries) {
14
14
  // Convert 1-based height to 0-based height index
15
15
  const heightIndex = massifHeight - 1;
16
- // Expected number of leaves for a full massif: f = 2^g = 1 << heightIndex
17
- const expectedLeaves = BigInt(1 << heightIndex);
16
+ // Expected number of leaves for a full massif: f = 2^g, in bigint (a JS
17
+ // number `1 << g` wraps at g = 32).
18
+ const expectedLeaves = 1n << BigInt(heightIndex);
18
19
  // Actual number of leaves: f = (n + 1) / 2
19
20
  const actualLeaves = (logEntries + 1n) >> 1n;
20
21
  return actualLeaves >= expectedLeaves;
@@ -11,5 +11,5 @@
11
11
  * @param blobSize - Size of the massif blob in bytes
12
12
  * @returns The last MMR index in the massif
13
13
  */
14
- export declare function computeLastMMRIndex(massifHeight: number, massifIndex: number, blobSize: number): bigint;
14
+ export declare function computeLastMMRIndex(massifHeight: number, massifIndex: number | bigint, blobSize: number): bigint;
15
15
  //# sourceMappingURL=mmrindex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mmrindex.d.ts","sourceRoot":"","sources":["../../src/massifs/mmrindex.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CAUR"}
1
+ {"version":3,"file":"mmrindex.d.ts","sourceRoot":"","sources":["../../src/massifs/mmrindex.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,QAAQ,EAAE,MAAM,GACf,MAAM,CAUR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forestrie/merklelog",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "MMR (merkle mountain range) proofs and massif storage format for Forestrie transparency logs",
@@ -18,8 +18,9 @@ export function isMassifFull(
18
18
  // Convert 1-based height to 0-based height index
19
19
  const heightIndex = massifHeight - 1;
20
20
 
21
- // Expected number of leaves for a full massif: f = 2^g = 1 << heightIndex
22
- const expectedLeaves = BigInt(1 << heightIndex);
21
+ // Expected number of leaves for a full massif: f = 2^g, in bigint (a JS
22
+ // number `1 << g` wraps at g = 32).
23
+ const expectedLeaves = 1n << BigInt(heightIndex);
23
24
 
24
25
  // Actual number of leaves: f = (n + 1) / 2
25
26
  const actualLeaves = (logEntries + 1n) >> 1n;
@@ -17,7 +17,7 @@ import { massifFirstLeaf } from "../mmr/index.js";
17
17
  */
18
18
  export function computeLastMMRIndex(
19
19
  massifHeight: number,
20
- massifIndex: number,
20
+ massifIndex: number | bigint,
21
21
  blobSize: number,
22
22
  ): bigint {
23
23
  // Calculate number of log entries (nodes) in the blob