import { d as AgentSignature, I as Issuer, C as Capability, e as AgentStatus, K as Krikos, c as AgentInput, A as Agent } from '../types-iaO2gHBL.js'; export { A as AgentPassport, b as buildPassport, c as canonicalPassportString } from '../fingerprint-Dv4gGA3L.js'; /** * Cryptographic agent identity for Krikos: Ed25519 key generation, signing, and verification, * with interchangeable Node and Web implementations. * * This is the opt-in security layer on top of the deterministic registry. The core never * requires it: an agent always has a non-cryptographic fingerprint, and authorization keys off * lifecycle state and declared capabilities. When a host wants verifiable, portable identity, * it signs an agent's canonical passport with a {@link Signer} and attaches the signature, or * exports a Signed Agent Card from `@takk/krikos/a2a`. * * Key encoding is shared across runtimes so a card signed under {@link nodeSigner} verifies under * {@link webSigner} and vice versa: public keys are the raw 32-byte Ed25519 key, private keys are * the raw 32-byte seed, both base64url. The Node and Web back ends rebuild the standard SPKI and * PKCS8 DER wrappers from those raw bytes using the fixed Ed25519 ASN.1 prefixes. * * The Node back end loads `node:crypto` lazily inside method bodies, so importing this module * stays safe in browsers and edge runtimes; the platform requirement only materializes when a * Node method actually runs. * * @packageDocumentation */ /** An Ed25519 key pair with raw, base64url-encoded keys. */ interface KeyPair { /** Raw 32-byte Ed25519 public key, base64url. */ readonly publicKey: string; /** Raw 32-byte Ed25519 private seed, base64url. Treat as a secret. */ readonly privateKey: string; } /** * A pluggable Ed25519 signer. Two interchangeable implementations ship: {@link nodeSigner} and * {@link webSigner}. A host may supply its own (an HSM, a KMS) as long as it honors the same key * encoding and Ed25519 semantics. */ interface Signer { /** Algorithm identifier, always `ed25519` in 1.0. */ readonly algorithm: 'ed25519'; /** Generates a fresh key pair. */ generateKeyPair(): Promise; /** Signs `message` with `privateKey`, returning a base64url detached signature. */ sign(message: string, privateKey: string): Promise; /** Verifies `signature` over `message` against `publicKey`. Never throws on a bad signature. */ verify(message: string, signature: string, publicKey: string): Promise; } /** * Creates an Ed25519 signer backed by `node:crypto`, loaded lazily. Use this on a Node server * or in the CLI. Throws only on genuinely malformed inputs (wrong key length, non-base64url); * a cryptographically invalid signature resolves to `false`, never throws. * * @returns A {@link Signer} bound to `node:crypto`. */ declare function nodeSigner(): Signer; /** * Creates an Ed25519 signer backed by the Web Crypto API (`globalThis.crypto.subtle`). Use this * in browsers and edge runtimes. Requires a runtime whose Web Crypto implements the Ed25519 * algorithm, which the major edge runtimes and modern browsers do as of 2026. * * @returns A {@link Signer} bound to Web Crypto. */ declare function webSigner(): Signer; /** * A2A-aligned cryptographic agent identity for Krikos. * * The Agent2Agent (A2A) protocol, hosted by the Linux Foundation, uses Agent Cards to advertise * an agent's identity and capabilities, and Signed Agent Cards to let a receiving party verify * that a card was issued by who it claims, before any interaction. A2A does not mandate how those * cards are produced or verified. Krikos fills that gap: it exports a registered agent as a card, * signs the agent's canonical passport with Ed25519, and verifies a presented card's signature * anywhere, in Node, the browser, or an edge runtime, with byte-identical key encoding. * * This module is the cryptographic surface. The core registry never requires it; an agent always * has a deterministic fingerprint and authorization keys off lifecycle state and capabilities. * * @packageDocumentation */ /** * A Krikos Agent Card: an A2A-aligned, self-describing identity document for one agent, suitable * for cross-boundary discovery and trust. When `signature` is present, a verifier can confirm the * card was issued by the holder of the corresponding key without contacting Krikos. */ interface KrikosAgentCard { /** Card schema version. */ readonly protocolVersion: 'krikos/1.0'; /** Opaque agent id. */ readonly id: string; /** Human-readable agent name. */ readonly name: string; /** The issuing principal. */ readonly issuer: Issuer; /** Declared capabilities. */ readonly capabilities: readonly Capability[]; /** Optional framework tag. */ readonly framework?: string; /** Credential epoch. */ readonly credentialVersion: number; /** Deterministic identity fingerprint. */ readonly fingerprint: string; /** Lifecycle state at the time the card was produced. */ readonly status: AgentStatus; /** Issue instant (epoch ms). */ readonly issuedAt: number; /** Expiration instant (epoch ms) or null. */ readonly expiresAt: number | null; /** Detached Ed25519 signature over the canonical passport, when signed. */ readonly signature?: AgentSignature; } /** * Maps a registered agent to its Agent Card. Carries the attached signature if present, so the * card is independently verifiable. * * @param agent - The agent to export. * @returns A {@link KrikosAgentCard}. */ declare function toAgentCard(agent: Agent): KrikosAgentCard; /** * Signs an agent's canonical passport, producing a detached signature that attests to its * fingerprint and credential version. Attach it with {@link Krikos.attachSignature}. * * @param agent - The agent to sign. * @param signer - The Ed25519 signer ({@link nodeSigner} or {@link webSigner}). * @param keyPair - The signing key pair; its public key is embedded in the signature. * @returns The detached {@link AgentSignature}. */ declare function signAgent(agent: Agent, signer: Signer, keyPair: KeyPair): Promise; /** A trust anchor: the issuer public key, or the set of keys, the verifier pins out of band. */ type TrustedKeys = string | readonly string[]; /** * Checks that an agent's attached signature is internally consistent: it covers the agent's current * fingerprint and credential version, and the Ed25519 signature verifies against the public key * embedded in the signature. * * This is NOT a trust check. A consistent signature proves only that the holder of the embedded * key signed this passport; it says nothing about whether that key belongs to the issuer you * trust. An attacker can mint a fully consistent self-signed card for any identity. Use it only * when the card already arrived over a trusted channel; otherwise use {@link verifyAgent} with a * pinned trust anchor. Returns false, never throws. * * @param agent - The agent whose signature to check. * @param signer - The Ed25519 signer to verify with. * @returns Whether the signature is internally consistent. */ declare function verifyAgentConsistency(agent: Agent, signer: Signer): Promise; /** The card-shaped counterpart of {@link verifyAgentConsistency}. Not a trust check. */ declare function verifyCardConsistency(card: KrikosAgentCard, signer: Signer): Promise; /** * Verifies an agent's identity against a pinned trust anchor: the signature must be internally * consistent AND signed by a public key the verifier already trusts (the issuer key, obtained out * of band, not the self-asserted key on the card). This is the real trust check; without a trust * anchor there is no verifiable identity, only self-consistency. * * A forged card signed with an attacker's own key fails here because the attacker's public key is * not among `trustedKeys`. Returns false, never throws. * * @param agent - The agent whose identity to verify. * @param signer - The Ed25519 signer to verify with. * @param trustedKeys - The pinned issuer public key(s) (base64url), obtained over a trusted channel. * @returns Whether the identity is verified against the trust anchor. */ declare function verifyAgent(agent: Agent, signer: Signer, trustedKeys: TrustedKeys): Promise; /** * Verifies a presented Agent Card against a pinned trust anchor, without access to the registry. * The card's signature must be internally consistent AND signed by a public key in `trustedKeys`. * A card signed with any other key (the impersonation case) is rejected. Returns false, never * throws. * * @param card - The presented Agent Card. * @param signer - The Ed25519 signer to verify with. * @param trustedKeys - The pinned issuer public key(s) (base64url), obtained over a trusted channel. * @returns Whether the card is verified against the trust anchor. */ declare function verifyAgentCard(card: KrikosAgentCard, signer: Signer, trustedKeys: TrustedKeys): Promise; /** * Convenience: issue an agent, generate a fresh key pair, sign the agent, and attach the * signature, in one call. Returns the signed agent and the key pair so the caller can persist the * private key in its own secret store, Krikos never retains it. * * @param krikos - The registry to issue into. * @param input - The agent input. * @param signer - The Ed25519 signer to use. * @returns The signed agent and the generated key pair. */ declare function issueSigned(krikos: Krikos, input: AgentInput, signer: Signer): Promise<{ readonly agent: Agent; readonly keyPair: KeyPair; }>; /** * One skill in an A2A-aligned card, mapped from a Krikos capability: the capability name as the * skill id, its actions as tags, and any resource scope carried alongside. */ interface A2ASkill { readonly id: string; readonly name: string; readonly tags: readonly string[]; readonly resources?: readonly string[]; } /** * An A2A-aligned agent card, shaped toward the Agent2Agent protocol's AgentCard so a krikos * identity can be advertised to A2A-aware peers. This is a best-effort alignment, not a certified * conformance to a specific A2A schema version; fields outside this subset are the host's to add. * The signature, when present, is the same Ed25519 detached signature verified by * {@link verifyAgentCard} with a pinned trust anchor. */ interface A2AAgentCard { readonly protocolVersion: 'a2a-aligned/1.0'; readonly name: string; readonly description: string; readonly version: string; readonly provider: { readonly organization: string; readonly url?: string; }; readonly skills: readonly A2ASkill[]; readonly fingerprint: string; readonly signatures?: readonly AgentSignature[]; } /** * Maps a registered agent to an A2A-aligned card, deriving one skill per declared capability. * * @param agent - The agent to export. * @param provider - The advertising organization and optional URL. * @returns An {@link A2AAgentCard}. */ declare function toA2ACard(agent: Agent, provider: { readonly organization: string; readonly url?: string; }): A2AAgentCard; export { type A2AAgentCard, type A2ASkill, type KeyPair, type KrikosAgentCard, type Signer, type TrustedKeys, issueSigned, nodeSigner, signAgent, toA2ACard, toAgentCard, verifyAgent, verifyAgentCard, verifyAgentConsistency, verifyCardConsistency, webSigner };