Projects
Overview
Rules Engine Property Manager

Rules Engine Property Manager Overview

Rules Engine Property Manager

The Rules Engine Property Manager (PM) implements the interface for users to verify compliance with customized predefined rules on-chain. It orchestrates and streamlines the verification process by managing a Property associated with Know-Your-Customer (KYC) information and employing the relevant Rule Verifiers, which utilize the corresponding Proof Verifiers.

Upon successful verification, the Rules Engine PM records the validation result on-chain, storing this data in the user's On-chain-Data-Container (ODC) KYC Property under the corresponding RuleKey, which is computed based on the address of the employed Rule Verifier and the Rule ID. These RuleKeys serve as essential tags for organizing and identifying the KYC information within the ODC storage system. ODCs having the KYC Property attached establish an on-chain linkage between their owners and their respective KYC data stored within this Property.

Notably, a Restriction of type TransferRestriction is applied to the KYC Property, preventing the transfer of associated ODCs. As a result, ODCs with the KYC Property are inherently restricted from being transferred, ensuring the integrity of KYC data association with the correct user.


img


In the following sections, we introduce the functions provided by the Rules Engine Property Manager smart contract for user interaction.

Verify

Users can call the verify() function to verify themselves against a specified rule.

This function performs the following tasks:

  • Retrieves the ID of the ODC (owned by the caller) that has the KYC Property. If the caller doesn't own an ODC with this Property, a new ODC is minted to the caller, and the KYC Property is added to the newly minted ODC.
    A Restriction of type TransferRestriction is also applied to this Property.
  • The verify() function of the employed Rule Verifer is invoked with input data such as the ID of the ODC, the ID of the rule and the provided proof data. The execution of this function either reverts (if the input data are invalid) or returns the validity timestamp of the rule for the caller.
  • The retrieved validity timestamp is stored in the ODC's KYC Property under the relevant RuleKey.
/**
 * @notice Verifies the validity of the specified rule for the caller, based on the provided proof.
 * @dev Emits a `Verification` event.
 * @param verifier Address of the RuleVerifier.
 * @param rule ID of the Rule to verify.
 * @param proof Proof data for verification.
 */
function verify(IRuleVerifier verifier, uint256 rule, bytes calldata proof) external;

IsVerified

Users can call the isVerified() function to query the validity of a given rule for the owner of the specified ODC.

This function performs the following tasks:

  • Retrieves the validity timestamp stored in the KYC Property under the provided rKey for the specified ODC.
  • Compares the retrieved validity timestamp with the current block timestamp to determine if the rule is still valid.
/**
 * @dev Checks whether a rule remains valid for a specified user.
 * @param ouid ID of the ODC.
 * @param rkey RuleKey to query.
 * @return bool True if the rule is still valid for the owner of the ODC, false; otherwise.
 */
function isVerified(uint256 ouid, bytes32 rkey) public view returns (bool);

RuleKey

Users can call the ruleKey() function to query the RuleKey associated with the specified Rule Verifier and rule.

/**
 * @dev Returns the RuleKey generated by the rule ID and the Rule Verifier address.
 * @param verifier Address of the Rule Verifier
 * @param rule ID of the rule
 * @return bytes32 The RuleKey generated by the encoding of the params.
 */
function ruleKey(address verifier, uint256 rule) public pure returns (bytes32);