WIP: prototype MMB - #3234
Conversation
| # Load and check position < num_leaves. | ||
| dup add.1 mem_load | ||
| # => [position, proof_ptr, ROOT, num_leaves, ...] | ||
| dup.6 u32assert2 u32lt assert.err="position is not an existing MMB leaf" |
There was a problem hiding this comment.
I think this only range-checks position, then drops it before building the root. That means the proof is not tied to the claimed leaf index. I could relabel a valid proof for position 0 as position 1 and it would still verify:
let mmb = TestMmb::from_len(17);
let mut proof = mmb.open(0);
proof.position = 1;
build_test!(&source)
.execute()
.expect_err("tampered position must not authenticate the proof");That test fails because execution succeeds. If callers use the opened position for recency or membership claims, this accepts the right leaf/root with the wrong position.
There was a problem hiding this comment.
Fixed! The verifier no longer trusts the directions stored in the proof. Instead it computes the expected path from the authenticated (num_leaves, position) pair (same rules as belt/shape.rs in crypto) and checks the proof length and every direction against it.
Your scenario is now a negative test (test_mmb_verify_leaf_rejects_tampered_position), along with tests for tampered directions and for the shape math itself.
|
|
||
| pub fn compile(core_lib: &CoreLibrary, source: &str) -> Program { | ||
| Assembler::default() | ||
| .with_static_library(core_lib.library()) |
There was a problem hiding this comment.
We've recently changed those APIs unfrotunately.
The live APIs look like Assembler::with_package(..., Linkage::...) and CoreLibrary::package(), so the new bench targets make the core-lib feature checks fail before they run.
There was a problem hiding this comment.
Rebased onto next and migrated!
|
Some benchmarks. Numbers are execution-trace rows on minimal standalone programs (padded = proving cost). Verify shows padded cost since a verify-only program is the real light-client workload; the other tables are MMR-vs-MMB comparisons, not absolute costs. Verify —
Unpack and root (rows; MMR has popcount-many peaks, so power-of-two sizes flatter it —
Append (rows):
|
Note
Draft/WIP, opening for visibility. VM-side companion to 0xMiden/crypto#1028.
Adds a VM-side Mountain Merkle Belt prototype for research/benchmarking.