Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/group id value #91

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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