/** * `@coproduct_inc/verify` — offline, zero-trust verification for Nucleus. * * Two receipt families share one package. The headline is the * **capability-boundary in-bounds attestation** — see `./attestation` * (re-exported below): given an agent run's tool-call trace + a declared * capability boundary, emit and offline-verify an Ed25519-signed receipt * that the agent stayed within bounds, keyed on a cryptographic principal * rather than a mutable display name. The auction-receipt surface documented * here is the original use case and remains available. * * --- * * Auction receipts: the agent NEVER trusts the hub's clearing price. * * The agent NEVER trusts the hub's clearing price. This package's WASM * core (the SAME `nucleus-wasm` binary the browser demo runs) re-runs the * auction clearing locally from the SIGNED bid set and asserts the * recomputed price equals the price the receipt claims — on top of the * Ed25519 signature + BLAKE3 root-hash check. * * ```ts * import { verify } from "@coproduct_inc/verify"; * const r = await verify(receiptJson, jwksJson); * if (!r.ok) throw new Error(r.reason ?? "receipt failed verification"); * // r.ok === signature_ok && root_hash_ok && price_recomputed_ok * ``` * * The Node target loads the wasm synchronously on first import; the * `verify` API is async-shaped so a future web/bundler entry can stream * the wasm without changing call sites. */ /** Which clearing rule the receipt commits to. */ export type RecomputePath = "vickrey" | "pigou-vcg"; /** * Full verification result. `ok` is the single boolean to gate on; the * component flags + recovered fields are for diagnostics / UI. All prices * are integer micro-USD that fit a JS `number` (the kernel's internal * u128 math never crosses this boundary). */ export interface FullVerifyReport { /** `signatureOk && rootHashOk && priceRecomputedOk`. */ ok: boolean; /** Ed25519 signature verified under the JWKS key matched by `kid`. */ signature_ok: boolean; /** BLAKE3 of the canonical envelope equals the receipt's root hash. */ root_hash_ok: boolean; /** The locally recomputed clearing price equals the receipt's price. */ price_recomputed_ok: boolean; /** Price the recompute produced (micro-USD). */ recomputed_price_micro_usd: number; /** Price the receipt claims (micro-USD), or null. */ signed_price_micro_usd: number | null; /** Clearing rule the receipt commits to (`"vickrey"` today). */ path: RecomputePath; /** Theorem-backed Pigou-VCG cross-check clearing, if externality data * was present (reported, not gated on). */ pigou_vcg_clearing_micro_usd: number | null; /** First failing reason, or null when `ok`. */ reason: string | null; } /** Recompute-only result (no signature check). */ export interface RecomputeReport { recomputed_price_micro_usd: number; receipt_price_micro_usd: number | null; matches_receipt: boolean; path: RecomputePath; recomputed_winner_spiffe_id: string | null; winner_matches: boolean; pigou_vcg_clearing_micro_usd: number | null; reason: string | null; } /** * Verify a signed auction receipt fully: signature + root hash + a LOCAL * recomputation of the clearing price from the signed bids. * * @param receiptJson the receipt as a JSON string (the hub's wire form). * @param jwksJson the pinned issuer JWKS document as a JSON string. * @returns the structured report; `ok === true` only when all three * checks pass. Never throws on a bad receipt — failures surface as * `ok: false` with a `reason`. */ export declare function verify(receiptJson: string, jwksJson: string): Promise; /** * Recompute the clearing price from the signed bids WITHOUT checking the * signature. Use when you have already verified the signature separately, * or to inspect the recomputed-vs-claimed delta. Most callers want * {@link verify} instead. */ export declare function recomputeClearing(receiptJson: string): Promise; /** * Signature + root-hash check only (the pre-recompute verifier). Kept for * back-compat / when you only need authenticity, not price-correctness. */ export declare function verifySignature(receiptJson: string, jwksJson: string): Promise; /** * Result of verifying a Proof-Carrying-Authorization certificate. `ok` is the * single boolean to gate on; the rest is diagnostics. A policy *decision* * reports `kind: "decision"` + `decision: "allow"|"deny"`; a *governance* * amendment reports `kind: "governance"` + `monotone`; a *delegation* reports * `kind: "delegation"`. */ export interface PolicyCertReport { /** Signature + freshness + context + commitment + recompute all passed. */ ok: boolean; /** The authority question answered: "decision" | "governance" | "delegation". */ kind: string | null; /** For a decision cert: "allow" | "deny" (the recompute-confirmed verdict). */ decision: string | null; /** For a governance cert: the amendment is non-weakening (true on success). */ monotone: boolean | null; /** Issuer Ed25519 public key (hex), on success. */ signer_pubkey_hex: string | null; /** First failing reason, or null when `ok`. */ reason: string | null; } /** * Verify a Proof-Carrying-Authorization certificate offline, with ZERO trust in * the issuer. Runs the SAME `nucleus-policy-cert::verify` the runtime does — * the Ed25519 signature over the cert's signing message, then the verbatim * recompute (`decide` / `governance_monotone`) against the carried policy, plus * freshness and (when `expectedContextHex` is given) the context binding. A * wrong decision (or mis-stated amendment) is structurally uncertifiable. * * `ok` means the certificate VALIDLY CERTIFIES its stated outcome — **not** that * the request is allowed. A validly-signed `Deny` cert returns `{ ok: true, * decision: "deny" }`. To gate an authorization use `ok && decision === "allow"`; * to gate a governance update use `ok && monotone === true`. * * @param certJson the certificate as a JSON string. * @param nowUnix current time (unix SECONDS) for the freshness check. A float * (e.g. `Date.now() / 1000`) is floored — pass whole seconds to be explicit. * @param expectedContextHex optional 64-hex-char context the cert must be bound * to (e.g. a lineage-edge / request hash). **Omit only when you intend NO * binding** — passing `undefined` from a missing variable silently skips the * splice/replay check (fail-open). Pass the hash explicitly whenever the cert * carries a `bound_context_hash`. */ export declare function verifyPolicyCertificate(certJson: string, nowUnix: number | bigint, expectedContextHex?: string): Promise; export * from "./attestation.js"; export * from "./toolproxy.js"; export * from "./cage.js"; export * from "./ifc-decide.js"; export * from "./ifc.js"; export * from "./workflow.js"; export * from "./license.js"; export * from "./claim.js";