Closed readygo67 closed 7 months ago
this test case is testing the functionality in is_valid_merkle_branch
which is an implementation of this spec function: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#is_valid_merkle_branch
given that this test passes, im inclined to leave it as-is
the generalized index view is a bit different from the one assumed here and I have a partial implementation here: https://github.com/ralexstokes/ssz-rs/pull/88
if you wanted to make an additional test to reflect your code here, I'd accept a PR :)
have been working on the Merkle proving code lately so how this works is fresh:
the is_valid_merkle_branch
works for a 0-indexed depth
, and a 0-indexed index
for the leaf's position in the bottom layer of the tree. so then, it makes sense that a merkle proof this verifier expects would have 4 nodes for a depth of 3 (which implies 4 layers of the tree, and the four siblings needed to verify each height starting from the leaf are given in branch
).
I wouldn't bring in the concern of generalized indices here -- if you want to see how to map from them to the is_valid_merkle_branch
setting, see here: https://github.com/ralexstokes/ssz-rs/blob/d42b0bb5cbd9277abe4c8c71c931c6cfcf64f4bd/ssz-rs/src/merkleization/proofs.rs#L184
I've also updated this particular test to use both verification routes, see here and here
I'll go ahead and close this issue as I expect things are self-consistent and I'll be testing against the Merkle proof test cases in the consensus spec tests soon
In merkleization>proof.rs file, the test_basic_proof function is confusing.
after fix these 2 issue, the test case is as following, and can pass.