Open hackaugusto opened 1 year ago
I think this approach may be prohibitively expensive for trees of meaningful depth (e.g., depth > 10). A more efficient, though probably a more complicated approach is not to traverse all possible nodes but look at subtree roots. If we have a root of an empty subtree, we can be sure that all leaf nodes should be zeros.
That is the proposal, this is only walking up the tree and checking the hash of the subtrees (i.e. only checking a merkle path), so the complexity here is O(n)
where n
is the depth of the tree.
Ah - I missed that! Makes sense.
Rough algorithm for
is_left
:Context: https://github.com/0xPolygonMiden/crypto/issues/170