-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contracts): add standard way to call external verifiers and aggr…
…egate their logic
- Loading branch information
Showing
22 changed files
with
454 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {IChecker} from "./interfaces/IChecker.sol"; | ||
|
||
/// @title Checker | ||
/// @notice Abstract base contract for implementing attribute verification logic. | ||
/// @dev Provides infrastructure to orchestrate third-party verifiers for single checks. | ||
abstract contract Checker is IChecker { | ||
/// @notice Array of third-party contract addresses used for verification. | ||
/// @dev Can include existing and already deployed Checkers, NFTs, MACI polls, and/or any other contract | ||
/// that provides evidence verification. These contracts should already be deployed and operational. | ||
address[] internal verifiers; | ||
|
||
/// @notice Initializes the Checker with an optional list of third-party verification contracts. | ||
/// @param _verifiers Array of addresses for existing verification contracts. | ||
/// @dev Each address should point to a deployed contract that will be consulted during verification. | ||
/// This array can remain empty if there's no reliance on external verifiers. | ||
constructor(address[] memory _verifiers) { | ||
verifiers = _verifiers; | ||
} | ||
|
||
/// @notice Retrieves the list of third-party verifiers' addresses. | ||
/// @return Array of addresses for the necessary verification contracts. | ||
function getVerifiers() internal view returns (address[] memory) { | ||
return verifiers; | ||
} | ||
|
||
/// @notice Retrieves the verifier address at a specific index. | ||
/// @param index The index of the verifier in the array. | ||
/// @return The address of the verifier at the specified index. | ||
/// @custom:throws VerifierNotFound if no address have been specified at given index. | ||
function getVerifierAtIndex(uint256 index) internal view returns (address) { | ||
if (index >= verifiers.length) revert VerifierNotFound(); | ||
|
||
return verifiers[index]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {IChecker} from "./IChecker.sol"; | ||
|
||
/// @title IBaseChecker. | ||
/// @notice Defines base validation functionality. | ||
interface IBaseChecker { | ||
interface IBaseChecker is IChecker { | ||
/// @notice Validates subject against evidence. | ||
/// @param subject Address to validate. | ||
/// @param evidence Validation data. | ||
/// @return checked True if validation passes. | ||
function check(address subject, bytes calldata evidence) external view returns (bool checked); | ||
function check(address subject, bytes[] calldata evidence) external view returns (bool checked); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
/// @title IChecker | ||
/// @notice Core checker interface for attribute verification functionalities. | ||
interface IChecker { | ||
/// @notice Core error conditions. | ||
error VerifierNotFound(); | ||
} |
Oops, something went wrong.