Skip to content

Commit

Permalink
compilation fix
Browse files Browse the repository at this point in the history
tests are still broken
  • Loading branch information
dcbuild3r committed Sep 6, 2023
1 parent cbdf914 commit a6ab8c0
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 67 deletions.
6 changes: 3 additions & 3 deletions src/WorldIDIdentityManagerImplV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ contract WorldIDIdentityManagerImplV2 is WorldIDIdentityManagerImplV1 {
}

// Having validated the preconditions we can now check the proof itself.
bytes32 inputHash = calculateIdentityDeletionInputHash(packedDeletionIndices, preRoot, postRoot, batchSize);
bytes32 inputHash =
calculateIdentityDeletionInputHash(packedDeletionIndices, preRoot, postRoot, batchSize);

// No matter what, the inputs can result in a hash that is not an element of the scalar
// field in which we're operating. We reduce it into the field before handing it to the
// verifier.
uint256 reducedElement = uint256(inputHash) % SNARK_SCALAR_FIELD;

// We need to look up the correct verifier before we can verify.
ITreeVerifier deletionVerifier =
batchDeletionVerifiers.getVerifierFor(batchSize);
ITreeVerifier deletionVerifier = batchDeletionVerifiers.getVerifierFor(batchSize);

// With that, we can properly try and verify.
try deletionVerifier.verifyProof(
Expand Down
112 changes: 101 additions & 11 deletions src/test/data/TestDeletionParams.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"inputHash": "0xfe7bd6158c7603ed86cef4dbe90a417fe7c16e94a730ae75ff0135837c6f4dd1",
"deletionIndices": [0, 2, 4],
"preRoot": "0x218676b10b4d8c25fce789f3b13f2b3e49497ce0b20f57bacd7dfda85c0b6ac2",
"postRoot": "0x7c453712267d1cca763c6da89bb632bd85bf9d8b48ef71bd0b7595f81357edb",
"identityCommitments": ["0x1", "0x3", "0x5"],
"inputHash": "0x227590f99431e20f2f95fdfb1b7dfb648c04242c950c31263ba165647c96501a",
"deletionIndices": [0, 2, 4, 6, 8, 10, 12, 14],
"preRoot": "0x18cb13df3e79b9f847a1494d0a2e6f3cc0041d9cae7e5ccb8cd1852ecdc4af58",
"postRoot": "0x82fcf94594d7363636338e2c29242cc77e3d04f36c8ad64d294d2ab4d251708",
"identityCommitments": ["0x1", "0x3", "0x5", "0x7", "0x9", "0xb", "0xd", "0xf"],
"merkleProofs": [
[
"0x2",
"0x20a3af0435914ccd84b806164531b0cd36e37d4efb93efab76913a93e1f30996",
"0x176cf35331147314efef56ab615fe64b748584a01d362fa17297672192d5ecd",
"0x18f43331537ee2af2e3d758d50f72106467c6eea50371dd528d57eb2b856d238",
"0x207c74956e87b3f9e6d31ca140770d3b0921e96ff4131e83c93404c448aace11",
"0x20eadd2578c984addd652554c2e2e104406bb3156de001b765b40bd2178c9b8d",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
Expand All @@ -26,8 +26,8 @@
[
"0x4",
"0x65e2c6cc08a36c4a943286bc91c216054a1981eb4f7570f67394ef8937a21b8",
"0x176cf35331147314efef56ab615fe64b748584a01d362fa17297672192d5ecd",
"0x18f43331537ee2af2e3d758d50f72106467c6eea50371dd528d57eb2b856d238",
"0x207c74956e87b3f9e6d31ca140770d3b0921e96ff4131e83c93404c448aace11",
"0x20eadd2578c984addd652554c2e2e104406bb3156de001b765b40bd2178c9b8d",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
Expand All @@ -43,9 +43,99 @@
],
[
"0x6",
"0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864",
"0x2aef487272d385cd5eba40e25144e80641fef93ff5b25a0133b0d1bd50077920",
"0x1ebadf14eecbfe79f7ac75d3b6c688b8630fb675fcf24ab20e2a08381998266f",
"0x18f43331537ee2af2e3d758d50f72106467c6eea50371dd528d57eb2b856d238",
"0x20eadd2578c984addd652554c2e2e104406bb3156de001b765b40bd2178c9b8d",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
"0x78295e5a22b84e982cf601eb639597b8b0515a88cb5ac7fa8a4aabe3c87349d",
"0x2fa5e5f18f6027a6501bec864564472a616b2e274a41211a444cbe3a99f3cc61",
"0xe884376d0d8fd21ecb780389e941f66e45e7acce3e228ab3e2156a614fcd747",
"0x1b7201da72494f1e28717ad1a52eb469f95892f957713533de6175e5da190af2",
"0x1f8d8822725e36385200c0b201249819a6e6e1e4650808b5bebc6bface7d7636",
"0x2c5d82f66c914bafb9701589ba8cfcfb6162b0a12acf88a8d0879a0471b5f85a",
"0x14c54148a0940bb820957f5adf3fa1134ef5c4aaa113f4646458f270e0bfbfd0",
"0x190d33b12f986f961e10c0ee44d8b9af11be25588cad89d416118e4bf4ebe80c",
"0x22f98aa9ce704152ac17354914ad73ed1167ae6596af510aa5b3649325e06c92"
],
[
"0x8",
"0x20dc7044757b1f24c7f832b9667c4556714019a71a066a22b92bdd77723f6b04",
"0x1ebadf14eecbfe79f7ac75d3b6c688b8630fb675fcf24ab20e2a08381998266f",
"0x20eadd2578c984addd652554c2e2e104406bb3156de001b765b40bd2178c9b8d",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
"0x78295e5a22b84e982cf601eb639597b8b0515a88cb5ac7fa8a4aabe3c87349d",
"0x2fa5e5f18f6027a6501bec864564472a616b2e274a41211a444cbe3a99f3cc61",
"0xe884376d0d8fd21ecb780389e941f66e45e7acce3e228ab3e2156a614fcd747",
"0x1b7201da72494f1e28717ad1a52eb469f95892f957713533de6175e5da190af2",
"0x1f8d8822725e36385200c0b201249819a6e6e1e4650808b5bebc6bface7d7636",
"0x2c5d82f66c914bafb9701589ba8cfcfb6162b0a12acf88a8d0879a0471b5f85a",
"0x14c54148a0940bb820957f5adf3fa1134ef5c4aaa113f4646458f270e0bfbfd0",
"0x190d33b12f986f961e10c0ee44d8b9af11be25588cad89d416118e4bf4ebe80c",
"0x22f98aa9ce704152ac17354914ad73ed1167ae6596af510aa5b3649325e06c92"
],
[
"0xa",
"0x1340c981e5112e73251c5f2e80a7d95c02a2d6086f8cd28c201e09f38d054cf8",
"0x2285bd343aa98c6c45b027216e1cb201894a8c3cf1a0b3765abca88a0ed3a644",
"0x1c430bfac3ed5c853cd68c414d64defb441b07efdd649912885a43f0c39a6f6e",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
"0x78295e5a22b84e982cf601eb639597b8b0515a88cb5ac7fa8a4aabe3c87349d",
"0x2fa5e5f18f6027a6501bec864564472a616b2e274a41211a444cbe3a99f3cc61",
"0xe884376d0d8fd21ecb780389e941f66e45e7acce3e228ab3e2156a614fcd747",
"0x1b7201da72494f1e28717ad1a52eb469f95892f957713533de6175e5da190af2",
"0x1f8d8822725e36385200c0b201249819a6e6e1e4650808b5bebc6bface7d7636",
"0x2c5d82f66c914bafb9701589ba8cfcfb6162b0a12acf88a8d0879a0471b5f85a",
"0x14c54148a0940bb820957f5adf3fa1134ef5c4aaa113f4646458f270e0bfbfd0",
"0x190d33b12f986f961e10c0ee44d8b9af11be25588cad89d416118e4bf4ebe80c",
"0x22f98aa9ce704152ac17354914ad73ed1167ae6596af510aa5b3649325e06c92"
],
[
"0xc",
"0x275543cd9fbcdee56ac8c9a937ad062f198be71714077c99e50ee6b5e2328a2c",
"0x2285bd343aa98c6c45b027216e1cb201894a8c3cf1a0b3765abca88a0ed3a644",
"0x1c430bfac3ed5c853cd68c414d64defb441b07efdd649912885a43f0c39a6f6e",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
"0x78295e5a22b84e982cf601eb639597b8b0515a88cb5ac7fa8a4aabe3c87349d",
"0x2fa5e5f18f6027a6501bec864564472a616b2e274a41211a444cbe3a99f3cc61",
"0xe884376d0d8fd21ecb780389e941f66e45e7acce3e228ab3e2156a614fcd747",
"0x1b7201da72494f1e28717ad1a52eb469f95892f957713533de6175e5da190af2",
"0x1f8d8822725e36385200c0b201249819a6e6e1e4650808b5bebc6bface7d7636",
"0x2c5d82f66c914bafb9701589ba8cfcfb6162b0a12acf88a8d0879a0471b5f85a",
"0x14c54148a0940bb820957f5adf3fa1134ef5c4aaa113f4646458f270e0bfbfd0",
"0x190d33b12f986f961e10c0ee44d8b9af11be25588cad89d416118e4bf4ebe80c",
"0x22f98aa9ce704152ac17354914ad73ed1167ae6596af510aa5b3649325e06c92"
],
[
"0xe",
"0x158743daa8227296c7b3b03fca21e8c7e7e535b1791091d38182cd29795e6001",
"0xa89786c05a24b044fcac8caa1e998c39d9975c454860e5442d85ff42be75e85",
"0x1c430bfac3ed5c853cd68c414d64defb441b07efdd649912885a43f0c39a6f6e",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
"0x78295e5a22b84e982cf601eb639597b8b0515a88cb5ac7fa8a4aabe3c87349d",
"0x2fa5e5f18f6027a6501bec864564472a616b2e274a41211a444cbe3a99f3cc61",
"0xe884376d0d8fd21ecb780389e941f66e45e7acce3e228ab3e2156a614fcd747",
"0x1b7201da72494f1e28717ad1a52eb469f95892f957713533de6175e5da190af2",
"0x1f8d8822725e36385200c0b201249819a6e6e1e4650808b5bebc6bface7d7636",
"0x2c5d82f66c914bafb9701589ba8cfcfb6162b0a12acf88a8d0879a0471b5f85a",
"0x14c54148a0940bb820957f5adf3fa1134ef5c4aaa113f4646458f270e0bfbfd0",
"0x190d33b12f986f961e10c0ee44d8b9af11be25588cad89d416118e4bf4ebe80c",
"0x22f98aa9ce704152ac17354914ad73ed1167ae6596af510aa5b3649325e06c92"
],
[
"0x10",
"0x158cdf90c232e1624129ff7a0994c9acb5b45340ad851036088946991e724354",
"0xa89786c05a24b044fcac8caa1e998c39d9975c454860e5442d85ff42be75e85",
"0x1c430bfac3ed5c853cd68c414d64defb441b07efdd649912885a43f0c39a6f6e",
"0x7f9d837cb17b0d36320ffe93ba52345f1b728571a568265caac97559dbc952a",
"0x2b94cf5e8746b3f5c9631f4c5df32907a699c58c94b2ad4d7b5cec1639183f55",
"0x2dee93c5a666459646ea7d22cca9e1bcfed71e6951b953611d11dda32ea09d78",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract WorldIDIdentityManagerCalculation is WorldIDIdentityManagerTest {
// Setup
bytes memory callData = abi.encodeCall(
ManagerImpl.calculateIdentityDeletionInputHash,
(deletionIndices, insertionPreRoot, insertionPostRoot)
(packedDeletionIndices, insertionPreRoot, insertionPostRoot, deletionBatchSize)
);
bytes memory returnData = abi.encode(deletionInputHash);

Expand All @@ -58,7 +58,7 @@ contract WorldIDIdentityManagerCalculation is WorldIDIdentityManagerTest {

// Test
managerImpl.calculateIdentityDeletionInputHash(
deletionIndices, insertionPreRoot, insertionPostRoot
packedDeletionIndices, deletionPreRoot, deletionPostRoot, deletionBatchSize
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ contract WorldIDIdentityManagerGettersSetters is WorldIDIdentityManagerTest {
/// identity deletion proofs.
function testCanSetDeleteIdentitiesVerifierLookupTable() public {
// Setup
(,VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
(, VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
address newVerifiersAddress = address(deletionVerifiers);
bytes memory callData = abi.encodeCall(
ManagerImpl.setDeleteIdentitiesVerifierLookupTable, (deletionVerifiers)
);
bytes memory callData =
abi.encodeCall(ManagerImpl.setDeleteIdentitiesVerifierLookupTable, (deletionVerifiers));
bytes memory checkCallData =
abi.encodeCall(ManagerImpl.getDeleteIdentitiesVerifierLookupTableAddress, ());
bytes memory expectedReturn = abi.encode(newVerifiersAddress);
Expand All @@ -141,12 +140,10 @@ contract WorldIDIdentityManagerGettersSetters is WorldIDIdentityManagerTest {
}

/// @notice Checks that the delete identities lookup table cannot be set except by the owner.
function testCannotSetDeleteIdentitiesVerifierLookupTableUnlessOwner(address notOwner)
public
{
function testCannotSetDeleteIdentitiesVerifierLookupTableUnlessOwner(address notOwner) public {
// Setup
vm.assume(notOwner != address(this) && notOwner != address(0x0));
(,VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
(, VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
bytes memory callData = abi.encodeCall(
ManagerImplV1.setRegisterIdentitiesVerifierLookupTable, (deletionVerifiers)
);
Expand All @@ -161,7 +158,7 @@ contract WorldIDIdentityManagerGettersSetters is WorldIDIdentityManagerTest {
/// identity deletion unless called via the proxy.
function testCannotSetDeleteIdentitiesVerifierLookupTableUnlessViaProxy() public {
// Setup
(,VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
(, VerifierLookupTable deletionVerifiers,) = makeVerifierLookupTables(TC.makeDynArray([40]));
vm.expectRevert("Function must be called through delegatecall");

// Test
Expand Down
Loading

0 comments on commit a6ab8c0

Please sign in to comment.