Skip to content

Commit 402f970

Browse files
authored
Add chacha20-poly1305 (#4)
1 parent 71ad109 commit 402f970

File tree

16 files changed

+494
-370
lines changed

16 files changed

+494
-370
lines changed

.cspell.jsonc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"chacha",
44
"ecies",
55
"hchacha",
6+
"webcrypto",
67
"xchacha"
78
],
89
"ignorePaths": [
10+
"LICENSE",
911
".git",
1012
".github",
1113
".gitignore",
1214
".cspell.jsonc",
13-
"LICENSE",
14-
"package.json"
15+
"settings.json",
16+
"package.json",
17+
"pnpm-lock.yaml"
1518
]
1619
}

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,8 @@ jobs:
7474
- name: check main.js
7575
run: |
7676
./scripts/check-runtime.sh example/main.js
77+
78+
- name: check main.js on mininum supported node version
79+
run: |
80+
curl -sL https://nodejs.org/download/release/v16.0.0/node-v16.0.0-linux-x64.tar.gz | tar -xz
81+
./node-v16.0.0-linux-x64/bin/node example/main.js && rm -rf node-v16.0.0-linux-x64

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Release Notes
22

3+
## 0.2.2
4+
5+
- Add `chacha20-poly1305` support
6+
- Bump dependencies
7+
- Add minimum supported node (16.0.0) runtime check in CI
8+
39
## 0.2.1
410

511
- Add React Native package exports
612

713
## 0.2.0
814

9-
- Add xchacha20-poly1305 support
15+
- Add `xchacha20-poly1305` support
1016

1117
## 0.1.0
1218

13-
- First beta version release with aes-256-gcm and aes-256-cbc support
19+
- First beta version release with `aes-256-gcm` and `aes-256-cbc` support

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# @ecies/ciphers
22

33
[![License](https://img.shields.io/github/license/ecies/js-ciphers.svg)](https://github.com/ecies/js-ciphers)
4-
[![Npm Package](https://img.shields.io/npm/v/@ecies/ciphers.svg)](https://www.npmjs.com/package/@ecies/ciphers)
4+
[![NPM Package](https://img.shields.io/npm/v/@ecies/ciphers.svg)](https://www.npmjs.com/package/@ecies/ciphers)
5+
![NPM Downloads](https://img.shields.io/npm/dm/@ecies/ciphers)
6+
[![Install size](https://packagephobia.com/badge?p=@ecies/ciphers)](https://packagephobia.com/result?p=@ecies/ciphers)
57
[![CI](https://img.shields.io/github/actions/workflow/status/ecies/js-ciphers/ci.yml)](https://github.com/ecies/js-ciphers/actions)
68
[![Codecov](https://img.shields.io/codecov/c/github/ecies/js-ciphers.svg)](https://codecov.io/gh/ecies/js-ciphers)
79

@@ -15,6 +17,8 @@ On node (or bun), it'll use [`node:crypto`](https://nodejs.org/api/crypto.html#c
1517
> You may need to polyfill [`crypto.getRandomValues`](https://github.com/LinusU/react-native-get-random-values) for React Native.
1618
>
1719
> There are some limitations, see [Known limitations](#known-limitations) below.
20+
>
21+
> This library is tree-shakeable, unused code will be excluded by bundlers.
1822
1923
Check the [example](./example/) folder for bun/deno usage.
2024

@@ -44,11 +48,15 @@ The API follows `@noble/ciphers`'s API for ease of use, you can check their [exa
4448
- `aes-256-cbc`
4549
- **Only for legacy applications**. You should use `xchacha20-poly1305` or `aes-256-gcm` as possible.
4650
- Nonce is always 16 bytes.
51+
- `chacha20-poly1305`
52+
- Nonce is always 12 bytes.
4753
- `xchacha20-poly1305`
4854
- Nonce is always 24 bytes.
4955

56+
If key is fixed and nonce is less than 16 bytes, avoid randomly generated nonce.
57+
5058
## Known limitations
5159

52-
- `xchacha20-poly1305` is implemented with pure JS [`hchacha`](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2) function and `node:crypto`'s `chacha20-poly1305`.
53-
- Currently (Oct 2024), `node:crypto`'s `chacha20-poly1305` is not supported on deno and [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.
60+
- `xchacha20-poly1305` is implemented with pure JS [`hchacha20`](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2) function and `node:crypto`'s `chacha20-poly1305` on node.
61+
- Currently (Nov 2024), `node:crypto`'s `chacha20-poly1305` is not supported on deno and [bun](https://github.com/oven-sh/bun/issues/8072), `@noble/ciphers`'s implementation is used on both platforms instead.
5462
- `deno` does not support **indirect** conditional exports. If you use this library to build another library, client code of your library probably falls back to the `node:crypto` implementation and may not work properly, specifically `aes-256-gcm` (16 bytes nonce) and `chacha20-poly1305`.

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "git",
1212
"url": "git+https://github.com/ecies/js-ciphers.git"
1313
},
14-
"version": "0.2.1",
14+
"version": "0.2.2",
1515
"engines": {
1616
"node": ">=16",
1717
"bun": ">=1",
@@ -22,12 +22,15 @@
2222
"cipher",
2323
"aes",
2424
"chacha",
25+
"chacha20",
26+
"chacha20poly1305",
2527
"xchacha20",
2628
"xchacha20poly1305"
2729
],
2830
"files": [
2931
"dist"
3032
],
33+
"main": "dist/index.js",
3134
"exports": {
3235
".": null,
3336
"./aes": {
@@ -56,10 +59,10 @@
5659
"@noble/ciphers": "^1.0.0"
5760
},
5861
"devDependencies": {
59-
"@types/node": "^22.8.6",
60-
"@vitest/coverage-v8": "^2.1.4",
61-
"typescript": "^5.6.3",
62-
"vitest": "^2.1.4"
62+
"@types/node": "^22.10.1",
63+
"@vitest/coverage-v8": "^2.1.6",
64+
"typescript": "^5.7.2",
65+
"vitest": "^2.1.6"
6366
},
64-
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
67+
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387"
6568
}

0 commit comments

Comments
 (0)