@cloakedxyz/clkd-privacy-pools

中文文档
3.1.0发布于 2026/05/20MITTypeScriptES Module近 30 天下载 1737

Privacy Pools key derivation, proof generation, and recovery tools for Cloaked

原始使用文档
文档目录7 节
  1. What this does
  2. Install
  3. Usage
  4. Amount Precision
  5. Supported chains
  6. Security
  7. License

@cloakedxyz/clkd-privacy-pools

Key derivation, proof generation, and recovery tools for 0xbow Privacy Pools integration in Cloaked.

What this does

  • Derives Privacy Pools secrets deterministically from a wallet signature (nothing to store)
  • Scans the chain for deposits and matches them to a wallet's key material
  • Generates ZK proofs for withdrawal and ragequit (commitment proofs)
  • Queries the ASP API for deposit review status and Merkle data
  • Calculates deposit fees from on-chain config

Install

pnpm add @cloakedxyz/clkd-privacy-pools

Usage

import {
  deriveMnemonic,
  deriveMasterKeys,
  deriveDepositSecrets,
  computePrecommitment,
  scanPoolEvents,
  getChainConfig,
} from '@cloakedxyz/clkd-privacy-pools';

// Derive PP secrets from a wallet signature
const mnemonic = await deriveMnemonic(signature);
const masterKeys = deriveMasterKeys(mnemonic);
const secrets = deriveDepositSecrets(masterKeys, poolScope, 0n);
const precommitment = computePrecommitment(secrets.nullifier, secrets.secret);

// Scan the chain for deposits
const config = getChainConfig(11155111); // Sepolia
const { depositsByPrecommitment } = await scanPoolEvents(
  publicClient,
  config.pools['ETH'].address,
  config.startBlock,
  latestBlock
);

Amount Precision

Privacy Pools emits deposit and withdrawal values in public on-chain events. Privacy Pools v1 uses a coarser deposit amount grid for the assets Cloaked supports: USDC, USDT, and ETH use 5 decimals for actual deposited event amounts. Relayed integrations should keep new deposit values on that same grid so a user does not stand out as the only account with extra decimal precision. Activity displays may render fewer decimals; that is presentation, not the amount rule.

These helpers encode that public amount convention. They are not a protocol or circuit constraint, and unsupported token symbols fail closed.

import {
  floorPrivacyPoolAmount,
  isPrivacyPoolAmountAligned,
} from '@cloakedxyz/clkd-privacy-pools';

const alignedDepositValue = floorPrivacyPoolAmount(netDepositValue, 6, 'USDC');
const isAligned = isPrivacyPoolAmountAligned(userDepositValue, 6, 'USDC');

For user-entered exact amounts, validate alignment and ask the user to adjust instead of silently changing the amount. For new max/all deposits, floor down to the grid before creating the deposit so every new Deposited value is aligned. Withdrawals can continue to use raw commitment amounts; once deposits are aligned, newly-created balances naturally stay on the same grid.

Supported chains

ChainIDASP API
Ethereum1api.0xbow.io
Sepolia11155111dw.0xbow.io

Security

  • Domain-separated key derivation (keccak256(encodePacked("privacy-pools-v1", signature))) ensures PP keys are cryptographically independent from stealth address keys derived from the same wallet signature
  • All proof generation runs client-side — no server ever sees user secrets
  • No private keys or secrets are stored — everything re-derives from the wallet

License

MIT

版本与发布记录

@cloakedxyz/clkd-privacy-pools 共发布 22 个版本,首次发布于 2026/03/22;过去 12 个月发布了 22 个版本。

版本发布日期距今
3.1.0latest2026/05/205 个月前
3.0.32026/05/066 个月前
3.0.22026/05/066 个月前
3.0.12026/05/066 个月前
3.0.02026/04/126 个月前
2.4.02026/04/067 个月前

关于 @cloakedxyz/clkd-privacy-pools 的常见问题

@cloakedxyz/clkd-privacy-pools 是什么?

Privacy Pools key derivation, proof generation, and recovery tools for Cloaked

如何安装 @cloakedxyz/clkd-privacy-pools?

在项目目录运行 npm install @cloakedxyz/clkd-privacy-pools,或使用 pnpm add / yarn add / bun add。

@cloakedxyz/clkd-privacy-pools 支持 TypeScript 吗?

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

@cloakedxyz/clkd-privacy-pools 支持 ESM 还是 CommonJS?

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

@cloakedxyz/clkd-privacy-pools 可以商用吗?

@cloakedxyz/clkd-privacy-pools 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cloakedxyz/clkd-privacy-pools 的下载量有多少?

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

@cloakedxyz/clkd-privacy-pools 还在维护吗?

最新版本 3.1.0 发布于 2026/05/20(5 个月前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/03/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。