-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Description
Problem
The Group constructor validates that no member can be 0n, but the removeMember() method sets removed members to 0n. This creates an inconsistency where a valid group state cannot be reconstructed using the constructor with the members array.
Steps to Reproduce
import { Group } from "@semaphore-protocol/group"
// Create a group and remove a member
const group = new Group([1n, 2n, 3n])
group.removeMember(1) // Sets members[1] to 0n
// Try to recreate the group from its members
const members = group.members // [1n, 0n, 3n]
const newGroup = new Group(members) // ❌ Throws: "Failed to add member: value cannot be 0"Current Behavior
The constructor throws an error when trying to create a group from a members array that contains 0n values (removed members).
Expected Behavior
The constructor should accept 0n values.
Impact
Users cannot reconstruct a group from its members array if any members have been removed
Related Code
semaphore/packages/group/src/index.ts
Lines 25 to 30 in 1dc597a
| constructor(members: BigNumber[] = []) { | |
| for (const member of members) { | |
| if (member === 0n || member === "0") { | |
| throw new Error("Failed to add member: value cannot be 0") | |
| } | |
| } |
Metadata
Metadata
Assignees
Labels
No labels