# @agentcontextdistributionprotocol/acdp-wasm 中文文档

规范地址：https://npmcn.com/package/%40agentcontextdistributionprotocol/acdp-wasm/

版本：0\.21\.4
npm 元数据更新时间：2026-11-07T04:51:33.464Z
中文译文更新时间：2026-11-06T15:59:20.138Z
软件包许可：MIT OR Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40agentcontextdistributionprotocol/acdp-wasm
原文对照：https://npmcn.com/package/%40agentcontextdistributionprotocol/acdp-wasm/?lang=original
项目主页：https://github.com/agentcontextdistributionprotocol/acdp-rs/tree/main/bindings/acdp-wasm
源码仓库：https://github.com/agentcontextdistributionprotocol/acdp-rs

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：873 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-07-07T02:16:36.260Z
- 最新版本发布：2026-11-07T04:51:33.109Z
- 近 30 天下载量：2806（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：31（近 12 个月 31 个）

## 中文简介

代理上下文分发协议——WebAssembly校验核心

## 安装

```sh
npm install @agentcontextdistributionprotocol/acdp-wasm
```

也可以使用：`pnpm add @agentcontextdistributionprotocol/acdp-wasm`、`yarn add @agentcontextdistributionprotocol/acdp-wasm`、`bun add @agentcontextdistributionprotocol/acdp-wasm`

## README

# acdp-wasm — ACDP 网络大会验证核心

这个 **浏览器/ 边缘** aCP 约束家庭成员 (单位:千美元)`bindings/acdp-py`, (中文(简体) ), `bindings/acdp-node`) (中文(简体) ). 纯洁的, **离线** 加密验证器:它允许消费者制作一个晶体开发方案的背景和 独立实现真正的核查 **判决** - 生产商 签名 `content_hash`,登记收据(RFC-ACDP-0010),a 区划头收据(RFC-ACDP-0011),一个透明记录的检查站 纳入/一致性证明(RFC-ACDP-0012),生命周期事件 (RFC-ACDP-0013)钥匙吊销(RFC-ACDP-0014)和证人 共同签署+法定人数(RFC-ACDP-0015) - **不信任任何服务器 已经做到了**这是控制台的客户端核查核心 判决需要消耗.

