Catalog npm
PACKAGE EXPLORERView in registry

@0xbow/privacy-pools-core-sdk

npm

Typescript SDK for the Privacy Pool protocol

Versions collected40
Direct dependencies28From release 1.5.0
Last observed20 Oct, 22:44 UTC

README

Current package documentation

Privacy Pool Core SDK

A TypeScript SDK for interacting with the Privacy Pool protocol. This SDK provides cryptographic utilities, proof generation, account management, and contract interactions for Privacy Pool integration.

Installation

npm install @0xbow/privacy-pools-core-sdk
# or
yarn add @0xbow/privacy-pools-core-sdk
# or
pnpm add @0xbow/privacy-pools-core-sdk

Setup

  1. Install dependencies by running pnpm install
  2. Build the SDK by running pnpm build

Available Scripts

ScriptDescription
buildBuild the SDK using Rollup
build:bundleBuild the SDK and set up circuits
check-typesCheck for TypeScript type issues
cleanRemove build artifacts
lintRun ESLint to check code quality
lint:fixFix linting issues automatically
formatCheck code formatting using Prettier
format:fixFix formatting issues automatically
testRun tests using Vitest
test:covGenerate test coverage report

Usage

Initialization

import { PrivacyPoolSDK, Circuits } from '@0xbow/privacy-pools-core-sdk';

// In Node.js — set browser: false to load artifacts from the filesystem
const circuits = new Circuits({ browser: false });

// In the browser — the default (browser: true) uses fetch
// const circuits = new Circuits();

const sdk = new PrivacyPoolSDK(circuits);

Commitment Proofs

const commitmentProof = await sdk.proveCommitment(value, label, nullifier, secret);
const isValid = await sdk.verifyCommitment(commitmentProof);

Withdrawal Proofs

const withdrawalProof = await sdk.proveWithdrawal(commitment, withdrawalInput);
const isValid = await sdk.verifyWithdrawal(withdrawalProof);

Key Derivation

The SDK derives deterministic master keys from a BIP-39 mnemonic phrase using generateMasterKeys. These keys are used to generate per-deposit and per-withdrawal nullifiers and secrets.

import { generateMasterKeys, generateDepositSecrets, generateWithdrawalSecrets } from '@0xbow/privacy-pools-core-sdk';

const { masterNullifier, masterSecret } = generateMasterKeys(mnemonic);

const depositSecrets = generateDepositSecrets(
  { masterNullifier, masterSecret },
  scope,
  index,
);

const withdrawalSecrets = generateWithdrawalSecrets(
  { masterNullifier, masterSecret },
  label,
  index,
);

Account Recovery

The AccountService reconstructs on-chain account state from a mnemonic by scanning deposit, withdrawal, and ragequit events.

import { AccountService, DataService } from '@0xbow/privacy-pools-core-sdk';

const { account, legacyAccount, errors } = await AccountService.initializeWithEvents(
  dataService,
  { mnemonic },
  pools,
);

Incomplete Scopes

A non-empty errors array means one or more pools failed to load. Reconstructed state for those scopes is absent, not empty — the account may hold notes that are not visible, so treating the scope as having no accounts will understate the next deposit index and produce a deposit that later reconstructions cannot find.

Check status before acting on a scope:

account.getScopeStatus(scope); // 'complete' | 'incomplete' | 'not-loaded'
account.isScopeComplete(scope); // true only for 'complete'
account.getIncompleteScopes(); // scopes whose last load failed

Block deposits and withdrawals for any scope that is not complete. createDepositSecrets(scope) without an explicit index throws for such a scope rather than guessing; pass an explicit index only in recovery flows. Status is stored on the account, so it survives persisting and restoring it.

To retry the failed pools, pass both services returned by the original call:

const retry = await AccountService.initializeWithEvents(
  dataService,
  { service: account, legacyService: legacyAccount },
  pools,
);

Omitting legacyService reconstructs the retried scopes without migration discovery, which silently omits migration-derived accounts.

Empty Nodes

account.getSpendableCommitments() returns the latest decrypted commitment of each account. By default (includeEmptyNodes: true) the result includes empty (zero-value), migrated, and ragequit nodes alongside spendable ones, so callers can see the full decrypted state.

