fix: AvlTree.insertOrUpdate returns None on a wrong-tree proof#886
Open
mwaddip wants to merge 1 commit into
Open
fix: AvlTree.insertOrUpdate returns None on a wrong-tree proof#886mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_evaldiscards 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::newerrors at construction on the digest mismatch, andINSERT_OR_UPDATE_EVAL_FNpropagated 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.