它是一个独立的货物包(它自己的 `[workspace]`这取决于 伞 `acdp` 带有 `default-features = false`这样 `reqwest` 编号 : `tokio` 编号 : `rustls` 永不输入 `.wasm` 二进制. 见 `docs/research/wasm-target.md` (历史)设计原理。 这个 软件包以相同的版本发布 `acdp` 箱; 哪个协议 每个释放工具都记录在 spec 中 [版本矩阵](https://github.com/agentcontextdistributionprotocol/agentcontextdistributionprotocol/blob/main/docs/version-matrix.md)。 。 。 . 仅 `wasm32-unknown-unknown` (浏览器 / 捆绑器 / 节点通过被包装) 是 (a) 建立和测试.

## 设计( 与 Python / 节点绑定的规则相同)

-   **JSON跨越边界.** 每次导出都使用 JSON 字符串和 返回 JSON 字符串 - a **判决对象** (单位:千美元)`{"valid": true, ...}` 编号 : `{"valid": false, "code"?, "error"}`用于核查结果,或a 构造器/解器的结果字符串。 错误 _东道主_ 投入 丢出一个 `JsError`; 失败 _核查_ 实值 `{"valid": false}`, (中文(简体) ), 从不扔.
-   **Rust的加密,主机的HTTP.** 没有网络通话. `did:web` 决议和所有运输停留在联署材料中`fetch` 文档 / 接收/身体,通过JSON英寸. `did:key` 完全核实 离线并不需要主机帮助——最高值浏览器路径.
-   **没有重新执行密码 .** 每张支票都一样 `acdp` 核心本地库 Python 和节点绑定使用。 0.3/0.4号 判决逻辑( e)`src/v030.rs`, (中文(简体) ), `src/v040.rs`页:1 **逐字记录, 字节相同** 从其他束缚.

## 导出表面

am-bindgen出口(JS/TypeScript中的骆驼案):

| 导出 | RFC (RFC ) (法语) | 目的 |
| --- | --- | --- |
| `verifyContentHash` | 0001第5.7节 | 重计算 `sha256(JCS(producer_content))` |
| `verifySignatureEd25519` 编号 : `verifySignatureP256` | 0001第5.8节 | aSCII的签字 `"sha256:<hex>"` 字符串 |
| `verifyCtxIdBinding` | 0006 第4.1节 第7步 | 绑定送达者 `ctx_id` ——见 [校验取回的正文](https://npmcn.com/package/%40agentcontextdistributionprotocol/acdp-wasm/#readme-verifying-a-retrieved-body) |
| `verifyBodyOffline` 编号 : `verifyPublishRequestOffline` | 0002 个 | 满 `did:key` 上下文验证( 无分辨率) |
| `fingerprintEd25519` 编号 : `verifyReceipt(receiptJson, bodyJson, registryPublicKeyB64, expectedCtxId, recomputedBodyHash, producerKeyFingerprint)` | 0010 (英语) | 登记册-接收核查——见 [核实登记收据](https://npmcn.com/package/%40agentcontextdistributionprotocol/acdp-wasm/#readme-verifying-a-registry-receipt) 下级 |
| `verifyLineageHeadReceipt` | 0011 (英语) | 区划头收据 |
| `verifyLogCheckpoint` 编号 : `verifyLogInclusion` 编号 : `verifyLogConsistency` 编号 : `buildLogLeaf` 编号 : `merkleLeafHash` 编号 : `merkleNodeHash` 编号 : `merkleRootHash` | 0012 (英语) | 透明度日志 |
| `verifyLifecycleEvent` | 0013 (英语) | 生命周期事件 |
| `parseKeyRevocation` 编号 : `classifyUnderRevocation` | 0014 (英语) | 密钥撤销 |
| `buildWitnessCosignature` 编号 : `verifyWitnessCosignature` 编号 : `evaluateWitnessQuorum` | 0015 (英语) | 证人签名+法定人数 |
| `resolveDidKey` | —— 说 | 离线 `did:key` • 公用钥匙 |
| `canonicalPreimage` 编号 : `explainHashMismatch` | —— 说 | hash-潜水诊断 |

## 安装

发布到 npm 为 **`@agentcontextdistributionprotocol/acdp-wasm`** 联合国 在 GitHub 动作上签名的 公共范围软件包,所以控制台 而其他消费者则依赖它

```bash
npm install @agentcontextdistributionprotocol/acdp-wasm
```

```js
import init, { verifyContentHash, verifySignatureEd25519, verifyCtxIdBinding }
  from "@agentcontextdistributionprotocol/acdp-wasm";
await init();
const verdict = JSON.parse(verifyContentHash(bodyJson, body.content_hash));
if (verdict.valid) { /* the hash the consumer recomputed itself checks out */ }

// Bind the served ctx_id to the one requested (RFC-ACDP-0006 §4.1 step 7).
// See "Verifying a retrieved body" below for why this is a separate call.
const binding = JSON.parse(verifyCtxIdBinding(bodyJson, requestedCtxId));
if (binding.valid) { /* the ctx_id you got back is the one you asked for */ }
```

### 校验取回的正文

`ctx_id` 登记并列入RFC-ACDP-0001§5.7排除条款 设定,所以它被剥去之前 `content_hash` 两者都是计算出来的 重新计算上面, 或制作人的签名覆盖它。 没有 明确比较,登记处可为任何其他有效签字机构服务 由同一生产商根据 `ctx_id` 您想要的 URL, 以及每个 上面的检查还是会过去的. `verifyCtxIdBinding(bodyJson, expectedCtxId)` 缩小这一差距: `bodyJson` 携带 _已服务_ 身份证明, `expectedCtxId` 这是你的要求。 喜欢 `verifyContentHash`,一个畸形 _已服务_ `ctx_id` 是一个 `{"valid": false, ...}` 判决,不是扔,而是扔 错误 `expectedCtxId` 参数丢出一个 `JsError`。 。 。 .

### 核实登记收据

`verifyReceipt` (RFC-ACDP-0010 第8节) `bodyJson` 作为 **所需经费** 第二个论点——它约束收据 `lineage_id`, (中文(简体) ), `origin_registry`,以及 `created_at` (第8节) 步骤 3 :

```js
const verdict = JSON.parse(verifyReceipt(
  receiptJson, bodyJson, registryPublicKeyB64,
  expectedCtxId, recomputedBodyHash, producerKeyFingerprint,
));
```

一个畸形 `bodyJson` 丢出一个 `JsError` (主机输入);机身/接收 不匹配是一个 `{"valid": false, ...}` 判决(核查结果),不 a 抛出——与 `verifyContentHash` 编号 : `verifyCtxIdBinding`。 。 。 . 两张支票仍然保留HOST的义务, 因为两者都不需要 机构:对服务机构有约束力的机构`receipt.registry_did` 必须是平等的 你们实际获得的权力)和重算(永远不要) {\\fn黑体\\fs22\\bord1\\shad0\\3ahbe\\4ah00\\fscx67\\fscy66\\2chffffff\\3ch808080}相信 {\\fn黑体\\fs22\\bord1\\shad0\\3ahbe\\4ah00\\fscx67\\fscy66\\2chffffff\\3ch808080}你通过的身体已经散了.

软件包由 `wasm-pack --target web`: 您的无害环境管理模块 初始化为 `await init()`这是箱子的目标 它在浏览器和浏览器中清空地装入 下一个客户端组件(webpack 5解决 `new URL(..., import.meta.url)` 是资产 `web` 目标发射——无 `experiments.asyncWebAssembly` 网页包覆盖,其中 `bundler` 目标要求).

## 构建

```bash
rustup target add wasm32-unknown-unknown

# Raw wasm (regression build-check):
cargo build --target wasm32-unknown-unknown            # verify-only default

# Browser package (.js / .wasm / .d.ts) with wasm-pack. `--scope` makes
# wasm-pack emit the package name `@agentcontextdistributionprotocol/acdp-wasm`
# (the same rename the release workflow performs):
wasm-pack build --target web --out-dir pkg --scope agentcontextdistributionprotocol
```

从浏览器( 本地、 未公布的构建) 导入 :

```js
import init, { verifyContentHash, verifySignatureEd25519, verifyCtxIdBinding } from "./pkg/acdp_wasm.js";
await init();
const verdict = JSON.parse(verifyContentHash(bodyJson, body.content_hash));
if (verdict.valid) { /* the hash the consumer recomputed itself checks out */ }
const binding = JSON.parse(verifyCtxIdBinding(bodyJson, requestedCtxId));
if (binding.valid) { /* the ctx_id you got back is the one you asked for */ }
```

## 黄金函数均等

`tests/golden.rs` 是一个 **本地语言** `cargo test` {\\fn黑体\\fs22\\bord1\\shad0\\3ahbe\\4ah00\\fscx67\\fscy66\\2chffffff\\3ch808080}那会运行着峡谷 `sig-001` (内容散列+Ed25519签名)和 `wit-001` (证人) 共同签名薄荷 + 验证) 光谱固定通过相同的纯度 `core` 函数导出为站点, 并显示字节复制 被钉住的黄金值—— 不变的 `acdp-py` 编号 : `acdp-node` 套接字针。 它通过 `ACDP_SPEC_DIR` 和优雅地跳过 缺席时:

```bash
ACDP_SPEC_DIR=../../../agentcontextdistributionprotocol cargo test
```

`tests/wasm.rs` 是一个 `wasm-bindgen-test` 真正的发动机烟雾测试 输出包装( 内置 sig- 001 常数, 不需要固定装置) :

```bash
wasm-pack test --node
```

## 随机——对研究备忘录的更正

`docs/research/wasm-target.md` 第4节预测a **仅验证** 建造会 需求 **没有 `getrandom` 后端** 任何目标。 保持不变 _运行时间_ - 没有出口核查(或确定性Ed25519) 证人薄荷)抽取随机. 没错 **没有** 暂停 _编译时间_ 页:1 `wasm32-unknown-unknown`: 核心箱拉动 **`getrandom 0.4`** **无条件**从两个地方, 它发出一个硬 `compile_error!` 除非后端有线,否则:

-   `acdp-crypto` 密钥生成( r)`getrandom::SysRng`,用于 `rand_core` 0.10,无 `OsRng`(二) 与
-   **`uuid` 页:1** (非可选择的依赖性) `acdp-primitives`) (中文(简体) ).

