Skip to main content
Version: 5.24.3

Class: MerkleTree

merkle.MerkleTree

Constructors​

constructor​

• new MerkleTree(leafHashes)

Parameters​

NameType
leafHashesstring[]

Defined in​

src/utils/merkle.ts:11

Properties​

leaves​

• leaves: string[]

Defined in​

src/utils/merkle.ts:5


branches​

• branches: string[][] = []

Defined in​

src/utils/merkle.ts:7


root​

• root: string

Defined in​

src/utils/merkle.ts:9

Methods​

hash​

â–¸ Static hash(a, b): string

Create pedersen hash from a and b

Parameters​

NameType
astring
bstring

Returns​

string

format: hex-string

Defined in​

src/utils/merkle.ts:43


build​

â–¸ Private build(leaves): string

Create Merkle tree

Parameters​

NameTypeDescription
leavesstring[]hex-string array

Returns​

string

format: hex-string; Merkle tree root

Defined in​

src/utils/merkle.ts:21


getProof​

â–¸ getProof(leaf, branch?, hashPath?): string[]

Return path to leaf

Parameters​

NameTypeDefault valueDescription
leafstringundefinedhex-string
branchstring[]undefinedhex-string array
hashPathstring[][]hex-string array

Returns​

string[]

format: hex-string array

Defined in​

src/utils/merkle.ts:55