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

/**
 * @title  IAerePQCOrder — post-quantum-authorized ERC-7683 cross-chain intent types
 *
 * @notice Shared header for the PQC intent path. A {PQCGaslessOrder} is the exact
 *         ERC-7683 gasless-order shape used by {AereSpokePool.openForPQC}, except the
 *         off-chain authorization is a NIST post-quantum signature (Falcon-512/1024,
 *         ML-DSA-44, SLH-DSA-128s) instead of an ECDSA secp256k1 signature. The order
 *         is therefore quantum-durable end to end: the message a solver's fill settles
 *         against was authorized only by a lattice/hash signature that a quantum
 *         adversary cannot forge, and it is verified on-chain by AERE's live native
 *         PQC precompiles routed through the governed crypto-agility registry.
 *
 * @dev    orderData reuses the SAME "AereV3Order" ABI encoding as the ECDSA path:
 *           (address inputToken, uint256 inputAmount, address outputToken,
 *            uint256 outputAmount, bytes32 recipient, uint64 destinationChainId)
 *         so an existing ERC-7683 / Across V3 solver fills a PQC-authorized order with
 *         no changes; only the AUTHORIZATION leg differs.
 */

/// @notice A gasless ERC-7683 order whose authorization is a post-quantum signature.
/// @param user           the funder: it must have bound `pubKey` (bindPQCKey) and
///                        approved the settler to pull `inputToken`. Anyone may relay.
/// @param nonce          per-user PQC replay nonce (monotonic; must equal the settler's
///                        current pqcNonce[user]).
/// @param originChainId  the intent's origin chain id; must equal the settler's chain.
/// @param openDeadline   relay-by timestamp (the order can be opened until then).
/// @param fillDeadline   ERC-7683 fill-by timestamp for the destination fill.
/// @param algorithmId    the requested crypto-agility registry scheme id. 0 means
///                        "use the authorizer's governed default". The value is
///                        resolveActive'd at open time, so a Foundation scheme swap
///                        migrates the accepted scheme with ZERO redeploy.
/// @param orderDataType  the order-data discriminator (must be the settler's AERE type).
/// @param orderData      the AereV3Order-encoded intent payload (see above).
struct PQCGaslessOrder {
    address user;
    uint256 nonce;
    uint256 originChainId;
    uint32 openDeadline;
    uint32 fillDeadline;
    uint256 algorithmId;
    bytes32 orderDataType;
    bytes orderData;
}

/**
 * @notice The PQC-order authorizer surface a settler consumes. A crypto-agility
 *         CONSUMER over AereCryptoRegistry: it computes the EIP-712 order digest and
 *         verifies the post-quantum signature through the registry's routed native
 *         verifier under whatever scheme is currently ACTIVE (resolveActive), so
 *         scheme migration requires no settler redeploy.
 */
interface IAerePQCOrderAuthorizer {
    /// @notice The EIP-712 digest (the 32-byte message the PQC key signs) for `order`
    ///         authorized by `pubKey`, domain-separated to `settler`.
    function orderDigest(address settler, PQCGaslessOrder calldata order, bytes calldata pubKey)
        external
        view
        returns (bytes32);

    /// @notice Fail-closed: true iff `signature` is a valid post-quantum signature by
    ///         `pubKey` over {orderDigest}(settler, order, pubKey), under the ACTIVE
    ///         scheme reachable from `order.algorithmId` (0 => governed default).
    ///         Never reverts: any registry revert (unknown id, dead-end/cyclic
    ///         successor chain, hash-only or revoked scheme, malformed input) is
    ///         reported as `false`.
    function checkOrder(address settler, PQCGaslessOrder calldata order, bytes calldata pubKey, bytes calldata signature)
        external
        view
        returns (bool);
}
