Auto merge of #889 - ebfull:new-imt-redux, r=ebfull
Implement and integrate new Incremental Merkle Tree This supersedes #823. ---- This is an implementation of a new incremental merkle tree with * no memory safety issues * a more sensible internal design * better space efficiency (tree representation, witnessing) * simpler API It is intended that this tracks the behavior of the previous tree, which it does, as verified by tests. I even wrote a little circuit for testing that all the paths work. This PR also integrates the tree into the codebase and deprecates the old tree in almost all of our code. (I left it alone in `zerocashTest` but everything else has been changed.) This change is compatible with the testnet but you will need to clear your *local* blockchain data out since the serialized representation of the merkle tree is now different. Closes #517, Closes #519, Closes #591, Closes #460, Closes #473
This commit is contained in:
@@ -2495,10 +2495,9 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
|
||||
uint256 commitment = uint256(commitment_v);
|
||||
|
||||
assert(pwalletMain != NULL);
|
||||
libsnark::merkle_authentication_path path(INCREMENTAL_MERKLE_TREE_DEPTH); // We don't care during receive... yet! :)
|
||||
size_t path_index = 0;
|
||||
libzcash::MerklePath path;
|
||||
uint256 anchor;
|
||||
auto found_in_chain = pwalletMain->WitnessBucketCommitment(commitment, path, path_index, anchor);
|
||||
auto found_in_chain = pwalletMain->WitnessBucketCommitment(commitment, path, anchor);
|
||||
|
||||
CAmount value_of_bucket = decrypted_bucket.getValue();
|
||||
|
||||
@@ -2602,14 +2601,13 @@ Value zc_raw_pour(const json_spirit::Array& params, bool fHelp)
|
||||
std::vector<unsigned char> commitment_v = input_coin.getCoinCommitment().getCommitmentValue();
|
||||
uint256 commitment = uint256(commitment_v);
|
||||
|
||||
libsnark::merkle_authentication_path path(INCREMENTAL_MERKLE_TREE_DEPTH);
|
||||
size_t path_index = 0;
|
||||
libzcash::MerklePath path;
|
||||
assert(pwalletMain != NULL);
|
||||
if (!pwalletMain->WitnessBucketCommitment(commitment, path, path_index, anchor)) {
|
||||
if (!pwalletMain->WitnessBucketCommitment(commitment, path, anchor)) {
|
||||
throw std::runtime_error("Couldn't find bucket in the blockchain");
|
||||
}
|
||||
|
||||
vpourin.push_back(PourInput(input_coin, zcaddress, path_index, path));
|
||||
vpourin.push_back(PourInput(input_coin, zcaddress, path));
|
||||
}
|
||||
|
||||
while (vpourin.size() < NUM_POUR_INPUTS) {
|
||||
|
||||
Reference in New Issue
Block a user