/** * Spend Policy Encoding & Verification * * Encodes human-readable spend policies into Bolyra's permission bitmask format * for ZKP circuit consumption. The encoded policy becomes a private input to the * AgentPolicy circuit — the verifier learns only that the policy is satisfied, * never the actual limits. * * Encoding scheme (fits in a single 253-bit BN254 scalar): * Bits 0-2: Base permission tier (from Bolyra Permission enum) * Bits 3-6: Amount tier (log-scale encoding of maxTransactionAmount) * Bits 7-10: Cumulative tier (log-scale encoding of maxCumulativeAmount) * Bits 11-14: Time window tier (duration bucket) * Bits 15-22: Category mask (top-8 MCC groups) * Bits 23-30: Vendor hash prefix (first 8 bits of Poseidon hash of vendor list) * Bits 31-62: Reserved for future extensions */ import type { SpendPolicy } from './types'; /** * Encode a spend policy into Bolyra's permission bitmask format. * * The resulting bigint can be used as the `permissionBitmask` field in an * AgentCredential, or as a private input to the AgentPolicy circuit. * * @param policy - The spend policy to encode * @returns The encoded permission bitmask (fits in 63 bits) */ export declare function encodeSpendPolicy(policy: SpendPolicy): bigint; /** * Decode the permission tier from an encoded bitmask. */ export declare function decodePermissionTier(bitmask: bigint): number; /** * Decode the amount tier from an encoded bitmask. */ export declare function decodeAmountTier(bitmask: bigint): number; /** * Decode the cumulative tier from an encoded bitmask. */ export declare function decodeCumulativeTier(bitmask: bigint): number; /** * Decode the time window tier from an encoded bitmask. */ export declare function decodeTimeTier(bitmask: bigint): number; /** * Decode the category mask from an encoded bitmask. */ export declare function decodeCategoryMask(bitmask: bigint): number; /** * Verify that a ZKP-proven spend policy meets a required policy. * * This is the merchant-side check: given the encoded bitmask from the agent's * ZKP proof (public signal), verify it satisfies the merchant's requirements. * The merchant never learns the actual policy — only that it is sufficient. * * @param provenBitmask - The permission bitmask from the ZKP public signals * @param requiredPolicy - The merchant's minimum required policy * @returns Object with `satisfied` boolean and human-readable `reasons` for failures */ export declare function verifySpendPolicyProof(provenBitmask: bigint, requiredPolicy: { minTransactionAmount?: number; minCumulativeAmount?: number; minDurationSeconds?: number; requiredMCCs?: string[]; }): { satisfied: boolean; reasons: string[]; }; /** * Get the amount tier thresholds (useful for UI display). */ export declare function getAmountTiers(): readonly number[]; /** * Get the time window tier thresholds (useful for UI display). */ export declare function getTimeWindowTiers(): readonly number[];