@libp2p/crypto 0.22.12 → 1.0.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/README.md +51 -48
- package/dist/src/keys/index.d.ts +1 -1
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/keys/jwk2pem.js +1 -1
- package/dist/src/keys/jwk2pem.js.map +1 -1
- package/package.json +8 -3
- package/src/keys/index.ts +1 -1
- package/src/keys/jwk2pem.ts +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @libp2p/crypto <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
[](http://libp2p.io/)
|
|
4
|
+
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
|
+
[](https://discuss.libp2p.io)
|
|
6
|
+
[](https://codecov.io/gh/libp2p/js-libp2p-crypto)
|
|
7
|
+
[](https://github.com/libp2p/js-libp2p-crypto/actions/workflows/js-test-and-release.yml)
|
|
8
|
+
|
|
9
|
+
> Crypto primitives for libp2p
|
|
10
|
+
|
|
11
|
+
## Table of contents <!-- omit in toc -->
|
|
12
|
+
|
|
13
|
+
- [Install](#install)
|
|
14
|
+
- [Lead Maintainer](#lead-maintainer)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Web Crypto API](#web-crypto-api)
|
|
17
|
+
- [API](#api)
|
|
18
|
+
- [`crypto.aes`](#cryptoaes)
|
|
19
|
+
- [`crypto.aes.create(key, iv)`](#cryptoaescreatekey-iv)
|
|
20
|
+
- [`decrypt(data)`](#decryptdata)
|
|
21
|
+
- [`encrypt(data)`](#encryptdata)
|
|
22
|
+
- [`crypto.hmac`](#cryptohmac)
|
|
23
|
+
- [`crypto.hmac.create(hash, secret)`](#cryptohmaccreatehash-secret)
|
|
24
|
+
- [`digest(data)`](#digestdata)
|
|
25
|
+
- [`crypto.keys`](#cryptokeys)
|
|
26
|
+
- [`crypto.keys.generateKeyPair(type, bits)`](#cryptokeysgeneratekeypairtype-bits)
|
|
27
|
+
- [`crypto.keys.generateEphemeralKeyPair(curve)`](#cryptokeysgenerateephemeralkeypaircurve)
|
|
28
|
+
- [`crypto.keys.keyStretcher(cipherType, hashType, secret)`](#cryptokeyskeystretcherciphertype-hashtype-secret)
|
|
29
|
+
- [`crypto.keys.marshalPublicKey(key, [type])`](#cryptokeysmarshalpublickeykey-type)
|
|
30
|
+
- [`crypto.keys.unmarshalPublicKey(buf)`](#cryptokeysunmarshalpublickeybuf)
|
|
31
|
+
- [`crypto.keys.marshalPrivateKey(key, [type])`](#cryptokeysmarshalprivatekeykey-type)
|
|
32
|
+
- [`crypto.keys.unmarshalPrivateKey(buf)`](#cryptokeysunmarshalprivatekeybuf)
|
|
33
|
+
- [`crypto.keys.import(encryptedKey, password)`](#cryptokeysimportencryptedkey-password)
|
|
34
|
+
- [`privateKey.export(password, format)`](#privatekeyexportpassword-format)
|
|
35
|
+
- [`crypto.randomBytes(number)`](#cryptorandombytesnumber)
|
|
36
|
+
- [`crypto.pbkdf2(password, salt, iterations, keySize, hash)`](#cryptopbkdf2password-salt-iterations-keysize-hash)
|
|
37
|
+
- [Contribute](#contribute)
|
|
38
|
+
- [License](#license)
|
|
39
|
+
- [Contribution](#contribution)
|
|
2
40
|
|
|
3
|
-
|
|
4
|
-
[](http://libp2p.io/)
|
|
5
|
-
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
6
|
-
[](https://discuss.libp2p.io)
|
|
7
|
-
[](https://codecov.io/gh/libp2p/js-libp2p-crypto)
|
|
8
|
-
[](https://travis-ci.com/libp2p/js-libp2p-crypto)
|
|
9
|
-
[](https://david-dm.org/libp2p/js-libp2p-crypto)
|
|
10
|
-
[](https://github.com/feross/standard)
|
|
41
|
+
## Install
|
|
11
42
|
|
|
12
|
-
|
|
43
|
+
```console
|
|
44
|
+
$ npm i @libp2p/crypto
|
|
45
|
+
```
|
|
13
46
|
|
|
14
47
|
This repo contains the JavaScript implementation of the crypto primitives needed for libp2p. This is based on this [go implementation](https://github.com/libp2p/go-libp2p-crypto).
|
|
15
48
|
|
|
@@ -17,43 +50,6 @@ This repo contains the JavaScript implementation of the crypto primitives needed
|
|
|
17
50
|
|
|
18
51
|
[Jacob Heun](https://github.com/jacobheun/)
|
|
19
52
|
|
|
20
|
-
## Table of Contents
|
|
21
|
-
|
|
22
|
-
- [js-libp2p-crypto](#js-libp2p-crypto)
|
|
23
|
-
- [Lead Maintainer](#lead-maintainer)
|
|
24
|
-
- [Table of Contents](#table-of-contents)
|
|
25
|
-
- [Install](#install)
|
|
26
|
-
- [Usage](#usage)
|
|
27
|
-
- [Web Crypto API](#web-crypto-api)
|
|
28
|
-
- [API](#api)
|
|
29
|
-
- [`crypto.aes`](#cryptoaes)
|
|
30
|
-
- [`crypto.aes.create(key, iv)`](#cryptoaescreatekey-iv)
|
|
31
|
-
- [`decrypt(data)`](#decryptdata)
|
|
32
|
-
- [`encrypt(data)`](#encryptdata)
|
|
33
|
-
- [`crypto.hmac`](#cryptohmac)
|
|
34
|
-
- [`crypto.hmac.create(hash, secret)`](#cryptohmaccreatehash-secret)
|
|
35
|
-
- [`digest(data)`](#digestdata)
|
|
36
|
-
- [`crypto.keys`](#cryptokeys)
|
|
37
|
-
- [`crypto.keys.generateKeyPair(type, bits)`](#cryptokeysgeneratekeypairtype-bits)
|
|
38
|
-
- [`crypto.keys.generateEphemeralKeyPair(curve)`](#cryptokeysgenerateephemeralkeypaircurve)
|
|
39
|
-
- [`crypto.keys.keyStretcher(cipherType, hashType, secret)`](#cryptokeyskeystretcherciphertype-hashtype-secret)
|
|
40
|
-
- [`crypto.keys.marshalPublicKey(key, [type])`](#cryptokeysmarshalpublickeykey-type)
|
|
41
|
-
- [`crypto.keys.unmarshalPublicKey(buf)`](#cryptokeysunmarshalpublickeybuf)
|
|
42
|
-
- [`crypto.keys.marshalPrivateKey(key, [type])`](#cryptokeysmarshalprivatekeykey-type)
|
|
43
|
-
- [`crypto.keys.unmarshalPrivateKey(buf)`](#cryptokeysunmarshalprivatekeybuf)
|
|
44
|
-
- [`crypto.keys.import(encryptedKey, password)`](#cryptokeysimportencryptedkey-password)
|
|
45
|
-
- [`privateKey.export(password, format)`](#privatekeyexportpassword-format)
|
|
46
|
-
- [`crypto.randomBytes(number)`](#cryptorandombytesnumber)
|
|
47
|
-
- [`crypto.pbkdf2(password, salt, iterations, keySize, hash)`](#cryptopbkdf2password-salt-iterations-keysize-hash)
|
|
48
|
-
- [Contribute](#contribute)
|
|
49
|
-
- [License](#license)
|
|
50
|
-
|
|
51
|
-
## Install
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
npm install --save libp2p-crypto
|
|
55
|
-
```
|
|
56
|
-
|
|
57
53
|
## Usage
|
|
58
54
|
|
|
59
55
|
```js
|
|
@@ -311,4 +307,11 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c
|
|
|
311
307
|
|
|
312
308
|
## License
|
|
313
309
|
|
|
314
|
-
|
|
310
|
+
Licensed under either of
|
|
311
|
+
|
|
312
|
+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
313
|
+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
314
|
+
|
|
315
|
+
## Contribution
|
|
316
|
+
|
|
317
|
+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
package/dist/src/keys/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import generateEphemeralKeyPair from './ephemeral-keys.js';
|
|
|
6
6
|
import * as RSA from './rsa-class.js';
|
|
7
7
|
import * as Ed25519 from './ed25519-class.js';
|
|
8
8
|
import * as Secp256k1 from './secp256k1-class.js';
|
|
9
|
-
import type { PrivateKey, PublicKey } from '@libp2p/
|
|
9
|
+
import type { PrivateKey, PublicKey } from '@libp2p/interface-keys';
|
|
10
10
|
export { keyStretcher };
|
|
11
11
|
export { generateEphemeralKeyPair };
|
|
12
12
|
export { keysPBM };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,wBAAwB,CAAA;AAC/B,OAAO,uBAAuB,CAAA;AAK9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,wBAAwB,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,wBAAwB,CAAA;AAC/B,OAAO,uBAAuB,CAAA;AAK9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,wBAAwB,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEnE,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,OAAO,EAAE,wBAAwB,EAAE,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB,oBAAY,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,WAAW,CAAA;AAEtD,eAAO,MAAM,aAAa;;;;CAIzB,CAAA;AAkBD,wBAAsB,eAAe,CAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEzF;AAID,wBAAsB,uBAAuB,CAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAMnH;AAID,wBAAgB,kBAAkB,CAAE,GAAG,EAAE,UAAU,GAAG,SAAS,CAc9D;AAGD,wBAAgB,gBAAgB,CAAE,GAAG,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAIvF;AAID,wBAAsB,mBAAmB,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAc/E;AAGD,wBAAgB,iBAAiB,CAAE,GAAG,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAIxF;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAgB5F"}
|
package/dist/src/keys/jwk2pem.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'node-forge/lib/rsa.js';
|
|
2
2
|
// @ts-expect-error types are missing
|
|
3
3
|
import forge from 'node-forge/lib/forge.js';
|
|
4
|
-
import { base64urlToBigInteger } from '../util';
|
|
4
|
+
import { base64urlToBigInteger } from '../util.js';
|
|
5
5
|
function convert(key, types) {
|
|
6
6
|
return types.map(t => base64urlToBigInteger(key[t]));
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwk2pem.js","sourceRoot":"","sources":["../../../src/keys/jwk2pem.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,qCAAqC;AACrC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"jwk2pem.js","sourceRoot":"","sources":["../../../src/keys/jwk2pem.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAA;AAC9B,qCAAqC;AACrC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,SAAS,OAAO,CAAE,GAAQ,EAAE,KAAe;IACzC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAE,GAAe;IACvC,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AACjG,CAAC;AAED,MAAM,UAAU,OAAO,CAAE,GAAe;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;AAC/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/crypto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Crypto primitives for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-crypto#readme",
|
|
@@ -48,18 +48,23 @@
|
|
|
48
48
|
],
|
|
49
49
|
"exports": {
|
|
50
50
|
".": {
|
|
51
|
+
"types": "./src/index.d.ts",
|
|
51
52
|
"import": "./dist/src/index.js"
|
|
52
53
|
},
|
|
53
54
|
"./aes": {
|
|
55
|
+
"types": "./dist/src/aes/index.d.ts",
|
|
54
56
|
"import": "./dist/src/aes/index.js"
|
|
55
57
|
},
|
|
56
58
|
"./ciphers": {
|
|
59
|
+
"types": "./dist/src/ciphers/index.d.ts",
|
|
57
60
|
"import": "./dist/src/ciphers/index.js"
|
|
58
61
|
},
|
|
59
62
|
"./hmac": {
|
|
63
|
+
"types": "./dist/src/hmac/index.d.ts",
|
|
60
64
|
"import": "./dist/src/hmac/index.js"
|
|
61
65
|
},
|
|
62
66
|
"./keys": {
|
|
67
|
+
"types": "./dist/src/keys/index.d.ts",
|
|
63
68
|
"import": "./dist/src/keys/index.js"
|
|
64
69
|
}
|
|
65
70
|
},
|
|
@@ -169,7 +174,7 @@
|
|
|
169
174
|
"generate": "protons ./src/keys/keys.proto"
|
|
170
175
|
},
|
|
171
176
|
"dependencies": {
|
|
172
|
-
"@libp2p/
|
|
177
|
+
"@libp2p/interface-keys": "^1.0.2",
|
|
173
178
|
"@noble/ed25519": "^1.6.0",
|
|
174
179
|
"@noble/secp256k1": "^1.5.4",
|
|
175
180
|
"err-code": "^3.0.1",
|
|
@@ -184,7 +189,7 @@
|
|
|
184
189
|
"aegir": "^37.0.12",
|
|
185
190
|
"benchmark": "^2.1.4",
|
|
186
191
|
"protons": "^3.0.4",
|
|
187
|
-
"sinon": "^
|
|
192
|
+
"sinon": "^14.0.0",
|
|
188
193
|
"util": "^0.12.3",
|
|
189
194
|
"wherearewe": "^1.0.0"
|
|
190
195
|
},
|
package/src/keys/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { importer } from './importer.js'
|
|
|
11
11
|
import * as RSA from './rsa-class.js'
|
|
12
12
|
import * as Ed25519 from './ed25519-class.js'
|
|
13
13
|
import * as Secp256k1 from './secp256k1-class.js'
|
|
14
|
-
import type { PrivateKey, PublicKey } from '@libp2p/
|
|
14
|
+
import type { PrivateKey, PublicKey } from '@libp2p/interface-keys'
|
|
15
15
|
|
|
16
16
|
export { keyStretcher }
|
|
17
17
|
export { generateEphemeralKeyPair }
|
package/src/keys/jwk2pem.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'node-forge/lib/rsa.js'
|
|
2
2
|
// @ts-expect-error types are missing
|
|
3
3
|
import forge from 'node-forge/lib/forge.js'
|
|
4
|
-
import { base64urlToBigInteger } from '../util'
|
|
4
|
+
import { base64urlToBigInteger } from '../util.js'
|
|
5
5
|
|
|
6
6
|
function convert (key: any, types: string[]) {
|
|
7
7
|
return types.map(t => base64urlToBigInteger(key[t]))
|