import { Address } from 'viem'; import { HexString } from '../binary.js'; import { CiphertextOf, EncryptionScheme, PlaintextOf, SupportedTeeType } from '../encryption/encryption.js'; import { Handle } from '../handle.js'; import type { XwingKeypair } from '../lite/xwing.js'; import type { BackoffConfig } from '../retry.js'; /** * The core reencryption function type. Takes a handle (and optional ciphertext) and returns * the decrypted plaintext. Supports retry configuration for handles that are not yet available. * * @typeParam S - The encryption scheme (e.g. X-Wing). */ export type Reencryptor = (args: ReencryptFnArgs, backoffConfig?: Partial) => Promise>; /** Arguments required to construct a {@link Reencryptor}. */ export interface ReencryptorArgs { chainId: bigint; } /** * Arguments for a single reencryption call. * * @typeParam S - The encryption scheme. * @typeParam T - The ENCRYPTION type of the ciphertext. */ export type ReencryptFnArgs = { handle: Handle; /** * Optional ciphertext hint. If provided, the reencrypt endpoint may use it directly * instead of fetching from the covalidators. */ ciphertext?: CiphertextOf; }; /** Union of supported ephemeral keypair types for reencryption (currently X-Wing only). */ export type SupportedEphemeralKeypairs = XwingKeypair; /** An object whose public key can be serialized to a `Uint8Array`. */ export interface PubKeyEncodable { encodePublicKey(): Uint8Array; } /** * A reencryption request to be sent to a reencrypt endpoint. * * @typeParam EKP - The type of ephemeral keypair used for the reencryption session. */ export interface ReencryptEndpointRequest { userAddress: Address; handle: Handle; eip712Signature: HexString; ephemeralKeypair: EKP; }