Skip to content

fix: accept full u8 range for STypeVar name length (JVM TypeSerializer parity) - #908

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/stypevar-name-length-bound
Open

fix: accept full u8 range for STypeVar name length (JVM TypeSerializer parity)#908
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/stypevar-name-length-bound

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 15, 2026

Copy link
Copy Markdown

The JVM TypeSerializer.deserialize reads the STypeVar name length via getUByte() (0..=255, no bound) then new String(getBytes(len)), so an empty name (length 0) and a 255-byte name both deserialize. sigma-rust bounded the name to BoundedVec<u8, 1, 254>, over-rejecting lengths 0 and 255 — a divergence from sigma-state 6.0.3 (the JVM accepts the tree, sigma-rust rejects it).

Fix: store the name as Vec<u8>; a get_u8 length is inherently 0..=255, so no bound is meaningful. Adds a regression test on STypeVar::sigma_parse for length 0x00 and 0xff. Validated against the JVM oracle (sigma-state 6.0.3) by the conformance suite.

Ref: core/.../serialization/TypeSerializer.scala:202-206

JVM `TypeSerializer.deserialize` reads the type-var name length via
`getUByte()` (0..=255, no bound) then `new String(getBytes(len))`, so an
empty name (length 0) and a 255-byte name both deserialize. sigma-rust
bounded the name to `BoundedVec<u8, 1, 254>`, over-rejecting length 0 and
255 with a parse error -- a deserialization divergence from sigma-state.

Use `Vec<u8>`: a `get_u8` length is inherently 0..=255, so no bound is
meaningful. The UTF-8 validity check is retained. Adds a regression test
on `STypeVar::sigma_parse` for length 0x00 and 0xff.
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