feat(mmr): add authenticated rooted-frontier path - #3184
Conversation
|
Follow-up to @huitseeker's benchmark question on 0xMiden/crypto#984. This is for the current PR implementation.
Caveat: assumes this PR's shared |
| # Load the first 16 padded peak words via 8 unrolled adv_pipes. `adv_pipe` is 1 cycle and writes | ||
| # 2 words to memory while leaving the sponge capacity unchanged, so this load is free of | ||
| # hash-chiplet rows. | ||
| adv_pipe adv_pipe adv_pipe adv_pipe adv_pipe adv_pipe adv_pipe adv_pipe |
There was a problem hiding this comment.
Could we either zero the padded peak words here, or assert that they are zero?
unpack_frontier writes all padded words from advice into MMR memory, but root_from_peak_end only authenticates the real peaks before peak_end. So the same (num_leaves, ROOT) can be accepted with different non-zero padding, and a later mmr::pack will hash those padding slots into a different legacy commitment.
There was a problem hiding this comment.
Fixed. unpack_frontier now zeroes the padded peak slots after loading them from advice. The root check still only uses the real peaks, but the memory layout is now canonical, so a later mmr::pack cannot hash non-zero padding.
Added a regression test for this.
Note
Draft/WIP, opening for visibility. VM-side companion to 0xMiden/crypto#984. Based on
mainfor local interop testing; will rebase/retarget later.Adds the authenticated Merkle-frontier path to the MMR:
mmr::root- raw rooted frontier rootmmr::root_with_len- authenticated(num_leaves, root)pairmmr::unpack_frontier- authenticates(num_leaves, root)against advice-provided padded peaks, then loads them soget/addkeep workingrootalone doesn't bind length (raw roots collide across lengths under empty padding);root_with_lendisambiguates, per the 0xMiden/crypto#984 regression. Also addsmmr/hash_primitivesbenches.