@forestrie/merklelog 0.2.0 → 0.2.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.
- package/dist/mmr/proof.d.ts.map +1 -1
- package/dist/mmr/proof.js +7 -0
- package/package.json +1 -1
- package/src/mmr/proof.ts +7 -0
package/dist/mmr/proof.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proof.d.ts","sourceRoot":"","sources":["../../src/mmr/proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"proof.d.ts","sourceRoot":"","sources":["../../src/mmr/proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;AA2CnD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,YAAY,EAAE,MAAM,EACpB,CAAC,EAAE,MAAM,GACR,UAAU,EAAE,CAyBd;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAcnD;AAaD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,MAAM,CAIR;AAQD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAczD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUrD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,CAAC,EAAE,MAAM,GACR,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAWrB"}
|
package/dist/mmr/proof.js
CHANGED
|
@@ -35,6 +35,13 @@ function jumpLeftPerfect(pos) {
|
|
|
35
35
|
* (go-merklelog `mmr/indexheight.go` PosHeight)
|
|
36
36
|
*/
|
|
37
37
|
function posHeight(pos) {
|
|
38
|
+
// Positions are 1-based; `pos <= 0` is out of domain and would spin forever
|
|
39
|
+
// (`jumpLeftPerfect(0) === 0`, `allOnes(0) === false`). Reject in bounded
|
|
40
|
+
// time so a malformed size fed to any caller (peakMMRIndexes, indexHeight,
|
|
41
|
+
// inclusionProof, …) fails loudly instead of hanging the verifier (FOR-414).
|
|
42
|
+
if (pos <= 0n) {
|
|
43
|
+
throw new Error(`posHeight: position must be >= 1, got ${pos}`);
|
|
44
|
+
}
|
|
38
45
|
let current = pos;
|
|
39
46
|
while (!allOnes(current)) {
|
|
40
47
|
current = jumpLeftPerfect(current);
|
package/package.json
CHANGED
package/src/mmr/proof.ts
CHANGED
|
@@ -40,6 +40,13 @@ function jumpLeftPerfect(pos: bigint): bigint {
|
|
|
40
40
|
* (go-merklelog `mmr/indexheight.go` PosHeight)
|
|
41
41
|
*/
|
|
42
42
|
function posHeight(pos: bigint): number {
|
|
43
|
+
// Positions are 1-based; `pos <= 0` is out of domain and would spin forever
|
|
44
|
+
// (`jumpLeftPerfect(0) === 0`, `allOnes(0) === false`). Reject in bounded
|
|
45
|
+
// time so a malformed size fed to any caller (peakMMRIndexes, indexHeight,
|
|
46
|
+
// inclusionProof, …) fails loudly instead of hanging the verifier (FOR-414).
|
|
47
|
+
if (pos <= 0n) {
|
|
48
|
+
throw new Error(`posHeight: position must be >= 1, got ${pos}`);
|
|
49
|
+
}
|
|
43
50
|
let current = pos;
|
|
44
51
|
while (!allOnes(current)) {
|
|
45
52
|
current = jumpLeftPerfect(current);
|