Neptune-Crypto / twenty-first

Collection of mathematics routines and cryptography for the twenty-first century
GNU General Public License v2.0
73 stars 22 forks source link

Allow manipulation of added leafs in MMR's `verify_batch_update` #217

Closed Sword-Smith closed 3 months ago

Sword-Smith commented 3 months ago

The function verify_batch_update takes a list of leaf mutations, which specify the leaf index, the new leaf value, and an authentication path for the mutated leaf. It also takes a list of new leaves that are appended to the MMR. Currently the bounds-check for the mutation data happens before the new leaves are added to the MMR. If this were to happen after the addition, leaves could be added and then mutated in the same function call.

I think that's preferable.

Sword-Smith commented 3 months ago

This change could make the function harder to understand, as it's not completely clear from the interface what state the MMR ends up in. Let's only do this if a concrete need arises.