@semaphore-protocol/contracts 2.2.0 → 2.4.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/README.md +60 -1
- package/Semaphore.sol +2 -2
- package/interfaces/ISemaphore.sol +10 -1
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<a href="https://github.com/semaphore-protocol">
|
|
10
|
-
<img src="https://img.shields.io/badge/project-
|
|
10
|
+
<img src="https://img.shields.io/badge/project-Semaphore-blue.svg?style=flat-square">
|
|
11
11
|
</a>
|
|
12
12
|
<a href="https://github.com/semaphore-protocol/semaphore/blob/main/LICENSE">
|
|
13
13
|
<img alt="Github license" src="https://img.shields.io/github/license/semaphore-protocol/semaphore.svg?style=flat-square">
|
|
@@ -59,3 +59,62 @@ or yarn:
|
|
|
59
59
|
```bash
|
|
60
60
|
yarn add @semaphore-protocol/contracts
|
|
61
61
|
```
|
|
62
|
+
|
|
63
|
+
## 📜 Usage
|
|
64
|
+
|
|
65
|
+
### Compile contracts
|
|
66
|
+
|
|
67
|
+
Compile the smart contracts with [Hardhat](https://hardhat.org/):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
yarn compile
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Testing
|
|
74
|
+
|
|
75
|
+
Run [Mocha](https://mochajs.org/) to test the contracts:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
yarn test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can also generate a test coverage report:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
yarn test:coverage
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or a test gas report:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
yarn test:report-gas
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Deploy contracts
|
|
94
|
+
|
|
95
|
+
Deploy a verifier contract with depth = 20:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
yarn deploy:verifier --depth 20
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Deploy the `Semaphore.sol` contract with one verifier:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
yarn deploy:semaphore --verifiers '[{"merkleTreeDepth": 20, "contractAddress": "0x06bcD633988c1CE7Bd134DbE2C12119b6f3E4bD1"}]'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Deploy all verifiers and Semaphore contract:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
yarn deploy:all
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If you want to deploy contracts in a specific network you can set up the `DEFAULT_NETWORK` variable in your `.env` file with the name of one of our supported networks (hardhat, localhost, goerli, arbitrum). Or you can specify it as option:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
yarn deploy:all --network goerli
|
|
117
|
+
yarn deploy:all --network localhost
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If you want to deploy contracts on Goerli or Arbitrum, remember to provide a valid private key and an Infura API in your `.env` file.
|
package/Semaphore.sol
CHANGED
|
@@ -168,8 +168,8 @@ contract Semaphore is ISemaphore, SemaphoreCore, SemaphoreGroups {
|
|
|
168
168
|
|
|
169
169
|
_verifyProof(signal, merkleTreeRoot, nullifierHash, externalNullifier, proof, verifier);
|
|
170
170
|
|
|
171
|
-
_saveNullifierHash(nullifierHash);
|
|
171
|
+
_saveNullifierHash(uint256(keccak256(abi.encodePacked(groupId, nullifierHash))));
|
|
172
172
|
|
|
173
|
-
emit ProofVerified(groupId, signal);
|
|
173
|
+
emit ProofVerified(groupId, merkleTreeRoot, nullifierHash, externalNullifier, signal);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -29,8 +29,17 @@ interface ISemaphore {
|
|
|
29
29
|
|
|
30
30
|
/// @dev Emitted when a Semaphore proof is verified.
|
|
31
31
|
/// @param groupId: Id of the group.
|
|
32
|
+
/// @param merkleTreeRoot: Root of the Merkle tree.
|
|
33
|
+
/// @param externalNullifier: External nullifier.
|
|
34
|
+
/// @param nullifierHash: Nullifier hash.
|
|
32
35
|
/// @param signal: Semaphore signal.
|
|
33
|
-
event ProofVerified(
|
|
36
|
+
event ProofVerified(
|
|
37
|
+
uint256 indexed groupId,
|
|
38
|
+
uint256 merkleTreeRoot,
|
|
39
|
+
uint256 externalNullifier,
|
|
40
|
+
uint256 nullifierHash,
|
|
41
|
+
bytes32 signal
|
|
42
|
+
);
|
|
34
43
|
|
|
35
44
|
/// @dev Saves the nullifier hash to avoid double signaling and emits an event
|
|
36
45
|
/// if the zero-knowledge proof is valid.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/contracts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -20,11 +20,8 @@
|
|
|
20
20
|
"circom",
|
|
21
21
|
"proof-of-membership"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/semaphore-protocol/semaphore.git.git"
|
|
27
|
-
},
|
|
23
|
+
"repository": "https://github.com/semaphore-protocol/semaphore",
|
|
24
|
+
"homepage": "https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts",
|
|
28
25
|
"bugs": {
|
|
29
26
|
"url": "https://github.com/semaphore-protocol/semaphore.git/issues"
|
|
30
27
|
},
|