Skip to content

Commit

Permalink
address centered model instead of userID and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Jan 8, 2025
1 parent 7ad4411 commit 7005a64
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 526 deletions.
30 changes: 6 additions & 24 deletions contracts/interfaces/IVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ interface IVerifier {
* @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;
Expand All @@ -54,10 +53,9 @@ interface IVerifier {
bytes params;
address creator;
uint256 verifierId;
bool isVerifierAuthenticated;
}
/**
* @dev AuthProofStatus. Structure for auth proof status.
* @dev GroupedRequests. Structure for auth proof status.
* @param groupId Group id of the requests.
* @param requests Requests of the group.
*/
Expand Down Expand Up @@ -128,20 +126,6 @@ interface IVerifier {
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 MultiRequest. Structure for multiRequest.
* @param multiRequestId MultiRequest id.
Expand Down Expand Up @@ -171,12 +155,10 @@ interface IVerifier {

/**
* @dev Sets different requests
* @param singleRequests The requests that are not in any group
* @param groupedRequests The requests that are in a group
* @param requests List of requests
*/
function setRequests(

Check failure on line 160 in contracts/interfaces/IVerifier.sol

View workflow job for this annotation

GitHub Actions / solhint

Replace ⏎········Request[]·calldata·requests⏎···· with Request[]·calldata·requests
Request[] calldata singleRequests,
GroupedRequests[] calldata groupedRequests
Request[] calldata requests
) external;

/**
Expand Down Expand Up @@ -208,17 +190,17 @@ interface IVerifier {
function getMultiRequestStatus(
uint256 multiRequestId,
address userAddress
) external view returns (AuthProofStatus[] memory, RequestProofStatus[] memory);
) external view returns (RequestProofStatus[] memory);

/**
* @dev Gets proof storage response field value
* @param requestId Id of the request
* @param userID Id of the user
* @param sender Address of the user
* @param responseFieldName Name of the proof storage response field to get
*/
function getResponseFieldValue(
uint256 requestId,
uint256 userID,
address sender,
string memory responseFieldName
) external view returns (uint256);

Expand Down
31 changes: 3 additions & 28 deletions contracts/lib/VerifierLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ library VerifierLib {
/**
* @dev Writes proof results.
* @param requestId The request ID of the proof
* @param userID The userID of the proof
* @param sender The address of the sender of the proof
* @param responseFields The array of response fields of the proof
*/
function writeProofResults(
Verifier.VerifierStorage storage self,
uint256 requestId,
uint256 userID,
address sender,
IRequestValidator.ResponseField[] memory responseFields
) public {
Proof[] storage proofs = self._proofs[requestId][userID];
Proof[] storage proofs = self._proofs[requestId][sender];
// We only keep only 1 proof now without history. Prepared for the future if needed.
if (proofs.length == 0) {
proofs.push();
Expand All @@ -63,29 +63,4 @@ library VerifierLib {
proofs[0].validatorVersion = self._requests[requestId].validator.version();
proofs[0].blockTimestamp = block.timestamp;
}

/**
* @dev Writes proof results.
* @param authType The auth type of the proof
* @param userID The userID of the proof
* @param responseFields The array of response fields of the proof
*/
function writeAuthProofResults(
Verifier.VerifierStorage storage self,
string memory authType,
uint256 userID,
IAuthValidator.ResponseField[] memory responseFields
) public {
AuthProof[] storage proofs = self._authProofs[authType][userID];
if (proofs.length == 0) {
proofs.push();
}
for (uint256 i = 0; i < responseFields.length; i++) {
proofs[0].storageFields[responseFields[i].name] = responseFields[i].value;
}

proofs[0].isVerified = true;
proofs[0].validatorVersion = self._authMethods[authType].validator.version();
proofs[0].blockTimestamp = block.timestamp;
}
}
Loading

0 comments on commit 7005a64

Please sign in to comment.