<!-- XE-13384 · Statechain genesis hash is line-ending sensitive — verify-genesis and node bootstrap fail on Windows (autocrlf) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13384>. The page is the record; this is the same page for reading.*

XE-13384 · Bounty

# Statechain genesis hash is line-ending sensitive — verify-genesis and node bootstrap fail on Windows (autocrlf)

Closed · duplicate
—
[xe#543](https://github.com/xeprotocol/xe/issues/543)
filed 2026-11-13 07:09 UTC
by itsmesan03

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Ops / testnet

Duplicate of
:   [XE-0038](https://bounty.xe.network/XE-0038) accepted

Tracked
:   internally

Updated
:   2026-11-20 13:01 UTC

Told
:   2026-11-20 13:00 UTC

### Patches

- [xe#555](https://github.com/xeprotocol/xe/pull/555) open by Khanhtnq
  statechain,genesis: normalize CRLF in canonical op encoding and enforce LF attributes (Fixes #543)
- [xe#915](https://github.com/xeprotocol/xe/pull/915) open by tipprb
  fix(xe): statechain-genesis-hash-is-lin (fixes #543)

### History

- [599205](https://bounty.xe.network/log/599205) 2026-11-20 13:00 UTC reply.mirrored
- [598552](https://bounty.xe.network/log/598552) 2026-11-20 13:00 UTC github.state\_pushed
- [598500](https://bounty.xe.network/log/598500) 2026-11-20 13:00 UTC github.labels
- [597648](https://bounty.xe.network/log/597648) 2026-11-20 12:59 UTC proposal.adopted
- [597647](https://bounty.xe.network/log/597647) 2026-11-20 12:59 UTC reply.sent
- [597646](https://bounty.xe.network/log/597646) 2026-11-20 12:59 UTC ticket.status new → closed
- [594368](https://bounty.xe.network/log/594368) 2026-11-20 12:58 UTC proposal.adopted
- [594367](https://bounty.xe.network/log/594367) 2026-11-20 12:58 UTC ticket.facts area
- [594366](https://bounty.xe.network/log/594366) 2026-11-20 12:58 UTC proposal.adopted
- [594365](https://bounty.xe.network/log/594365) 2026-11-20 12:58 UTC ticket.facts
- [594364](https://bounty.xe.network/log/594364) 2026-11-20 12:58 UTC proposal.adopted
- [594363](https://bounty.xe.network/log/594363) 2026-11-20 12:58 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13384) · [JSON](https://bounty.xe.network/v1/tickets/XE-13384) · [markdown](https://bounty.xe.network/XE-13384.md)

### Report

## Summary

The statechain "canonical" block hash is not canonical: it depends on the file's
line endings (LF vs CRLF), not just the semantic JSON content. On a Windows
checkout with git's default `core.autocrlf=true` (the repo ships no
.gitattributes), the published genesis bundle is rewritten to CRLF on checkout,
and `xe verify-genesis` fails with `hash mismatch`, so a user cannot verify or
bootstrap a node by following the README.

## Root cause

- statechain/types.go: Op.Value is json.RawMessage.
- encoding/json decodes each "value" field by capturing its raw bytes verbatim,
  including any CRLF inside the multi-line JSON value.
- statechain/encoding.go MarshalCanonical() writes \[\]byte(op.Value) straight
  into the hash buffer; statechain/crypto.go HashBlock() \= sha256 of that.

The committed genesis declares hash d01aabc1... (computed over LF bytes), but a
CRLF checkout re-hashes the same logical genesis to f620d15b....

## Reproduction (Windows, Go 1.25)

1. git clone https://github.com/xeprotocol/xe.git (default autocrlf)
2. go build ./cmd/xe
3. ./xe verify-genesis --genesis-dir ./genesis/testnet-0005

Result:

error: genesis: genesis/testnet-0005/statechain-genesis.json:
hash mismatch: got d01aabc1...c8f296d6, want f620d15b...0ac981

The same happens to the compiled-in embedded statechain/genesis.json.

4. Fix to confirm: strip the carriage returns from the genesis file (sed
   or a text edit), the file re-hashes to the declared d01aabc1... and
   verify-genesis passes.

## Impact

Any operator/researcher cloning on Windows (or any autocrlf\=true checkout) and
following the README cannot verify the bundle or bootstrap a node.

## Suggested fix

Hash the decoded/typed value instead of the raw json.RawMessage bytes (or
normalize op.Value before hashing). Also consider a .gitattributes forcing
\*.json to LF.

## Related

XE-0038 covers the embedded BIP39 wordlist under autocrlf; this is the
genesis-JSON surface (verify-genesis \+ node bootstrap), which is a distinct
impact.

### Thread

**Joseph Denne**team2026-11-20 13:00 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0038, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-13384 and says what differs; it is read like any other.
