-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: checkpoint signature aggregation logic
- Loading branch information
Showing
7 changed files
with
135 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
[profile.default] | ||
evm_version = 'cancun' | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
via_ir = true | ||
optimizer = true | ||
optimizer_runs = 200 | ||
|
||
remappings = [ | ||
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", | ||
"@account-abstraction/contracts/=lib/account-abstraction/contracts/", | ||
"@world-id-contracts/=lib/world-id-contracts/src/", | ||
"@account-abstraction/=lib/account-abstraction/contracts/", | ||
"@BokkyPooBahsDateTimeLibrary/=lib/BokkyPooBahsDateTimeLibrary/contracts/", | ||
"@helpers/=src/helpers/", | ||
"openzeppelin-contracts/=lib/world-id-contracts/lib/openzeppelin-contracts/contracts/", | ||
] | ||
|
||
[fuzz] | ||
runs = 5000 | ||
max_test_rejects = 150000 | ||
|
||
|
||
|
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,66 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {IAggregator} from "@account-abstraction/contracts/interfaces/IAggregator.sol"; | ||
import {IPBHVerifier} from "./interfaces/IPBHVerifier.sol"; | ||
import "@account-abstraction/contracts/interfaces/PackedUserOperation.sol"; | ||
|
||
contract PBHSignatureAggregator is IAggregator { | ||
error InvalidUserOperations(); | ||
|
||
/// @notice The PBHVerifier contract. | ||
IPBHVerifier internal immutable pbhVerifier; | ||
|
||
constructor(address _pbhVerifier) { | ||
pbhVerifier = IPBHVerifier(_pbhVerifier); | ||
} | ||
|
||
/** | ||
* Validate aggregated signature. | ||
* Revert if the aggregated signature does not match the given list of operations. | ||
* @param userOps - Array of UserOperations to validate the signature for. | ||
* @param signature - The aggregated signature. | ||
*/ | ||
function validateSignatures(PackedUserOperation[] calldata userOps, bytes calldata) external view { | ||
bytes memory encoded = abi.encode(userOps); | ||
try pbhVerifier.validateSignaturesCallback(keccak256(encoded)) {} | ||
catch { | ||
revert InvalidUserOperations(); | ||
} | ||
} | ||
|
||
/** | ||
* Validate signature of a single userOp. | ||
* This method should be called by bundler after EntryPointSimulation.simulateValidation() returns | ||
* the aggregator this account uses. | ||
* First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps. | ||
* @param userOp - The userOperation received from the user. | ||
* @return sigForUserOp - The value to put into the signature field of the userOp when calling handleOps. | ||
* (usually empty, unless account and aggregator support some kind of "multisig". | ||
*/ | ||
function validateUserOpSignature(PackedUserOperation calldata userOp) | ||
external | ||
view | ||
returns (bytes memory sigForUserOp) | ||
{} | ||
|
||
/** | ||
* Aggregate multiple signatures into a single value. | ||
* This method is called off-chain to calculate the signature to pass with handleOps() | ||
* bundler MAY use optimized custom code perform this aggregation. | ||
* @param userOps - Array of UserOperations to collect the signatures from. | ||
* @return aggregatedSignature - The aggregated signature. | ||
*/ | ||
function aggregateSignatures(PackedUserOperation[] calldata userOps) | ||
external | ||
view | ||
returns (bytes memory aggregatedSignature) | ||
{ | ||
// Aggregates all of the proofs on | ||
for (uint256 i = 0; i < userOps.length; ++i) { | ||
// (0:65) - UserOp Signature | ||
// (65:65 + 320) - Packed Proof Data | ||
bytes memory signature = userOps[i].signature; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {IWorldIDGroups} from "@world-id-contracts/interfaces/IWorldIDGroups.sol"; | ||
|
||
interface IPBHVerifier { | ||
function initialize(address __worldId, address __entryPoint, uint8 _numPbhPerMonth) external; | ||
|
||
function verifyPbhProof( | ||
uint256 root, | ||
address sender, | ||
uint256 nonce, | ||
bytes memory callData, | ||
uint256 pbhExternalNullifier, | ||
uint256 nullifierHash, | ||
uint256[8] memory proof | ||
) external; | ||
|
||
function validateSignaturesCallback() external view; | ||
|
||
function setNumPbhPerMonth(uint8 _numPbhPerMonth) external; | ||
|
||
function setWorldId(address worldId) 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
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