Skip to content

Commit

Permalink
fix(maci): amended the signUp function to reflect the checks-effect…
Browse files Browse the repository at this point in the history
…s-interaction pattern

Moved the `_pubKey` check above before increasing the number of signups.

fix #503
  • Loading branch information
ctrlc03 committed Sep 30, 2022
1 parent 8300cc5 commit d62c7c7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions contracts/contracts/MACI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,18 @@ contract MACI is IMACI, DomainObjs, Params, SnarkCommon, Ownable {
"MACI: maximum number of signups reached"
);

require(
_pubKey.x < SNARK_SCALAR_FIELD && _pubKey.y < SNARK_SCALAR_FIELD,
"MACI: _pubKey values should be less than the snark scalar field"
);

// Increment the number of signups
numSignUps++;

// Register the user via the sign-up gatekeeper. This function should
// throw if the user has already registered or if ineligible to do so.
signUpGatekeeper.register(msg.sender, _signUpGatekeeperData);

require(
_pubKey.x < SNARK_SCALAR_FIELD && _pubKey.y < SNARK_SCALAR_FIELD,
"MACI: _pubKey values should be less than the snark scalar field"
);

// Get the user's voice credit balance.
uint256 voiceCreditBalance = initialVoiceCreditProxy.getVoiceCredits(
msg.sender,
Expand Down

0 comments on commit d62c7c7

Please sign in to comment.