This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hey, I'm dangerousfood-4099038 and I have contributed to the Privacy Pools Ceremony. | |
The following are my contribution signatures: | |
Circuit # 1 (withdraw) | |
Contributor # 382 | |
Contribution Hash: | |
afcc0420 400ac5f9 2b8ed8db 0c7312b9 | |
77e7752f 32121933 efbe5c67 7b079ec6 | |
1c1ffcfc 13ce0abf 26f97f72 29c92f31 | |
a32cc8b7 cb4953b9 f0fc9132 f42e5fcc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sushi = new ethers.Contract('0x6b3595068778dd592e39a122f4f5a5cf09c90fe2', abi, provider) | |
let totalSushiStakedinXSushi = await sushi.methods.balanceOf('0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272').call() | |
let xSushi = new ethers.Contract('0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272', abi, provider) | |
let totalXSushiSupply = await xSushi.methods.totalSupply().call() | |
let exchangeRate = totalSushiStakedinBar.div(totalXSushiSupply) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@public | |
@constant | |
def get_deposit_root() -> bytes32: | |
root: bytes32 = 0x0000000000000000000000000000000000000000000000000000000000000000 | |
size: uint256 = self.deposit_count | |
for h in range(DEPOSIT_CONTRACT_TREE_DEPTH): | |
if bitwise_and(size, 1) == 1: | |
root = sha3(concat(self.branch[h], root)) | |
else: | |
root = sha3(concat(root, self.zerohashes[h])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Bytes32> getProofTreeByIndex(int index) { | |
if (dirty) calcBranches(); | |
List<Bytes32> proof = new ArrayList<Bytes32>(); | |
for (int i = 0; i < height; i++) { | |
index = index % 2 == 1 ? index - 1 : index + 1; | |
if (index < tree.get(i).size()) proof.add(tree.get(i).get(index)); | |
else proof.add(zeroHashes.get(i)); | |
index /= 2; | |
} | |
return proof; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void calcBranches() { | |
for (int i = 0; i < height; i++) { | |
List<Bytes32> parent = tree.get(i + 1); | |
List<Bytes32> child = tree.get(i); | |
for (int j = 0; j < child.size(); j += 2) { | |
Bytes32 leftNode = child.get(j); | |
Bytes32 rightNode = (j + 1 < child.size()) ? child.get(j + 1) : zeroHashes.get(i); | |
parent.add(j / 2, Hash.sha2_256(Bytes.concatenate(leftNode, rightNode))); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void add(int index, Bytes32 leaf) { | |
dirty = true; | |
tree.get(0).add(index, leaf); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<Bytes32> generateZeroHashes(int height) { | |
List<Bytes32> zeroHashes = new ArrayList<Bytes32>(); | |
for (int i = 0; i < height; i++) zeroHashes.add(Bytes32.ZERO); | |
for (int i = 0; i < height - 1; i++) | |
zeroHashes.set(i + 1, Hash.sha2_256(Bytes.concatenate(zeroHashes.get(i), zeroHashes.get(i)))); | |
return zeroHashes; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final List<List<Bytes32>> tree; | |
private final List<Bytes32> zeroHashes; | |
private final int height; | |
private boolean dirty = true; | |
public MerkleTree(int height) { | |
assert (height > 1); | |
this.height = height; | |
tree = new ArrayList<List<Bytes32>>(); | |
for (int i = 0; i <= height; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2019 ConsenSys AG. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean verify_merkle_branch( | |
Bytes32 leaf, List<Bytes32> proof, int depth, int index, Bytes32 root) { | |
Bytes32 value = leaf; | |
for (int i = 0; i < depth; i++) { | |
if (Math.floor(index / Math.pow(2, i)) % 2 != 0) { | |
value = Hash.sha2_256(Bytes.concatenate(proof.get(i), value)); | |
} else { | |
value = Hash.sha2_256(Bytes.concatenate(value, proof.get(i))); | |
} | |
} |
NewerOlder