Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

TweetNaCl.js

JavaScript implementation of NaCl cryptography for Solana wallet signing.

Crypto and web3NPM

GitHubWebsite

1. License

License from npm.

github.com/dchest/tweetnacl-js

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What TweetNaCl.js does

TweetNaCl.js is a deliberately literal JavaScript port of the C library TweetNaCl, and its own README tells you to use the WebCrypto API where possible, since WebCrypto covers most of its primitives except XSalsa20-Poly1305 encryption.

TweetNaCl.js popularity

67 / 100
Gid Score, #556 overall
52.1M
downloads a week, npm
1,923
GitHub stars
14
agent projects use it
TweetNaCl.js: downloads per weeknpm, tweetnacl 52,131,481
TweetNaCl.js: GitHub starsdchest/tweetnacl-js 1,923

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How TweetNaCl.js is used

  • TweetNaCl.js is a dependency in 14 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 241 projects, and what it is used with below comes from all of them.
  • The most used alternative in our scan is viem (47 projects).
  • Projects that use it most often also use Solana Web3.js (89.2%), Solana SPL Token (31.1%), bip39 (29.0%).

By coding agent

9 projects, 0.3%
5 projects, 0.2%
5 projects, 0.2%

Often used with

In 89.2% of its projects
In 31.1% of its projects
In 29.0% of its projects
In 29.5% of its projects
In 57.7% of its projects
In 24.9% of its projects
In 24.1% of its projects
In 23.7% of its projects

TweetNaCl.js in practice

Strengths

Cure53 audit in 2017

Cure53 audited the library in January-February 2017. The report, as quoted in the README, says the testers were unable to find any security problems. The README adds that one bug was discovered and fixed after the audit.

A near-literal port you can pick over the fast one

<code>nacl.js</code> stays close to the C source, plus the high-level API. <code>nacl-fast.js</code> swaps in faster functions and is what the npm package loads by default.

A test run that diffs against C TweetNaCl

A separate script, <code>npm run test-node-all</code>, runs the full Node.js suite. That suite includes comparing the JavaScript port's outputs with the original C version. The default <code>npm run test-node</code> tests <code>nacl.min.js</code> unless <code>NACL_SRC</code> points elsewhere.

Maintainer benchmarks for the fast build

By the README's own benchmarks, <code>nacl-fast.js</code> encrypts and authenticates more than 57000 1024-byte messages per second on a typical laptop. The README also gives more than 14000 on a $170 smartphone, per CPU core.

Watch out for

The README recommends WebCrypto where possible

The maintainers note that WebCrypto supports most of the primitives here: X25519, Ed25519 and SHA-512. The exception is XSalsa20-Poly1305 authenticated encryption. Their advice is to use WebCrypto if possible.

<code>box</code> and <code>secretbox</code> are not key-committing

One ciphertext can decrypt to valid plaintexts under two different keys. The README says this may lead to vulnerabilities where key commitment is expected.

<code>nacl.sign</code> signatures are malleable

Anyone can produce a second valid signature for an already signed message without the secret key. The README warns about contexts where malleability is not expected.

Plugging in your own entropy source

nacl.setPRNG(function(x, n) {
  // ... copy n random bytes into x ...
});

More about TweetNaCl.js

Packages around it
  • @solana/web3.js: Solana JavaScript SDK
  • @solana/spl-token: Solana token program client
  • axios: HTTP client
  • bip39: Mnemonic seed phrases
  • react: UI library
  • ed25519-hd-key: Ed25519 HD key derivation
More in Crypto and web3

Alternatives

TweetNaCl.js This page

UnlicenseGid 6752.1M/wk

viem

TypeScript interface for Ethereum with type-safe interactions.

MITGid 7310.7M/wk

ethers.js

Complete Ethereum library for building dapps, wallets and blockchain tools.

MITGid 695.1M/wk

Compare TweetNaCl.js with another tool

Get started

Install it.

npm install tweetnacl

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## TweetNaCl.js
- Pass and expect `Uint8Array` everywhere. Encode or decode strings with `tweetnacl-util` or another codec package.
- To get a Node `Buffer` from a result, copy with `Buffer.from(array)`. Never use `Buffer.from(array.buffer)`, because some functions return subarrays.
- The 24-byte nonce for `nacl.box` and `nacl.secretbox` must be unique for each distinct message under the key or key pair.
- Check for `null` from `nacl.box.open`, `nacl.secretbox.open` and `nacl.sign.open`, and for `false` from `nacl.sign.detached.verify`.
- Generate signing keys with `nacl.sign.keyPair()`. The docs say `fromSeed` is not recommended for general use.
- Expect `nacl.randomBytes`, `nacl.box.keyPair` and `nacl.sign.keyPair` to throw if the platform has no suitable PRNG. Only call `nacl.setPRNG` with a cryptographically strong source, never `Math.random`. It completely replaces the internal generator.
- Prefer WebCrypto for X25519, Ed25519 and SHA-512 where available. Do not design protocols that rely on key commitment, signature uniqueness or SHA-512 resistance to length extension.