@semaphore-protocol/contracts 3.15.1 → 4.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -5
- package/Semaphore.sol +75 -89
- package/base/SemaphoreGroups.sol +94 -82
- package/base/SemaphoreVerifier.sol +358 -104
- package/interfaces/ISemaphore.sol +65 -74
- package/interfaces/ISemaphoreGroups.sol +35 -6
- package/interfaces/ISemaphoreVerifier.sol +7 -31
- package/package.json +2 -3
- package/base/Pairing.sol +0 -151
- package/extensions/SemaphoreVoting.sol +0 -96
- package/extensions/SemaphoreWhistleblowing.sol +0 -77
- package/interfaces/ISemaphoreVoting.sol +0 -78
- package/interfaces/ISemaphoreWhistleblowing.sol +0 -53
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
//SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.4;
|
|
3
|
-
|
|
4
|
-
/// @title SemaphoreVoting contract interface.
|
|
5
|
-
interface ISemaphoreVoting {
|
|
6
|
-
error Semaphore__CallerIsNotThePollCoordinator();
|
|
7
|
-
error Semaphore__MerkleTreeDepthIsNotSupported();
|
|
8
|
-
error Semaphore__PollHasAlreadyBeenStarted();
|
|
9
|
-
error Semaphore__PollIsNotOngoing();
|
|
10
|
-
error Semaphore__YouAreUsingTheSameNillifierTwice();
|
|
11
|
-
|
|
12
|
-
enum PollState {
|
|
13
|
-
Created,
|
|
14
|
-
Ongoing,
|
|
15
|
-
Ended
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
struct Verifier {
|
|
19
|
-
address contractAddress;
|
|
20
|
-
uint256 merkleTreeDepth;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
struct Poll {
|
|
24
|
-
address coordinator;
|
|
25
|
-
PollState state;
|
|
26
|
-
mapping(uint256 => bool) nullifierHashes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/// @dev Emitted when a new poll is created.
|
|
30
|
-
/// @param pollId: Id of the poll.
|
|
31
|
-
/// @param coordinator: Coordinator of the poll.
|
|
32
|
-
event PollCreated(uint256 pollId, address indexed coordinator);
|
|
33
|
-
|
|
34
|
-
/// @dev Emitted when a poll is started.
|
|
35
|
-
/// @param pollId: Id of the poll.
|
|
36
|
-
/// @param coordinator: Coordinator of the poll.
|
|
37
|
-
/// @param encryptionKey: Key to encrypt the poll votes.
|
|
38
|
-
event PollStarted(uint256 pollId, address indexed coordinator, uint256 encryptionKey);
|
|
39
|
-
|
|
40
|
-
/// @dev Emitted when a user votes on a poll.
|
|
41
|
-
/// @param pollId: Id of the poll.
|
|
42
|
-
/// @param vote: User encrypted vote.
|
|
43
|
-
event VoteAdded(uint256 indexed pollId, uint256 vote);
|
|
44
|
-
|
|
45
|
-
/// @dev Emitted when a poll is ended.
|
|
46
|
-
/// @param pollId: Id of the poll.
|
|
47
|
-
/// @param coordinator: Coordinator of the poll.
|
|
48
|
-
/// @param decryptionKey: Key to decrypt the poll votes.
|
|
49
|
-
event PollEnded(uint256 pollId, address indexed coordinator, uint256 decryptionKey);
|
|
50
|
-
|
|
51
|
-
/// @dev Creates a poll and the associated Merkle tree/group.
|
|
52
|
-
/// @param pollId: Id of the poll.
|
|
53
|
-
/// @param coordinator: Coordinator of the poll.
|
|
54
|
-
/// @param merkleTreeDepth: Depth of the tree.
|
|
55
|
-
function createPoll(uint256 pollId, address coordinator, uint256 merkleTreeDepth) external;
|
|
56
|
-
|
|
57
|
-
/// @dev Adds a voter to a poll.
|
|
58
|
-
/// @param pollId: Id of the poll.
|
|
59
|
-
/// @param identityCommitment: Identity commitment of the group member.
|
|
60
|
-
function addVoter(uint256 pollId, uint256 identityCommitment) external;
|
|
61
|
-
|
|
62
|
-
/// @dev Starts a pull and publishes the key to encrypt the votes.
|
|
63
|
-
/// @param pollId: Id of the poll.
|
|
64
|
-
/// @param encryptionKey: Key to encrypt poll votes.
|
|
65
|
-
function startPoll(uint256 pollId, uint256 encryptionKey) external;
|
|
66
|
-
|
|
67
|
-
/// @dev Casts an anonymous vote in a poll.
|
|
68
|
-
/// @param vote: Encrypted vote.
|
|
69
|
-
/// @param nullifierHash: Nullifier hash.
|
|
70
|
-
/// @param pollId: Id of the poll.
|
|
71
|
-
/// @param proof: Private zk-proof parameters.
|
|
72
|
-
function castVote(uint256 vote, uint256 nullifierHash, uint256 pollId, uint256[8] calldata proof) external;
|
|
73
|
-
|
|
74
|
-
/// @dev Ends a pull and publishes the key to decrypt the votes.
|
|
75
|
-
/// @param pollId: Id of the poll.
|
|
76
|
-
/// @param decryptionKey: Key to decrypt poll votes.
|
|
77
|
-
function endPoll(uint256 pollId, uint256 decryptionKey) external;
|
|
78
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
//SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.4;
|
|
3
|
-
|
|
4
|
-
/// @title SemaphoreWhistleblowing contract interface.
|
|
5
|
-
interface ISemaphoreWhistleblowing {
|
|
6
|
-
error Semaphore__CallerIsNotTheEditor();
|
|
7
|
-
error Semaphore__MerkleTreeDepthIsNotSupported();
|
|
8
|
-
|
|
9
|
-
struct Verifier {
|
|
10
|
-
address contractAddress;
|
|
11
|
-
uint256 merkleTreeDepth;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/// @dev Emitted when a new entity is created.
|
|
15
|
-
/// @param entityId: Id of the entity.
|
|
16
|
-
/// @param editor: Editor of the entity.
|
|
17
|
-
event EntityCreated(uint256 entityId, address indexed editor);
|
|
18
|
-
|
|
19
|
-
/// @dev Emitted when a whistleblower publish a new leak.
|
|
20
|
-
/// @param entityId: Id of the entity.
|
|
21
|
-
/// @param leak: News leak.
|
|
22
|
-
event LeakPublished(uint256 indexed entityId, uint256 leak);
|
|
23
|
-
|
|
24
|
-
/// @dev Creates an entity and the associated Merkle tree/group.
|
|
25
|
-
/// @param entityId: Id of the entity.
|
|
26
|
-
/// @param editor: Editor of the entity.
|
|
27
|
-
/// @param merkleTreeDepth: Depth of the tree.
|
|
28
|
-
function createEntity(uint256 entityId, address editor, uint256 merkleTreeDepth) external;
|
|
29
|
-
|
|
30
|
-
/// @dev Adds a whistleblower to an entity.
|
|
31
|
-
/// @param entityId: Id of the entity.
|
|
32
|
-
/// @param identityCommitment: Identity commitment of the group member.
|
|
33
|
-
function addWhistleblower(uint256 entityId, uint256 identityCommitment) external;
|
|
34
|
-
|
|
35
|
-
/// @dev Removes a whistleblower from an entity.
|
|
36
|
-
/// @param entityId: Id of the entity.
|
|
37
|
-
/// @param identityCommitment: Identity commitment of the group member.
|
|
38
|
-
/// @param proofSiblings: Array of the sibling nodes of the proof of membership.
|
|
39
|
-
/// @param proofPathIndices: Path of the proof of membership.
|
|
40
|
-
function removeWhistleblower(
|
|
41
|
-
uint256 entityId,
|
|
42
|
-
uint256 identityCommitment,
|
|
43
|
-
uint256[] calldata proofSiblings,
|
|
44
|
-
uint8[] calldata proofPathIndices
|
|
45
|
-
) external;
|
|
46
|
-
|
|
47
|
-
/// @dev Allows whistleblowers to publish leaks anonymously.
|
|
48
|
-
/// @param leak: News leak.
|
|
49
|
-
/// @param nullifierHash: Nullifier hash.
|
|
50
|
-
/// @param entityId: Id of the entity.
|
|
51
|
-
/// @param proof: Private zk-proof parameters.
|
|
52
|
-
function publishLeak(uint256 leak, uint256 nullifierHash, uint256 entityId, uint256[8] calldata proof) external;
|
|
53
|
-
}
|