DCP-AI クイックスタートガイド¶
英語版の参考訳です(28/10/2026 更新)。内容が異なる場合は英語版が優先されます。識別子、コマンド、コードブロックは翻訳せずにそのまま掲載しています。
このガイドでは、SDK で DCP の証拠を作成・検証する方法と、どのツールがデモかを説明します。
進め方を選ぶ¶
- SDK で証拠を作成・検証する。 公開済みの SDK をインストールします。§3 TypeScript と §4 Python の例は署名済みバンドルを作成して検証します。その他の SDK では Go、Rust、 WebAssembly のインストール方法と参照先を示しています。検証は完全性と署名を確認するもので、プリンシパルへの信頼、 受け入れ、認可を確立するものではありません(受け入れを参照)。
- デモで概要をつかむ。 インストール不要の近道のプレイグラウンドとスタータープロジェクト、 および §1 と §2 の CLI ウィザードは、概念を示すものです。制約は それぞれ異なり(模擬的な PQ 鍵や署名、仮の鍵、署名されていない記録、構造だけの確認)、作成されるものは検証の証拠 ではありません。
- SDK をインストールせずに検証器を動かす。 同じ近道と参照サービスの実行にある、 参照検証サーバーの任意の Docker イメージはバンドルを検証しますが、作成はしません。
パッケージの現在のバージョンは公開済みバージョンにあります。
前提条件¶
使用する SDK に応じて次が必要です。
- Node.js 18 以上 — TypeScript SDK、CLI、WASM パッケージ、
@dcp-ai/*の統合に必要です。QUICKSTART_LANGCHAIN.md の現行の LangChain.js(v1)には Node.js 22 以上が必要です - Python 3.10 以上 — Python SDK に必要です。QUICKSTART_AGNO.md の別パッケージ
agno-dcpには 3.11 以上が必要です - Go 1.25 以上 — Go SDK に必要です
- Rust 安定版 — Rust のクレートに必要です
必要なのは、実際に使う言語だけです。すべての SDK は同じ V2 のワイヤーフォーマットを実装しています。共有ベクターと相互運用マトリクスが SDK 間の署名と検証をテストしており、各 SDK の README に残っている不足点が載っています。
公開パッケージとこのガイド¶
TypeScript の例は公開済みの @dcp-ai/sdk 2.2.1、npm CLI は @dcp-ai/cli 2.1.1、Python は PyPI の dcp-ai 2.10.1 を使います。npm、Python、SECURITY.md を参照してください。Go と Rust の公開は別です。ソース開発には次を使います。
git clone https://github.com/dcp-ai-protocol/dcp-ai.git
cd dcp-ai/sdks/typescript && npm install && npm run build # TypeScript SDK of main
cd ../../cli && npm install --no-save --package-lock=false --ignore-scripts --install-links ../sdks/typescript
pip install -e /path/to/dcp-ai/sdks/python # Python SDK of main
このガイドのレジストリのコマンドは、公開済みのバージョンをインストールします。
インストール不要の近道¶
これらの近道は main ではなく、公開済みのパッケージとイメージを使います。プレイグラウンドとスターターはデモで、SDK の検証の証拠は作成しません(制約は下記)。Docker イメージは参照検証サーバーを実行し、バンドルを検証しますが作成はしません。
- インタラクティブなプレイグラウンド: https://docs.dcp-ai.org/playground/ — ブラウザーでアイデンティティを生成し、バンドルを構築し、署名を検証できます。
- 雛形のスターター:
npm create @dcp-ai/langchain my-app(または/crewai、/openai、/express)を実行すると、スタータープロジェクトが生成されます。 - Docker の 1 行コマンド:
docker run -p 3000:3000 ghcr.io/dcp-ai-protocol/dcp-ai/verification:latestで、何もクローンせずにリファレンス検証サーバーを起動できます。
プレイグラウンドはデモです。PQ 署名はシミュレーションで、正規化と Merkle の処理も簡略化されているため、そのバンドルは SDK で検証するための証拠にはなりません。スターターテンプレートにも制限があります。LangChain、CrewAI、OpenAI はプレースホルダーの鍵と署名を使い、Express は構造だけを確認します。検証可能なバンドルには、以下の SDK の例を使ってください。
1. CLI をインストールする¶
CLI のウィザードは試しに見て回るためのデモです。その「ML-DSA-65」鍵はシミュレーション(ランダムなバイト列)で、書き出される RPR とパスポートは署名されておらず、V2 スキーマにも合いません。検証できるアイデンティティとバンドルを作るには §3 か §4 に進んでください。制限の一覧はエージェントの作成にあります。
公開済みのバージョンを、インストールするか直接実行します。
チェックアウト(上記)からは、プロジェクトのディレクトリでリポジトリのウィザードを実行します:node /path/to/dcp-ai/cli/bin/dcp-ai.js init。
2. エージェントを初期化する¶
これにより、プロジェクトに次のデモ用ファイルが作成されます。
| ファイル | 目的 |
|---|---|
.dcp/config.json |
エージェントの設定とメタデータ |
.dcp/keys/ed25519_public.key、.dcp/keys/ed25519_secret.key |
Ed25519 の鍵ペア |
.dcp/keys/ml_dsa_65_public.key、.dcp/keys/ml_dsa_65_secret.key |
ポスト量子鍵を選んだ場合の、シミュレーションの「ML-DSA-65」鍵ペア(ランダムなバイト列) |
.dcp/identity.json |
RPR に似たレコード(未署名で、スキーマに合わない) |
.dcp/passport.json |
パスポートに似たレコード(未署名で、スキーマに合わない) |
秘密鍵のファイルは既定の権限(通常の umask 022 では 0644)で書き出されます。chmod 600 .dcp/keys/*_secret.key を実行し、.dcp/keys/ を .gitignore に追加してバージョン管理から外してください。
3. TypeScript SDK¶
以下の TypeScript の例は npm SDK 2.2.1 または開発用チェックアウトで動作します(公開パッケージとこのガイドを参照)。
次のどちらかをインストールします。
- ソース開発用にチェックアウトからビルドした
mainの SDK:
- または、これらの修正と機能を含む公開済み SDK 2.2.1:
バンドルを作成して署名する(V1 — Ed25519)¶
RPR とパスポートは、それぞれ signature フィールドを除いたオブジェクトに対して署名されます。verifySignedBundle はバンドルの署名、ハッシュ、チェーンを確認し、内部の署名は別に確認します。
import { BundleBuilder, generateKeypair, signBundle, signObject, verifyObject, verifySignedBundle } from '@dcp-ai/sdk';
import type { AgentPassport, ResponsiblePrincipalRecord } from '@dcp-ai/sdk';
const now = new Date().toISOString();
const principalKeys = generateKeypair();
const agentKeys = generateKeypair();
// Each artifact is signed over the object without its `signature` field.
const rprBody: Omit<ResponsiblePrincipalRecord, 'signature'> = {
dcp_version: '1.0', human_id: 'human:example-001', legal_name: 'Example Principal',
entity_type: 'natural_person', jurisdiction: 'ES', liability_mode: 'owner_responsible',
override_rights: true, issued_at: now, expires_at: null, contact: null,
};
const rpr: ResponsiblePrincipalRecord = { ...rprBody, signature: signObject(rprBody, principalKeys.secretKeyB64) };
const passportBody: Omit<AgentPassport, 'signature'> = {
dcp_version: '1.0', agent_id: 'agent:example-001', public_key: agentKeys.publicKeyB64,
principal_binding_reference: rpr.human_id, capabilities: ['browse', 'api_call'],
risk_tier: 'low', created_at: now, status: 'active',
};
const passport: AgentPassport = { ...passportBody, signature: signObject(passportBody, agentKeys.secretKeyB64) };
const bundle = new BundleBuilder()
.responsiblePrincipalRecord(rpr)
.agentPassport(passport)
.intent({
dcp_version: '1.0', intent_id: 'intent:example-001', agent_id: passport.agent_id, human_id: rpr.human_id,
timestamp: now, action_type: 'api_call', target: { channel: 'api', domain: 'api.example.com' },
data_classes: ['none'], estimated_impact: 'low', requires_consent: false,
})
.policyDecision({
dcp_version: '1.0', intent_id: 'intent:example-001', decision: 'approve', risk_score: 0.05,
reasons: ['low-impact call'], required_confirmation: null,
})
.createAuditEntry({
dcp_version: '1.0', audit_id: 'audit:example-001', timestamp: now, agent_id: passport.agent_id,
human_id: rpr.human_id, intent_id: 'intent:example-001', policy_decision: 'approved',
outcome: 'call_completed', evidence: { tool: 'http', result_ref: null },
})
.build();
const signed = signBundle(bundle, { secretKeyB64: principalKeys.secretKeyB64, signerType: 'human', signerId: rpr.human_id });
console.log(verifySignedBundle(signed, principalKeys.publicKeyB64)); // { verified: true }
// The inner signatures, over the same objects without `signature`
console.log(verifyObject(rprBody, rpr.signature, principalKeys.publicKeyB64)); // true
console.log(verifyObject(passportBody, passport.signature, agentKeys.publicKeyB64)); // true
バンドルを検証する¶
import { readFileSync } from 'node:fs';
import { getDefaultRegistry, registerDefaultProviders, verifySignedBundleV2 } from '@dcp-ai/sdk';
registerDefaultProviders();
const signedBundle = JSON.parse(readFileSync('bundle.signed.json', 'utf8'));
const result = await verifySignedBundleV2(signedBundle, getDefaultRegistry());
console.log(result.verified, result.errors);
V2 — ポスト量子のハイブリッド署名¶
各アーティファクトは、そのドメイン分離コンテキストのもとで Ed25519 + ML-DSA-65 により署名された SignedPayload です。プリンシパルは RPR とマニフェストに、エージェントはパスポート、意図、ポリシー判断に署名します。
import {
AlgorithmRegistry, BundleBuilderV2, DCP_CONTEXTS, Ed25519Provider, MlDsa65Provider, compositeSign,
generateSessionNonce, preparePayload, sha256Hex, canonicalizeV2, signBundleV2, verifySignedBundleV2,
} from '@dcp-ai/sdk';
import type {
AgentPassportV2, AuditEventV2, CompositeKeyPair, DcpContext, IntentV2, KeyEntry, PolicyDecisionV2,
ResponsiblePrincipalRecordV2, SignedPayload,
} from '@dcp-ai/sdk';
const registry = new AlgorithmRegistry();
const ed25519 = new Ed25519Provider();
const mlDsa65 = new MlDsa65Provider();
registry.registerSigner(ed25519);
registry.registerSigner(mlDsa65);
async function hybridKeys(): Promise<CompositeKeyPair> {
const c = await ed25519.generateKeypair();
const p = await mlDsa65.generateKeypair();
return {
classical: { kid: c.kid, alg: 'ed25519', secretKeyB64: c.secretKeyB64, publicKeyB64: c.publicKeyB64 },
pq: { kid: p.kid, alg: 'ml-dsa-65', secretKeyB64: p.secretKeyB64, publicKeyB64: p.publicKeyB64 },
};
}
const keyEntries = (keys: CompositeKeyPair): KeyEntry[] => [keys.classical, keys.pq].map((k) => ({
kid: k.kid, alg: k.alg, public_key_b64: k.publicKeyB64, created_at: '2026-01-01T00:00:00Z', expires_at: null, status: 'active',
}));
const sha256Of = (value: unknown) => `sha256:${sha256Hex(new TextEncoder().encode(canonicalizeV2(value)))}`;
async function signed<T>(payload: T, context: DcpContext, keys: CompositeKeyPair): Promise<SignedPayload<T>> {
const { canonicalBytes, payloadHash } = preparePayload(payload);
return { payload, payload_hash: payloadHash, composite_sig: await compositeSign(registry, context, canonicalBytes, keys) };
}
const principal = await hybridKeys();
const agent = await hybridKeys();
const nonce = generateSessionNonce();
const now = new Date().toISOString();
const rpr: ResponsiblePrincipalRecordV2 = {
dcp_version: '2.0', human_id: 'human:example-001', session_nonce: nonce, legal_name: 'Example Principal',
entity_type: 'natural_person', jurisdiction: 'ES', liability_mode: 'owner_responsible', override_rights: true,
issued_at: now, expires_at: null, contact: null, binding_keys: keyEntries(principal),
};
const passport: AgentPassportV2 = {
dcp_version: '2.0', agent_id: 'agent:example-001', session_nonce: nonce, keys: keyEntries(agent),
principal_binding_reference: rpr.human_id, capabilities: ['browse', 'api_call'], risk_tier: 'low',
created_at: now, status: 'active',
};
const intent: IntentV2 = {
dcp_version: '2.0', intent_id: 'intent:example-001', session_nonce: nonce, agent_id: passport.agent_id,
human_id: rpr.human_id, timestamp: now, action_type: 'api_call', target: { channel: 'api', domain: 'api.example.com' },
data_classes: ['none'], estimated_impact: 'low', requires_consent: false,
};
const policy: PolicyDecisionV2 = {
dcp_version: '2.0', intent_id: intent.intent_id, session_nonce: nonce, decision: 'approve', risk_score: 50,
reasons: ['low-impact call'], required_confirmation: null, applied_policy_hash: sha256Of({ policy: 'default' }), timestamp: now,
};
const audit: AuditEventV2 = {
dcp_version: '2.0', audit_id: 'audit:example-001', session_nonce: nonce, prev_hash: 'GENESIS', hash_alg: 'sha256',
timestamp: now, agent_id: passport.agent_id, human_id: rpr.human_id, intent_id: intent.intent_id,
intent_hash: sha256Of(intent), policy_decision: 'approved', outcome: 'call_completed',
evidence: { tool: 'http', result_ref: null, evidence_hash: null }, pq_checkpoint_ref: null,
};
const bundle = new BundleBuilderV2(nonce)
.responsiblePrincipalRecord(await signed(rpr, DCP_CONTEXTS.ResponsiblePrincipal, principal))
.agentPassport(await signed(passport, DCP_CONTEXTS.AgentPassport, agent))
.intent(await signed(intent, DCP_CONTEXTS.Intent, agent))
.policyDecision(await signed(policy, DCP_CONTEXTS.PolicyDecision, agent))
.addAuditEntry(audit)
.build();
const signedBundle = await signBundleV2(bundle, { registry, signerType: 'human', signerId: rpr.human_id, keys: principal });
const result = await verifySignedBundleV2(signedBundle, registry);
console.log(result.verified, result.errors); // true []
4. Python SDK¶
次のどちらかをインストールします。
- SDK 開発用のチェックアウト:
- または、ここで説明する修正と API を含む公開済みの 2.10.1:
バンドルを作成して検証する¶
from datetime import datetime, timezone
from dcp_ai import (
AgentPassport,
AuditEvidence,
BundleBuilder,
Intent,
PolicyDecision,
ResponsiblePrincipalRecord,
generate_keypair,
sign_bundle,
sign_object,
verify_object,
verify_signed_bundle,
)
now = datetime.now(timezone.utc).isoformat()
principal_keys = generate_keypair()
agent_keys = generate_keypair()
# 1. The responsible principal, signed with the principal's key (the object without "signature")
rpr_body = {
"dcp_version": "1.0", "human_id": "human:example-001", "legal_name": "Example Principal",
"entity_type": "natural_person", "jurisdiction": "ES", "liability_mode": "owner_responsible",
"override_rights": True, "issued_at": now, "expires_at": None, "contact": None,
}
rpr = {**rpr_body, "signature": sign_object(rpr_body, principal_keys["secret_key_b64"])}
# 2. The agent passport, signed with the agent's key (the object without "signature")
passport_body = {
"dcp_version": "1.0", "agent_id": "agent:example-001", "public_key": agent_keys["public_key_b64"],
"principal_binding_reference": "human:example-001", "capabilities": ["browse", "api_call"],
"risk_tier": "low", "created_at": now, "status": "active",
}
passport = {**passport_body, "signature": sign_object(passport_body, agent_keys["secret_key_b64"])}
# 3. Intent, policy decision and one audit entry
intent = Intent(
intent_id="intent:example-001", agent_id="agent:example-001", human_id="human:example-001",
timestamp=now, action_type="api_call", target={"channel": "api", "domain": "api.example.com"},
data_classes=["none"], estimated_impact="low", requires_consent=False,
)
policy = PolicyDecision(
intent_id="intent:example-001", decision="approve", risk_score=0.05, reasons=["low-impact call"],
)
bundle = (
BundleBuilder()
.responsible_principal_record(ResponsiblePrincipalRecord(**rpr))
.agent_passport(AgentPassport(**passport))
.intent(intent)
.policy_decision(policy)
.create_audit_entry(
audit_id="audit:example-001", timestamp=now, agent_id="agent:example-001",
human_id="human:example-001", intent_id="intent:example-001", policy_decision="approved",
outcome="call_completed", evidence=AuditEvidence(tool="http", result_ref=None),
)
.build()
)
# 4. Sign with the principal's key and verify against the principal's public key
signed = sign_bundle(bundle, principal_keys["secret_key_b64"])
print(verify_signed_bundle(signed, principal_keys["public_key_b64"])) # {'verified': True}
# 5. The inner signatures, over the same objects without "signature"
print(verify_object(rpr_body, rpr["signature"], principal_keys["public_key_b64"])) # True
print(verify_object(passport_body, passport["signature"], agent_keys["public_key_b64"])) # True
Python での V2 バンドルについては V2 Bundles を参照してください。
5. セキュリティティア¶
DCP は、意図のリスクプロファイルに基づいて暗号上のセキュリティティアを自動的に選びます。
| ティア | 名前 | 検証モード | PQ チェックポイントの間隔 | 条件 |
|---|---|---|---|---|
| 0 | Routine | クラシカルのみ(Ed25519) | 50 イベントごと | 以下のどの条件にも当てはまらない |
| 1 | Standard | ハイブリッド推奨 | 10 イベントごと | リスクスコア 200〜499、estimated_impact: medium |
| 2 | Elevated | ハイブリッド必須 | すべてのイベント | リスクスコア 500〜799、個人情報・金融・健康データ、支払い、estimated_impact: high、未知の値 |
| 3 | Maximum | ハイブリッド必須 | すべてのイベント | リスクスコア 800 以上、認証情報、子どものデータ |
リスクスコアはポリシー判断の risk_score です(仕様 §14.2)。
import { computeSecurityTier, tierToVerificationMode } from '@dcp-ai/sdk';
const tier = computeSecurityTier(intent, policyDecision);
const mode = tierToVerificationMode(tier);
// tier: 'elevated', mode: 'hybrid_required'
6. テレメトリーとオブザーバビリティ¶
import { dcpTelemetry } from '@dcp-ai/sdk';
dcpTelemetry.init({
serviceName: 'my-agent',
enabled: true,
exporterType: 'console', // or 'otlp'
});
// Automatic span tracking
const spanId = dcpTelemetry.startSpan('sign_bundle', { tier: 'elevated' });
// ... perform operation ...
dcpTelemetry.endSpan(spanId);
// Record metrics
dcpTelemetry.recordSignLatency(12.5, 'ed25519');
// Get summary
const summary = dcpTelemetry.getMetricsSummary();
console.log(summary.sign.p95); // p95 sign latency in ms
7. エージェント間(A2A)通信¶
import { createHello, createWelcome, createSession, encryptMessage } from '@dcp-ai/sdk';
// Agent A initiates
const hello = createHello(bundleA, kemPublicKeyB64, ['api_call'], 'standard');
// Agent B responds
const welcome = createWelcome(bundleB, kemPubB, kemCiphertextB64, 'standard');
// Establish encrypted session
const session = createSession(sessionId, sessionKey, 'agent-a', 'agent-b', 'standard');
// Send encrypted messages
const encrypted = encryptMessage(session, { action: 'transfer', amount: 100 });
ほかの SDK¶
Go¶
import dcp "github.com/dcp-ai-protocol/dcp-ai/sdks/go/v2/dcp"
canonical, _ := dcp.Canonicalize(map[string]string{"b": "2", "a": "1"})
// produces {"a":"1","b":"2"}
Rust¶
ML-DSA-65、ML-KEM-768、SLH-DSA-192f、Ed25519 のプロバイダーは dcp_ai::providers::* にあります。すべての API は docs.rs の dcp-ai クレートのドキュメントを参照してください。
WebAssembly(ブラウザー)¶
npm install @dcp-ai/wasm@^2.1.1 # the published version; for main, see the WASM SDK's Release status
Rust SDK の基本機能をブラウザーと Node.js に公開します。Node.js では、initDcp() は .wasm ファイルを data: URL として必要とします。初期化を参照してください。
リファレンスサービスを実行する¶
仕様が参照する 4 つのサービス(検証サーバー、anchor、透明性ログ、失効レジストリ)はすべて Docker イメージとして提供されています。空のディレクトリから次を実行します。
docker run -d -p 3000:3000 ghcr.io/dcp-ai-protocol/dcp-ai/verification:latest
docker run -d -p 3001:3001 ghcr.io/dcp-ai-protocol/dcp-ai/anchor:latest
docker run -d -p 3002:3002 ghcr.io/dcp-ai-protocol/dcp-ai/transparency-log:latest
docker run -d -p 3003:3003 ghcr.io/dcp-ai-protocol/dcp-ai/revocation:latest
マネージドなホスティングについては、deploy/fly/ の Fly.io の設定と、Cloud Run / Railway / Compose という選択肢を扱うデプロイガイドを参照してください。
次のステップ¶
- LangChain との統合 — LangChain のエージェントに DCP を追加する
- CrewAI との統合 — CrewAI のクルーに DCP を追加する
- OpenAI との統合 — OpenAI の関数呼び出しに DCP を追加する
- Express ミドルウェア — Express の API で DCP バンドルを検証する
- API リファレンス — SDK の完全なドキュメント
- プロトコル仕様 — DCP v2.0 の完全な仕様
- セキュリティモデル — 脅威モデルとセキュリティアーキテクチャ
- オペレーターガイド — 本番環境での検証サービスとアンカリングサービスの運用