import { type IssuedCoin } from "./client.js"; /** * The §6.3 domain-separation tag, 27 ASCII bytes. A constant, so §6.12's * fixed-width rule applies: emitted bare, with no length prefix. */ export declare const DEPOSIT_PERMISSION_CONTEXT: Uint8Array; /** * A deposit permission that did not verify. * * Distinct from the `RangeError`s a mis-sized input raises: §6.5 maps this * onto `BAD_PERMISSION_SIG`, which a facilitator forwards to whoever * presented the coin. Carries no operand values — the message under signature * contains the coin itself. */ export declare class BadDepositPermissionError extends Error { constructor(); } /** * The exact bytes a deposit permission is signed over (§6.3, encoded per * §6.12). * * `sigma` is taken as bytes and emitted at **its own length**, prefixed with * `be32(L)`. That length must be `pad(σ, L)`'s — i.e. `bitlen(N)/8` for the * denomination the id names — which is what {@link signSpend} checks against * the coin's key before it signs. Taking the width from the bytes here rather * than from a key matches `px402_registry::deposit_permission_message`, which * is the verifier this signature must satisfy and which has only the wire * bytes in hand. */ export declare function depositPermissionMessage(coinPub: Uint8Array, denomId: string, sigma: Uint8Array, fraction: bigint, contractTermsHash: Uint8Array): Uint8Array; /** Sign {@link depositPermissionMessage} with the coin's own Ed25519 secret. */ export declare function depositPermission(coinSecret: Uint8Array, denomId: string, sigma: Uint8Array, fraction: bigint, contractTermsHash: Uint8Array): Uint8Array; /** * Verify a deposit permission against the coin public key it names. * * `zip215: false` is load-bearing — see the module docs. An undecodable or * degenerate `coinPub` lands in the same refusal rather than a separate * error: both outcomes are "this permission is not authenticated", which is * the only branch a verifier acts on. * * @throws BadDepositPermissionError on any failure, including a tampered * fraction, denomination, σ, or terms hash — all four are inside the message. */ export declare function verifyDepositPermission(coinPub: Uint8Array, denomId: string, sigma: Uint8Array, fraction: bigint, contractTermsHash: Uint8Array, signature: Uint8Array): void; /** One coin and the fraction of it being spent. */ export interface SpendPart { readonly coin: IssuedCoin; /** `f_i`, in USDC base units. `Σ f_i = accepted.amount` (§6.3). */ readonly fraction: bigint; } /** A {@link SpendPart} with its permission signed. */ export interface SignedSpend extends SpendPart { readonly depositSig: Uint8Array; } /** * Sign one deposit permission per part, all against the same * `H(contractTerms)`. * * Checks each part before signing: * * - **`σ` is exactly `L = bitlen(N)/8` bytes.** §6.12 forbids the * minimal-length encoding, and `be32(L) ‖ σ` in the signed message takes * the width from the bytes, so a short `σ` would sign a message the * registry — which resolves `L` from the key — never reconstructs. * - **`0 < f ≤ value(denomId)`.** A zero fraction authorizes nothing, and a * fraction above the face value is a spend the registry rejects with * `INSUFFICIENT_VALUE` after the signature has already been made and * forwarded. */ export declare function signSpend(parts: readonly SpendPart[], contractTermsHash: Uint8Array): SignedSpend[];