/** * receipt-verifier.ts — Offline verification of ClawNet Soma Receipts * * Allows any agent running soma-sense to verify a ClawNet transaction receipt * without contacting ClawNet's API. Pure cryptographic verification using * the platform's Ed25519 public key from /.well-known/soma.json. * * This is the "trust but verify" primitive for the agent economy: * Agent A shows Agent B a Soma Receipt. Agent B verifies it locally. * No account needed, no API call, no trust in ClawNet's availability. * * @example * ```ts * import { verifyClawNetReceipt } from "soma-sense"; * * const result = verifyClawNetReceipt(receiptJson, { * publicKeyMultibase: "z6Mk...", // from ClawNet's /.well-known/soma.json * }); * * if (result.valid) { * console.log("Receipt is authentic:", result.receiptId); * } * ``` */ /** A ClawNet Soma Receipt as returned by /v1/soma/receipt/:id */ export interface SomaReceipt { id: string; requestId: string; paymentMethod: string; creditsCost: number; requestHash: string; responseHash: string; somaDataHash: string | null; heartbeatIndex: number | null; cached: boolean; signature: string; algorithm: string; hybridSignature?: { version: "2.0"; algorithms: ["Ed25519", "ML-DSA-65"]; ed25519: string; mlDsa65: string; }; easUid: string | null; easScanUrl: string | null; createdAt: string; verification: { platformDid: string; publicKeyMultibase: string; attesterAddress: string | null; algorithm: string; hashAlgorithm: string; }; } export interface ReceiptVerificationOptions { /** Platform's Ed25519 public key in multibase base58btc format (z...) */ publicKeyMultibase: string; } export interface ReceiptVerificationResult { /** Whether the receipt signature is valid */ valid: boolean; /** Receipt ID if valid */ receiptId: string | null; /** Algorithm used for verification */ algorithm: string; /** Error message if invalid */ error?: string; /** Receipt details (only if valid) */ details?: { paymentMethod: string; creditsCost: number; requestHash: string; responseHash: string; hasProvenance: boolean; easUid: string | null; createdAt: string; }; } /** * Verify a ClawNet Soma Receipt offline. * * Reconstructs the signed payload from the receipt fields, hashes it, * and verifies the Ed25519 signature against the platform's public key. * * No network calls needed — pure cryptographic verification. */ export declare function verifyClawNetReceipt(receipt: SomaReceipt, options: ReceiptVerificationOptions): ReceiptVerificationResult; /** * Fetch a receipt from ClawNet and verify it offline. * Convenience wrapper — uses network to fetch, then verifies locally. */ export declare function fetchAndVerifyReceipt(receiptId: string, options: ReceiptVerificationOptions & { apiBase?: string; }): Promise; //# sourceMappingURL=receipt-verifier.d.ts.map