Skip to content

fix: AvlTree.insertOrUpdate returns None on a wrong-tree proof#886

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/avltree-insertorupdate-bad-proof
Open

fix: AvlTree.insertOrUpdate returns None on a wrong-tree proof#886
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/avltree-insertorupdate-bad-proof

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 7, 2026

Copy link
Copy Markdown

The reference impl's AVL verifier construction never throws: given a proof that does not match the tree digest it yields a verifier with no reconstructed tree, every operation fails — and insertOrUpdate_eval discards per-op failures (forall fast-break, no raise) — so the final digest is None and the method returns None (CErgoTreeEvaluator.insertOrUpdate_eval).

sigma-rust's BatchAVLVerifier::new errors at construction on the digest mismatch, and INSERT_OR_UPDATE_EVAL_FN propagated that as an eval error where the JVM returns None. The op loop and digest inspection already mirrored the reference; only the construction error escaped. Catch it and return None.

Pinned by a prover-built wrong-tree-proof test and a JVM-blessed byte vector.

…rong-tree proof

The reference impl's verifier construction never throws: with a proof
that does not match the tree digest it yields a verifier with no
reconstructed tree, every operation fails (and insertOrUpdate_eval
discards per-op failures), and the final digest is None — so the
method returns None (CErgoTreeEvaluator.insertOrUpdate_eval).

sigma-rust's BatchAVLVerifier::new instead errors at construction on
the digest mismatch, and INSERT_OR_UPDATE_EVAL_FN propagated that as
an eval error where the JVM returns None. The op loop and digest
inspection already mirrored the reference; only the construction
error escaped. Catch it and return None.

Pinned by a prover-built wrong-tree proof test and the JVM-blessed
byte vector (santa-eval AvlTree.insertOrUpdate#bad-proof).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mwaddip added a commit to mwaddip/sigma-rust that referenced this pull request Jun 7, 2026
… verifier semantics

The reference impl's verifier construction never throws: a proof that
does not match the tree digest yields a verifier with no reconstructed
tree, every op fails, and each method maps that per its own semantics
(CErgoTreeEvaluator): contains → false (failed lookup); get/getMany →
"Tree proof is incorrect" (and getMany with no keys returns the empty
collection — no lookup runs); insert → raise pre-v3 / None from v3
(issue #908), None with no entries; update/remove → None (None digest).

sigma-rust's BatchAVLVerifier::new instead errors at construction on
the digest mismatch, and every method but insertOrUpdate (PR ergoplatform#886)
propagated that as an eval error. Catch it per method; the op loops
and digest inspection already mirrored the reference.

Pinned by prover-built wrong-tree proof tests per method and the
JVM-blessed byte vectors (santa-eval AvlTree.wrong_tree_proof
contains-false/update-none/remove-none, AvlTree.insert_wrong_tree
insert-none).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant