-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
475 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { IMessageProcessorFactory } from "./interfaces/IMPFactory.sol"; | |
import { ITallyFactory } from "./interfaces/ITallyFactory.sol"; | ||
import { IVerifier } from "./interfaces/IVerifier.sol"; | ||
import { IVkRegistry } from "./interfaces/IVkRegistry.sol"; | ||
import { ISignUpGatekeeper } from "./interfaces/ISignUpGatekeeper.sol"; | ||
import { InitialVoiceCreditProxy } from "./initialVoiceCreditProxy/InitialVoiceCreditProxy.sol"; | ||
import { SignUpGatekeeper } from "./gatekeepers/SignUpGatekeeper.sol"; | ||
import { IMACI } from "./interfaces/IMACI.sol"; | ||
|
@@ -187,7 +188,8 @@ contract MACI is IMACI, DomainObjs, Params, Utilities { | |
PubKey memory _coordinatorPubKey, | ||
address _verifier, | ||
address _vkRegistry, | ||
Mode _mode | ||
Mode _mode, | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter MACI.deployPoll(uint256,Params.TreeDepths,uint8,DomainObjs.PubKey,address,address,DomainObjs.Mode,address)._mode is not in mixedCase
|
||
address _gatekeeper | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter MACI.deployPoll(uint256,Params.TreeDepths,uint8,DomainObjs.PubKey,address,address,DomainObjs.Mode,address)._gatekeeper is not in mixedCase
|
||
) public virtual { | ||
// cache the poll to a local variable so we can increment it | ||
uint256 pollId = nextPollId; | ||
|
@@ -208,7 +210,8 @@ contract MACI is IMACI, DomainObjs, Params, Utilities { | |
ExtContracts memory extContracts = ExtContracts({ | ||
maci: IMACI(address(this)), | ||
verifier: IVerifier(_verifier), | ||
vkRegistry: IVkRegistry(_vkRegistry) | ||
vkRegistry: IVkRegistry(_vkRegistry), | ||
gatekeeper: ISignUpGatekeeper(_gatekeeper) | ||
}); | ||
|
||
address p = pollFactory.deploy( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { SnarkCommon } from "./crypto/SnarkCommon.sol"; | |
import { LazyIMTData, InternalLazyIMT } from "./trees/LazyIMT.sol"; | ||
import { IMACI } from "./interfaces/IMACI.sol"; | ||
import { IPoll } from "./interfaces/IPoll.sol"; | ||
import { ISignUpGatekeeper } from "./interfaces/ISignUpGatekeeper.sol"; | ||
import { Utilities } from "./utilities/Utilities.sol"; | ||
import { CurveBabyJubJub } from "./crypto/BabyJubJub.sol"; | ||
|
||
|
@@ -278,28 +279,31 @@ contract Poll is Params, Utilities, SnarkCommon, IPoll { | |
PubKey calldata _pubKey, | ||
uint256 _newVoiceCreditBalance, | ||
uint256 _stateRootIndex, | ||
uint256[8] calldata _proof | ||
uint256[8] calldata _proof, | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter Poll.joinPoll(uint256,DomainObjs.PubKey,uint256,uint256,uint256[8],bytes)._proof is not in mixedCase
|
||
bytes memory _signUpGatekeeperData | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter Poll.joinPoll(uint256,DomainObjs.PubKey,uint256,uint256,uint256[8],bytes)._signUpGatekeeperData is not in mixedCase
|
||
) public virtual isWithinVotingDeadline { | ||
// Whether the user has already joined | ||
if (pollNullifier[_nullifier]) { | ||
revert UserAlreadyJoined(); | ||
} | ||
|
||
// Set nullifier for user's private key | ||
pollNullifier[_nullifier] = true; | ||
|
||
// Verify user's proof | ||
if (!verifyPollProof(_nullifier, _newVoiceCreditBalance, _stateRootIndex, _pubKey, _proof)) { | ||
revert InvalidPollProof(); | ||
} | ||
|
||
// Check if the user is eligible to join the poll | ||
extContracts.gatekeeper.register(msg.sender, _signUpGatekeeperData); | ||
|
||
// Store user in the pollStateTree | ||
uint256 timestamp = block.timestamp; | ||
uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, _newVoiceCreditBalance, timestamp)); | ||
uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, _newVoiceCreditBalance, block.timestamp)); | ||
InternalLazyIMT._insert(pollStateTree, stateLeaf); | ||
|
||
// Set nullifier for user's private key | ||
pollNullifier[_nullifier] = true; | ||
|
||
uint256 pollStateIndex = pollStateTree.numberOfLeaves - 1; | ||
emit PollJoined(_pubKey.x, _pubKey.y, _newVoiceCreditBalance, timestamp, _nullifier, pollStateIndex); | ||
emit PollJoined(_pubKey.x, _pubKey.y, _newVoiceCreditBalance, block.timestamp, _nullifier, pollStateIndex); | ||
} | ||
|
||
/// @notice Verify the proof for Poll | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/contracts/contracts/interfaces/ISignUpGatekeeper.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.10; | ||
|
||
/// @title ISignUpGatekeeper | ||
/// @notice SignUpGatekeeper interface | ||
interface ISignUpGatekeeper { | ||
/// @notice Register a user | ||
/// @param _user User address | ||
/// @param _data Data to register | ||
function register(address _user, bytes memory _data) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.