/** * BitcoinProviderRegistry reader (LIT Action side). * * The on-chain registry stores one encrypted slot per `(chainId, providerId)`. * This module: * 1. Reads every registered slot for the caller's chain via a single * `getProviders(chainId)` view call (so network RPC cost is O(1) * regardless of how many slots are registered). * 2. Decrypts each slot's ciphertext with `Lit.Actions.Decrypt` using the * slot's pkpId — plaintext URLs only ever materialize inside the running * LIT Action, never on-chain or in the bundle. * 3. Compares the caller-supplied URL against the decrypted plaintexts and * returns the matching providerId (short-circuits on first match). * * This module is consumed exclusively by non-regtest validators; hardhat * (regtest) uses `policy.allowArbitraryBitcoinProvider` and skips it entirely. */ import type { BitcoinProviderConfig } from "../constants"; import type { ChainPolicy } from "./chain-policy"; export interface ProviderEntry { providerId: string; ciphertext: string; pkpId: string; addedAt: number; } /** * Fetch every registered encrypted provider slot for `chainId` in a single * RPC call. Returns an empty array when the chain has no slots — the caller * decides whether that's a fatal condition (for prod chains it is). */ export declare function fetchBitcoinProviderEntries(chainId: number, provider: any, registryAddress: string): Promise; /** * Audit M-6-adv / C-7 (2026-05-27): self-verify the bundle CID before any * decrypt attempt. * * The on-chain `BitcoinProviderRegistry` (v1.1.0+) maintains a per-chainId * allowlist of CID hashes that may decrypt provider slots. Without this * check the LIT Action would rely solely on the off-chain Lit access-control * condition bound at encryption time — and a rogue CID added to the Chipotle * "Diamond Hands" group whose ACC matched the legacy "any caller running on * this group" predicate could exfiltrate every encrypted URL. * * Reads `globalThis.ipfsId` (the LIT runtime injects this), hashes it as * `keccak256(utf8(cidString))`, and calls `BitcoinProviderRegistry.isAllowedCid`. * Throws — with a descriptive message — if the registry returns false or * cannot be reached. Returns void on success. * * Callers should invoke this BEFORE the first `Lit.Actions.Decrypt` per * invocation. The contract view costs one eth_call. */ export declare function assertSelfCidAllowedForDecrypt(args: { chainId: number; ethersProvider: any; registryAddress: string; }): Promise; /** * Decrypt a single registered slot back to its plaintext URL. * * Wraps v8 `Lit.Actions.Decrypt({ pkpId, ciphertext })` (the successor to the * deprecated `decryptToSingleNode`). The access-control condition bound at * encryption time still gates which CIDs may recover the plaintext — this * helper only runs inside the LIT node. * * Callers MUST invoke {@link assertSelfCidAllowedForDecrypt} first to enforce * the on-chain CID allowlist (audit C-7). The decrypt-side ACC alone is not a * sufficient gate today — see the audit note for details. */ export declare function decryptProviderUrl(ciphertext: string, pkpId: string): Promise; /** * Iterate registered entries, decrypting each, and return the providerId of * the slot whose plaintext URL matches `candidateUrl`. Returns `null` when no * slot matches. * * Short-circuits on first match — for sepolia's expected 2–3 slots this * keeps decrypt cost minimal. A larger N would still fit inside LIT's * execution budget because `Lit.Actions.Decrypt` is network-parallelised. */ export declare function matchAllowedProviderUrl(entries: ProviderEntry[], candidateUrl: string): Promise; /** * Single-shot resolver used by every validator. * * - hardhat (policy.allowArbitraryBitcoinProvider) → caller URL accepted * verbatim, no contract read. * - sepolia / ethereum → registry address is REQUIRED. Fetch the chain's * registered slots, decrypt each, require `bitcoinProviderUrl` to match * one of the plaintexts. Throws with a descriptive reason if anything * fails — no silent fallback to an attacker-controlled URL. */ export declare function resolveBitcoinProviderForPolicy(args: { policy: ChainPolicy; bitcoinProviderUrl: string; ethersProvider: any; registryAddress?: string; }): Promise; /** * Resolve EVERY Bitcoin provider for the chain, in registry order: the dev * override on hardhat (single-element list), or all registered + decrypted * providers on prod chains. Caller never supplies the URL. * * This is the consensus-capable resolver. Index 0 is the "primary" provider * used for the value read; the full list is fed to * `assertBitcoinBalanceConsensus` so a single bad provider cannot influence a * signed value (audit C-1/C-2). `resolveDefaultBitcoinProvider` delegates here * and returns element 0, so the two helpers can never diverge. */ export declare function resolveAllBitcoinProviders(args: { policy: ChainPolicy; ethersProvider: any; registryAddress?: string; devBitcoinProviderUrl?: string; }): Promise; /** * Resolve a single Bitcoin provider (the first registered, or the dev override * on hardhat). Thin wrapper over `resolveAllBitcoinProviders` — kept for the * read path of callers that also run consensus separately, and for flows that * genuinely need only one provider. Caller never supplies the URL. */ export declare function resolveDefaultBitcoinProvider(args: { policy: ChainPolicy; ethersProvider: any; registryAddress?: string; devBitcoinProviderUrl?: string; }): Promise; /** * Fetch and decrypt EVERY registered provider for the chain. * * Used by validators that want consensus across all registered providers * (rather than trusting a caller-supplied URL via `resolveBitcoinProviderForPolicy`). * Throws if no providers are registered — for non-hardhat chains the registry * is the authoritative source and an empty list is a fatal config error. */ export declare function fetchAllDecryptedProviderConfigs(policy: ChainPolicy, ethersProvider: any, registryAddress: string): Promise; //# sourceMappingURL=bitcoin-provider-registry.d.ts.map