Supported Verifiers
Rule Verifiers
GroupRuleVerifier
The GroupRuleVerifier smart contract implementation facilitates verification based on group membership criteria and employs the GroupZKProofVerifier to verify the Zero-Knowledge proofs (ZK proofs) users submit.
The GroupRule
struct defines the criteria for group membership rules.
Users can be included or excluded from specified groups, with validity periods ensuring timely verification.
/**
* @notice This struct defines the data for Group Rules.
* @param enabled True if the rule is added (i.e., already exists), false; otherwise .
* @param groups The groups specified in the rule (e.g., can be NPA codes, ISO 3166-1, etc.).
* @param operator `1` - include (whitelist feature) or `0` - exclude (blacklist feature) from `groups`.
* @param validityPeriod The Unix timestamp denoting the validity period for this rule verification.
*/
struct GroupRule {
bool enabled;
uint256[] groups;
uint256 operator;
uint256 validityPeriod;
}
The following function is used by the owner of the GroupRuleVerifier to integrate a new Group Rule.
/**
* @notice Adds a new Group Rule.
* @dev The `ruleId` must not be already assigned to an existing Group Rule.
* @dev Emits a `RuleAdded` event.
* @param ruleId The ID to be assigned to the new Group Rule.
* @param rule The data defining the Group Rule.
*/
function addRule(uint256 ruleId, GroupRule calldata rule) external onlyOwner;
Each integrated Group Rule is assigned a distinctive ID. These unique identifiers serve as pivotal keys, enabling efficient organization and retrieval of rule definition data within the contract.
/// @dev Mapping from Rule ID to the associated Rule definition data
mapping(uint256 => GroupRule) public rules;
Users can retrieve the data of a specified Group Rule with the following function:
/**
* @notice Retrieves the data of a specified Group Rule.
* @param ruleId The ID of the Group Rule to query.
*/
function getRule(uint256 ruleId) public view returns (GroupRule memory);
Existing Group Rules can be updated by the owner with the following function:
/**
* @notice Updates the data of an existing Group Rule.
* @dev The `ruleId` must be already assigned to an existing Group Rule.
* @dev Emits a `RuleUpdated` event.
* @param ruleId The ID of the targeted Group Rule.
* @param rule The data defining the Group Rule.
*/
function updateRule(uint256 ruleId, GroupRule calldata rule) external onlyOwner;
Users can prove compliance with a specified Group Rule by providing the ID of the rule and the required ZK proof data.
/**
* @notice Verifies compliance with a specified Group Rule.
* @param ruleId The ID of the targeted Group Rule.
* @param proof The ZK proof data.
* @return The validity timestamp of verification.
*/
function verify(uint256 ruleId, bytes calldata proof) external view returns (uint256 validity);
NumberThresholdRuleVerifier
The NumberThresholdRuleVerifier smart contract implementation facilitates verification against numerical thresholds and employs the NumberThresholdZkProofVerifier to verify the Zero-Knowledge proofs (ZK proofs) users submit.
The NumberRule
struct defines the criteria for number threshold rules.
Users must meet specific numerical criteria, such as age restrictions, with validity periods ensuring timely verification.
/**
* @notice This struct defines the data for Number Threshold Rules.
* @param enabled True if the rule is added (i.e., already exists), false; otherwise.
* @param numberThreshold The numerical value defining the threshold.
* @param operator `1` for >= or `0` for < the `numberThreshold`.
* @param validityPeriod The Unix timestamp denoting the validity period for this rule verification.
*/
struct NumberRule {
bool enabled;
uint256 numberThreshold;
uint256 operator;
uint256 validityPeriod;
}
The following function is used by the owner of the NumberThresholdRuleVerifier to integrate a new Number Threshold Rule.
/**
* @notice Adds a new Number Threshold Rule.
* @dev The `ruleId` must not be already assigned to an existing Number Threshold Rule.
* @dev Emits a `RuleAdded` event.
* @param ruleId The ID to be assigned to the new Number Threshold Rule.
* @param rule The data defining the Number Threshold Rule.
*/
function addRule(uint256 ruleId, NumberRule calldata rule) external onlyOwner;
Each integrated Number Threshold Rule is assigned a distinctive ID. These unique identifiers serve as pivotal keys, enabling efficient organization and retrieval of rule definition data within the contract.
/// @dev Mapping from Rule ID to the associated Rule definition data
mapping(uint256 => NumberRule) public rules;
Users can retrieve the data of a specified Number Threshold Rule with the following function:
/**
* @notice Retrieves the data of a specified Number Threshold Rule.
* @param ruleId The ID of the Number Threshold Rule to query.
*/
function getRule(uint256 ruleId) public view returns (NumberRule memory);
Existing Number Threshold Rules can be updated by the owner with the following function:
/**
* @notice Updates the data of an existing Number Threshold Rule.
* @dev The `ruleId` must be already assigned to an existing Number Threshold Rule.
* @dev Emits a `RuleUpdated` event.
* @param ruleId The ID of the targeted Number Threshold Rule.
* @param rule The data defining the Number Threshold Rule.
*/
function updateRule(uint256 ruleId, NumberRule calldata rule) external onlyOwner;
Users can prove compliance with a specified Number Threshold Rule by providing the ID of the rule and the required ZK proof data.
/**
* @notice Verifies compliance with a specified Number Threshold Rule.
* @param ruleId The ID of the targeted Number Threshold Rule.
* @param proof The ZK proof data.
* @return The validity timestamp of verification.
*/
function verify(uint256 ruleId, bytes calldata proof) external view returns (uint256 validity);