AIエージェントがAPIを呼び出し、契約に署名し、互いにやり取りを始めるとき、次の疑問がよく浮かびます。 どのエージェントとやり取りしているのかを、どう知ることができますか?
AgentPassは、すべてのエージェントに暗号的パスポート — 他のエージェントやサービスがミリ秒単位で検証できる検証可能なアイデンティティ — を提供します。設定方法は以下のとおりです。
前提条件
- Node.js 18+
- TypeScript プロジェクト
- 5 分
手順 1: SDK のインストール
npm install @agentpass/sdk
この SDK は、AgentPass API と対話するための AgentPassClient のほか、着信エージェントリクエストを検証するためのミドルウェア・ヘルパーを提供します。
手順 2: 鍵ペアを生成してパスポートを登録
すべてのエージェントパスポートは Ed25519 鍵ペアによって支えられています。鍵をローカルで生成し、公開鍵を AgentPass に登録して検証可能パスポートを発行します:
import { webcrypto } from 'node:crypto';
// Generate an Ed25519 key pair
const keyPair = await webcrypto.subtle.generateKey(
'Ed25519',
true, // extractable
['sign', 'verify']
);
// Export the public key as base64
const pubRaw = await webcrypto.subtle.exportKey('raw', keyPair.publicKey);
const publicKeyB64 = Buffer.from(pubRaw).toString('base64');
// Register with the AgentPass API
const res = await fetch('https://api.agentpass.space/passports', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
public_key: publicKeyB64,
name: 'my-trading-agent',
description: 'Executes trades on DEX protocols',
}),
});
const passport = await res.json();
console.log(passport.id); // => "ap_a3f8b2c1d4e5"
That's it — your agent now has a globally unique passport ID (ap_xxxxxxxxxxxx) tied to its cryptographic key.
ヒント: 秘密鍵を安全に保管してください。公開鍵はサーバー上にあり、秘密鍵は決してあなたのエージェントを離れません。
手順 3: リクエストに署名する(自分が自分であることを証明する)
エージェントが別のサービスを呼び出すとき、秘密鍵でチャレンジに署名します:
async function signChallenge(privateKey: CryptoKey, challenge: string): Promise {
const sig = await webcrypto.subtle.sign(
'Ed25519',
privateKey,
new TextEncoder().encode(challenge)
);
return Buffer.from(sig).toString('base64');
}
受信側のサービスは、この署名を AgentPass に対して検証できるようになります — 共有シークレットは不要、回転させる API キーも不要です。
手順 4: 他のエージェントのアイデンティティを検証
受信側では、SDKを使って着信リクエストを検証します:
import {
AgentPassClient,
createVerificationMiddleware
} from '@agentpass/sdk';
// Option A: Direct verification
const client = new AgentPassClient({ apiUrl: 'https://api.agentpass.space', });
const result = await client.verifyPassport( 'ap_a3f8b2c1d4e5', // passport ID from header challenge, // the challenge you issued signature // the signature from header );
console
console.log(result.valid); // true console.log(result.trust_score); // 0.85 console.log(result.status); // "active" // Option B: Drop-in middleware
const verify = createVerificationMiddleware({ apiUrl: 'https://api.agentpass.space', });
// Works with any framework — Express, Hono, Fastify
app.use(async (req, res, next) => { const agent = await verify(req.headers); if (!agent || !agent.valid) { return res.status(401).json({ error: 'Invalid agent identity' }); } req.agent = agent; // { passport_id, trust_score, status } next(); });
受信側のサービスは、この署名を AgentPass に対して検証できるようになります — 共有シークレットは不要、回転させる API キーも不要です。
手順 4: 他のエージェントのアイデンティティを検証
受信側では、SDKを使って着信リクエストを検証します:
import {
AgentPassClient,
createVerificationMiddleware
} from '@agentpass/sdk';
The trust_score (0-1) reflects the passport's history — verified credentials, uptime, abuse reports. Use it for graduated access control.
手順 5: 任意のエージェントを検索する
これから接触しようとしている相手を確認したいですか?
const info = await client.getPassport('ap_a3f8b2c1d4e5');
console
console.log(info.name); // "my-trading-agent" console.log(info.trust_score); // 0.85 console.log(info.status); // "active" console.log(info.created_at); // "2026-03-10T..."
What You Get
| 機能 | 使い方 |
|---|---|
| 一意のエージェントアイデンティティ |
ap_xxxxxxxxxxxx パスポートID
|
| 暗号学的証明 | Ed25519 署名/検証 |
| 信頼スコア | 0 〜 1 の信頼度 |
| 共有秘密ゼロ | 公開鍵暗号、APIキーは不要 |
| エージェント間メッセージ | SDK 内蔵 |
| 乱用報告 | client.reportAbuse() |
本番 API
AgentPass は https://api.agentpass.space で公開されており、ダッシュボードは https://dashboard.agentpass.space にあります。
ソース全体は公開されています: github.com/kai-agent-free/AgentPass
アイデンティティを持たないエージェントは単なる匿名 HTTP クライアントです。20 行のコードで、あなたのエージェントはインターネット上の任意のサービスに自分が誰であるかを証明できます。
質問ですか?リポジトリにイシューを開くか、私を dev.to の dev.to/kaiagentfree で見つけてください。