unicitynetwork / unicitynetwork/state-transition-sdk-java

Sync Java SDK SMT/RSMT bit ordering with the spec

Open
#79 0 comments 0 reactions 1 assignee View on GitHub

@martti007 is already working on this.

Since Jul 8, 2026.

  • #80 by @martti007 — merged
Dominant language
Java
Stars
3
Forks
0
Avg merge
5h 14m
Merged PRs (30d)
1

Description

The Yellowpaper now treats 32-byte Merkle keys as 256-bit big-endian bit strings: depth 0 is key[0] & 0x80, depth 7 is key[0] & 0x01, and depth 255 is key[31] & 0x01. Bitmap vectors are also big-endian bit vectors. The Java SDK still contains old LSB-oriented tree routing.

Hot spots:

  • src/main/java/org/unicitylabs/sdk/util/BitString.java: retire/avoid fromBytesReversedLSB for Merkle paths; expose one spec-aligned key-path helper.
  • src/main/java/org/unicitylabs/sdk/smt/CommonPath.java: update common-prefix logic from low-bit-first paths to big-endian prefix paths.
  • src/main/java/org/unicitylabs/sdk/smt/radix/SparseMerkleTree.java: update aggregator-facing SMT insertion/routing.
  • src/main/java/org/unicitylabs/sdk/api/InclusionCertificate.java: update key-path conversion, bitmap masks (0x80 >> (depth % 8)), bitmap decoding, and proof reconstruction.
  • src/main/java/org/unicitylabs/sdk/smt/plain/*, src/main/java/org/unicitylabs/sdk/smt/sum/*, and payment split code using toBitString().toBigInteger(): align split-allocation SMT/SMST paths with the same convention.
  • src/test/java/org/unicitylabs/sdk/TestAggregatorClient.java and SMT/proof fixtures: update expected paths, bitmaps, and vectors.
  • src/main/java/org/unicitylabs/sdk/api/bft/ShardId.java / ShardIdMatchesStateIdRule: verify these remain MSB-prefix compatible; they appear to already use high-bit prefix semantics.

Acceptance:

  • Depth/bitmap examples above are covered by tests.
  • Region/path-prefix bytes, where serialized or hashed, preserve high-order prefix bits and zero the suffix.
  • Traversal/sort order is raw unsigned lexicographic byte order (rsmt_sort_key(k) = k).
  • Inclusion certificates and split-allocation proofs interoperate with the spec and aggregator after the bit-order update.

Feel free to tailgate issue-75 if it feels appropriate.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.