// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

/**
 * @title MockFalcon512Verifier
 * @notice Test-only stand-in for AereFalcon512Verifier used by the AereHybridAuth
 *         unit tests. Real Falcon-512 signatures cannot be produced inside the
 *         hardhat test process, so the Falcon leg is mocked with a settable
 *         result while the on-chain (mainnet) demonstration uses the LIVE
 *         AereFalcon512Verifier with a genuine reference-generated signature.
 *
 *         By default it echoes acceptance from a per-(pk,message,nonce,compSig)
 *         allowlist so tests can assert both accept and reject paths precisely.
 */
contract MockFalcon512Verifier {
    bool public defaultResult;
    mapping(bytes32 => bool) public accept; // keccak(pk,message,nonce,compSig) => result override
    mapping(bytes32 => bool) private _hasOverride;

    function setDefault(bool v) external {
        defaultResult = v;
    }

    function setResult(
        bytes calldata pk,
        bytes calldata message,
        bytes calldata nonce,
        bytes calldata compSig,
        bool v
    ) external {
        bytes32 k = keccak256(abi.encode(pk, message, nonce, compSig));
        accept[k] = v;
        _hasOverride[k] = true;
    }

    function verify(
        bytes memory pk,
        bytes memory message,
        bytes memory nonce,
        bytes memory compSig
    ) external view returns (bool) {
        bytes32 k = keccak256(abi.encode(pk, message, nonce, compSig));
        if (_hasOverride[k]) return accept[k];
        return defaultResult;
    }
}
