Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions solidity/src/authorization/Authorization.sol
Comment thread
keyleu marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ contract Authorization is Ownable, ICallback, ReentrancyGuard {
bytes32[] calldata vks,
bool[] memory validateBlockNumber
) external onlyOwner {
// Check that the verification gateway is set
if (address(verificationGateway) == address(0)) {
revert("Verification gateway not set");
}
Comment thread
keyleu marked this conversation as resolved.

// Since we are allowing multiple registries to be added at once, we need to check that the arrays are the same length
// because for each registry we have a list of users, a verification key and a boolean
// Allowing multiple to be added is useful for gas optimization
Expand All @@ -584,6 +589,11 @@ contract Authorization is Ownable, ICallback, ReentrancyGuard {
* @param registries Array of registry IDs to be removed
*/
function removeRegistries(uint64[] memory registries) external onlyOwner {
// Check that the verification gateway is set
if (address(verificationGateway) == address(0)) {
revert("Verification gateway not set");
}
Comment thread
keyleu marked this conversation as resolved.

for (uint256 i = 0; i < registries.length; i++) {
// Remove the registry from the verification gateway
verificationGateway.removeRegistry(registries[i]);
Expand Down
40 changes: 40 additions & 0 deletions solidity/test/authorization/AuthorizationZK.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,46 @@ contract AuthorizationZKTest is Test {
vm.stopPrank();
}

function test_RevertWhen_AddRegistriesNoVerificationGateway() public {
vm.startPrank(owner);

// Deploy a new authorization contract without a verification gateway
Authorization authWithoutGateway = new Authorization(owner, address(processor), address(0), true);

// Create registry data
uint64[] memory registries = new uint64[](1);
registries[0] = registryId1;

address[][] memory users = new address[][](1);
users[0] = new address[](1);
users[0][0] = user1;

bytes32[] memory vks = new bytes32[](1);
vks[0] = vk1;

bool[] memory validateBlockNumbers = new bool[](1);
validateBlockNumbers[0] = validateBlockNumber1;

// Should fail because verification gateway is not set
vm.expectRevert("Verification gateway not set");
Comment thread
keyleu marked this conversation as resolved.
authWithoutGateway.addRegistries(registries, users, vks, validateBlockNumbers);

vm.stopPrank();
}

function test_RevertWhen_RemoveRegistriesNoVerificationGateway() public {
vm.startPrank(owner);

// Deploy a new authorization contract without a verification gateway
Authorization authWithoutGateway = new Authorization(owner, address(processor), address(0), true);

// Should fail because verification gateway is not set
vm.expectRevert("Verification gateway not set");
Comment thread
keyleu marked this conversation as resolved.
authWithoutGateway.removeRegistries(new uint64[](1));

vm.stopPrank();
}

// ======================= ZK MESSAGE EXECUTION TESTS =======================

function test_RevertWhen_VerificationGatewayNotSet() public {
Expand Down
Loading