diff --git a/src/merkletree.ts b/src/merkletree.ts index eda1b81..69a92e3 100644 --- a/src/merkletree.ts +++ b/src/merkletree.ts @@ -49,6 +49,7 @@ export abstract class MerkleTreeImpl implements MerkleTree { 'Leaf values cannot be numbers', ); this.hashLookup = Object.fromEntries(values.map(({ treeIndex }, valueIndex) => [tree[treeIndex], valueIndex])); + this.validate(); } protected static prepare( diff --git a/src/simple.ts b/src/simple.ts index ff1d550..9029d80 100644 --- a/src/simple.ts +++ b/src/simple.ts @@ -33,7 +33,6 @@ export class SimpleMerkleTree extends MerkleTreeImpl { ); const tree = new SimpleMerkleTree(data.tree, data.values, formatLeaf, nodeHash); - tree.validate(); return tree; } diff --git a/src/standard.ts b/src/standard.ts index c69488d..434b5a2 100644 --- a/src/standard.ts +++ b/src/standard.ts @@ -34,7 +34,6 @@ export class StandardMerkleTree extends MerkleTreeImpl { validateArgument(data.leafEncoding !== undefined, 'Expected leaf encoding'); const tree = new StandardMerkleTree(data.tree, data.values, data.leafEncoding); - tree.validate(); return tree; }