diff --git a/contracts/interfaces/IRequestValidator.sol b/contracts/interfaces/IRequestValidator.sol index a66729d9..fd97195f 100644 --- a/contracts/interfaces/IRequestValidator.sol +++ b/contracts/interfaces/IRequestValidator.sol @@ -7,6 +7,9 @@ import {IState} from "./IState.sol"; * @dev IRequestValidator. Interface for verification of request query data. */ interface IRequestValidator { + + function getGroupID(bytes params) external view returns (uint256); + /** * @dev ResponseField. Information about response fields from verification. Used in verify function. * @param name Name of the response field diff --git a/contracts/verifiers/UniversalVerifierMultiQuery.sol b/contracts/verifiers/UniversalVerifierMultiQuery.sol index 3949fa7d..1f312a56 100644 --- a/contracts/verifiers/UniversalVerifierMultiQuery.sol +++ b/contracts/verifiers/UniversalVerifierMultiQuery.sol @@ -52,32 +52,13 @@ contract UniversalVerifierMultiQuery is Ownable2StepUpgradeable { * @param metadata Metadata of the request. */ struct Response { - uint256 queryId; uint256 requestId; - //uint256 groupId; // TODO: We remove from response and add to the query groupIdFromRequestId bytes proof; bytes metadata; } - // TODO discussion result start - // struct ResponseFieldFromRequest { - // uint256 requestId; - // string responseFieldName; - // uint256 groupId; - // } - // - //ResponseFieldFromRequest[][] - - // [ - // [{linkID, 1, 0}, {linkID, 2, 0}] - // [{linkID, 2, 2}, {linkID, 3, 1}], - // [{issuerID, 2, 3}, {issuer, 3, 4}], - // ] - // TODO discussion result start - struct ResponseFieldFromRequest { uint256 requestId; - uint256 groupId; string responseFieldName; } @@ -90,16 +71,53 @@ contract UniversalVerifierMultiQuery is Ownable2StepUpgradeable { struct Query { uint256 queryId; uint256[] requestIds; - uint256[] groupIdFromRequests; // TODO: We need it to know the group id of the request ResponseFieldFromRequest[][] linkedResponseFields; // this are response fields linked between requests bytes metadata; } + //ResponseFieldFromRequest[][] + // [ + // [ + // {1, linkID}, {200, linkID} + // ], + // [ + // {2, linkID}, {201, linkID} + // ] + // ] /// @custom:storage-location erc7201:iden3.storage.UniversalVerifierMultiQuery struct UniversalVerifierMultiQueryStorage { // Information about requests - mapping(uint256 queryId => mapping(uint256 groupId => mapping(uint256 requestId => mapping(uint256 userID => Proof)))) _proofs; + mapping(uint256 requestId => mapping(uint256 userID => Proof)) _proofs; mapping(uint256 requestId => Request) _requests; + + mapping(uint256 groupId => uint256[] requestIds) _groupedRequests; + +// 1. Set Req 1 (groupID = 1) + // Check that groupID doesn't exist yet +// 2. Set Req 2 (groupID = 1) + // Check that groupID doesn't exist yet +// 3. Set Req 200 (groupID = 1) + // Check that groupID doesn't exist yet + +// 4. Set Req 3 (groupID = 2) +// 5. Set Req 201 (groupID = 2) + +// 6. setQuery[1,2] + // Check that groupID doesn't exist yet +// 1 => [1, 2] +// 2 => [3, 201] + +// 7. submitResponse: requests 1, 2, 200 +// 7.1 Check that all the group are full +// 7.2 Check LinkID is the same for each of the groups + +// 8. getQueryStatus: it result to FALSE cuz requests 3 and 201 are false +// 9. submitResponse: requests 3,201 +// 10. getQueryStatus: it result to TRUE as all requests are true + + // Query1 => (1, 2, 200), (3, 201) + // Query2 => (1, 2, 200), 10 + uint256[] _requestIds; IState _state; // Information about queries diff --git a/contracts/verifiers/query1.json b/contracts/verifiers/query1.json new file mode 100644 index 00000000..97876eb4 --- /dev/null +++ b/contracts/verifiers/query1.json @@ -0,0 +1,103 @@ +{ + "id": "f8aee09d-f592-4fcc-8d2a-8938aa26676c", + "typ": "application/iden3comm-plain-json", + "type": "https://iden3-communication.io/authorization/1.0/request", + "thid": "f8aee09d-f592-4fcc-8d2a-8938aa26676c", + "from": "did:polygonid:polygon:mumbai:2qFroxB5kwgCxgVrNGUM6EW3khJgCdHHnKTr3VnTcp", + "body": { + "callbackUrl": "https://test.com/callback", + "reason": "age verification", + "message": "test message", + "scope": [ + { + "id": 1, + "circuitId": "credentialAtomicQueryV3", + "params": { + "nullifierSessionId" : "123443290439234342342423423423423" + }, + "query": { + "groupId": 1, + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "KYCEmployee", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + }, + { + "id": 2, + "circuitId": "credentialAtomicQueryV3", + "params": { + "nullifierSessionId" : "123443290439234342342423423423423" + }, + "query": { + "groupId": 1, + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "KYCEmployee", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + }, + { + "id": 200, + "circuitId": "LinkedMultiQuery", + "query": { + "groupId" : 1, + "credentialSubject": { + "bithdate": { + "$lt": "20010101", + "$gt": "19900101" + }, + "country": { + "$eq": "20010101" + } + } + } + }, + { + "id": 3, + "circuitId": "credentialAtomicQueryV3", + "params": { + "nullifierSessionId" : "123443290439234342342423423423423" + }, + "query": { + "groupId": 1, + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "KYCEmployee", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + }, + { + "id": 201, + "circuitId": "LinkedMultiQuery", + "query": { + "groupId" : 2, + "credentialSubject": { + "bithdate": { + "$lt": "20010101", + "$gt": "19900101" + }, + "country": { + "$eq": "20010101" + } + } + } + } + ] + } +} diff --git a/contracts/verifiers/query2.json b/contracts/verifiers/query2.json new file mode 100644 index 00000000..b044a878 --- /dev/null +++ b/contracts/verifiers/query2.json @@ -0,0 +1,83 @@ +{ + "id": "f8aee09d-f592-4fcc-8d2a-8938aa26676c", + "typ": "application/iden3comm-plain-json", + "type": "https://iden3-communication.io/authorization/1.0/request", + "thid": "f8aee09d-f592-4fcc-8d2a-8938aa26676c", + "from": "did:polygonid:polygon:mumbai:2qFroxB5kwgCxgVrNGUM6EW3khJgCdHHnKTr3VnTcp", + "body": { + "callbackUrl": "https://test.com/callback", + "reason": "age verification", + "message": "test message", + "scope": [ + { + "id": 1, + "circuitId": "credentialAtomicQueryV3", + "params": { + "nullifierSessionId" : "123443290439234342342423423423423" + }, + "query": { + "groupId": 1, + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "KYCEmployee", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + }, + { + "id": 2, + "circuitId": "credentialAtomicQueryV3", + "params": { + "nullifierSessionId" : "123443290439234342342423423423423" + }, + "query": { + "groupId": 1, + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "KYCEmployee", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + }, + { + "id": 200, + "circuitId": "LinkedMultiQuery", + "query": { + "groupId" : 1, + "credentialSubject": { + "bithdate": { + "$lt": "20010101", + "$gt": "19900101" + }, + "country": { + "$eq": "20010101" + } + } + } + }, + { + "id": 10, + "circuitId": "credentialAtomicQueryV3", + "query": { + "proofType": "BJJSignature", + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", + "type": "AgeCredential", + "credentialSubject": { + "position": { + "$eq": "developer" + } + } + } + } + ] + } +}