Skip to content

fix(group): fix(group): reject string representations of zero - #1092

Open
daixiheguu wants to merge 1 commit into
semaphore-protocol:mainfrom
daixiheguu:main
Open

fix(group): fix(group): reject string representations of zero#1092
daixiheguu wants to merge 1 commit into
semaphore-protocol:mainfrom
daixiheguu:main

Conversation

@daixiheguu

Copy link
Copy Markdown

This PR fixes zero-value validation in Group.addMember() and

Description

This PR fixes zero-value validation in Group.addMember() and Group.addMembers().

The previous implementation compared the raw BigNumber input against 0n and "0" before converting it to bigint. As a result, strings such as "00", "0x0", "-0" and whitespace-padded zero values bypassed the check and were inserted as 0n.

The inputs are now normalized with BigInt() before validation and insertion.

Batch inputs are fully normalized and validated before the tree is modified.

The Group constructor remains unchanged because it intentionally accepts 0n when reconstructing groups containing removed leaves.

Related Issue(s)

Fixes #1091

Other information

Tests were added for alternative string representations of zero in both addMember() and addMembers(). The batch test also verifies that the group is not partially modified when validation fails.

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn format and yarn lint without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Important

We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a GitHub Issue to report them so they can be properly tracked and addressed.

This PR fixes zero-value validation in `Group.addMember()` and
@daixiheguu
daixiheguu requested a review from a team as a code owner August 4, 2026 17:13
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.

Group.addMember and addMembers accept alternative string representations of zero

1 participant