ethereum-cryptographyy 2.1.2
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.
Potentially problematic release.
This version of ethereum-cryptographyy might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +508 -0
- package/aes.d.ts +2 -0
- package/aes.js +98 -0
- package/bip39/index.d.ts +1 -0
- package/bip39/index.js +10 -0
- package/bip39/wordlists/czech.d.ts +1 -0
- package/bip39/wordlists/czech.js +5 -0
- package/bip39/wordlists/english.d.ts +1 -0
- package/bip39/wordlists/english.js +5 -0
- package/bip39/wordlists/french.d.ts +1 -0
- package/bip39/wordlists/french.js +5 -0
- package/bip39/wordlists/italian.d.ts +1 -0
- package/bip39/wordlists/italian.js +5 -0
- package/bip39/wordlists/japanese.d.ts +1 -0
- package/bip39/wordlists/japanese.js +5 -0
- package/bip39/wordlists/korean.d.ts +1 -0
- package/bip39/wordlists/korean.js +5 -0
- package/bip39/wordlists/simplified-chinese.d.ts +1 -0
- package/bip39/wordlists/simplified-chinese.js +5 -0
- package/bip39/wordlists/spanish.d.ts +1 -0
- package/bip39/wordlists/spanish.js +5 -0
- package/bip39/wordlists/traditional-chinese.d.ts +1 -0
- package/bip39/wordlists/traditional-chinese.js +5 -0
- package/blake2b.d.ts +1 -0
- package/blake2b.js +13 -0
- package/esm/aes.js +93 -0
- package/esm/bip39/index.js +1 -0
- package/esm/bip39/wordlists/czech.js +1 -0
- package/esm/bip39/wordlists/english.js +1 -0
- package/esm/bip39/wordlists/french.js +1 -0
- package/esm/bip39/wordlists/italian.js +1 -0
- package/esm/bip39/wordlists/japanese.js +1 -0
- package/esm/bip39/wordlists/korean.js +1 -0
- package/esm/bip39/wordlists/simplified-chinese.js +1 -0
- package/esm/bip39/wordlists/spanish.js +1 -0
- package/esm/bip39/wordlists/traditional-chinese.js +1 -0
- package/esm/blake2b.js +9 -0
- package/esm/hdkey.js +1 -0
- package/esm/index.js +2 -0
- package/esm/keccak.js +10 -0
- package/esm/package.json +3 -0
- package/esm/pbkdf2.js +26 -0
- package/esm/random.js +7 -0
- package/esm/ripemd160.js +3 -0
- package/esm/scrypt.js +12 -0
- package/esm/secp256k1-compat.js +254 -0
- package/esm/secp256k1.js +1 -0
- package/esm/sha256.js +3 -0
- package/esm/sha512.js +3 -0
- package/esm/utils.js +47 -0
- package/hdkey.d.ts +1 -0
- package/hdkey.js +6 -0
- package/index.d.ts +0 -0
- package/index.js +2 -0
- package/keccak.d.ts +11 -0
- package/keccak.js +13 -0
- package/package.json +365 -0
- package/pbkdf2.d.ts +2 -0
- package/pbkdf2.js +31 -0
- package/random.d.ts +2 -0
- package/random.js +12 -0
- package/ripemd160.d.ts +1 -0
- package/ripemd160.js +6 -0
- package/scrypt.d.ts +4 -0
- package/scrypt.js +17 -0
- package/secp256k1-compat.d.ts +35 -0
- package/secp256k1-compat.js +278 -0
- package/secp256k1.d.ts +1 -0
- package/secp256k1.js +5 -0
- package/sha256.d.ts +1 -0
- package/sha256.js +6 -0
- package/sha512.d.ts +1 -0
- package/sha512.js +6 -0
- package/utils.d.ts +12 -0
- package/utils.js +63 -0
package/package.json
ADDED
@@ -0,0 +1,365 @@
|
|
1
|
+
{
|
2
|
+
"name": "ethereum-cryptographyy",
|
3
|
+
"version": "2.1.2",
|
4
|
+
"description": "All the cryptographic primitives used in Ethereum",
|
5
|
+
"contributors": [
|
6
|
+
{
|
7
|
+
"name": "Patricio Palladino",
|
8
|
+
"email": "patricio@nomiclabs.io"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "Paul Miller",
|
12
|
+
"url": "https://paulmillr.com"
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"repository": "https://github.com/ethereum/js-ethereum-cryptography",
|
16
|
+
"license": "MIT",
|
17
|
+
"main": "./index.js",
|
18
|
+
"files": [
|
19
|
+
"bip39/*.js",
|
20
|
+
"bip39/*.d.ts",
|
21
|
+
"bip39/wordlists/*.js",
|
22
|
+
"bip39/wordlists/*.d.ts",
|
23
|
+
"*.js",
|
24
|
+
"*.d.ts",
|
25
|
+
"esm"
|
26
|
+
],
|
27
|
+
"dependencies": {
|
28
|
+
"@jackshanyeshuzi/curvess": "^1.1.0",
|
29
|
+
"@noble/curves": "1.1.0",
|
30
|
+
"@noble/hashes": "1.3.1",
|
31
|
+
"@scure/bip32": "1.3.1",
|
32
|
+
"@scure/bip39": "1.2.1"
|
33
|
+
},
|
34
|
+
"exports": {
|
35
|
+
".": {
|
36
|
+
"types": "./index.d.ts",
|
37
|
+
"import": "./esm/index.js",
|
38
|
+
"default": "./index.js"
|
39
|
+
},
|
40
|
+
"./aes": {
|
41
|
+
"types": "./aes.d.ts",
|
42
|
+
"import": "./esm/aes.js",
|
43
|
+
"default": "./aes.js"
|
44
|
+
},
|
45
|
+
"./bip39": {
|
46
|
+
"types": "./bip39/index.d.ts",
|
47
|
+
"import": "./esm/bip39/index.js",
|
48
|
+
"default": "./bip39/index.js"
|
49
|
+
},
|
50
|
+
"./blake2b": {
|
51
|
+
"types": "./blake2b.d.ts",
|
52
|
+
"import": "./esm/blake2b.js",
|
53
|
+
"default": "./blake2b.js"
|
54
|
+
},
|
55
|
+
"./hdkey": {
|
56
|
+
"types": "./hdkey.d.ts",
|
57
|
+
"import": "./esm/hdkey.js",
|
58
|
+
"default": "./hdkey.js"
|
59
|
+
},
|
60
|
+
"./index": {
|
61
|
+
"types": "./index.d.ts",
|
62
|
+
"import": "./esm/index.js",
|
63
|
+
"default": "./index.js"
|
64
|
+
},
|
65
|
+
"./keccak": {
|
66
|
+
"types": "./keccak.d.ts",
|
67
|
+
"import": "./esm/keccak.js",
|
68
|
+
"default": "./keccak.js"
|
69
|
+
},
|
70
|
+
"./pbkdf2": {
|
71
|
+
"types": "./pbkdf2.d.ts",
|
72
|
+
"import": "./esm/pbkdf2.js",
|
73
|
+
"default": "./pbkdf2.js"
|
74
|
+
},
|
75
|
+
"./random": {
|
76
|
+
"types": "./random.d.ts",
|
77
|
+
"import": "./esm/random.js",
|
78
|
+
"default": "./random.js"
|
79
|
+
},
|
80
|
+
"./ripemd160": {
|
81
|
+
"types": "./ripemd160.d.ts",
|
82
|
+
"import": "./esm/ripemd160.js",
|
83
|
+
"default": "./ripemd160.js"
|
84
|
+
},
|
85
|
+
"./scrypt": {
|
86
|
+
"types": "./scrypt.d.ts",
|
87
|
+
"import": "./esm/scrypt.js",
|
88
|
+
"default": "./scrypt.js"
|
89
|
+
},
|
90
|
+
"./secp256k1-compat": {
|
91
|
+
"types": "./secp256k1-compat.d.ts",
|
92
|
+
"import": "./esm/secp256k1-compat.js",
|
93
|
+
"default": "./secp256k1-compat.js"
|
94
|
+
},
|
95
|
+
"./secp256k1": {
|
96
|
+
"types": "./secp256k1.d.ts",
|
97
|
+
"import": "./esm/secp256k1.js",
|
98
|
+
"default": "./secp256k1.js"
|
99
|
+
},
|
100
|
+
"./sha256": {
|
101
|
+
"types": "./sha256.d.ts",
|
102
|
+
"import": "./esm/sha256.js",
|
103
|
+
"default": "./sha256.js"
|
104
|
+
},
|
105
|
+
"./sha512": {
|
106
|
+
"types": "./sha512.d.ts",
|
107
|
+
"import": "./esm/sha512.js",
|
108
|
+
"default": "./sha512.js"
|
109
|
+
},
|
110
|
+
"./utils": {
|
111
|
+
"types": "./utils.d.ts",
|
112
|
+
"import": "./esm/utils.js",
|
113
|
+
"default": "./utils.js"
|
114
|
+
},
|
115
|
+
"./bip39/index": {
|
116
|
+
"types": "./bip39/index.d.ts",
|
117
|
+
"import": "./esm/bip39/index.js",
|
118
|
+
"default": "./bip39/index.js"
|
119
|
+
},
|
120
|
+
"./bip39/wordlists/czech": {
|
121
|
+
"types": "./bip39/wordlists/czech.d.ts",
|
122
|
+
"import": "./esm/bip39/wordlists/czech.js",
|
123
|
+
"default": "./bip39/wordlists/czech.js"
|
124
|
+
},
|
125
|
+
"./bip39/wordlists/english": {
|
126
|
+
"types": "./bip39/wordlists/english.d.ts",
|
127
|
+
"import": "./esm/bip39/wordlists/english.js",
|
128
|
+
"default": "./bip39/wordlists/english.js"
|
129
|
+
},
|
130
|
+
"./bip39/wordlists/french": {
|
131
|
+
"types": "./bip39/wordlists/french.d.ts",
|
132
|
+
"import": "./esm/bip39/wordlists/french.js",
|
133
|
+
"default": "./bip39/wordlists/french.js"
|
134
|
+
},
|
135
|
+
"./bip39/wordlists/italian": {
|
136
|
+
"types": "./bip39/wordlists/italian.d.ts",
|
137
|
+
"import": "./esm/bip39/wordlists/italian.js",
|
138
|
+
"default": "./bip39/wordlists/italian.js"
|
139
|
+
},
|
140
|
+
"./bip39/wordlists/japanese": {
|
141
|
+
"types": "./bip39/wordlists/japanese.d.ts",
|
142
|
+
"import": "./esm/bip39/wordlists/japanese.js",
|
143
|
+
"default": "./bip39/wordlists/japanese.js"
|
144
|
+
},
|
145
|
+
"./bip39/wordlists/korean": {
|
146
|
+
"types": "./bip39/wordlists/korean.d.ts",
|
147
|
+
"import": "./esm/bip39/wordlists/korean.js",
|
148
|
+
"default": "./bip39/wordlists/korean.js"
|
149
|
+
},
|
150
|
+
"./bip39/wordlists/simplified-chinese": {
|
151
|
+
"types": "./bip39/wordlists/simplified-chinese.d.ts",
|
152
|
+
"import": "./esm/bip39/wordlists/simplified-chinese.js",
|
153
|
+
"default": "./bip39/wordlists/simplified-chinese.js"
|
154
|
+
},
|
155
|
+
"./bip39/wordlists/spanish": {
|
156
|
+
"types": "./bip39/wordlists/spanish.d.ts",
|
157
|
+
"import": "./esm/bip39/wordlists/spanish.js",
|
158
|
+
"default": "./bip39/wordlists/spanish.js"
|
159
|
+
},
|
160
|
+
"./bip39/wordlists/traditional-chinese": {
|
161
|
+
"types": "./bip39/wordlists/traditional-chinese.d.ts",
|
162
|
+
"import": "./esm/bip39/wordlists/traditional-chinese.js",
|
163
|
+
"default": "./bip39/wordlists/traditional-chinese.js"
|
164
|
+
},
|
165
|
+
"./aes.js": {
|
166
|
+
"types": "./aes.d.ts",
|
167
|
+
"import": "./esm/aes.js",
|
168
|
+
"default": "./aes.js"
|
169
|
+
},
|
170
|
+
"./bip39.js": {
|
171
|
+
"types": "./bip39/index.d.ts",
|
172
|
+
"import": "./esm/bip39/index.js",
|
173
|
+
"default": "./bip39/index.js"
|
174
|
+
},
|
175
|
+
"./blake2b.js": {
|
176
|
+
"types": "./blake2b.d.ts",
|
177
|
+
"import": "./esm/blake2b.js",
|
178
|
+
"default": "./blake2b.js"
|
179
|
+
},
|
180
|
+
"./hdkey.js": {
|
181
|
+
"types": "./hdkey.d.ts",
|
182
|
+
"import": "./esm/hdkey.js",
|
183
|
+
"default": "./hdkey.js"
|
184
|
+
},
|
185
|
+
"./index.js": {
|
186
|
+
"types": "./index.d.ts",
|
187
|
+
"import": "./esm/index.js",
|
188
|
+
"default": "./index.js"
|
189
|
+
},
|
190
|
+
"./keccak.js": {
|
191
|
+
"types": "./keccak.d.ts",
|
192
|
+
"import": "./esm/keccak.js",
|
193
|
+
"default": "./keccak.js"
|
194
|
+
},
|
195
|
+
"./pbkdf2.js": {
|
196
|
+
"types": "./pbkdf2.d.ts",
|
197
|
+
"import": "./esm/pbkdf2.js",
|
198
|
+
"default": "./pbkdf2.js"
|
199
|
+
},
|
200
|
+
"./random.js": {
|
201
|
+
"types": "./random.d.ts",
|
202
|
+
"import": "./esm/random.js",
|
203
|
+
"default": "./random.js"
|
204
|
+
},
|
205
|
+
"./ripemd160.js": {
|
206
|
+
"types": "./ripemd160.d.ts",
|
207
|
+
"import": "./esm/ripemd160.js",
|
208
|
+
"default": "./ripemd160.js"
|
209
|
+
},
|
210
|
+
"./scrypt.js": {
|
211
|
+
"types": "./scrypt.d.ts",
|
212
|
+
"import": "./esm/scrypt.js",
|
213
|
+
"default": "./scrypt.js"
|
214
|
+
},
|
215
|
+
"./secp256k1-compat.js": {
|
216
|
+
"types": "./secp256k1-compat.d.ts",
|
217
|
+
"import": "./esm/secp256k1-compat.js",
|
218
|
+
"default": "./secp256k1-compat.js"
|
219
|
+
},
|
220
|
+
"./secp256k1.js": {
|
221
|
+
"types": "./secp256k1.d.ts",
|
222
|
+
"import": "./esm/secp256k1.js",
|
223
|
+
"default": "./secp256k1.js"
|
224
|
+
},
|
225
|
+
"./sha256.js": {
|
226
|
+
"types": "./sha256.d.ts",
|
227
|
+
"import": "./esm/sha256.js",
|
228
|
+
"default": "./sha256.js"
|
229
|
+
},
|
230
|
+
"./sha512.js": {
|
231
|
+
"types": "./sha512.d.ts",
|
232
|
+
"import": "./esm/sha512.js",
|
233
|
+
"default": "./sha512.js"
|
234
|
+
},
|
235
|
+
"./utils.js": {
|
236
|
+
"types": "./utils.d.ts",
|
237
|
+
"import": "./esm/utils.js",
|
238
|
+
"default": "./utils.js"
|
239
|
+
},
|
240
|
+
"./bip39/index.js": {
|
241
|
+
"types": "./bip39/index.d.ts",
|
242
|
+
"import": "./esm/bip39/index.js",
|
243
|
+
"default": "./bip39/index.js"
|
244
|
+
},
|
245
|
+
"./bip39/wordlists/czech.js": {
|
246
|
+
"types": "./bip39/wordlists/czech.d.ts",
|
247
|
+
"import": "./esm/bip39/wordlists/czech.js",
|
248
|
+
"default": "./bip39/wordlists/czech.js"
|
249
|
+
},
|
250
|
+
"./bip39/wordlists/english.js": {
|
251
|
+
"types": "./bip39/wordlists/english.d.ts",
|
252
|
+
"import": "./esm/bip39/wordlists/english.js",
|
253
|
+
"default": "./bip39/wordlists/english.js"
|
254
|
+
},
|
255
|
+
"./bip39/wordlists/french.js": {
|
256
|
+
"types": "./bip39/wordlists/french.d.ts",
|
257
|
+
"import": "./esm/bip39/wordlists/french.js",
|
258
|
+
"default": "./bip39/wordlists/french.js"
|
259
|
+
},
|
260
|
+
"./bip39/wordlists/italian.js": {
|
261
|
+
"types": "./bip39/wordlists/italian.d.ts",
|
262
|
+
"import": "./esm/bip39/wordlists/italian.js",
|
263
|
+
"default": "./bip39/wordlists/italian.js"
|
264
|
+
},
|
265
|
+
"./bip39/wordlists/japanese.js": {
|
266
|
+
"types": "./bip39/wordlists/japanese.d.ts",
|
267
|
+
"import": "./esm/bip39/wordlists/japanese.js",
|
268
|
+
"default": "./bip39/wordlists/japanese.js"
|
269
|
+
},
|
270
|
+
"./bip39/wordlists/korean.js": {
|
271
|
+
"types": "./bip39/wordlists/korean.d.ts",
|
272
|
+
"import": "./esm/bip39/wordlists/korean.js",
|
273
|
+
"default": "./bip39/wordlists/korean.js"
|
274
|
+
},
|
275
|
+
"./bip39/wordlists/simplified-chinese.js": {
|
276
|
+
"types": "./bip39/wordlists/simplified-chinese.d.ts",
|
277
|
+
"import": "./esm/bip39/wordlists/simplified-chinese.js",
|
278
|
+
"default": "./bip39/wordlists/simplified-chinese.js"
|
279
|
+
},
|
280
|
+
"./bip39/wordlists/spanish.js": {
|
281
|
+
"types": "./bip39/wordlists/spanish.d.ts",
|
282
|
+
"import": "./esm/bip39/wordlists/spanish.js",
|
283
|
+
"default": "./bip39/wordlists/spanish.js"
|
284
|
+
},
|
285
|
+
"./bip39/wordlists/traditional-chinese.js": {
|
286
|
+
"types": "./bip39/wordlists/traditional-chinese.d.ts",
|
287
|
+
"import": "./esm/bip39/wordlists/traditional-chinese.js",
|
288
|
+
"default": "./bip39/wordlists/traditional-chinese.js"
|
289
|
+
}
|
290
|
+
},
|
291
|
+
"browser": {
|
292
|
+
"crypto": false
|
293
|
+
},
|
294
|
+
"sideEffects": false,
|
295
|
+
"scripts": {
|
296
|
+
"prepare": "npm run build",
|
297
|
+
"build": "npm-run-all build:tsc",
|
298
|
+
"build:tsc": "tsc --project tsconfig.prod.json && tsc --project tsconfig.prod.esm.json",
|
299
|
+
"test": "npm-run-all test:node",
|
300
|
+
"test:node": "cd test && npm install && cd .. && mocha",
|
301
|
+
"clean": "rimraf test/test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'",
|
302
|
+
"lint": "eslint",
|
303
|
+
"lint:fix": "eslint --fix",
|
304
|
+
"browser-tests": "npm-run-all browser-tests:build browser-tests:test",
|
305
|
+
"browser-tests:build": "bash -x ./scripts/build-browser-tests.sh",
|
306
|
+
"browser-tests:test": "npm-run-all browser-tests:test-parcel browser-tests:test-browserify browser-tests:test-webpack browser-tests:test-rollup",
|
307
|
+
"browser-tests:test-parcel": "karma start --single-run --browsers ChromeHeadless test/karma.parcel.conf.js",
|
308
|
+
"browser-tests:test-browserify": "karma start --single-run --browsers ChromeHeadless test/karma.browserify.conf.js",
|
309
|
+
"browser-tests:test-webpack": "karma start --single-run --browsers ChromeHeadless test/karma.webpack.conf.js",
|
310
|
+
"browser-tests:test-rollup": "karma start --single-run --browsers ChromeHeadless test/karma.rollup.conf.js"
|
311
|
+
},
|
312
|
+
"devDependencies": {
|
313
|
+
"@rollup/plugin-commonjs": "22.0.1",
|
314
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
315
|
+
"@types/estree": "1.0.0",
|
316
|
+
"@types/mocha": "9.1.1",
|
317
|
+
"@types/node": "18.15.11",
|
318
|
+
"@typescript-eslint/eslint-plugin": "5.30.6",
|
319
|
+
"@typescript-eslint/parser": "5.30.6",
|
320
|
+
"browserify": "17.0.0",
|
321
|
+
"eslint": "8.38.0",
|
322
|
+
"eslint-plugin-prettier": "4.2.1",
|
323
|
+
"karma": "6.4.0",
|
324
|
+
"karma-chrome-launcher": "3.1.1",
|
325
|
+
"karma-mocha": "2.0.1",
|
326
|
+
"karma-mocha-reporter": "2.2.5",
|
327
|
+
"mocha": "10.0.0",
|
328
|
+
"npm-run-all": "4.1.5",
|
329
|
+
"parcel": "2.6.2",
|
330
|
+
"prettier": "2.7.1",
|
331
|
+
"rimraf": "~3.0.2",
|
332
|
+
"rollup": "2.76.0",
|
333
|
+
"ts-node": "10.9.1",
|
334
|
+
"typescript": "5.0.2",
|
335
|
+
"webpack": "5.76.0",
|
336
|
+
"webpack-cli": "4.10.0"
|
337
|
+
},
|
338
|
+
"keywords": [
|
339
|
+
"ethereum",
|
340
|
+
"cryptography",
|
341
|
+
"digital signature",
|
342
|
+
"hash",
|
343
|
+
"encryption",
|
344
|
+
"prng",
|
345
|
+
"keccak",
|
346
|
+
"scrypt",
|
347
|
+
"pbkdf2",
|
348
|
+
"sha-256",
|
349
|
+
"ripemd-160",
|
350
|
+
"blake2b",
|
351
|
+
"aes",
|
352
|
+
"advanced encryption standard",
|
353
|
+
"secp256k1",
|
354
|
+
"ecdsa",
|
355
|
+
"bip32",
|
356
|
+
"hierarchical deterministic keys",
|
357
|
+
"hdwallet",
|
358
|
+
"hdkeys"
|
359
|
+
],
|
360
|
+
"targets": {
|
361
|
+
"parcel_tests": {
|
362
|
+
"context": "browser"
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
package/pbkdf2.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare function pbkdf2(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, digest: string): Promise<Uint8Array>;
|
2
|
+
export declare function pbkdf2Sync(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, digest: string): Uint8Array;
|
package/pbkdf2.js
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.pbkdf2Sync = exports.pbkdf2 = void 0;
|
4
|
+
const pbkdf2_1 = require("@noble/hashes/pbkdf2");
|
5
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
6
|
+
const sha512_1 = require("@noble/hashes/sha512");
|
7
|
+
const utils_js_1 = require("./utils.js");
|
8
|
+
async function pbkdf2(password, salt, iterations, keylen, digest) {
|
9
|
+
if (!["sha256", "sha512"].includes(digest)) {
|
10
|
+
throw new Error("Only sha256 and sha512 are supported");
|
11
|
+
}
|
12
|
+
(0, utils_js_1.assertBytes)(password);
|
13
|
+
(0, utils_js_1.assertBytes)(salt);
|
14
|
+
return (0, pbkdf2_1.pbkdf2Async)(digest === "sha256" ? sha256_1.sha256 : sha512_1.sha512, password, salt, {
|
15
|
+
c: iterations,
|
16
|
+
dkLen: keylen
|
17
|
+
});
|
18
|
+
}
|
19
|
+
exports.pbkdf2 = pbkdf2;
|
20
|
+
function pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
21
|
+
if (!["sha256", "sha512"].includes(digest)) {
|
22
|
+
throw new Error("Only sha256 and sha512 are supported");
|
23
|
+
}
|
24
|
+
(0, utils_js_1.assertBytes)(password);
|
25
|
+
(0, utils_js_1.assertBytes)(salt);
|
26
|
+
return (0, pbkdf2_1.pbkdf2)(digest === "sha256" ? sha256_1.sha256 : sha512_1.sha512, password, salt, {
|
27
|
+
c: iterations,
|
28
|
+
dkLen: keylen
|
29
|
+
});
|
30
|
+
}
|
31
|
+
exports.pbkdf2Sync = pbkdf2Sync;
|
package/random.d.ts
ADDED
package/random.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getRandomBytes = exports.getRandomBytesSync = void 0;
|
4
|
+
const utils_1 = require("@noble/hashes/utils");
|
5
|
+
function getRandomBytesSync(bytes) {
|
6
|
+
return (0, utils_1.randomBytes)(bytes);
|
7
|
+
}
|
8
|
+
exports.getRandomBytesSync = getRandomBytesSync;
|
9
|
+
async function getRandomBytes(bytes) {
|
10
|
+
return (0, utils_1.randomBytes)(bytes);
|
11
|
+
}
|
12
|
+
exports.getRandomBytes = getRandomBytes;
|
package/ripemd160.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const ripemd160: (msg: Uint8Array) => Uint8Array;
|
package/ripemd160.js
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ripemd160 = void 0;
|
4
|
+
const ripemd160_1 = require("@noble/hashes/ripemd160");
|
5
|
+
const utils_js_1 = require("./utils.js");
|
6
|
+
exports.ripemd160 = (0, utils_js_1.wrapHash)(ripemd160_1.ripemd160);
|
package/scrypt.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
type OnProgressCallback = (progress: number) => void;
|
2
|
+
export declare function scrypt(password: Uint8Array, salt: Uint8Array, n: number, p: number, r: number, dkLen: number, onProgress?: OnProgressCallback): Promise<Uint8Array>;
|
3
|
+
export declare function scryptSync(password: Uint8Array, salt: Uint8Array, n: number, p: number, r: number, dkLen: number, onProgress?: OnProgressCallback): Uint8Array;
|
4
|
+
export {};
|
package/scrypt.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.scryptSync = exports.scrypt = void 0;
|
4
|
+
const scrypt_1 = require("@noble/hashes/scrypt");
|
5
|
+
const utils_js_1 = require("./utils.js");
|
6
|
+
async function scrypt(password, salt, n, p, r, dkLen, onProgress) {
|
7
|
+
(0, utils_js_1.assertBytes)(password);
|
8
|
+
(0, utils_js_1.assertBytes)(salt);
|
9
|
+
return (0, scrypt_1.scryptAsync)(password, salt, { N: n, r, p, dkLen, onProgress });
|
10
|
+
}
|
11
|
+
exports.scrypt = scrypt;
|
12
|
+
function scryptSync(password, salt, n, p, r, dkLen, onProgress) {
|
13
|
+
(0, utils_js_1.assertBytes)(password);
|
14
|
+
(0, utils_js_1.assertBytes)(salt);
|
15
|
+
return (0, scrypt_1.scrypt)(password, salt, { N: n, r, p, dkLen, onProgress });
|
16
|
+
}
|
17
|
+
exports.scryptSync = scryptSync;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
type Output = Uint8Array | ((len: number) => Uint8Array);
|
2
|
+
interface Signature {
|
3
|
+
signature: Uint8Array;
|
4
|
+
recid: number;
|
5
|
+
}
|
6
|
+
export declare function createPrivateKeySync(): Uint8Array;
|
7
|
+
export declare function createPrivateKey(): Promise<Uint8Array>;
|
8
|
+
export declare function privateKeyVerify(privateKey: Uint8Array): boolean;
|
9
|
+
export declare function publicKeyCreate(privateKey: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
10
|
+
export declare function publicKeyVerify(publicKey: Uint8Array): boolean;
|
11
|
+
export declare function publicKeyConvert(publicKey: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
12
|
+
export declare function ecdsaSign(msgHash: Uint8Array, privateKey: Uint8Array, options?: {
|
13
|
+
noncefn: undefined;
|
14
|
+
data: undefined;
|
15
|
+
}, out?: Output): Signature;
|
16
|
+
export declare function ecdsaRecover(signature: Uint8Array, recid: number, msgHash: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
17
|
+
export declare function ecdsaVerify(signature: Uint8Array, msgHash: Uint8Array, publicKey: Uint8Array): boolean;
|
18
|
+
export declare function privateKeyTweakAdd(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array;
|
19
|
+
export declare function privateKeyNegate(privateKey: Uint8Array): Uint8Array;
|
20
|
+
export declare function publicKeyNegate(publicKey: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
21
|
+
export declare function publicKeyCombine(publicKeys: Uint8Array[], compressed?: boolean, out?: Output): Uint8Array;
|
22
|
+
export declare function publicKeyTweakAdd(publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
23
|
+
export declare function publicKeyTweakMul(publicKey: Uint8Array, tweak: Uint8Array, compressed?: boolean, out?: Output): Uint8Array;
|
24
|
+
export declare function privateKeyTweakMul(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array;
|
25
|
+
export declare function signatureExport(signature: Uint8Array, out?: Output): Uint8Array;
|
26
|
+
export declare function signatureImport(signature: Uint8Array, out?: Output): Uint8Array;
|
27
|
+
export declare function signatureNormalize(signature: Uint8Array): Uint8Array;
|
28
|
+
export declare function ecdh(publicKey: Uint8Array, privateKey: Uint8Array, options?: {
|
29
|
+
xbuf?: Uint8Array;
|
30
|
+
ybuf?: Uint8Array;
|
31
|
+
data?: Uint8Array;
|
32
|
+
hashfn?: (x: Uint8Array, y: Uint8Array, data: Uint8Array) => Uint8Array;
|
33
|
+
}, out?: Output): Uint8Array;
|
34
|
+
export declare function contextRandomize(seed: Uint8Array): void;
|
35
|
+
export {};
|