-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full Multi-query support onchain #321
base: master
Are you sure you want to change the base?
Changes from 44 commits
bf71699
74b24a1
16a8b27
f05104d
779513f
8da12c7
ba75a5d
ae9cec1
790a0e3
1858dce
4527834
bb82ff3
e66a160
d416b9a
a26861c
0c2e792
16f8b5a
4afb814
8f55467
657fa6c
46d17ab
1e7b877
2942cdf
a91c1e7
849e790
a02592c
6b82ff0
d35e4b4
3811b9c
4030067
6135f84
b860ab0
fc7bc91
c3bb7e3
14d08fb
3734eb5
4c8e01d
24888ad
14ca44b
636f590
88ff859
fb2a5b4
faa2d0b
a8c8653
6336ad5
31aa30b
a30dbfd
c6077eb
d31f2ca
7ad4411
7005a64
85804dd
1d49a4e
4a9e988
81fdf83
034de2c
10eb73d
ca1f04f
188bb13
ffe4e6e
f607131
848e609
4bac7da
1e9c474
d510368
296bb68
78610dd
1641d15
9f33dec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.27; | ||
|
||
import {IState} from "./IState.sol"; | ||
|
||
/** | ||
* @dev IAuthValidator. Interface for verification of auth data. | ||
*/ | ||
interface IAuthValidator { | ||
/** | ||
* @dev ResponseField. Information about response fields from verification. Used in verify function. | ||
* @param name Name of the response field | ||
* @param value Value of the response field | ||
*/ | ||
struct ResponseField { | ||
string name; | ||
uint256 value; | ||
} | ||
|
||
/** | ||
* @dev Get version of the contract | ||
*/ | ||
function version() external view returns (string memory); | ||
|
||
/** | ||
* @dev Verify the proof with the supported method informed in the auth query data | ||
* packed as bytes and that the proof was generated by the sender. | ||
* @param proof Proof packed as bytes to verify. | ||
* @param data Request query data of the credential to verify. | ||
* @param sender Sender of the proof. | ||
* @param state State contract to get identities and gist states to check. | ||
* @return Array of response fields as result. | ||
*/ | ||
function verify( | ||
bytes calldata proof, | ||
bytes calldata data, | ||
address sender, | ||
IState state | ||
) external returns (ResponseField[] memory); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just return bool, as agreed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will return |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.27; | ||
|
||
/** | ||
* @dev IGroth16Verifier. Interface for verification of groth16 proofs. | ||
*/ | ||
interface IGroth16Verifier { | ||
/** | ||
* @dev Verify the circuit with the groth16 proof π=([πa]1,[πb]2,[πc]1). | ||
* @param a πa element of the groth16 proof. | ||
* @param b πb element of the groth16 proof. | ||
* @param c πc element of the groth16 proof. | ||
* @param input Public inputs of the circuit. | ||
* @return r true if the proof is verified. | ||
*/ | ||
function verify( | ||
uint256[2] calldata a, | ||
uint256[2][2] calldata b, | ||
uint256[2] calldata c, | ||
uint256[] calldata input | ||
) external view returns (bool r); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity 0.8.27; | ||
|
||
import {IState} from "./IState.sol"; | ||
|
||
/** | ||
* @dev IRequestValidator. Interface for verification of request query data. | ||
*/ | ||
interface IRequestValidator { | ||
/** | ||
* @dev ResponseField. Information about response fields from verification. Used in verify function. | ||
* @param name Name of the response field | ||
* @param value Value of the response field | ||
*/ | ||
struct ResponseField { | ||
string name; | ||
uint256 value; | ||
} | ||
|
||
/** | ||
* @dev Get version of the contract | ||
*/ | ||
function version() external view returns (string memory); | ||
|
||
/** | ||
* @dev Verify the proof with the supported method informed in the request query data | ||
* packed as bytes and that the proof was generated by the sender. | ||
* @param proof Proof packed as bytes to verify. | ||
* @param data Request query data of the credential to verify. | ||
* @param sender Sender of the proof. | ||
* @param state State contract to get identities and gist states to check. | ||
* @return Array of response fields as result. | ||
*/ | ||
function verify( | ||
bytes calldata proof, | ||
bytes calldata data, | ||
daveroga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
address sender, | ||
IState state | ||
) external returns (ResponseField[] memory); | ||
|
||
/** | ||
* @dev Get the group ID of the request query data. | ||
* @param params Request query data of the credential to verify. | ||
* @return Group ID of the request query data. | ||
*/ | ||
function getGroupID(bytes calldata params) external view returns (uint256); | ||
|
||
/** | ||
* @dev Get the verifier ID of the request query data. | ||
* @param params Request query data of the credential to verify. | ||
* @return Verifier ID encoded in the request query data. | ||
*/ | ||
function getVerifierId(bytes calldata params) external view returns (uint256); | ||
daveroga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,265 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity 0.8.27; | ||
|
||
import {IAuthValidator} from "./IAuthValidator.sol"; | ||
import {IRequestValidator} from "./IRequestValidator.sol"; | ||
|
||
/** | ||
* @dev IVerifier. Interface for verification of groth16 proofs. | ||
* @dev IVerifier. Interface for verification of groth16 proofs for validators circuits. | ||
*/ | ||
interface IVerifier { | ||
/** | ||
* @dev Verify the circuit with the groth16 proof π=([πa]1,[πb]2,[πc]1). | ||
* @param a πa element of the groth16 proof. | ||
* @param b πb element of the groth16 proof. | ||
* @param c πc element of the groth16 proof. | ||
* @param input Public inputs of the circuit. | ||
* @return r true if the proof is verified. | ||
*/ | ||
function verify( | ||
uint256[2] calldata a, | ||
uint256[2][2] calldata b, | ||
uint256[2] calldata c, | ||
uint256[] calldata input | ||
) external view returns (bool r); | ||
* @dev Request. Structure for request. | ||
* @param requestId Request id. | ||
* @param metadata Metadata of the request. | ||
* @param validator Validator to verify the response. | ||
* @param params Parameters data of the request. | ||
*/ | ||
struct Request { | ||
uint256 requestId; | ||
string metadata; | ||
IRequestValidator validator; | ||
bytes params; | ||
} | ||
|
||
/** | ||
* @dev Request. Structure for request for storage. | ||
* @param metadata Metadata of the request. | ||
* @param validator Validator circuit. | ||
* @param params Params of the request. Proof parameters could be ZK groth16, plonk, ESDSA, EIP712, etc. | ||
*/ | ||
struct RequestData { | ||
string metadata; | ||
IRequestValidator validator; | ||
bytes params; | ||
address creator; | ||
uint256 verifierId; | ||
} | ||
|
||
/** | ||
* @dev RequestInfo. Structure for request info. | ||
* @param requestId Request id. | ||
* @param metadata Metadata of the request. | ||
* @param validator Validator to verify the response. | ||
* @param params Parameters data of the request. | ||
* @param creator Creator of the request. | ||
* @param verifierId Verifier id. | ||
* @param isVerifierAuthenticated True if the verifier is authenticated. | ||
*/ | ||
struct RequestInfo { | ||
uint256 requestId; | ||
string metadata; | ||
IRequestValidator validator; | ||
bytes params; | ||
address creator; | ||
uint256 verifierId; | ||
bool isVerifierAuthenticated; | ||
} | ||
/** | ||
* @dev AuthProofStatus. Structure for auth proof status. | ||
* @param groupId Group id of the requests. | ||
* @param requests Requests of the group. | ||
*/ | ||
struct GroupedRequests { | ||
uint256 groupId; | ||
Request[] requests; | ||
} | ||
|
||
/** | ||
* @dev ProofStatus. Structure for proof status. | ||
* @param isVerified True if the proof is verified. | ||
* @param validatorVersion Version of the validator. | ||
* @param blockTimestamp Block timestamp of the proof. | ||
*/ | ||
struct ProofStatus { | ||
bool isVerified; | ||
string validatorVersion; | ||
uint256 blockTimestamp; | ||
} | ||
|
||
/** | ||
* @dev Response. Structure for response. | ||
* @param requestId Request id of the request. | ||
* @param proof proof to verify. | ||
* @param metadata Metadata of the request. | ||
*/ | ||
struct Response { | ||
uint256 requestId; | ||
bytes proof; | ||
bytes metadata; | ||
} | ||
/** | ||
* @dev GroupedResponses. Structure for grouped responses. | ||
* @param groupId Group id of the responses. | ||
* @param responses Responses of the group. | ||
*/ | ||
struct GroupedResponses { | ||
uint256 groupId; | ||
Response[] responses; | ||
} | ||
/** | ||
* @dev AuthResponse. Structure for auth response. | ||
* @param authType Auth type of the proof response. | ||
* @param proof proof to verify. | ||
*/ | ||
struct AuthResponse { | ||
string authType; //zkp-auth-v2, zkp-auth-v3, etc. will deside later | ||
bytes proof; | ||
} | ||
|
||
/** | ||
* @dev RequestProofStatus. Structure for request proof status. | ||
* @param requestId Request id of the proof. | ||
* @param isVerified True if the proof is verified. | ||
* @param validatorVersion Version of the validator. | ||
* @param timestamp Timestamp of the proof. | ||
*/ | ||
struct RequestProofStatus { | ||
uint256 requestId; | ||
bool isVerified; | ||
string validatorVersion; | ||
uint256 timestamp; | ||
} | ||
|
||
struct AuthType { | ||
string authType; | ||
IAuthValidator validator; | ||
bytes params; | ||
} | ||
|
||
/** | ||
* @dev AuthProofStatus. Structure for auth proof status. | ||
* @param authType Auth type of the auth proof. | ||
* @param isVerified True if the proof is verified. | ||
* @param validatorVersion Version of the validator. | ||
* @param timestamp Timestamp of the proof. | ||
*/ | ||
struct AuthProofStatus { | ||
string authType; | ||
bool isVerified; | ||
string validatorVersion; | ||
uint256 timestamp; | ||
} | ||
|
||
/** | ||
* @dev Query. Structure for query. | ||
* @param queryId Query id. | ||
* @param requestIds Request ids for this multi query (without groupId. Single requests). | ||
* @param groupIds Group ids for this multi query (all the requests included in the group. Grouped requests). | ||
* @param metadata Metadata for the query. Empty in first version. | ||
*/ | ||
struct Query { | ||
uint256 queryId; | ||
uint256[] requestIds; | ||
uint256[] groupIds; | ||
bytes metadata; | ||
} | ||
|
||
/** | ||
* @dev Submits an array of responses and updates proofs status | ||
* @param authResponses The list of auth responses including auth type and proof | ||
* @param singleResponses The list of responses including request ID, proof and metadata for single requests | ||
* @param groupedResponses The list of responses including request ID, proof and metadata for grouped requests | ||
* @param crossChainProofs The list of cross chain proofs from universal resolver (oracle). This | ||
* includes identities and global states. | ||
*/ | ||
function submitResponse( | ||
AuthResponse[] memory authResponses, | ||
Response[] memory singleResponses, | ||
GroupedResponses[] memory groupedResponses, | ||
bytes memory crossChainProofs | ||
) external; | ||
|
||
/** | ||
* @dev Sets different requests | ||
* @param singleRequests The requests that are not in any group | ||
* @param groupedRequests The requests that are in a group | ||
*/ | ||
function setRequests( | ||
Request[] calldata singleRequests, | ||
GroupedRequests[] calldata groupedRequests | ||
) external; | ||
|
||
/** | ||
* @dev Gets a specific request by ID | ||
* @param requestId The ID of the request | ||
* @return request The request info | ||
*/ | ||
function getRequest(uint256 requestId) external view returns (RequestInfo memory request); | ||
|
||
/** | ||
* @dev Get the requests count. | ||
* @return Requests count. | ||
*/ | ||
function getRequestsCount() external view returns (uint256); | ||
|
||
/** | ||
* @dev Checks if a request ID exists | ||
* @param requestId The ID of the request | ||
* @return Whether the request ID exists | ||
*/ | ||
function requestIdExists(uint256 requestId) external view returns (bool); | ||
|
||
/** | ||
* @dev Gets the status of the query verification | ||
* @param queryId The ID of the query | ||
* @param userAddress The address of the user | ||
* @return status The status of the query. "True" if all requests are verified, "false" otherwise | ||
*/ | ||
function getQueryStatus( | ||
uint256 queryId, | ||
address userAddress | ||
) external view returns (AuthProofStatus[] memory, RequestProofStatus[] memory); | ||
|
||
/** | ||
* @dev Gets proof storage response field value | ||
* @param requestId Id of the request | ||
* @param userID Id of the user | ||
* @param responseFieldName Name of the proof storage response field to get | ||
*/ | ||
function getResponseFieldValue( | ||
uint256 requestId, | ||
uint256 userID, | ||
string memory responseFieldName | ||
) external view returns (uint256); | ||
|
||
/** | ||
* @dev Get if proof is verified for the sender and request with requestId. | ||
* @param sender Sender of the proof. | ||
* @param requestId Request id of the Request to verify. | ||
* @return True if proof is verified for the sender and request id. | ||
*/ | ||
function isProofVerified(address sender, uint256 requestId) external view returns (bool); | ||
|
||
/** | ||
* @dev Sets an auth type | ||
* @param authType The auth type to add | ||
*/ | ||
function setAuthType(AuthType calldata authType) external; | ||
|
||
/** | ||
* @dev Sets a query | ||
* @param queryId The ID of the query | ||
* @param query The query data | ||
*/ | ||
function setQuery(uint256 queryId, Query calldata query) external; | ||
daveroga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @dev Gets a specific multi query by ID | ||
* @param queryId The ID of the multi query | ||
* @return query The query data | ||
*/ | ||
function getQuery(uint256 queryId) external view returns (IVerifier.Query memory query); | ||
|
||
/** | ||
* @dev Get the proof status for the sender and request with requestId. | ||
* @param sender Sender of the proof. | ||
* @param requestId Request id of the proof. | ||
* @return Proof status. | ||
*/ | ||
function getProofStatus( | ||
address sender, | ||
uint256 requestId | ||
) external view returns (ProofStatus memory); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we agreed, we don't need this struct in IAuthValidator