Skip to content

Commit b3a1048

Browse files
make names more explicit
1 parent 5f98b22 commit b3a1048

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ deno run https://deno.land/x/merkletrees/usage-example.ts
1313

1414
```
1515

16-
```ts
16+
```ts
17+
1718
import { MerkleTree, Helper } from "https://deno.land/x/merkletrees/mod.ts"
1819

1920
const exampleArray = ["dog", "horse", "cow", "chicken"]
2021

2122
const merkleTree = new MerkleTree(exampleArray)
2223

2324
const investigatedEntry = "dog"
24-
const proof = merkleTree.getProofElements(exampleArray.indexOf(investigatedEntry))
25+
const proofElements = merkleTree.getProofElements(exampleArray.indexOf(investigatedEntry))
2526
const investigatedEntryHashed = Helper.sha256(investigatedEntry)
2627
const rootHash = merkleTree.getRootHash()
27-
const isValid = merkleTree.verify(proof, investigatedEntryHashed, rootHash, exampleArray.indexOf(investigatedEntry))
28+
const isValid = merkleTree.verify(proofElements, investigatedEntryHashed, rootHash, exampleArray.indexOf(investigatedEntry))
2829

2930
if (isValid) {
3031
console.log(`we can be pretty sure that ${investigatedEntry} is in the array at index: ${exampleArray.indexOf(investigatedEntry)}`)
3132
}
33+
3234
```

usage-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const exampleArray = ["dog", "horse", "cow", "chicken"]
66
const merkleTree = new MerkleTree(exampleArray)
77

88
const investigatedEntry = "dog"
9-
const proof = merkleTree.getProofElements(exampleArray.indexOf(investigatedEntry))
9+
const proofElements = merkleTree.getProofElements(exampleArray.indexOf(investigatedEntry))
1010
const investigatedEntryHashed = Helper.sha256(investigatedEntry)
1111
const rootHash = merkleTree.getRootHash()
12-
const isValid = merkleTree.verify(proof, investigatedEntryHashed, rootHash, exampleArray.indexOf(investigatedEntry))
12+
const isValid = merkleTree.verify(proofElements, investigatedEntryHashed, rootHash, exampleArray.indexOf(investigatedEntry))
1313

1414
if (isValid) {
1515
console.log(`we can be pretty sure that ${investigatedEntry} is in the array at index: ${exampleArray.indexOf(investigatedEntry)}`)
16-
}
16+
}

0 commit comments

Comments
 (0)