An ECMAScript module for NaCl / TweetNaCl high security cryptographic library.
| .github | ||
| _test | ||
| .codeql.yml | ||
| .gitattributes | ||
| .gitignore | ||
| .npm-codeberg.build.ts | ||
| .npm-github.build.ts | ||
| .npm-kaki87.build.ts | ||
| .npm-npm.build.ts | ||
| .yamllint.yml | ||
| _random_bytes.ts | ||
| CITATION.cff | ||
| CONTRIBUTING.md | ||
| deno.jsonc | ||
| jsr.jsonc | ||
| LICENSE.md | ||
| lowlevel.ts | ||
| mod.ts | ||
| README.md | ||
| SECURITY.md | ||
NaCl (ES)
An ECMAScript module for NaCl / TweetNaCl high security cryptographic library.
This is a modified edition of the TweetNaCl JS which with ECMAScript and TypeScript.
🎯 Targets
| Runtime \ Source | GitHub Raw | JSR | NPM |
|---|---|---|---|
| Bun >= v1.1.0 | ❌ | ✔️ | ✔️ |
| Deno >= v2.1.0 | ✔️ | ✔️ | ✔️ |
| NodeJS >= 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
-
function box(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; -
function boxBefore(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; -
function boxKeyPair(): KeyPair; -
function boxKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair; -
function boxOpen(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null; -
function hash(msg: Uint8Array): Uint8Array; -
function scalarMult(n: Uint8Array, p: Uint8Array): Uint8Array; -
function scalarMultBase(n: Uint8Array): Uint8Array; -
function secretBox(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; -
function secretBoxOpen(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; -
function sign(msg: Uint8Array, secretKey: Uint8Array): Uint8Array; -
function signDetached(msg: Uint8Array, secretKey: Uint8Array): Uint8Array; -
function signDetachedVerify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean; -
function signKeyPair(): KeyPair; -
function signKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair; -
function signKeyPairFromSeed(seed: Uint8Array): KeyPair; -
function signOpen(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null; -
function verify(x: Uint8Array, y: Uint8Array): boolean; -
interface KeyPair { publicKey: Uint8Array; secretKey: Uint8Array; }
Note
- For the full or prettier documentation, can visit via: