Skip to main content
Version: 6.11.0

Namespace: merkle

Classes​

Functions​

proofMerklePath​

â–¸ proofMerklePath(root, leaf, path, hashMethod?): boolean

Tests a Merkle tree path

Parameters​

NameTypeDefault valueDescription
rootstringundefinedhex-string
leafstringundefinedhex-string
pathstring[]undefinedhex-string array
hashMethod(a: BigNumberish, b: BigNumberish) => stringcomputePedersenHashhash method to use, default: Pedersen

Returns​

boolean

true if the path is valid, false otherwise

Example

const leaves = ['0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7'];
const tree = new MerkleTree(leaves);
const result = proofMerklePath(tree.root, '0x3', [
'0x4',
'0x5bb9440e27889a364bcb678b1f679ecd1347acdedcbf36e83494f857cc58026',
'0x8c0e46dd2df9aaf3a8ebfbc25408a582ad7fa7171f0698ddbbc5130b4b4e60',
]);
// result = true

Defined in​

src/utils/merkle.ts:148