Skip to content

Commit

Permalink
chore: add internal _verifyPbh
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Jan 27, 2025
1 parent 756e31d commit f814fe5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contracts/src/PBHEntryPointImplV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
emit PBHEntryPointImplInitialized(_worldId, _entryPoint, _numPbhPerMonth, multicall3, _pbhGasLimit);
}

/// @notice Verifies a PBH payload.
/// @param signalHash The signal hash associated with the PBH payload.
/// @param pbhPayload The PBH payload containing the proof data.
function verifyPbh(uint256 signalHash, PBHPayload memory pbhPayload)
public
Expand All @@ -175,6 +177,13 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
onlyProxy
onlyInitialized
{
_verifyPbh(signalHash, pbhPayload);
}

/// @notice Verifies a PBH payload.
/// @param signalHash The signal hash associated with the PBH payload.
/// @param pbhPayload The PBH payload containing the proof data.
function _verifyPbh(uint256 signalHash, PBHPayload memory pbhPayload) internal view {
// First, we make sure this nullifier has not been used before.
if (nullifierHashes[pbhPayload.nullifierHash]) {
revert InvalidNullifier();
Expand Down Expand Up @@ -219,7 +228,7 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
sender, opsPerAggregator[i].userOps[j].nonce, opsPerAggregator[i].userOps[j].callData
).hashToField();

verifyPbh(signalHash, pbhPayloads[j]);
_verifyPbh(signalHash, pbhPayloads[j]);
nullifierHashes[pbhPayloads[j].nullifierHash] = true;
emit PBH(sender, signalHash, pbhPayloads[j]);
}
Expand Down Expand Up @@ -252,7 +261,7 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
returns (IMulticall3.Result[] memory returnData)
{
uint256 signalHash = abi.encode(msg.sender, calls).hashToField();
verifyPbh(signalHash, pbhPayload);
_verifyPbh(signalHash, pbhPayload);
nullifierHashes[pbhPayload.nullifierHash] = true;

returnData = IMulticall3(_multicall3).aggregate3{gas: pbhGasLimit}(calls);
Expand Down

0 comments on commit f814fe5

Please sign in to comment.