Skip to content

#134 Use big endian bit ordering and byte array paths in smt#135

Merged
b3y0urs3lf merged 3 commits into
mainfrom
issue-134
Jul 11, 2026
Merged

#134 Use big endian bit ordering and byte array paths in smt#135
b3y0urs3lf merged 3 commits into
mainfrom
issue-134

Conversation

@martti007

Copy link
Copy Markdown
Collaborator

No description provided.

@martti007
martti007 requested a review from MastaP July 9, 2026 02:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Sparse Merkle Tree (SMT) and Sparse Merkle Sum Tree (SMST) implementations to use spec-compliant big-endian key routing instead of LSB-first routing. It replaces bigint-based path routing with direct Uint8Array operations, introducing utility functions like commonPrefixLength, regionFromKey, and getBitAtDepth, while updating node classes, error handling, and tests accordingly. The review feedback focuses on performance optimizations, suggesting byte-by-byte comparisons in commonPrefixLength and using bitwise operators (>> 3 and & 7) instead of division and modulo operations in regionFromKey, getBitAtDepth, and InclusionCertificate.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/smt/SparseMerkleTreePathUtils.ts
Comment thread src/smt/SparseMerkleTreePathUtils.ts
Comment thread src/smt/SparseMerkleTreePathUtils.ts
Comment thread src/api/InclusionCertificate.ts Outdated
@martti007 martti007 linked an issue Jul 9, 2026 that may be closed by this pull request
Base automatically changed from issue-129 to main July 9, 2026 08:32

@MastaP MastaP left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the branch — logic checks out (I also ran dense-random-tree round-trip checks for InclusionCertificate and SplitAllocationProof locally, all green). A few cleanups and test-coverage notes inline.

Comment thread src/smt/LeafExistsError.ts
Comment thread src/api/InclusionCertificate.ts
Comment thread src/smt/radixsum/SparseMerkleSumTree.ts
Comment thread src/smt/SparseMerkleTreePathUtils.ts Outdated
Comment thread src/smt/radix/FinalizedLeafBranch.ts Outdated
Comment thread src/smt/radix/PendingNodeBranch.ts Outdated
@b3y0urs3lf
b3y0urs3lf merged commit 7cdeed7 into main Jul 11, 2026
1 check passed
@b3y0urs3lf
b3y0urs3lf deleted the issue-134 branch July 11, 2026 06:58
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.

Sync TypeScript SDK SMT/RSMT bit ordering with the spec (big endian)

3 participants