@semaphore-protocol/contracts 4.5.0 → 4.7.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 CHANGED
@@ -46,18 +46,16 @@ To learn more about contracts visit [semaphore.pse.dev](https://docs.semaphore.p
46
46
 
47
47
  ## 🛠 Install
48
48
 
49
- ### npm or yarn
49
+ You can install the semaphore protocol contracts with any node package manager (`bun`, `npm`, `pnpm`,`yarn`) or the solidity package manager [`soldeer`](https://soldeer.xyz).
50
50
 
51
- Install the `@semaphore-protocol/contracts` package with npm:
52
-
53
- ```bash
51
+ ```commandline
52
+ bun add @semaphore-protocol/contracts
54
53
  npm i @semaphore-protocol/contracts
55
- ```
56
-
57
- or yarn:
58
-
59
- ```bash
54
+ pnpm add @semaphore-protocol/contracts
60
55
  yarn add @semaphore-protocol/contracts
56
+
57
+ # for soldeer, an explicit version is required, e.g:
58
+ soldeer install semaphore-protocol-contracts~4.6.0
61
59
  ```
62
60
 
63
61
  ## 📜 Usage
package/Semaphore.sol CHANGED
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  import {ISemaphore} from "./interfaces/ISemaphore.sol";
5
5
  import {ISemaphoreVerifier} from "./interfaces/ISemaphoreVerifier.sol";
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  /// @dev Minimum supported tree depth.
5
5
  uint8 constant MIN_DEPTH = 1;
@@ -1,5 +1,5 @@
1
1
  //SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  import {ISemaphoreGroups} from "../interfaces/ISemaphoreGroups.sol";
5
5
  import {InternalLeanIMT, LeanIMTData} from "@zk-kit/lean-imt.sol/InternalLeanIMT.sol";
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Part of this file was generated with [snarkJS](https://github.com/iden3/snarkjs).
3
3
 
4
- pragma solidity 0.8.23;
4
+ pragma solidity >=0.8.23 <=0.8.28;
5
5
 
6
6
  import {MAX_DEPTH} from "./Constants.sol";
7
7
  import {SemaphoreVerifierKeyPts} from "./SemaphoreVerifierKeyPts.sol";
@@ -59,7 +59,10 @@ contract SemaphoreVerifier {
59
59
  mstore(add(mIn, 32), y)
60
60
  mstore(add(mIn, 64), s)
61
61
 
62
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
62
+ // ecMul gas cost is fixed at 6000. Add 33.3% gas for safety buffer.
63
+ // Last checked in 2024 Oct, evm codename Cancun
64
+ // ref: https://www.evm.codes/precompiled?fork=cancun#0x07
65
+ success := staticcall(8000, 7, mIn, 96, mIn, 64)
63
66
 
64
67
  if iszero(success) {
65
68
  mstore(0, 0)
@@ -69,7 +72,10 @@ contract SemaphoreVerifier {
69
72
  mstore(add(mIn, 64), mload(pR))
70
73
  mstore(add(mIn, 96), mload(add(pR, 32)))
71
74
 
72
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
75
+ // ecAdd gas cost is fixed at 150. Add 33.3% gas for safety buffer.
76
+ // Last checked in 2024 Oct, evm codename Cancun
77
+ // ref: https://www.evm.codes/precompiled?fork=cancun#0x06
78
+ success := staticcall(200, 6, mIn, 128, pR, 64)
73
79
 
74
80
  if iszero(success) {
75
81
  mstore(0, 0)
@@ -149,7 +155,10 @@ contract SemaphoreVerifier {
149
155
  mstore(add(_pPairing, 704), mload(add(vkPoints, 64)))
150
156
  mstore(add(_pPairing, 736), mload(add(vkPoints, 96)))
151
157
 
152
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
158
+ // ecPairing gas cost at 181000 given 768 bytes input. Add 33.3% gas for safety buffer.
159
+ // Last checked in 2024 Oct, evm codename Cancun
160
+ // ref: https://www.evm.codes/precompiled?fork=cancun#0x08
161
+ let success := staticcall(241333, 8, _pPairing, 768, _pPairing, 0x20)
153
162
 
154
163
  isOk := and(success, mload(_pPairing))
155
164
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Part of this file was generated with [snarkJS](https://github.com/iden3/snarkjs).
3
- pragma solidity 0.8.23;
3
+ pragma solidity >=0.8.23 <=0.8.28;
4
4
 
5
5
  library SemaphoreVerifierKeyPts {
6
6
  error Semaphore__VKPtBytesMaxDepthInvariantViolated(uint256 actual, uint256 expected);
@@ -1,5 +1,5 @@
1
1
  //SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  /// @title Semaphore contract interface.
5
5
  interface ISemaphore {
@@ -1,5 +1,5 @@
1
1
  //SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  /// @title SemaphoreGroups contract interface.
5
5
  interface ISemaphoreGroups {
@@ -1,5 +1,5 @@
1
1
  //SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.23;
2
+ pragma solidity >=0.8.23 <=0.8.28;
3
3
 
4
4
  /// @title SemaphoreVerifier contract interface.
5
5
  interface ISemaphoreVerifier {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/contracts",
3
- "version": "4.5.0",
3
+ "version": "4.7.0",
4
4
  "description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
5
5
  "license": "MIT",
6
6
  "files": [