ts-tweetnacl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS.md +27 -0
- package/CHANGELOG.md +283 -0
- package/LICENSE +24 -0
- package/PULL_REQUEST_TEMPLATE.md +20 -0
- package/README.md +527 -0
- package/nacl-fast.js +2391 -0
- package/nacl-fast.min.js +1 -0
- package/nacl.d.ts +98 -0
- package/nacl.js +1178 -0
- package/nacl.min.js +1 -0
- package/package.json +56 -0
package/AUTHORS.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
List of TweetNaCl.js authors
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
Format: Name (GitHub username or URL)
|
|
5
|
+
|
|
6
|
+
* Dmitry Chestnykh (@dchest)
|
|
7
|
+
* Devi Mandiri (@devi)
|
|
8
|
+
* AndSDev (@AndSDev)
|
|
9
|
+
|
|
10
|
+
List of authors of third-party public domain code from which TweetNaCl.js code was derived
|
|
11
|
+
==========================================================================================
|
|
12
|
+
|
|
13
|
+
[TweetNaCl](http://tweetnacl.cr.yp.to/)
|
|
14
|
+
--------------------------------------
|
|
15
|
+
|
|
16
|
+
* Bernard van Gastel
|
|
17
|
+
* Daniel J. Bernstein <http://cr.yp.to/djb.html>
|
|
18
|
+
* Peter Schwabe <http://www.cryptojedi.org/users/peter/>
|
|
19
|
+
* Sjaak Smetsers <http://www.cs.ru.nl/~sjakie/>
|
|
20
|
+
* Tanja Lange <http://hyperelliptic.org/tanja>
|
|
21
|
+
* Wesley Janssen
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[Poly1305-donna](https://github.com/floodyberry/poly1305-donna)
|
|
25
|
+
--------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
* Andrew Moon (@floodyberry)
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
TweetNaCl.js Changelog
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
v1.0.3
|
|
5
|
+
------
|
|
6
|
+
|
|
7
|
+
***IMPORTANT BUG FIX***. Due to a bug in calculating carry in
|
|
8
|
+
modulo reduction that used bit operations on integers larger than
|
|
9
|
+
32 bits, `nacl.sign` or `nacl.sign.detached` could have created
|
|
10
|
+
incorrect signatures.
|
|
11
|
+
|
|
12
|
+
This only affects signing, not verification.
|
|
13
|
+
|
|
14
|
+
Thanks to @valerini on GitHub for finding and reporting the bug.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
v1.0.2
|
|
18
|
+
------
|
|
19
|
+
|
|
20
|
+
Exported more internal undocumented functions for
|
|
21
|
+
third-party projects that rely on low-level interface,
|
|
22
|
+
(something users of TweetNaCl shouldn't care about).
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
v1.0.1
|
|
26
|
+
------
|
|
27
|
+
|
|
28
|
+
Updated documentation and typings.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
v1.0.0
|
|
32
|
+
------
|
|
33
|
+
|
|
34
|
+
No code changes from v1.0.0-rc.1.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
v1.0.0-rc.1
|
|
38
|
+
-----------
|
|
39
|
+
|
|
40
|
+
* **IMPORTANT!** In previous versions, `nacl.secretbox.open`, `nacl.box.open`,
|
|
41
|
+
and `nacl.box.after` returned `false` when opening failed (for example, when
|
|
42
|
+
using incorrect key, nonce, or when input was maliciously or accidentally
|
|
43
|
+
modified after encryption). This version instead returns `null`.
|
|
44
|
+
|
|
45
|
+
The usual way to check for this condition:
|
|
46
|
+
|
|
47
|
+
`if (!result) { ... }`
|
|
48
|
+
|
|
49
|
+
is correct and will continue to work.
|
|
50
|
+
|
|
51
|
+
However, direct comparison with `false`:
|
|
52
|
+
|
|
53
|
+
`if (result == false) { ... }`
|
|
54
|
+
|
|
55
|
+
it will no longer work and **will not detect failure**. Please check
|
|
56
|
+
your code for this condition.
|
|
57
|
+
|
|
58
|
+
(`nacl.sign.open` always returned `null`, so it is not affected.)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
* Arguments type check now uses `instanceof Uint8Array` instead of `Object.prototype.toString`.
|
|
62
|
+
* Removed deprecation checks for `nacl.util` (moved to a
|
|
63
|
+
[separate package](https://github.com/dchest/tweetnacl-util-js) in v0.14.0).
|
|
64
|
+
* Removed deprecation checks for the old signature API (changed in v0.10.0).
|
|
65
|
+
* Improved benchmarking.
|
|
66
|
+
|
|
67
|
+
v0.14.5
|
|
68
|
+
-------
|
|
69
|
+
|
|
70
|
+
* Fixed incomplete return types in TypeScript typings.
|
|
71
|
+
* Replaced COPYING.txt with LICENSE file, which now has public domain dedication
|
|
72
|
+
text from The Unlicense. License fields in package.json and bower.json have
|
|
73
|
+
been set to "Unlicense". The project was and will be in the public domain --
|
|
74
|
+
this change just makes it easier for automated tools to know about this fact by
|
|
75
|
+
using the widely recognized and SPDX-compatible template for public domain
|
|
76
|
+
dedication.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
v0.14.4
|
|
80
|
+
-------
|
|
81
|
+
|
|
82
|
+
* Added TypeScript type definitions (contributed by @AndSDev).
|
|
83
|
+
* Improved benchmarking code.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
v0.14.3
|
|
87
|
+
-------
|
|
88
|
+
|
|
89
|
+
Fixed a bug in the fast version of Poly1305 and brought it back.
|
|
90
|
+
|
|
91
|
+
Thanks to @floodyberry for promptly responding and fixing the original C code:
|
|
92
|
+
|
|
93
|
+
> "The issue was not properly detecting if st->h was >= 2^130 - 5, coupled with
|
|
94
|
+
> [testing mistake] not catching the failure. The chance of the bug affecting
|
|
95
|
+
> anything in the real world is essentially zero luckily, but it's good to have
|
|
96
|
+
> it fixed."
|
|
97
|
+
|
|
98
|
+
https://github.com/floodyberry/poly1305-donna/issues/2#issuecomment-202698577
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
v0.14.2
|
|
102
|
+
-------
|
|
103
|
+
|
|
104
|
+
Switched Poly1305 fast version back to original (slow) version due to a bug.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
v0.14.1
|
|
108
|
+
-------
|
|
109
|
+
|
|
110
|
+
No code changes, just tweaked packaging and added COPYING.txt.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
v0.14.0
|
|
114
|
+
-------
|
|
115
|
+
|
|
116
|
+
* **Breaking change!** All functions from `nacl.util` have been removed. These
|
|
117
|
+
functions are no longer available:
|
|
118
|
+
|
|
119
|
+
nacl.util.decodeUTF8
|
|
120
|
+
nacl.util.encodeUTF8
|
|
121
|
+
nacl.util.decodeBase64
|
|
122
|
+
nacl.util.encodeBase64
|
|
123
|
+
|
|
124
|
+
If want to continue using them, you can include
|
|
125
|
+
<https://github.com/dchest/tweetnacl-util-js> package:
|
|
126
|
+
|
|
127
|
+
<script src="nacl.min.js"></script>
|
|
128
|
+
<script src="nacl-util.min.js"></script>
|
|
129
|
+
|
|
130
|
+
or
|
|
131
|
+
|
|
132
|
+
var nacl = require('tweetnacl');
|
|
133
|
+
nacl.util = require('tweetnacl-util');
|
|
134
|
+
|
|
135
|
+
However it is recommended to use better packages that have wider
|
|
136
|
+
compatibility and better performance. Functions from `nacl.util` were never
|
|
137
|
+
intended to be robust solution for string conversion and were included for
|
|
138
|
+
convenience: cryptography library is not the right place for them.
|
|
139
|
+
|
|
140
|
+
Currently calling these functions will throw error pointing to
|
|
141
|
+
`tweetnacl-util-js` (in the next version this error message will be removed).
|
|
142
|
+
|
|
143
|
+
* Improved detection of available random number generators, making it possible
|
|
144
|
+
to use `nacl.randomBytes` and related functions in Web Workers without
|
|
145
|
+
changes.
|
|
146
|
+
|
|
147
|
+
* Changes to testing (see README).
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
v0.13.3
|
|
151
|
+
-------
|
|
152
|
+
|
|
153
|
+
No code changes.
|
|
154
|
+
|
|
155
|
+
* Reverted license field in package.json to "Public domain".
|
|
156
|
+
|
|
157
|
+
* Fixed typo in README.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
v0.13.2
|
|
161
|
+
-------
|
|
162
|
+
|
|
163
|
+
* Fixed undefined variable bug in fast version of Poly1305. No worries, this
|
|
164
|
+
bug was *never* triggered.
|
|
165
|
+
|
|
166
|
+
* Specified CC0 public domain dedication.
|
|
167
|
+
|
|
168
|
+
* Updated development dependencies.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
v0.13.1
|
|
172
|
+
-------
|
|
173
|
+
|
|
174
|
+
* Exclude `crypto` and `buffer` modules from browserify builds.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
v0.13.0
|
|
178
|
+
-------
|
|
179
|
+
|
|
180
|
+
* Made `nacl-fast` the default version in NPM package. Now
|
|
181
|
+
`require("tweetnacl")` will use fast version; to get the original version,
|
|
182
|
+
use `require("tweetnacl/nacl.js")`.
|
|
183
|
+
|
|
184
|
+
* Cleanup temporary array after generating random bytes.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
v0.12.2
|
|
188
|
+
-------
|
|
189
|
+
|
|
190
|
+
* Improved performance of curve operations, making `nacl.scalarMult`, `nacl.box`,
|
|
191
|
+
`nacl.sign` and related functions up to 3x faster in `nacl-fast` version.
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
v0.12.1
|
|
195
|
+
-------
|
|
196
|
+
|
|
197
|
+
* Significantly improved performance of Salsa20 (~1.5x faster) and
|
|
198
|
+
Poly1305 (~3.5x faster) in `nacl-fast` version.
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
v0.12.0
|
|
202
|
+
-------
|
|
203
|
+
|
|
204
|
+
* Instead of using the given secret key directly, TweetNaCl.js now copies it to
|
|
205
|
+
a new array in `nacl.box.keyPair.fromSecretKey` and
|
|
206
|
+
`nacl.sign.keyPair.fromSecretKey`.
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
v0.11.2
|
|
210
|
+
-------
|
|
211
|
+
|
|
212
|
+
* Added new constant: `nacl.sign.seedLength`.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
v0.11.1
|
|
216
|
+
-------
|
|
217
|
+
|
|
218
|
+
* Even faster hash for both short and long inputs (in `nacl-fast`).
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
v0.11.0
|
|
222
|
+
-------
|
|
223
|
+
|
|
224
|
+
* Implement `nacl.sign.keyPair.fromSeed` to enable creation of sign key pairs
|
|
225
|
+
deterministically from a 32-byte seed. (It behaves like
|
|
226
|
+
[libsodium's](http://doc.libsodium.org/public-key_cryptography/public-key_signatures.html)
|
|
227
|
+
`crypto_sign_seed_keypair`: the seed becomes a secret part of the secret key.)
|
|
228
|
+
|
|
229
|
+
* Fast version now has an improved hash implementation that is 2x-5x faster.
|
|
230
|
+
|
|
231
|
+
* Fixed benchmarks, which may have produced incorrect measurements.
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
v0.10.1
|
|
235
|
+
-------
|
|
236
|
+
|
|
237
|
+
* Exported undocumented `nacl.lowlevel.crypto_core_hsalsa20`.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
v0.10.0
|
|
241
|
+
-------
|
|
242
|
+
|
|
243
|
+
* **Signature API breaking change!** `nacl.sign` and `nacl.sign.open` now deal
|
|
244
|
+
with signed messages, and new `nacl.sign.detached` and
|
|
245
|
+
`nacl.sign.detached.verify` are available.
|
|
246
|
+
|
|
247
|
+
Previously, `nacl.sign` returned a signature, and `nacl.sign.open` accepted a
|
|
248
|
+
message and "detached" signature. This was unlike NaCl's API, which dealt with
|
|
249
|
+
signed messages (concatenation of signature and message).
|
|
250
|
+
|
|
251
|
+
The new API is:
|
|
252
|
+
|
|
253
|
+
nacl.sign(message, secretKey) -> signedMessage
|
|
254
|
+
nacl.sign.open(signedMessage, publicKey) -> message | null
|
|
255
|
+
|
|
256
|
+
Since detached signatures are common, two new API functions were introduced:
|
|
257
|
+
|
|
258
|
+
nacl.sign.detached(message, secretKey) -> signature
|
|
259
|
+
nacl.sign.detached.verify(message, signature, publicKey) -> true | false
|
|
260
|
+
|
|
261
|
+
(Note that it's `verify`, not `open`, and it returns a boolean value, unlike
|
|
262
|
+
`open`, which returns an "unsigned" message.)
|
|
263
|
+
|
|
264
|
+
* NPM package now comes without `test` directory to keep it small.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
v0.9.2
|
|
268
|
+
------
|
|
269
|
+
|
|
270
|
+
* Improved documentation.
|
|
271
|
+
* Fast version: increased theoretical message size limit from 2^32-1 to 2^52
|
|
272
|
+
bytes in Poly1305 (and thus, secretbox and box). However this has no impact
|
|
273
|
+
in practice since JavaScript arrays or ArrayBuffers are limited to 32-bit
|
|
274
|
+
indexes, and most implementations won't allocate more than a gigabyte or so.
|
|
275
|
+
(Obviously, there are no tests for the correctness of implementation.) Also,
|
|
276
|
+
it's not recommended to use messages that large without splitting them into
|
|
277
|
+
smaller packets anyway.
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
v0.9.1
|
|
281
|
+
------
|
|
282
|
+
|
|
283
|
+
* Initial release
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <http://unlicense.org>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Important!
|
|
2
|
+
|
|
3
|
+
If your contribution is not trivial (not a typo fix, etc.), we can only accept
|
|
4
|
+
it if you dedicate your copyright for the contribution to the public domain.
|
|
5
|
+
Make sure you understand what it means (see http://unlicense.org/)! If you
|
|
6
|
+
agree, please add yourself to AUTHORS.md file, and include the following text
|
|
7
|
+
to your pull request description or a comment in it:
|
|
8
|
+
|
|
9
|
+
------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
I dedicate any and all copyright interest in this software to the
|
|
12
|
+
public domain. I make this dedication for the benefit of the public at
|
|
13
|
+
large and to the detriment of my heirs and successors. I intend this
|
|
14
|
+
dedication to be an overt act of relinquishment in perpetuity of all
|
|
15
|
+
present and future rights to this software under copyright law.
|
|
16
|
+
|
|
17
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
18
|
+
distribute this software, either in source code form or as a compiled
|
|
19
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
20
|
+
means.
|