Skip to content

Commit

Permalink
Merge pull request #91 from appliedzkp/fix/group-id-value
Browse files Browse the repository at this point in the history
Fix/group id value
  • Loading branch information
cedoor authored Mar 9, 2022
2 parents 8022e4b + 5d8243c commit aacbb11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions contracts/base/SemaphoreGroups.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
uint8 depth,
uint256 zeroValue
) internal virtual {
require(groupId < SNARK_SCALAR_FIELD, "SemaphoreGroups: group id must be < SNARK_SCALAR_FIELD");
require(getDepth(groupId) == 0, "SemaphoreGroups: group already exists");

groups[groupId].init(depth, zeroValue);
Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appliedzkp/semaphore-contracts",
"version": "0.6.0",
"version": "0.6.1",
"description": "A privacy gadget for creating anonymous proof of membership on Ethereum.",
"license": "GPL-3.0",
"files": [
Expand Down
10 changes: 10 additions & 0 deletions test/SemaphoreVoting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ describe("SemaphoreVoting", () => {
await expect(transaction).to.be.revertedWith("SemaphoreVoting: depth value is not supported")
})

it("Should not create a poll greater than the snark scalar field", async () => {
const transaction = contract.createPoll(
BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495618"),
coordinator,
depth
)

await expect(transaction).to.be.revertedWith("SemaphoreGroups: group id must be < SNARK_SCALAR_FIELD")
})

it("Should create a poll", async () => {
const transaction = contract.createPoll(pollIds[0], coordinator, depth)

Expand Down
10 changes: 10 additions & 0 deletions test/SemaphoreWhistleblowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ describe("SemaphoreWhistleblowing", () => {
await expect(transaction).to.be.revertedWith("SemaphoreWhistleblowing: depth value is not supported")
})

it("Should not create an entity greater than the snark scalar field", async () => {
const transaction = contract.createEntity(
BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495618"),
editor,
depth
)

await expect(transaction).to.be.revertedWith("SemaphoreGroups: group id must be < SNARK_SCALAR_FIELD")
})

it("Should create an entity", async () => {
const transaction = contract.createEntity(entityIds[0], editor, depth)

Expand Down

0 comments on commit aacbb11

Please sign in to comment.