@@ -1213,7 +1213,7 @@ for (let index = 0; index < storages.length; index++) {
1213
1213
expect ( cvp . value . string ( ) ) . to . be . equal ( '22' ) ;
1214
1214
expect ( cvp . fnc ) . to . be . equal ( 0 ) ;
1215
1215
} ) ;
1216
- it ( 'calcualte depth for mtp' , async ( ) => {
1216
+ it ( 'calculate depth for mtp' , async ( ) => {
1217
1217
const storage = getTreeStorage ( 'calculatedepth' ) ;
1218
1218
const mt = new Merkletree ( storage , true , 40 ) ;
1219
1219
@@ -1231,6 +1231,29 @@ for (let index = 0; index < storages.length; index++) {
1231
1231
expect ( proof . nodeAux ) . to . deep . equal ( p . nodeAux ) ;
1232
1232
expect ( proof . existence ) . to . equal ( p . existence ) ;
1233
1233
1234
+ let isValid = await verifyProof ( await mt . root ( ) , proof , BigInt ( '11' ) , BigInt ( '0' ) ) ;
1235
+ expect ( isValid ) . to . be . true ;
1236
+ isValid = await verifyProof ( await mt . root ( ) , p , BigInt ( '11' ) , BigInt ( '0' ) ) ;
1237
+ expect ( isValid ) . to . be . true ;
1238
+ } ) ;
1239
+ it ( 'calculate depth for mtp (old format)' , async ( ) => {
1240
+ const storage = getTreeStorage ( 'calculatedepth' ) ;
1241
+ const mt = new Merkletree ( storage , true , 40 ) ;
1242
+
1243
+ await mt . add ( BigInt ( '1' ) , BigInt ( '2' ) ) ;
1244
+ await mt . add ( BigInt ( '3' ) , BigInt ( '8' ) ) ;
1245
+ await mt . add ( BigInt ( '7' ) , BigInt ( '8' ) ) ;
1246
+ await mt . add ( BigInt ( '9' ) , BigInt ( '8' ) ) ;
1247
+
1248
+ const { proof } : { proof : Proof } = await mt . generateProof ( BigInt ( '11' ) , await mt . root ( ) ) ;
1249
+
1250
+ const given = `{ "existence": false, "siblings": [ "0", "12166698708103333637493481507263348370172773813051235807348785759284762677336", "7750564177398573185975752951631372712868228752107043582052272719841058100111", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "nodeAux": { "key": "3", "value": "8" }}` ;
1251
+ const p = Proof . fromJSON ( JSON . parse ( given ) ) ;
1252
+
1253
+ expect ( proof . allSiblings ( ) ) . to . deep . equal ( p . allSiblings ( ) ) ;
1254
+ expect ( proof . nodeAux ) . to . deep . equal ( p . nodeAux ) ;
1255
+ expect ( proof . existence ) . to . equal ( p . existence ) ;
1256
+
1234
1257
let isValid = await verifyProof ( await mt . root ( ) , proof , BigInt ( '11' ) , BigInt ( '0' ) ) ;
1235
1258
expect ( isValid ) . to . be . true ;
1236
1259
isValid = await verifyProof ( await mt . root ( ) , p , BigInt ( '11' ) , BigInt ( '0' ) ) ;
0 commit comments