Skip to content

Commit 2ef955a

Browse files
authored
fix: ofac check to aadhaar (#1050)
1 parent 054cfaf commit 2ef955a

File tree

3 files changed

+46
-52
lines changed

3 files changed

+46
-52
lines changed

contracts/contracts/IdentityVerificationHubImplV2.sol

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ contract IdentityVerificationHubImplV2 is ImplRoot {
624624
// Scope 2: Root and date checks
625625
{
626626
_performRootCheck(header.attestationId, vcAndDiscloseProof, indices);
627+
_performOfacCheck(header.attestationId, vcAndDiscloseProof, indices);
627628
if (header.attestationId == AttestationId.AADHAAR) {
628629
_performNumericCurrentDateCheck(vcAndDiscloseProof, indices);
629630
} else {
@@ -705,11 +706,11 @@ contract IdentityVerificationHubImplV2 is ImplRoot {
705706
}
706707
} else if (attestationId == AttestationId.AADHAAR) {
707708
uint256 timestamp = registerCircuitProof.pubSignals[CircuitConstantsV2.AADHAAR_TIMESTAMP_INDEX];
708-
if (timestamp < block.timestamp - 20 minutes) {
709+
if (timestamp < (block.timestamp - 20 minutes)) {
709710
revert InvalidUidaiTimestamp();
710711
}
711712

712-
if (timestamp > block.timestamp + 20 minutes) {
713+
if (timestamp > (block.timestamp + 20 minutes)) {
713714
revert InvalidUidaiTimestamp();
714715
}
715716

@@ -884,6 +885,46 @@ contract IdentityVerificationHubImplV2 is ImplRoot {
884885
}
885886
}
886887

888+
function _performOfacCheck(
889+
bytes32 attestationId,
890+
GenericProofStruct memory vcAndDiscloseProof,
891+
CircuitConstantsV2.DiscloseIndices memory indices
892+
) internal view {
893+
IdentityVerificationHubStorage storage $ = _getIdentityVerificationHubStorage();
894+
895+
if (attestationId == AttestationId.E_PASSPORT) {
896+
if (
897+
!IIdentityRegistryV1($._registries[attestationId]).checkOfacRoots(
898+
vcAndDiscloseProof.pubSignals[indices.passportNoSmtRootIndex],
899+
vcAndDiscloseProof.pubSignals[indices.namedobSmtRootIndex],
900+
vcAndDiscloseProof.pubSignals[indices.nameyobSmtRootIndex]
901+
)
902+
) {
903+
revert InvalidOfacRoots();
904+
}
905+
} else if (attestationId == AttestationId.EU_ID_CARD) {
906+
if (
907+
!IIdentityRegistryIdCardV1($._registries[attestationId]).checkOfacRoots(
908+
vcAndDiscloseProof.pubSignals[indices.namedobSmtRootIndex],
909+
vcAndDiscloseProof.pubSignals[indices.nameyobSmtRootIndex]
910+
)
911+
) {
912+
revert InvalidOfacRoots();
913+
}
914+
} else if (attestationId == AttestationId.AADHAAR) {
915+
if (
916+
!IIdentityRegistryAadhaarV1($._registries[attestationId]).checkOfacRoots(
917+
vcAndDiscloseProof.pubSignals[indices.namedobSmtRootIndex],
918+
vcAndDiscloseProof.pubSignals[indices.nameyobSmtRootIndex]
919+
)
920+
) {
921+
revert InvalidOfacRoots();
922+
}
923+
} else {
924+
revert InvalidAttestationId();
925+
}
926+
}
927+
887928
/**
888929
* @notice Performs current date validation
889930
*/

contracts/contracts/interfaces/IIdentityRegistryAadhaarV1.sol

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,9 @@ interface IIdentityRegistryAadhaarV1 {
7777
* @notice Checks if the provided OFAC roots match the stored OFAC roots.
7878
* @param nameAndDobRoot The name and date of birth OFAC root to verify.
7979
* @param nameAndYobRoot The name and year of birth OFAC root to verify.
80-
* @param nameAndDobReverseRoot The name and date of birth OFAC root to verify.
81-
* @param nameAndYobReverseRoot The name and year of birth OFAC root to verify.
8280
* @return True if all provided roots match the stored values, false otherwise.
8381
*/
84-
function checkOfacRoots(
85-
uint256 nameAndDobRoot,
86-
uint256 nameAndYobRoot,
87-
uint256 nameAndDobReverseRoot,
88-
uint256 nameAndYobReverseRoot
89-
) external view returns (bool);
82+
function checkOfacRoots(uint256 nameAndDobRoot, uint256 nameAndYobRoot) external view returns (bool);
9083

9184
/**
9285
* @notice Checks if the provided UIDAI pubkey is stored in the registry and also if it's not expired.

contracts/contracts/registry/IdentityRegistryAadhaarImplV1.sol

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ abstract contract IdentityRegistryAadhaarStorageV1 is ImplRoot {
6464

6565
/// @notice Current name and year of birth OFAC root.
6666
uint256 internal _nameAndYobOfacRoot;
67-
68-
/// @notice Current name and date of birth reverse OFAC root.
69-
uint256 internal _nameAndDobReverseOfacRoot;
70-
71-
/// @notice Current name and year of birth reverse OFAC root.
72-
uint256 internal _nameAndYobReverseOfacRoot;
7367
}
7468

7569
/**
@@ -253,33 +247,15 @@ contract IdentityRegistryAadhaarImplV1 is IdentityRegistryAadhaarStorageV1, IIde
253247
return _nameAndYobOfacRoot;
254248
}
255249

256-
/// @notice Retrieves the current name and date of birth reverse OFAC root.
257-
/// @return The current name and date of birth reverse OFAC root value.
258-
function getNameAndDobReverseOfacRoot() external view virtual onlyProxy returns (uint256) {
259-
return _nameAndDobReverseOfacRoot;
260-
}
261-
262-
/// @notice Retrieves the current name and year of birth reverse OFAC root.
263-
/// @return The current name and year of birth reverse OFAC root value.
264-
function getNameAndYobReverseOfacRoot() external view virtual onlyProxy returns (uint256) {
265-
return _nameAndYobReverseOfacRoot;
266-
}
267-
268250
/// @notice Validates whether the provided OFAC roots match the stored values.
269251
/// @param nameAndDobRoot The name and date of birth OFAC root to validate.
270252
/// @param nameAndYobRoot The name and year of birth OFAC root to validate.
271253
/// @return True if all provided roots match the stored values, false otherwise.
272254
function checkOfacRoots(
273255
uint256 nameAndDobRoot,
274-
uint256 nameAndYobRoot,
275-
uint256 nameAndDobReverseRoot,
276-
uint256 nameAndYobReverseRoot
256+
uint256 nameAndYobRoot
277257
) external view virtual onlyProxy returns (bool) {
278-
return
279-
_nameAndDobOfacRoot == nameAndDobRoot &&
280-
_nameAndYobOfacRoot == nameAndYobRoot &&
281-
_nameAndDobReverseOfacRoot == nameAndDobReverseRoot &&
282-
_nameAndYobReverseOfacRoot == nameAndYobReverseRoot;
258+
return _nameAndDobOfacRoot == nameAndDobRoot && _nameAndYobOfacRoot == nameAndYobRoot;
283259
}
284260

285261
/// @notice Checks if the provided UIDAI pubkey is stored in the registry and also if it's not expired.
@@ -337,22 +313,6 @@ contract IdentityRegistryAadhaarImplV1 is IdentityRegistryAadhaarStorageV1, IIde
337313
emit NameAndYobOfacRootUpdated(newNameAndYobOfacRoot);
338314
}
339315

340-
/// @notice Updates the name and date of birth reverse OFAC root.
341-
/// @dev Callable only via a proxy and restricted to the contract owner.
342-
/// @param newNameAndDobReverseOfacRoot The new name and date of birth reverse OFAC root value.
343-
function updateNameAndDobReverseOfacRoot(uint256 newNameAndDobReverseOfacRoot) external onlyProxy onlyOwner {
344-
_nameAndDobReverseOfacRoot = newNameAndDobReverseOfacRoot;
345-
emit NameAndDobReverseOfacRootUpdated(newNameAndDobReverseOfacRoot);
346-
}
347-
348-
/// @notice Updates the name and year of birth reverse OFAC root.
349-
/// @dev Callable only via a proxy and restricted to the contract owner.
350-
/// @param newNameAndYobReverseOfacRoot The new name and year of birth reverse OFAC root value.
351-
function updateNameAndYobReverseOfacRoot(uint256 newNameAndYobReverseOfacRoot) external onlyProxy onlyOwner {
352-
_nameAndYobReverseOfacRoot = newNameAndYobReverseOfacRoot;
353-
emit NameAndYobReverseOfacRootUpdated(newNameAndYobReverseOfacRoot);
354-
}
355-
356316
/// @notice Registers a new UIDAI pubkey commitment.
357317
/// @dev Callable only via a proxy and restricted to the contract owner.
358318
/// @param commitment The UIDAI pubkey commitment to register.

0 commit comments

Comments
 (0)