@@ -184,13 +184,6 @@ contract GSECore is IGSECore, Ownable {
184184 // intended.
185185 IERC20 public immutable ASSET;
186186
187- // the `gap` pushes the `checkProofOfPossession` into its own slot
188- // so we don't have the trouble of being in the middle of a slot
189- uint256 private gap = 0 ;
190-
191- // @note Always true, exists to override to false for testing only.
192- bool public checkProofOfPossession = true ;
193-
194187 // The GSE's history of rollups.
195188 Checkpoints.Trace224 internal rollups;
196189 // Mapping from instance address to its historical attester information.
@@ -332,28 +325,7 @@ contract GSECore is IGSECore, Ownable {
332325 instances[recipientInstance].attesters.add (_attester), Errors.GSE__AlreadyRegistered (recipientInstance, _attester)
333326 );
334327
335- if (checkProofOfPossession) {
336- // Make sure the attester has not registered before
337- G1Point memory previouslyRegisteredPoint = configOf[_attester].publicKey;
338- require (
339- (previouslyRegisteredPoint.x == 0 && previouslyRegisteredPoint.y == 0 ),
340- Errors.GSE__CannotChangePublicKeys (previouslyRegisteredPoint.x, previouslyRegisteredPoint.y)
341- );
342-
343- // Make sure the incoming point has not been seen before
344- // NOTE: we only need to check for the existence of Pk1, and not also for Pk2,
345- // as the Pk2 will be constrained to have the same underlying secret key as part of the proofOfPossession,
346- // so existence/correctness of Pk2 is implied by existence/correctness of Pk1.
347- bytes32 hashedIncomingPoint = keccak256 (abi.encodePacked (_publicKeyInG1.x, _publicKeyInG1.y));
348- require ((! ownedPKs[hashedIncomingPoint]), Errors.GSE__ProofOfPossessionAlreadySeen (hashedIncomingPoint));
349-
350- require (
351- BN254Lib.proofOfPossession (_publicKeyInG1, _publicKeyInG2, _proofOfPossession),
352- Errors.GSE__InvalidProofOfPossession ()
353- );
354-
355- ownedPKs[hashedIncomingPoint] = true ;
356- }
328+ _checkProofOfPossession (_attester, _publicKeyInG1, _publicKeyInG2, _proofOfPossession);
357329
358330 // This is the ONLY place where we set the configuration for an attester.
359331 // This means that their withdrawer and public keys are set once, globally.
@@ -616,6 +588,33 @@ contract GSECore is IGSECore, Ownable {
616588 getGovernance ().vote (_proposalId, _amount, _support);
617589 }
618590
591+ function _checkProofOfPossession (
592+ address _attester ,
593+ G1Point memory _publicKeyInG1 ,
594+ G2Point memory _publicKeyInG2 ,
595+ G1Point memory _proofOfPossession
596+ ) internal virtual {
597+ // Make sure the attester has not registered before
598+ G1Point memory previouslyRegisteredPoint = configOf[_attester].publicKey;
599+ require (
600+ (previouslyRegisteredPoint.x == 0 && previouslyRegisteredPoint.y == 0 ),
601+ Errors.GSE__CannotChangePublicKeys (previouslyRegisteredPoint.x, previouslyRegisteredPoint.y)
602+ );
603+
604+ // Make sure the incoming point has not been seen before
605+ // NOTE: we only need to check for the existence of Pk1, and not also for Pk2,
606+ // as the Pk2 will be constrained to have the same underlying secret key as part of the proofOfPossession,
607+ // so existence/correctness of Pk2 is implied by existence/correctness of Pk1.
608+ bytes32 hashedIncomingPoint = keccak256 (abi.encodePacked (_publicKeyInG1.x, _publicKeyInG1.y));
609+ require ((! ownedPKs[hashedIncomingPoint]), Errors.GSE__ProofOfPossessionAlreadySeen (hashedIncomingPoint));
610+ ownedPKs[hashedIncomingPoint] = true ;
611+
612+ require (
613+ BN254Lib.proofOfPossession (_publicKeyInG1, _publicKeyInG2, _proofOfPossession),
614+ Errors.GSE__InvalidProofOfPossession ()
615+ );
616+ }
617+
619618 function _pendingThrough (uint256 _proposalId ) internal view returns (Timestamp) {
620619 return getGovernance ().getProposal (_proposalId).pendingThroughMemory ();
621620 }
0 commit comments