From 60f92abf685b0dc064ece0eee388cda83f3196d8 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Mon, 14 Aug 2023 12:59:39 -0400 Subject: [PATCH 1/5] fix: removed unused constant EMPTY_LEAF --- src/WorldIDIdentityManagerImplV1.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/WorldIDIdentityManagerImplV1.sol b/src/WorldIDIdentityManagerImplV1.sol index f02fa8d..877c85d 100644 --- a/src/WorldIDIdentityManagerImplV1.sol +++ b/src/WorldIDIdentityManagerImplV1.sol @@ -71,10 +71,6 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { /// group. uint256 internal rootHistoryExpiry; - /// @notice Represents the initial leaf in an empty merkle tree. - /// @dev Prevents the empty leaf from being inserted into the root history. - uint256 internal constant EMPTY_LEAF = uint256(0); - /// @notice The `r` for the finite field `Fr` under which arithmetic is done on the proof input. /// @dev Used internally to ensure that the proof input is scaled to within the field `Fr`. uint256 internal constant SNARK_SCALAR_FIELD = From ee87998f9374e64af2cdab353d6b61ae1c3122d1 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Mon, 14 Aug 2023 13:08:46 -0400 Subject: [PATCH 2/5] fix: add natspec for validateArrayIsInReducedForm --- src/WorldIDIdentityManagerImplV1.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WorldIDIdentityManagerImplV1.sol b/src/WorldIDIdentityManagerImplV1.sol index 877c85d..c1c059d 100644 --- a/src/WorldIDIdentityManagerImplV1.sol +++ b/src/WorldIDIdentityManagerImplV1.sol @@ -841,6 +841,8 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { } } + /// @notice Validates that an array of identity commitments is within bounds of the SNARK_SCALAR_FIELD + /// @param identityCommitments The array of identity commitments to be validated. function validateArrayIsInReducedForm(uint256[] calldata identityCommitments) internal view From 4473f032a3f4361b8ace77412a23bd4135ee3597 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Mon, 14 Aug 2023 13:12:59 -0400 Subject: [PATCH 3/5] fix: updated natspec to reflect functions that can only be called by the identity operator --- src/WorldIDIdentityManagerImplV1.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WorldIDIdentityManagerImplV1.sol b/src/WorldIDIdentityManagerImplV1.sol index c1c059d..4bd1e3b 100644 --- a/src/WorldIDIdentityManagerImplV1.sol +++ b/src/WorldIDIdentityManagerImplV1.sol @@ -329,7 +329,7 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { /////////////////////////////////////////////////////////////////////////////// /// @notice Registers identities into the WorldID system. - /// @dev Can only be called by the owner. + /// @dev Can only be called by the identity operator. /// @dev Registration is performed off-chain and verified on-chain via the `insertionProof`. /// This saves gas and time over inserting identities one at a time. /// @@ -436,7 +436,7 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { } /// @notice Updates identities in the WorldID system. - /// @dev Can only be called by the owner. + /// @dev Can only be called by the identity operator. /// @dev The update is performed off-chain and verified on-chain via the `updateProof`. This /// saves gas and time over removing identities one at a time. /// @dev This function can perform arbitrary identity alterations and does not require any From d6d4ab3873abf2b6c3b4d627c8bda698d9b59576 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Mon, 14 Aug 2023 13:34:20 -0400 Subject: [PATCH 4/5] fix: added check to ensure that oldIdentities and newIdenties are the same length --- src/WorldIDIdentityManagerImplV1.sol | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/WorldIDIdentityManagerImplV1.sol b/src/WorldIDIdentityManagerImplV1.sol index 4bd1e3b..5cf2d3f 100644 --- a/src/WorldIDIdentityManagerImplV1.sol +++ b/src/WorldIDIdentityManagerImplV1.sol @@ -195,6 +195,9 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { /// length. error MismatchedInputLengths(); + /// @notice Thrown when the inputs to `newIdentities` or `oldIdentities` do not match in + /// length. + error MismatchedIdentityLengths(); /////////////////////////////////////////////////////////////////////////////// /// EVENTS /// /////////////////////////////////////////////////////////////////////////////// @@ -888,6 +891,11 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { ) internal view virtual { validateArrayIsInReducedForm(oldIdentities); validateArrayIsInReducedForm(newIdentities); + + // Check that the arrays are the same length. + if (oldIdentities.length != newIdentities.length) { + revert MismatchedIdentityLengths(); + } } /// @notice Reverts if the provided root value is not valid. From 978cdf4f8500e1c9f381fe7b01d30e0a2aa91272 Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Wed, 16 Aug 2023 11:42:20 -0400 Subject: [PATCH 5/5] fix: removed redundant identity length check --- src/WorldIDIdentityManagerImplV1.sol | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/WorldIDIdentityManagerImplV1.sol b/src/WorldIDIdentityManagerImplV1.sol index 5cf2d3f..4bd1e3b 100644 --- a/src/WorldIDIdentityManagerImplV1.sol +++ b/src/WorldIDIdentityManagerImplV1.sol @@ -195,9 +195,6 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { /// length. error MismatchedInputLengths(); - /// @notice Thrown when the inputs to `newIdentities` or `oldIdentities` do not match in - /// length. - error MismatchedIdentityLengths(); /////////////////////////////////////////////////////////////////////////////// /// EVENTS /// /////////////////////////////////////////////////////////////////////////////// @@ -891,11 +888,6 @@ contract WorldIDIdentityManagerImplV1 is WorldIDImpl, IWorldID { ) internal view virtual { validateArrayIsInReducedForm(oldIdentities); validateArrayIsInReducedForm(newIdentities); - - // Check that the arrays are the same length. - if (oldIdentities.length != newIdentities.length) { - revert MismatchedIdentityLengths(); - } } /// @notice Reverts if the provided root value is not valid.