{
 "kind": "tool",
 "slug": "tweetnacl",
 "path": "tools/tweetnacl/",
 "name": "TweetNaCl.js",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Crypto and web3",
   "tools/web3/"
  ]
 ],
 "lead": "JavaScript implementation of NaCl cryptography for Solana wallet signing.",
 "chips": [
  {
   "label": "Crypto and web3",
   "path": "tools/web3/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install tweetnacl"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/dchest/tweetnacl-js"
  },
  {
   "label": "Website",
   "href": "https://tweetnacl.js.org"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Unlicense",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/dchest/tweetnacl-js"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Quiet for a year",
   "status": "cond",
   "sub": "Last change Aug 15, 2025",
   "note": "Latest GitHub release Feb 10, 2020. ",
   "src": "https://github.com/dchest/tweetnacl-js"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "14 projects",
   "status": "info",
   "sub": "#5 of 155 in its category",
   "note": "Dependency in 14 public GitHub projects set up for AI coding agents that we scanned (0.2%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What TweetNaCl.js does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "TweetNaCl.js popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "67",
       "of": "/ 100",
       "l": "Gid Score, #556 overall"
      },
      {
       "n": "52.1M",
       "l": "downloads a week, npm"
      },
      {
       "n": "1,923",
       "l": "GitHub stars"
      },
      {
       "n": "14",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How TweetNaCl.js is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "9 projects, 0.3%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "5 projects, 0.2%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "5 projects, 0.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 89.2% of its projects",
       "v": "Solana Web3.js",
       "path": "tools/solana-web3-js/"
      },
      {
       "l": "In 31.1% of its projects",
       "v": "Solana SPL Token",
       "path": "tools/solana-spl-token/"
      },
      {
       "l": "In 29.0% of its projects",
       "v": "bip39",
       "path": "tools/bip39/"
      },
      {
       "l": "In 29.5% of its projects",
       "v": "Axios",
       "path": "tools/axios/"
      },
      {
       "l": "In 57.7% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 24.9% of its projects",
       "v": "ed25519-hd-key",
       "path": "tools/ed25519-hd-key/"
      },
      {
       "l": "In 24.1% of its projects",
       "v": "ethers.js",
       "path": "tools/ethers/"
      },
      {
       "l": "In 23.7% of its projects",
       "v": "Solana Wallet Adapter",
       "path": "tools/solana-wallet-adapter-react/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "TweetNaCl.js in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Cure53 audit in 2017",
       "v": "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."
      },
      {
       "l": "A near-literal port you can pick over the fast one",
       "v": "<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."
      },
      {
       "l": "A test run that diffs against C TweetNaCl",
       "v": "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."
      },
      {
       "l": "Maintainer benchmarks for the fast build",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The README recommends WebCrypto where possible",
       "v": "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."
      },
      {
       "l": "<code>box</code> and <code>secretbox</code> are not key-committing",
       "v": "One ciphertext can decrypt to valid plaintexts under two different keys. The README says this may lead to vulnerabilities where key commitment is expected."
      },
      {
       "l": "<code>nacl.sign</code> signatures are malleable",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Plugging in your own entropy source"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Js",
       "code": "nacl.setPRNG(function(x, n) {\n  // ... copy n random bytes into x ...\n});"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about TweetNaCl.js",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "@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"
       ]
      },
      {
       "title": "More in Crypto and web3",
       "path": "tools/web3/",
       "items": [
        {
         "text": "Solana Web3.js",
         "path": "tools/solana-web3-js/"
        },
        {
         "text": "wagmi",
         "path": "tools/wagmi/"
        },
        {
         "text": "Hardhat",
         "path": "tools/hardhat/"
        },
        {
         "text": "OpenZeppelin Contracts",
         "path": "tools/openzeppelin/"
        },
        {
         "text": "Solana SPL Token",
         "path": "tools/solana-spl-token/"
        },
        {
         "text": "Hardhat Toolbox",
         "path": "tools/nomicfoundation-hardhat-toolbox/"
        },
        {
         "text": "Metaplex",
         "path": "tools/metaplex-foundation/"
        },
        {
         "text": "web3.py",
         "path": "tools/web3-tool-pypi/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "TweetNaCl.js",
       "me": true,
       "facts": [
        "Unlicense",
        "Gid 67",
        "52.1M/wk"
       ]
      },
      {
       "name": "viem",
       "why": "TypeScript interface for Ethereum with type-safe interactions.",
       "path": "tools/viem/",
       "facts": [
        "MIT",
        "Gid 73",
        "10.7M/wk"
       ]
      },
      {
       "name": "ethers.js",
       "why": "Complete Ethereum library for building dapps, wallets and blockchain tools.",
       "path": "tools/ethers/",
       "facts": [
        "MIT",
        "Gid 69",
        "5.1M/wk"
       ]
      }
     ],
     "more": "Compare TweetNaCl.js with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install tweetnacl"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## TweetNaCl.js\n- Pass and expect `Uint8Array` everywhere. Encode or decode strings with `tweetnacl-util` or another codec package.\n- To get a Node `Buffer` from a result, copy with `Buffer.from(array)`. Never use `Buffer.from(array.buffer)`, because some functions return subarrays.\n- The 24-byte nonce for `nacl.box` and `nacl.secretbox` must be unique for each distinct message under the key or key pair.\n- Check for `null` from `nacl.box.open`, `nacl.secretbox.open` and `nacl.sign.open`, and for `false` from `nacl.sign.detached.verify`.\n- Generate signing keys with `nacl.sign.keyPair()`. The docs say `fromSeed` is not recommended for general use.\n- 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.\n- 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.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm tweetnacl"
  ],
  [
   "Category",
   "Crypto and web3"
  ],
  [
   "License",
   "Unlicense"
  ],
  [
   "Latest version",
   "1.0.3, February 10, 2020"
  ],
  [
   "On GitHub since",
   "January 2014"
  ],
  [
   "Gid Score",
   "66.9"
  ],
  [
   "Rank in category",
   "#5 of 155"
  ],
  [
   "GitHub",
   "dchest/tweetnacl-js"
  ],
  [
   "Last change",
   "Aug 15, 2025"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/dchest.png"
}