IRevealPolicy Interface
The interface that all reveal policy contracts must implement.
Interface
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IRevealPolicy {
function validate(
bytes32 commitment,
bytes32 nullifier,
address recipient,
uint256 amount,
address token,
bytes calldata policyParams
) external view returns (bool);
}
Parameters
| Parameter | Type | Description |
|---|---|---|
commitment | bytes32 | The commitment being revealed |
nullifier | bytes32 | The derived nullifier |
recipient | address | Address that will receive the minted tokens |
amount | uint256 | Amount being revealed (in base units) |
token | address | Token contract address (address(0) for native GHOST) |
policyParams | bytes | ABI-encoded policy-specific parameters |
Return value
true— reveal is allowedfalse— reveal is rejected (transaction reverts withPolicyValidationFailed)
Execution context
- Called via
staticcall— your contract cannot modify state - Gas limit: 100,000 — keep validation logic efficient
- The function must be
vieworpure
Policy params hash
The policyParamsHash stored in the commitment must match the hash of the policyParams provided during reveal. This is verified inside the ZK circuit, preventing parameter tampering.
The hash is computed as:
policyParamsHash = Poseidon(decodedParamFields...)
The exact encoding depends on the policy implementation.