后端是阴茎 **`wasm_js` 特性** 联 合 国 `getrandom_wasm` 别名在 `Cargo.toml`),加 (中文(简体) ) `--cfg getrandom_backend="wasm_js"` 内 `.cargo/config.toml`,这是 惰性为0.4.3并保持前向相容性. `uuid` 额外 需要自己的钱 **`js` 特性** 为它的v4 RNG shim. (较旧的直线 `getrandom 0.2` a. 依赖 `js` 特性,用于前者 `rand_core 0.6` 编号 : `OsRng` 路径, 已删除; 这里没有 绑定的图表使用0.2 。 )

两者都接通了这里, **目标为 `wasm32` 仅限** (见 `Cargo.toml` 财务报告和审定财务报表 `.cargo/config.toml`),故为本地人 `cargo test` 实值 无所未有. `crypto.getRandomValues` (单位:千美元) `wasm_js` 后端)为 CSPRNG RFC-ACDP-0001 (中文(简体) ). §5.10 浏览器的名称, 所以选择是 spec-bloods ——但在核实路径上从未引用过;它只是用来链接的.

一个未来 `producer` 特性(保留,尚未接线)将暴露新鲜 密钥生成( r)`SigningKey::generate`,唯一一个 `SysRng` 电话) 运行时随机抽取的图.

