Skip to content

fix: read Header version as a signed Byte at the unparsedBytes gate (JVM parity)#909

Open
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/header-version-signed-gate
Open

fix: read Header version as a signed Byte at the unparsedBytes gate (JVM parity)#909
mwaddip wants to merge 1 commit into
ergoplatform:developfrom
mwaddip:fix/header-version-signed-gate

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 15, 2026

Copy link
Copy Markdown

The JVM HeaderWithoutPow reads version as a signed Byte and gates unparsedBytes on version > 1. sigma-rust compared version as u8, so a version byte 0x80 (-128 signed) was read as 128 > 1: the parser consumed unparsedBytes, shifting the AutolykosSolution parse and yielding a different minerPk than the JVM (which skips the region) — a fork vs sigma-state 6.0.3.

Fix: compare the signed value (version as i8) > 1 at the parse and serialize gates. Versions 1/2/3 are positive (signed == unsigned); only version >= 0x80 changes, matching the JVM. Adds a regression test on the 0x80/0x7f witness headers (minerPk infinity vs real point). Validated against the JVM oracle by the conformance suite.

… gate

The JVM `HeaderWithoutPow` reads `version` as a signed `Byte` and gates the
`unparsedBytes` region on `version > 1`. sigma-rust compared `version` as
`u8`, so a version byte 0x80 (-128 signed) was seen as 128 > 1: the parser
consumed `unparsedBytes`, shifting the AutolykosSolution parse and yielding a
different `minerPk` than the JVM (which skips the region) -- a deserialization
fork vs sigma-state 6.0.3.

Compare the signed interpretation `(version as i8) > 1` at the parse and
serialize gates. Versions 1/2/3 are positive, so signed == unsigned; only
version >= 0x80 changes, matching the JVM. The two `version > 1` sites in the
arbitrary proptest generator are left unchanged: it emits only versions {1,2},
and one is a v2-field nulling gate (`!= 1`), not an unparsedBytes gate. Adds a
regression test on the 0x80/0x7f witness headers (minerPk infinity vs real).
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