https://github.com/hugoalh/nacl-es
An ECMAScript (JavaScript & TypeScript) module for NaCl / TweetNaCl high-security cryptographic library.
https://github.com/hugoalh/nacl-es
ecmascript ecmascript-module es es-module esm esmodule javascript js nacl ts typescript
Last synced: 12 days ago
JSON representation
An ECMAScript (JavaScript & TypeScript) module for NaCl / TweetNaCl high-security cryptographic library.
- Host: GitHub
- URL: https://github.com/hugoalh/nacl-es
- Owner: hugoalh
- License: other
- Created: 2025-07-16T06:09:28.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-08-29T09:59:10.000Z (about 2 months ago)
- Last Synced: 2025-09-05T14:04:10.484Z (about 1 month ago)
- Topics: ecmascript, ecmascript-module, es, es-module, esm, esmodule, javascript, js, nacl, ts, typescript
- Language: TypeScript
- Homepage:
- Size: 2.05 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# NaCl (ES)
[**⚖️** MIT](./LICENSE.md)
[](https://github.com/hugoalh/nacl-es)
[](https://jsr.io/@hugoalh/nacl)
[](https://www.npmjs.com/package/@hugoalh/nacl)An ECMAScript module for [NaCl](https://nacl.cr.yp.to/) / [TweetNaCl](https://tweetnacl.cr.yp.to/) high security cryptographic library.
This is a modified edition of the [TweetNaCl JS](https://github.com/dchest/tweetnacl-js) which with ECMAScript and TypeScript.
## 🎯 Targets
| **Runtime \\ Source** | **GitHub Raw** | **JSR** | **NPM** |
|:--|:-:|:-:|:-:|
| **[Bun](https://bun.sh/)** >= v1.1.0 | ❌ | ✔️ | ✔️ |
| **[Deno](https://deno.land/)** >= v2.1.0 | ✔️ | ✔️ | ✔️ |
| **[NodeJS](https://nodejs.org/)** >= v20.9.0 | ❌ | ✔️ | ✔️ |## 🛡️ Runtime Permissions
This does not request any runtime permission.
## #️⃣ Sources
- GitHub Raw
```
https://raw.githubusercontent.com/hugoalh/nacl-es/{Tag}/mod.ts
```
- JSR
```
jsr:@hugoalh/nacl[@{Tag}]
```
- NPM
```
npm:@hugoalh/nacl[@{Tag}]
```> [!NOTE]
> - It is recommended to include tag for immutability.
> - These are not part of the public APIs hence should not be used:
> - Benchmark/Test file (e.g.: `example.bench.ts`, `example.test.ts`).
> - Entrypoint name or path include any underscore prefix (e.g.: `_example.ts`, `foo/_example.ts`).
> - Identifier/Namespace/Symbol include any underscore prefix (e.g.: `_example`, `Foo._example`).## ⤵️ Entrypoints
| **Name** | **Path** | **Description** |
|:--|:--|:--|
| `.` | `./mod.ts` | Default. High level APIs. |
| `./lowlevel` | `./lowlevel.ts` | Low level APIs. |## 🧩 APIs
- ```ts
function box(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
```
- ```ts
function boxBefore(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
```
- ```ts
function boxKeyPair(): KeyPair;
```
- ```ts
function boxKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair;
```
- ```ts
function boxOpen(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null;
```
- ```ts
function hash(msg: Uint8Array): Uint8Array;
```
- ```ts
function scalarMult(n: Uint8Array, p: Uint8Array): Uint8Array;
```
- ```ts
function scalarMultBase(n: Uint8Array): Uint8Array;
```
- ```ts
function secretBox(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array;
```
- ```ts
function secretBoxOpen(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null;
```
- ```ts
function sign(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
```
- ```ts
function signDetached(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
```
- ```ts
function signDetachedVerify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean;
```
- ```ts
function signKeyPair(): KeyPair;
```
- ```ts
function signKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair;
```
- ```ts
function signKeyPairFromSeed(seed: Uint8Array): KeyPair;
```
- ```ts
function signOpen(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null;
```
- ```ts
function verify(x: Uint8Array, y: Uint8Array): boolean;
```
- ```ts
interface KeyPair {
publicKey: Uint8Array;
secretKey: Uint8Array;
}
```> [!NOTE]
> - For the full or prettier documentation, can visit via:
> - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc/)
> - [JSR](https://jsr.io/@hugoalh/nacl)