-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { MerkleTree } = require('merkletreejs') | ||
const keccak256 = require('keccak256') | ||
|
||
const whitelist = [ | ||
'0x7a68Ab63Ba083916a1e4875588b61676F52Bd08b', | ||
'0x9e1D367A900bc7103e3f2f2af9B71ae9d29a3e58', | ||
'0x5191c9832B5bf6512F7216eE24cc0Ba44558993F', | ||
'0xdd9c4E0B11c319E980c00773296fc1bA6e3D3d23', | ||
'0xC4282694CE35e1b2DD7823BBF3693cfe1E99c398' | ||
] | ||
const leaves = whitelist.map(addr => keccak256(addr)) | ||
const tree = new MerkleTree(leaves, keccak256) | ||
const root = tree.getHexRoot() | ||
console.log(tree.toString()) | ||
console.log(root) | ||
|
||
const leaf = keccak256('0x7a68Ab63Ba083916a1e4875588b61676F52Bd08b') | ||
const proof = tree.getProof(leaf) | ||
console.log(tree.getHexProof(leaf)) | ||
const verified = MerkleTree.verify(proof, leaf, root, keccak256) | ||
console.log(verified) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { MerkleTree } = require('merkletreejs') | ||
const SHA256 = require('crypto-js/sha256') | ||
|
||
const leaves = ['a', 'b', 'c'].map(x => SHA256(x)) | ||
const tree = new MerkleTree(leaves, SHA256) | ||
const root = tree.getHexRoot() | ||
console.log(tree.toString()) | ||
console.log(root) | ||
|
||
const leaf = SHA256('a') | ||
const proof = tree.getProof(leaf) | ||
console.log(tree.verify(proof, leaf, root)) // true | ||
const verified = MerkleTree.verify(proof, leaf, root, SHA256) | ||
console.log(verified) | ||
|
||
|
||
const badLeaves = ['a', 'x', 'c'].map(x => SHA256(x)) | ||
const badTree = new MerkleTree(badLeaves, SHA256) | ||
const badLeaf = SHA256('x') | ||
const badProof = badTree.getProof(badLeaf) | ||
console.log(badTree.verify(badProof, badLeaf, root)) // false |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chaosky.tech |
Large diffs are not rendered by default.