fix: AvlTree digest is variable-length; updateDigest stores any-length Coll[Byte]#894
Open
mwaddip wants to merge 1 commit into
Open
fix: AvlTree digest is variable-length; updateDigest stores any-length Coll[Byte]#894mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
…h Coll[Byte] The reference `AvlTreeData.digest` is a `Coll[Byte]` (variable-length), and `CAvlTree.updateDigest` stores whatever bytes it is given with no length check. sigma-rust used a fixed `ADDigest` (33 bytes) and `updateDigest` rejected any other length via `ADDigest::try_from` — a consensus split: a script calling `tree.updateDigest(shortColl)` succeeds on the reference interpreter but errored here. Change `AvlTreeData.digest` to `Vec<u8>`; `updateDigest` now stores the bytes verbatim, matching the reference. Serialization mirrors the JVM `AvlTreeData.serializer`: the digest is written raw (`putBytes`) and the parser reads exactly 33 bytes (`getBytes(DigestSize)`), so the wire format is byte-identical for normal trees and a non-33 digest exists only in memory (it cannot round-trip, same as the reference impl). CreateAvlTree keeps its 33-byte validation, unchanged. 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
AvlTreeData.digestis aColl[Byte](variable-length) andCAvlTree.updateDigeststores any-length bytes with no length check. sigma-rust used a fixedADDigest(33 bytes), soupdateDigestrejected other lengths — a consensus split:tree.updateDigest(shortColl)succeeds on the reference interpreter but errored here.AvlTreeData.digestbecomesVec<u8>;updateDigeststores the bytes verbatim. Serialization mirrors the referenceAvlTreeData.serializer: the digest is written raw (putBytes) and the parser reads exactly 33 bytes (getBytes(DigestSize)) — wire-identical for normal trees; a non-33 digest exists only in memory (cannot round-trip, same as the reference). CreateAvlTree keeps its 33-byte validation.Found via SANTA conformance testing.