0xPolygonMiden / crypto

Cryptographic primitives used in Polygon Miden rollup
MIT License
101 stars 35 forks source link

Minor improvements to the MMR API #324

Closed bobbinth closed 2 months ago

bobbinth commented 2 months ago

This PR renames Mmr::open() into Mmr::open_at() and Mmr::peaks() into Mmr::peaks_at() and also introduces Mmr::open() and Mmr::peaks() which rely on Mmr::open_at() and Mmr::peaks() respectively.

This makes the API a bit more ergonomic when we are working with the latest state of the MMR. For example, things like mmr.open(leaf_pos, mmr.forest() become just mmr.open(leaf_pos).

As an aside, open() method is a bit inconsistent as it doesn't actually return the leaf at the specified position. To improve it further, we'd need to either modify the MmrProof to include the leaf, or return (MmrProof, RpoDigest) from open(). But I left it for future PRs.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud