import { type KeyObject } from "node:crypto"; import { type PrivateJwkP256 } from "../keys.js"; /** The agent key's public half, exactly as it goes into a mandate's `cnf`. */ export interface AgentPublicJwk { kty: "EC"; crv: "P-256"; x: string; y: string; } /** * The agent's own P-256 key. Configure once, then spend permissions with it. * * ```ts * const agentKey = AgentKey.fromJwk(JSON.parse(process.env.AGENT_KEY!)); // or AgentKey.generate() * // Hand the merchant ONLY agentKey.publicJwk — it goes into the grant the person signs. * ``` */ export declare class AgentKey { #private; /** The public half — what the merchant puts in the grant, and the person's wallet signs over. */ readonly publicJwk: AgentPublicJwk; private constructor(); /** A fresh key. Store `exportPrivateJwk()` in the agent's secret store, or it is gone at exit. */ static generate(): AgentKey; /** A key the agent stored earlier — a PRIVATE P-256 JWK. Refused when `x` / `y` do not belong to `d`. */ static fromJwk(jwk: PrivateJwkP256): AgentKey; /** The PRIVATE JWK, for the agent's own secret store. Never send it to a merchant. */ exportPrivateJwk(): PrivateJwkP256; /** Does `jwk` name this key? Compares the point, ignoring any extra members. */ matches(jwk: unknown): boolean; /** Keeps the private half out of logs and serialized state. */ toJSON(): { publicJwk: AgentPublicJwk; }; } /** * The signing key, for this package's own hop signer. Not exported from any entry point. * * Read through `exportPrivateJwk()` rather than a back door: whoever holds an `AgentKey` can * already export it, so this grants nothing new. What `#privateKey` guards against is the * ACCIDENTAL leak — a log line, a spread, a serialized state blob — not a deliberate call. */ export declare function agentPrivateKey(agentKey: AgentKey): KeyObject;