To restore the spendable-only behavior — returning only commitments with a non-zero value whose account has not been ragequit or migrated — set includeEmptyNodes: false:

const { account } = await AccountService.initializeWithEvents(
  dataService,
  { mnemonic },
  pools,
  { includeEmptyNodes: false },
);

The same option can be passed when constructing an AccountService directly:

const account = new AccountService(dataService, { mnemonic, includeEmptyNodes: false });

Note: when includeEmptyNodes is true, getSpendableCommitments() may return commitments that are not actually spendable (zero-value, migrated, or ragequit). Filter on value / account flags before attempting to spend.

Contract Interactions

const contracts = sdk.createContractInstance(rpcUrl, chain, entrypointAddress, privateKey);

Mnemonic Security

The SDK does not provide a generateMnemonic utility. Use a trusted BIP-39 library (e.g. @scure/bip39 or viem/accounts) to generate mnemonic phrases externally.

  • Never hardcode mnemonics in source code or configuration files.
  • Never log or transmit mnemonics in plaintext.
  • Store mnemonics using OS-level secure storage (e.g. OS keychain, encrypted vault) — never in browser localStorage or unencrypted files.
  • Do not reuse a single mnemonic across unrelated applications. A compromised mnemonic exposes all derived keys and the funds they control.
  • The mnemonic is the sole root of all derived keys. Loss of the mnemonic means permanent loss of access to all associated commitments and funds.

Circuit Artifact Integrity

The SDK verifies every downloaded circuit artifact (wasm, vkey, zkey) against expected SHA-256 digests. Artifacts without a registered hash are rejected at load time.

ArtifactSHA-256
commitment.wasm254d2130607182fd6fd1aee67971526b13cfe178c88e360da96dce92663828d8
commitment.vkey7d48b4eb3dedc12fb774348287b587f0c18c3c7254cd60e9cf0f8b3636a570d8
commitment.zkey494ae92d64098fda2a5649690ddc5821fcd7449ca5fe8ef99ee7447544d7e1f3
withdraw.wasm36cda22791def3d520a55c0fc808369cd5849532a75fab65686e666ed3d55c10
withdraw.vkey666bd0983b20c1611543b04f7712e067fbe8cad69f07ada8a310837ff398d21e
withdraw.zkey2a893b42174c813566e5c40c715a8b90cd49fc4ecf384e3a6024158c3d6de677

You can independently verify these against the committed artifacts:

shasum -a 256 packages/circuits/trusted-setup/final-keys/*.{vkey,zkey}
shasum -a 256 packages/circuits/build/*/*_js/*.wasm

Features

  • Zero-knowledge proof generation and verification (commitments and withdrawals)
  • Deterministic key derivation from BIP-39 mnemonics
  • Account state recovery from on-chain events
  • Commitment and Merkle proof utilities
  • Contract interaction helpers
  • Type-safe API

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Apache-2.0 License - see the LICENSE file for details.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 40

Collected releases
VersionPublishedDirect dependenciesOpen version
1.5.0Registry latest31 Aug 202628
1.4.06 Aug 202628
1.2.019 Mar 202628
1.1.18 Mar 202628
0.0.0-3dpf8pk5 Mar 202628
1.1.019 Feb 202628
0.0.0-83f8c417 Feb 202628
0.0.0-83f8c316 Feb 202628
0.0.0-83f8c216 Feb 202628
1.0.413 Feb 202626
0.0.0-b21c14ef13 Feb 202625
0.0.0-b21c14bf13 Feb 202625
0.0.0-b21c14bd13 Feb 202625
0.0.0-b21c14ba12 Feb 202625
0.0.012 Feb 202625
1.0.312 Feb 202625
0.0.0-e101aa4 Sept 202525
1.0.22 Sept 202525
0.0.0-c42a71a328 Aug 202525
0.0.0-c42a71a228 Aug 202525

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
0xbow-io/privacy-pools-core

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:734b9a47786b9f3408cb1bad1c9888a213d99a8e52cee75de427a626bb764f7d