## 安全说明

-   这个文物是 **校验者, 不是取取器**。 。 。 . `RegistryClient`, (中文(简体) ), `CrossRegistryResolver`,以及 `did:web` 分辨率不移动到相机; 该主机拥有 HTTP 和 RFC-ACDP-0006 §7 / RFC-ACDP-0008 SSRF 辩护。 传取出的文件作为JSON.
-   浏览器标签不是 HSM 。 核查没有秘密,但 未来 `producer`/ 键根表面会把签名种子放入相机 线性内存(RFC-ACDP-0001§5.10).

## 常见问题

### @agentcontextdistributionprotocol/acdp-wasm 是什么？

代理上下文分发协议——WebAssembly校验核心

### 如何安装 @agentcontextdistributionprotocol/acdp-wasm？

在项目目录运行 npm install @agentcontextdistributionprotocol/acdp-wasm，或使用 pnpm add / yarn add / bun add。

### @agentcontextdistributionprotocol/acdp-wasm 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @agentcontextdistributionprotocol/acdp-wasm 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @agentcontextdistributionprotocol/acdp-wasm 可以商用吗？

@agentcontextdistributionprotocol/acdp-wasm 使用 MIT OR Apache-2\.0 许可。可在 MIT、Apache-2\.0 中任选其一遵守。选择 MIT 时，宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @agentcontextdistributionprotocol/acdp-wasm 的下载量有多少？

根据 npm 官方下载统计，@agentcontextdistributionprotocol/acdp-wasm 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,806 次，日均约 94 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @agentcontextdistributionprotocol/acdp-wasm 还在维护吗？

最新版本 0\.21\.4 发布于 2026/11/07（今天）；至今共发布 31 个版本，其中过去 12 个月发布了 31 个；首次发布于 2026/07/07。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

