Skip to content

Commit

Permalink
Merge branch 'main' into osiris/release-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Jan 10, 2025
2 parents d20114d + d37d6f7 commit aa13378
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 27 deletions.
14 changes: 14 additions & 0 deletions contracts/src/PBH4337Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import {ISafe} from "@4337/interfaces/Safe.sol";
import {SafeModuleSignatures} from "./lib/SafeModuleSignatures.sol";

contract PBHSafe4337Module is Safe4337Module {
///////////////////////////////////////////////////////////////////////////////
/// STATE VARIABLES ///
//////////////////////////////////////////////////////////////////////////////

/// @notice The length of an ECDSA signature.
uint256 internal constant ECDSA_SIGNATURE_LENGTH = 65;

/// @notice The length of the timestamp bytes.
/// @dev 6 bytes each for validAfter and validUntil.
uint256 internal constant TIMESTAMP_BYTES = 12;

/// @notice The length of the encoded proof data.
uint256 internal constant ENCODED_PROOF_BYTES = 352;

Expand All @@ -24,6 +30,10 @@ contract PBHSafe4337Module is Safe4337Module {
/// @dev This key is used to identify a PBH user operation.
uint192 public immutable PBH_NONCE_KEY;

///////////////////////////////////////////////////////////////////////////////
/// ERRORS ///
//////////////////////////////////////////////////////////////////////////////

/// @notice Thrown when the proof size is invalid.
error InvalidProofSize();

Expand All @@ -33,6 +43,10 @@ contract PBHSafe4337Module is Safe4337Module {
/// @notice Thrown when the PBH Nonce Key is not initialized.
error UninitializedNonceKey();

///////////////////////////////////////////////////////////////////////////////
/// FUNCTIONS ///
///////////////////////////////////////////////////////////////////////////////

constructor(address entryPoint, address _pbhSignatureAggregator, uint192 _pbhNonceKey) Safe4337Module(entryPoint) {
require(_pbhSignatureAggregator != address(0), AddressZero());
require(entryPoint != address(0), AddressZero());
Expand Down
44 changes: 22 additions & 22 deletions contracts/src/PBHEntryPointImplV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
uint256 pbhGasLimit
);

/// @notice Emitted once for each successful PBH verification.
///
/// @param sender The sender of this particular transaction or UserOp.
/// @param signalHash Signal hash associated with the PBHPayload.
/// @param payload The zero-knowledge proof that demonstrates the claimer is registered with World ID.
event PBH(address indexed sender, uint256 indexed signalHash, PBHPayload payload);

/// @notice Emitted when the World ID address is set.
///
/// @param worldId The World ID instance that will be used for verifying proofs.
event WorldIdSet(address indexed worldId);

/// @notice Emitted when the number of PBH transactions allowed per month is set.
///
/// @param numPbhPerMonth The number of allowed PBH transactions per month.
event NumPbhPerMonthSet(uint8 indexed numPbhPerMonth);

/// @notice Emitted when setting the PBH gas limit.
///
/// @param pbhGasLimit The gas limit for a PBH multicall transaction.
event PBHGasLimitSet(uint256 indexed pbhGasLimit);

///////////////////////////////////////////////////////////////////////////////
/// ERRORS ///
//////////////////////////////////////////////////////////////////////////////
Expand All @@ -86,28 +108,6 @@ contract PBHEntryPointImplV1 is IPBHEntryPoint, WorldIDImpl, ReentrancyGuardTran
/// @notice Thrown when setting the gas limit for a PBH multicall to 0
error InvalidPBHGasLimit(uint256 gasLimit);

/// @notice Emitted once for each successful PBH verification.
///
/// @param sender The sender of this particular transaction or UserOp.
/// @param signalHash Signal hash associated with the PBHPayload.
/// @param payload The zero-knowledge proof that demonstrates the claimer is registered with World ID.
event PBH(address indexed sender, uint256 indexed signalHash, PBHPayload payload);

/// @notice Emitted when the World ID address is set.
///
/// @param worldId The World ID instance that will be used for verifying proofs.
event WorldIdSet(address indexed worldId);

/// @notice Emitted when the number of PBH transactions allowed per month is set.
///
/// @param numPbhPerMonth The number of allowed PBH transactions per month.
event NumPbhPerMonthSet(uint8 indexed numPbhPerMonth);

/// @notice Emitted when setting the PBH gas limit.
///
/// @param pbhGasLimit The gas limit for a PBH multicall transaction.
event PBHGasLimitSet(uint256 indexed pbhGasLimit);

///////////////////////////////////////////////////////////////////////////////
/// FUNCTIONS ///
///////////////////////////////////////////////////////////////////////////////
Expand Down
22 changes: 17 additions & 5 deletions contracts/src/PBHSignatureAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ import {SafeModuleSignatures} from "./lib/SafeModuleSignatures.sol";
contract PBHSignatureAggregator is IAggregator {
using ByteHasher for bytes;

///////////////////////////////////////////////////////////////////////////////
/// STATE VARIABLES ///
//////////////////////////////////////////////////////////////////////////////

/// @notice The PBHVerifier contract.
IPBHEntryPoint public immutable pbhEntryPoint;

/// @notice The WorldID contract.
IWorldID public immutable worldID;

///////////////////////////////////////////////////////////////////////////////
/// ERRORS ///
//////////////////////////////////////////////////////////////////////////////

/// @notice Thrown when the Hash of the UserOperations is not
/// in transient storage of the `PBHVerifier`.
error InvalidUserOperations();
Expand All @@ -28,11 +42,9 @@ contract PBHSignatureAggregator is IAggregator {
/// @notice Thrown when a zero address is passed as the PBHEntryPoint.
error AddressZero();

/// @notice The PBHVerifier contract.
IPBHEntryPoint public immutable pbhEntryPoint;

/// @notice The WorldID contract.
IWorldID public immutable worldID;
///////////////////////////////////////////////////////////////////////////////
/// FUNCTIONS ///
///////////////////////////////////////////////////////////////////////////////

constructor(address _pbhEntryPoint, address _worldID) {
require(_pbhEntryPoint != address(0), AddressZero());
Expand Down

0 comments on commit aa13378

Please sign in to comment.