@semaphore-protocol/contracts 0.1.0 → 0.2.0
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/Semaphore.sol +84 -84
- package/base/SemaphoreCore.sol +41 -41
- package/base/SemaphoreGroups.sol +70 -70
- package/extensions/SemaphoreVoting.sol +74 -74
- package/extensions/SemaphoreWhistleblowing.sol +61 -61
- package/interfaces/ISemaphore.sol +58 -58
- package/interfaces/ISemaphoreCore.sol +3 -3
- package/interfaces/ISemaphoreGroups.sol +27 -27
- package/interfaces/ISemaphoreNullifiers.sol +6 -6
- package/interfaces/ISemaphoreVoting.sol +59 -59
- package/interfaces/ISemaphoreWhistleblowing.sol +43 -43
- package/interfaces/IVerifier.sol +6 -6
- package/package.json +36 -36
- package/{base/Verifier.sol → verifiers/Verifier16.sol} +40 -53
- package/verifiers/Verifier17.sol +237 -0
- package/verifiers/Verifier18.sol +237 -0
- package/verifiers/Verifier19.sol +237 -0
- package/verifiers/Verifier20.sol +237 -0
- package/verifiers/Verifier21.sol +237 -0
- package/verifiers/Verifier22.sol +237 -0
- package/verifiers/Verifier23.sol +237 -0
- package/verifiers/Verifier24.sol +237 -0
- package/verifiers/Verifier25.sol +237 -0
- package/verifiers/Verifier26.sol +237 -0
- package/verifiers/Verifier27.sol +237 -0
- package/verifiers/Verifier28.sol +237 -0
- package/verifiers/Verifier29.sol +237 -0
- package/verifiers/Verifier30.sol +237 -0
- package/verifiers/Verifier31.sol +237 -0
- package/verifiers/Verifier32.sol +237 -0
|
@@ -10,79 +10,79 @@ import "../base/SemaphoreGroups.sol";
|
|
|
10
10
|
/// organization, newspaper) and to allow them to publish news leaks anonymously.
|
|
11
11
|
/// Leaks can be IPFS hashes, permanent links or other kinds of reference.
|
|
12
12
|
contract SemaphoreWhistleblowing is ISemaphoreWhistleblowing, SemaphoreCore, SemaphoreGroups {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/// @dev Gets a tree depth and returns its verifier address.
|
|
14
|
+
mapping(uint8 => IVerifier) internal verifiers;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/// @dev Gets an editor address and return their entity.
|
|
17
|
+
mapping(address => uint256) private entities;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
/// @dev Since there can be multiple verifier contracts (each associated with a certain tree depth),
|
|
20
|
+
/// it is necessary to pass the addresses of the previously deployed contracts with the associated
|
|
21
|
+
/// tree depth. Depending on the depth chosen when creating the entity, a certain verifier will be
|
|
22
|
+
/// used to verify that the proof is correct.
|
|
23
|
+
/// @param depths: Three depths used in verifiers.
|
|
24
|
+
/// @param verifierAddresses: Verifier addresses.
|
|
25
|
+
constructor(uint8[] memory depths, address[] memory verifierAddresses) {
|
|
26
|
+
require(
|
|
27
|
+
depths.length == verifierAddresses.length,
|
|
28
|
+
"SemaphoreWhistleblowing: parameters lists does not have the same length"
|
|
29
|
+
);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
for (uint8 i = 0; i < depths.length; i++) {
|
|
32
|
+
verifiers[depths[i]] = IVerifier(verifierAddresses[i]);
|
|
33
|
+
}
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
/// @dev Checks if the editor is the transaction sender.
|
|
37
|
+
/// @param entityId: Id of the entity.
|
|
38
|
+
modifier onlyEditor(uint256 entityId) {
|
|
39
|
+
require(entityId == entities[_msgSender()], "SemaphoreWhistleblowing: caller is not the editor");
|
|
40
|
+
_;
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
/// @dev See {ISemaphoreWhistleblowing-createEntity}.
|
|
44
|
+
function createEntity(
|
|
45
|
+
uint256 entityId,
|
|
46
|
+
address editor,
|
|
47
|
+
uint8 depth
|
|
48
|
+
) public override {
|
|
49
|
+
require(address(verifiers[depth]) != address(0), "SemaphoreWhistleblowing: depth value is not supported");
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
_createGroup(entityId, depth, 0);
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
entities[editor] = entityId;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
emit EntityCreated(entityId, editor);
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
/// @dev See {ISemaphoreWhistleblowing-addWhistleblower}.
|
|
59
|
+
function addWhistleblower(uint256 entityId, uint256 identityCommitment) public override onlyEditor(entityId) {
|
|
60
|
+
_addMember(entityId, identityCommitment);
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
/// @dev See {ISemaphoreWhistleblowing-removeWhistleblower}.
|
|
64
|
+
function removeWhistleblower(
|
|
65
|
+
uint256 entityId,
|
|
66
|
+
uint256 identityCommitment,
|
|
67
|
+
uint256[] calldata proofSiblings,
|
|
68
|
+
uint8[] calldata proofPathIndices
|
|
69
|
+
) public override onlyEditor(entityId) {
|
|
70
|
+
_removeMember(entityId, identityCommitment, proofSiblings, proofPathIndices);
|
|
71
|
+
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
/// @dev See {ISemaphoreWhistleblowing-publishLeak}.
|
|
74
|
+
function publishLeak(
|
|
75
|
+
bytes32 leak,
|
|
76
|
+
uint256 nullifierHash,
|
|
77
|
+
uint256 entityId,
|
|
78
|
+
uint256[8] calldata proof
|
|
79
|
+
) public override onlyEditor(entityId) {
|
|
80
|
+
uint8 depth = getDepth(entityId);
|
|
81
|
+
uint256 root = getRoot(entityId);
|
|
82
|
+
IVerifier verifier = verifiers[depth];
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
_verifyProof(leak, root, nullifierHash, entityId, proof, verifier);
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
emit LeakPublished(entityId, leak);
|
|
87
|
+
}
|
|
88
88
|
}
|
|
@@ -4,69 +4,69 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title Semaphore interface.
|
|
5
5
|
/// @dev Interface of a Semaphore contract.
|
|
6
6
|
interface ISemaphore {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
struct Verifier {
|
|
8
|
+
address contractAddress;
|
|
9
|
+
uint8 merkleTreeDepth;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
/// @dev Emitted when an admin is assigned to a group.
|
|
13
|
+
/// @param groupId: Id of the group.
|
|
14
|
+
/// @param oldAdmin: Old admin of the group.
|
|
15
|
+
/// @param newAdmin: New admin of the group.
|
|
16
|
+
event GroupAdminUpdated(uint256 indexed groupId, address indexed oldAdmin, address indexed newAdmin);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/// @dev Emitted when a Semaphore proof is verified.
|
|
19
|
+
/// @param groupId: Id of the group.
|
|
20
|
+
/// @param signal: Semaphore signal.
|
|
21
|
+
event ProofVerified(uint256 indexed groupId, bytes32 signal);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
/// @dev Saves the nullifier hash to avoid double signaling and emits an event
|
|
24
|
+
/// if the zero-knowledge proof is valid.
|
|
25
|
+
/// @param groupId: Id of the group.
|
|
26
|
+
/// @param signal: Semaphore signal.
|
|
27
|
+
/// @param nullifierHash: Nullifier hash.
|
|
28
|
+
/// @param externalNullifier: External nullifier.
|
|
29
|
+
/// @param proof: Zero-knowledge proof.
|
|
30
|
+
function verifyProof(
|
|
31
|
+
uint256 groupId,
|
|
32
|
+
bytes32 signal,
|
|
33
|
+
uint256 nullifierHash,
|
|
34
|
+
uint256 externalNullifier,
|
|
35
|
+
uint256[8] calldata proof
|
|
36
|
+
) external;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
/// @dev Creates a new group. Only the admin will be able to add or remove members.
|
|
39
|
+
/// @param groupId: Id of the group.
|
|
40
|
+
/// @param depth: Depth of the tree.
|
|
41
|
+
/// @param zeroValue: Zero value of the tree.
|
|
42
|
+
/// @param admin: Admin of the group.
|
|
43
|
+
function createGroup(
|
|
44
|
+
uint256 groupId,
|
|
45
|
+
uint8 depth,
|
|
46
|
+
uint256 zeroValue,
|
|
47
|
+
address admin
|
|
48
|
+
) external;
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
/// @dev Updates the group admin.
|
|
51
|
+
/// @param groupId: Id of the group.
|
|
52
|
+
/// @param newAdmin: New admin of the group.
|
|
53
|
+
function updateGroupAdmin(uint256 groupId, address newAdmin) external;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/// @dev Adds a new member to an existing group.
|
|
56
|
+
/// @param groupId: Id of the group.
|
|
57
|
+
/// @param identityCommitment: New identity commitment.
|
|
58
|
+
function addMember(uint256 groupId, uint256 identityCommitment) external;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
/// @dev Removes a member from an existing group. A proof of membership is
|
|
61
|
+
/// needed to check if the node to be removed is part of the tree.
|
|
62
|
+
/// @param groupId: Id of the group.
|
|
63
|
+
/// @param identityCommitment: Identity commitment to be deleted.
|
|
64
|
+
/// @param proofSiblings: Array of the sibling nodes of the proof of membership.
|
|
65
|
+
/// @param proofPathIndices: Path of the proof of membership.
|
|
66
|
+
function removeMember(
|
|
67
|
+
uint256 groupId,
|
|
68
|
+
uint256 identityCommitment,
|
|
69
|
+
uint256[] calldata proofSiblings,
|
|
70
|
+
uint8[] calldata proofPathIndices
|
|
71
|
+
) external;
|
|
72
72
|
}
|
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title SemaphoreCore interface.
|
|
5
5
|
/// @dev Interface of SemaphoreCore contract.
|
|
6
6
|
interface ISemaphoreCore {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/// @notice Emitted when a proof is verified correctly and a new nullifier hash is added.
|
|
8
|
+
/// @param nullifierHash: Hash of external and identity nullifiers.
|
|
9
|
+
event NullifierHashAdded(uint256 nullifierHash);
|
|
10
10
|
}
|
|
@@ -4,36 +4,36 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title SemaphoreGroups interface.
|
|
5
5
|
/// @dev Interface of a SemaphoreGroups contract.
|
|
6
6
|
interface ISemaphoreGroups {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/// @dev Emitted when a new group is created.
|
|
8
|
+
/// @param groupId: Id of the group.
|
|
9
|
+
/// @param depth: Depth of the tree.
|
|
10
|
+
/// @param zeroValue: Zero value of the tree.
|
|
11
|
+
event GroupCreated(uint256 indexed groupId, uint8 depth, uint256 zeroValue);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/// @dev Emitted when a new identity commitment is added.
|
|
14
|
+
/// @param groupId: Group id of the group.
|
|
15
|
+
/// @param identityCommitment: New identity commitment.
|
|
16
|
+
/// @param root: New root hash of the tree.
|
|
17
|
+
event MemberAdded(uint256 indexed groupId, uint256 identityCommitment, uint256 root);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
/// @dev Emitted when a new identity commitment is removed.
|
|
20
|
+
/// @param groupId: Group id of the group.
|
|
21
|
+
/// @param identityCommitment: New identity commitment.
|
|
22
|
+
/// @param root: New root hash of the tree.
|
|
23
|
+
event MemberRemoved(uint256 indexed groupId, uint256 identityCommitment, uint256 root);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/// @dev Returns the last root hash of a group.
|
|
26
|
+
/// @param groupId: Id of the group.
|
|
27
|
+
/// @return Root hash of the group.
|
|
28
|
+
function getRoot(uint256 groupId) external view returns (uint256);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
/// @dev Returns the depth of the tree of a group.
|
|
31
|
+
/// @param groupId: Id of the group.
|
|
32
|
+
/// @return Depth of the group tree.
|
|
33
|
+
function getDepth(uint256 groupId) external view returns (uint8);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
/// @dev Returns the number of tree leaves of a group.
|
|
36
|
+
/// @param groupId: Id of the group.
|
|
37
|
+
/// @return Number of tree leaves.
|
|
38
|
+
function getNumberOfLeaves(uint256 groupId) external view returns (uint256);
|
|
39
39
|
}
|
|
@@ -4,11 +4,11 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title SemaphoreNullifiers interface.
|
|
5
5
|
/// @dev Interface of SemaphoreNullifiers contract.
|
|
6
6
|
interface ISemaphoreNullifiers {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/// @dev Emitted when a external nullifier is added.
|
|
8
|
+
/// @param externalNullifier: External Semaphore nullifier.
|
|
9
|
+
event ExternalNullifierAdded(uint256 externalNullifier);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/// @dev Emitted when a external nullifier is removed.
|
|
12
|
+
/// @param externalNullifier: External Semaphore nullifier.
|
|
13
|
+
event ExternalNullifierRemoved(uint256 externalNullifier);
|
|
14
14
|
}
|
|
@@ -4,73 +4,73 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title SemaphoreVoting interface.
|
|
5
5
|
/// @dev Interface of SemaphoreVoting contract.
|
|
6
6
|
interface ISemaphoreVoting {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
enum PollState {
|
|
8
|
+
Created,
|
|
9
|
+
Ongoing,
|
|
10
|
+
Ended
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
struct Poll {
|
|
14
|
+
address coordinator;
|
|
15
|
+
PollState state;
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/// @dev Emitted when a new poll is created.
|
|
19
|
+
/// @param pollId: Id of the poll.
|
|
20
|
+
/// @param coordinator: Coordinator of the poll.
|
|
21
|
+
event PollCreated(uint256 pollId, address indexed coordinator);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
/// @dev Emitted when a poll is started.
|
|
24
|
+
/// @param pollId: Id of the poll.
|
|
25
|
+
/// @param coordinator: Coordinator of the poll.
|
|
26
|
+
/// @param encryptionKey: Key to encrypt the poll votes.
|
|
27
|
+
event PollStarted(uint256 pollId, address indexed coordinator, uint256 encryptionKey);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
/// @dev Emitted when a user votes on a poll.
|
|
30
|
+
/// @param pollId: Id of the poll.
|
|
31
|
+
/// @param vote: User encrypted vote.
|
|
32
|
+
event VoteAdded(uint256 indexed pollId, bytes32 vote);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
/// @dev Emitted when a poll is ended.
|
|
35
|
+
/// @param pollId: Id of the poll.
|
|
36
|
+
/// @param coordinator: Coordinator of the poll.
|
|
37
|
+
/// @param decryptionKey: Key to decrypt the poll votes.
|
|
38
|
+
event PollEnded(uint256 pollId, address indexed coordinator, uint256 decryptionKey);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
/// @dev Creates a poll and the associated Merkle tree/group.
|
|
41
|
+
/// @param pollId: Id of the poll.
|
|
42
|
+
/// @param coordinator: Coordinator of the poll.
|
|
43
|
+
/// @param depth: Depth of the tree.
|
|
44
|
+
function createPoll(
|
|
45
|
+
uint256 pollId,
|
|
46
|
+
address coordinator,
|
|
47
|
+
uint8 depth
|
|
48
|
+
) external;
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
/// @dev Adds a voter to a poll.
|
|
51
|
+
/// @param pollId: Id of the poll.
|
|
52
|
+
/// @param identityCommitment: Identity commitment of the group member.
|
|
53
|
+
function addVoter(uint256 pollId, uint256 identityCommitment) external;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
/// @dev Starts a pull and publishes the key to encrypt the votes.
|
|
56
|
+
/// @param pollId: Id of the poll.
|
|
57
|
+
/// @param encryptionKey: Key to encrypt poll votes.
|
|
58
|
+
function startPoll(uint256 pollId, uint256 encryptionKey) external;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
/// @dev Casts an anonymous vote in a poll.
|
|
61
|
+
/// @param vote: Encrypted vote.
|
|
62
|
+
/// @param nullifierHash: Nullifier hash.
|
|
63
|
+
/// @param pollId: Id of the poll.
|
|
64
|
+
/// @param proof: Private zk-proof parameters.
|
|
65
|
+
function castVote(
|
|
66
|
+
bytes32 vote,
|
|
67
|
+
uint256 nullifierHash,
|
|
68
|
+
uint256 pollId,
|
|
69
|
+
uint256[8] calldata proof
|
|
70
|
+
) external;
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
/// @dev Ends a pull and publishes the key to decrypt the votes.
|
|
73
|
+
/// @param pollId: Id of the poll.
|
|
74
|
+
/// @param decryptionKey: Key to decrypt poll votes.
|
|
75
|
+
function endPoll(uint256 pollId, uint256 decryptionKey) external;
|
|
76
76
|
}
|
|
@@ -4,52 +4,52 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title SemaphoreWhistleblowing interface.
|
|
5
5
|
/// @dev Interface of SemaphoreWhistleblowing contract.
|
|
6
6
|
interface ISemaphoreWhistleblowing {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/// @dev Emitted when a new entity is created.
|
|
8
|
+
/// @param entityId: Id of the entity.
|
|
9
|
+
/// @param editor: Editor of the entity.
|
|
10
|
+
event EntityCreated(uint256 entityId, address indexed editor);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/// @dev Emitted when a whistleblower publish a new leak.
|
|
13
|
+
/// @param entityId: Id of the entity.
|
|
14
|
+
/// @param leak: News leak.
|
|
15
|
+
event LeakPublished(uint256 indexed entityId, bytes32 leak);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
/// @dev Creates an entity and the associated Merkle tree/group.
|
|
18
|
+
/// @param entityId: Id of the entity.
|
|
19
|
+
/// @param editor: Editor of the entity.
|
|
20
|
+
/// @param depth: Depth of the tree.
|
|
21
|
+
function createEntity(
|
|
22
|
+
uint256 entityId,
|
|
23
|
+
address editor,
|
|
24
|
+
uint8 depth
|
|
25
|
+
) external;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
/// @dev Adds a whistleblower to an entity.
|
|
28
|
+
/// @param entityId: Id of the entity.
|
|
29
|
+
/// @param identityCommitment: Identity commitment of the group member.
|
|
30
|
+
function addWhistleblower(uint256 entityId, uint256 identityCommitment) external;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
/// @dev Removes a whistleblower from an entity.
|
|
33
|
+
/// @param entityId: Id of the entity.
|
|
34
|
+
/// @param identityCommitment: Identity commitment of the group member.
|
|
35
|
+
/// @param proofSiblings: Array of the sibling nodes of the proof of membership.
|
|
36
|
+
/// @param proofPathIndices: Path of the proof of membership.
|
|
37
|
+
function removeWhistleblower(
|
|
38
|
+
uint256 entityId,
|
|
39
|
+
uint256 identityCommitment,
|
|
40
|
+
uint256[] calldata proofSiblings,
|
|
41
|
+
uint8[] calldata proofPathIndices
|
|
42
|
+
) external;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
/// @dev Allows whistleblowers to publish leaks anonymously.
|
|
45
|
+
/// @param leak: News leak.
|
|
46
|
+
/// @param nullifierHash: Nullifier hash.
|
|
47
|
+
/// @param entityId: Id of the entity.
|
|
48
|
+
/// @param proof: Private zk-proof parameters.
|
|
49
|
+
function publishLeak(
|
|
50
|
+
bytes32 leak,
|
|
51
|
+
uint256 nullifierHash,
|
|
52
|
+
uint256 entityId,
|
|
53
|
+
uint256[8] calldata proof
|
|
54
|
+
) external;
|
|
55
55
|
}
|
package/interfaces/IVerifier.sol
CHANGED
|
@@ -4,10 +4,10 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/// @title Verifier interface.
|
|
5
5
|
/// @dev Interface of Verifier contract.
|
|
6
6
|
interface IVerifier {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
function verifyProof(
|
|
8
|
+
uint256[2] memory a,
|
|
9
|
+
uint256[2][2] memory b,
|
|
10
|
+
uint256[2] memory c,
|
|
11
|
+
uint256[4] memory input
|
|
12
|
+
) external view;
|
|
13
13
|
}
|