
Security News
Socket Security Analysis Is Now One Click Away on npm
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.
@aztec/bb.js
Advanced tools
Prover/verifier library for barretenberg. It bundles support for the following:
If running within node.js on a support os/architecture we will use appropriate native code. If running within node.js on an unsupported architecture we will fallback to multi-threaded WASM. If running within the browser and served without COOP/COEP headers, we use the single-threaded WASM. If running within the browser served with COOP/COEP headers, we use the multi-threaded WASM.
npm install @aztec/bb.js
or with yarn
yarn add @aztec/bb.js
To create the API and do a blake2s hash:
import { Crs, Barretenberg, RawBuffer } from './index.js';
const api = await Barretenberg.new({ threads: 1 });
const input = Buffer.from('hello world!');
const result = await api.blake2s(input);
await api.destroy();
All methods are asynchronous. If no threads are specified, will default to number of cores with a maximum of 32.
If 1 is specified, fallback to non multi-threaded wasm that doesn't need shared memory.
See src/main.ts for larger example of how to use.
It's recommended to use a dynamic import. This allows the developer to pick the time at which the package (several MB in size) is loaded and keeps page load times responsive.
const { Barretenberg, RawBuffer, Crs } = await import('@aztec/bb.js');
Multithreading in bb.js requires SharedArrayBuffer to be enabled. It is only enabled in browsers if COOP and COEP headers are set by the server. Read more here.
You can configure your server to set these headers for pages that perform proof generation. See this example project that implements multi-threaded browser proving, which contains the below Next.js config:
{
...
async headers() {
return [
{
source: '/:path*',
headers: [
{ key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' },
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
],
},
];
},
}
Note that adding COOP and COEP headers will disable loading of external scripts, which might be required by your application.
You can enable these headers for specific pages that perform proof generation, but this may be challenging, especially in single-page applications. One workaround is to move the proof generation to a separate page, load it in an invisible iframe within your main application, and then use postMessage to communicate between the pages for generating proofs.
Got an unhelpful stack trace in wasm? Run:
BUILD_CPP=1 NO_STRIP=1 ./script/copy_wasm.sh
This will drop unstripped wasms into the dest folder. Run your test again to get a trace.
FAQs
Prover/verifier executable and API for barretenberg. Default cli arguments are appropriate for running within Noir project structures.
The npm package @aztec/bb.js receives a total of 16,078 weekly downloads. As such, @aztec/bb.js popularity was classified as popular.
We found that @aztec/bb.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.