@@ -7,6 +7,7 @@ import { WitnessCalculator } from "./resources/witness_calculator";
77import { BytesUtils } from "./utils/bytes.js" ;
88import { dateToEpoch , epochIntToBytes } from "./utils/epoch.js" ;
99import { poseidonHash , sha256 } from "./utils/hash.js" ;
10+ import { MERKLE_TREE_DEPTH } from "./utils/merkle.js" ;
1011
1112export class Zerokit {
1213 public constructor (
@@ -83,7 +84,6 @@ export class Zerokit {
8384
8485 public async generateRLNProof (
8586 msg : Uint8Array ,
86- index : number , // index of the leaf in the merkle tree
8787 epoch : Uint8Array | Date | undefined ,
8888 idSecretHash : Uint8Array ,
8989 pathElements : Uint8Array [ ] ,
@@ -103,7 +103,10 @@ export class Zerokit {
103103 throw new Error (
104104 `ID secret hash must be 32 bytes, got ${ idSecretHash . length } `
105105 ) ;
106- if ( index < 0 ) throw new Error ( "index must be >= 0" ) ;
106+ if ( pathElements . length !== MERKLE_TREE_DEPTH )
107+ throw new Error ( `Path elements must be ${ MERKLE_TREE_DEPTH } bytes` ) ;
108+ if ( identityPathIndex . length !== MERKLE_TREE_DEPTH )
109+ throw new Error ( `Identity path index must be ${ MERKLE_TREE_DEPTH } bytes` ) ;
107110 if (
108111 rateLimit < RATE_LIMIT_PARAMS . MIN_RATE ||
109112 rateLimit > RATE_LIMIT_PARAMS . MAX_RATE
0 commit comments