Skip to content

Commit 43ea2cc

Browse files
explicit demo step by step
1 parent ef87ce1 commit 43ea2cc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import hashJs from 'https://deno.land/x/hash/mod-hashjs.ts'
2+
3+
const exampleArray = ["dog", "horse", "cow", "chicken"]
4+
5+
for (const entry of exampleArray) {
6+
const hashValue = hashJs.sha256().update(entry).digest('hex')
7+
console.log(`the hash of ${entry} is ${hashValue}.`)
8+
}
9+
10+
// the hash of dog is cd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944. E(1,1)
11+
// the hash of horse is fd62862b6dc213bee77c2badd6311528253c6cb3107e03c16051aa15584eca1c. E(1,2)
12+
// the hash of cow is beb134754910a4b4790c69ab17d3975221f4c534b70c8d6e82b30c165e8c0c09. E(1,3)
13+
// the hash of chicken is 811eb81b9d11d65a36c53c3ebdb738ee303403cb79d781ccf4b40764e0a9d12a. E(1,4)
14+
15+
const e11Ande12 = "cd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944fd62862b6dc213bee77c2badd6311528253c6cb3107e03c16051aa15584eca1c"
16+
const proofElement1e21 = hashJs.sha256().update(e11Ande12).digest('hex')
17+
console.log(`proof element number 1 e21: ${proofElement1e21}`)
18+
const e13Ande14 = "beb134754910a4b4790c69ab17d3975221f4c534b70c8d6e82b30c165e8c0c09811eb81b9d11d65a36c53c3ebdb738ee303403cb79d781ccf4b40764e0a9d12a"
19+
const proofElement2e22 = hashJs.sha256().update(e13Ande14).digest('hex')
20+
console.log(`proof element number 2 e22: ${proofElement2e22}`)
21+
22+
const e21Ande22 = "fd0b63475c07217708eef70ed11984a9d5a71b1c059955e88da9b9750a9f52caa12b2f7a5ddb20963c22654f6b22a6955c9956a20c76a0e8f169a437aafb4c98"
23+
const rootHash = hashJs.sha256().update(e21Ande22).digest('hex')
24+
console.log(`rootHash e31: ${rootHash}`)

0 commit comments

Comments
 (0)