Skip to content

Commit

Permalink
Discussion result
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriianChestnykh committed Dec 3, 2024
1 parent 46d17ab commit 7038a4d
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 21 deletions.
3 changes: 3 additions & 0 deletions contracts/interfaces/IRequestValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {IState} from "./IState.sol";
* @dev IRequestValidator. Interface for verification of request query data.
*/
interface IRequestValidator {

Check failure on line 10 in contracts/interfaces/IRequestValidator.sol

View workflow job for this annotation

GitHub Actions / solhint

Delete ⏎
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
Expand Down
60 changes: 39 additions & 21 deletions contracts/verifiers/UniversalVerifierMultiQuery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;

Check failure on line 92 in contracts/verifiers/UniversalVerifierMultiQuery.sol

View workflow job for this annotation

GitHub Actions / solhint

Delete ⏎
mapping(uint256 groupId => uint256[] requestIds) _groupedRequests;

Check failure on line 94 in contracts/verifiers/UniversalVerifierMultiQuery.sol

View workflow job for this annotation

GitHub Actions / solhint

Replace ⏎ with ········
// 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
Expand Down
103 changes: 103 additions & 0 deletions contracts/verifiers/query1.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
]
}
}
83 changes: 83 additions & 0 deletions contracts/verifiers/query2.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
]
}
}

0 comments on commit 7038a4d

Please sign in to comment.