@libp2p/crypto 5.1.3 → 5.1.4-2a7425cdb
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/keys/ecdsa/ecdsa.d.ts +3 -3
- package/dist/src/keys/ecdsa/ecdsa.d.ts.map +1 -1
- package/dist/src/keys/ecdsa/ecdsa.js +4 -4
- package/dist/src/keys/ecdsa/ecdsa.js.map +1 -1
- package/dist/src/keys/ecdsa/index.d.ts +3 -2
- package/dist/src/keys/ecdsa/index.d.ts.map +1 -1
- package/dist/src/keys/ecdsa/index.js +8 -3
- package/dist/src/keys/ecdsa/index.js.map +1 -1
- package/dist/src/keys/ed25519/ed25519.d.ts +3 -3
- package/dist/src/keys/ed25519/ed25519.d.ts.map +1 -1
- package/dist/src/keys/ed25519/ed25519.js +4 -2
- package/dist/src/keys/ed25519/ed25519.js.map +1 -1
- package/dist/src/keys/ed25519/index.d.ts +1 -1
- package/dist/src/keys/ed25519/index.d.ts.map +1 -1
- package/dist/src/keys/rsa/index.browser.d.ts +4 -3
- package/dist/src/keys/rsa/index.browser.d.ts.map +1 -1
- package/dist/src/keys/rsa/index.browser.js +15 -7
- package/dist/src/keys/rsa/index.browser.js.map +1 -1
- package/dist/src/keys/rsa/index.d.ts +4 -3
- package/dist/src/keys/rsa/index.d.ts.map +1 -1
- package/dist/src/keys/rsa/index.js +8 -5
- package/dist/src/keys/rsa/index.js.map +1 -1
- package/dist/src/keys/rsa/rsa.d.ts +3 -3
- package/dist/src/keys/rsa/rsa.d.ts.map +1 -1
- package/dist/src/keys/rsa/rsa.js +4 -4
- package/dist/src/keys/rsa/rsa.js.map +1 -1
- package/dist/src/keys/secp256k1/index.browser.d.ts +3 -2
- package/dist/src/keys/secp256k1/index.browser.d.ts.map +1 -1
- package/dist/src/keys/secp256k1/index.browser.js +19 -4
- package/dist/src/keys/secp256k1/index.browser.js.map +1 -1
- package/dist/src/keys/secp256k1/index.d.ts +3 -2
- package/dist/src/keys/secp256k1/index.d.ts.map +1 -1
- package/dist/src/keys/secp256k1/index.js +4 -2
- package/dist/src/keys/secp256k1/index.js.map +1 -1
- package/dist/src/keys/secp256k1/secp256k1.d.ts +3 -3
- package/dist/src/keys/secp256k1/secp256k1.d.ts.map +1 -1
- package/dist/src/keys/secp256k1/secp256k1.js +4 -4
- package/dist/src/keys/secp256k1/secp256k1.js.map +1 -1
- package/package.json +5 -5
- package/src/keys/ecdsa/ecdsa.ts +5 -5
- package/src/keys/ecdsa/index.ts +10 -3
- package/src/keys/ed25519/ed25519.ts +5 -3
- package/src/keys/ed25519/index.ts +1 -1
- package/src/keys/rsa/index.browser.ts +18 -7
- package/src/keys/rsa/index.ts +11 -5
- package/src/keys/rsa/rsa.ts +5 -5
- package/src/keys/secp256k1/index.browser.ts +22 -4
- package/src/keys/secp256k1/index.ts +6 -2
- package/src/keys/secp256k1/secp256k1.ts +5 -5
- package/dist/typedoc-urls.json +0 -40
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/keys/secp256k1/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/keys/secp256k1/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAIjE,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,uBAAuB,GAAG,EAAE,CAAA;A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AAM,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAE5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
|
-
import type { Secp256k1PublicKey as Secp256k1PublicKeyInterface, Secp256k1PrivateKey as Secp256k1PrivateKeyInterface } from '@libp2p/interface';
|
|
2
|
+
import type { Secp256k1PublicKey as Secp256k1PublicKeyInterface, Secp256k1PrivateKey as Secp256k1PrivateKeyInterface, AbortOptions } from '@libp2p/interface';
|
|
3
3
|
import type { Digest } from 'multiformats/hashes/digest';
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
5
5
|
export declare class Secp256k1PublicKey implements Secp256k1PublicKeyInterface {
|
|
@@ -11,7 +11,7 @@ export declare class Secp256k1PublicKey implements Secp256k1PublicKeyInterface {
|
|
|
11
11
|
toCID(): CID<unknown, 114, 0x0, 1>;
|
|
12
12
|
toString(): string;
|
|
13
13
|
equals(key: any): boolean;
|
|
14
|
-
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean;
|
|
14
|
+
verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array, options?: AbortOptions): boolean;
|
|
15
15
|
}
|
|
16
16
|
export declare class Secp256k1PrivateKey implements Secp256k1PrivateKeyInterface {
|
|
17
17
|
readonly type = "secp256k1";
|
|
@@ -19,6 +19,6 @@ export declare class Secp256k1PrivateKey implements Secp256k1PrivateKeyInterface
|
|
|
19
19
|
readonly publicKey: Secp256k1PublicKey;
|
|
20
20
|
constructor(key: Uint8Array, publicKey?: Uint8Array);
|
|
21
21
|
equals(key?: any): boolean;
|
|
22
|
-
sign(message: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
|
|
22
|
+
sign(message: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array | Promise<Uint8Array>;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=secp256k1.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["../../../../src/keys/secp256k1/secp256k1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAMtC,OAAO,KAAK,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,mBAAmB,IAAI,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["../../../../src/keys/secp256k1/secp256k1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAMtC,OAAO,KAAK,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,mBAAmB,IAAI,4BAA4B,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC7J,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,qBAAa,kBAAmB,YAAW,2BAA2B;IACpE,SAAgB,IAAI,eAAc;IAClC,SAAgB,GAAG,EAAE,UAAU,CAAA;IAC/B,SAAgB,IAAI,EAAE,UAAU,CAAA;gBAEnB,GAAG,EAAE,UAAU;IAK5B,WAAW,IAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC;IAInC,KAAK,IAAK,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAInC,QAAQ,IAAK,MAAM;IAInB,MAAM,CAAE,GAAG,EAAE,GAAG,GAAG,OAAO;IAQ1B,MAAM,CAAE,IAAI,EAAE,UAAU,GAAG,cAAc,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO;CAG7F;AAED,qBAAa,mBAAoB,YAAW,4BAA4B;IACtE,SAAgB,IAAI,eAAc;IAClC,SAAgB,GAAG,EAAE,UAAU,CAAA;IAC/B,SAAgB,SAAS,EAAE,kBAAkB,CAAA;gBAEhC,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,UAAU;IAKpD,MAAM,CAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO;IAQ3B,IAAI,CAAE,OAAO,EAAE,UAAU,GAAG,cAAc,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAGtG"}
|
|
@@ -28,8 +28,8 @@ export class Secp256k1PublicKey {
|
|
|
28
28
|
}
|
|
29
29
|
return uint8ArrayEquals(this.raw, key.raw);
|
|
30
30
|
}
|
|
31
|
-
verify(data, sig) {
|
|
32
|
-
return hashAndVerify(this._key, sig, data);
|
|
31
|
+
verify(data, sig, options) {
|
|
32
|
+
return hashAndVerify(this._key, sig, data, options);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export class Secp256k1PrivateKey {
|
|
@@ -46,8 +46,8 @@ export class Secp256k1PrivateKey {
|
|
|
46
46
|
}
|
|
47
47
|
return uint8ArrayEquals(this.raw, key.raw);
|
|
48
48
|
}
|
|
49
|
-
sign(message) {
|
|
50
|
-
return hashAndSign(this.raw, message);
|
|
49
|
+
sign(message, options) {
|
|
50
|
+
return hashAndSign(this.raw, message, options);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
//# sourceMappingURL=secp256k1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../../src/keys/secp256k1/secp256k1.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Crypto primitives for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/crypto#readme",
|
|
@@ -85,20 +85,20 @@
|
|
|
85
85
|
"generate": "protons ./src/keys/keys.proto"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@libp2p/interface": "
|
|
88
|
+
"@libp2p/interface": "2.10.2-2a7425cdb",
|
|
89
89
|
"@noble/curves": "^1.9.1",
|
|
90
90
|
"@noble/hashes": "^1.8.0",
|
|
91
|
-
"multiformats": "^13.3.
|
|
91
|
+
"multiformats": "^13.3.6",
|
|
92
92
|
"protons-runtime": "^5.5.0",
|
|
93
93
|
"uint8arraylist": "^2.4.8",
|
|
94
94
|
"uint8arrays": "^5.1.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@types/mocha": "^10.0.10",
|
|
98
|
-
"aegir": "^47.0.
|
|
98
|
+
"aegir": "^47.0.14",
|
|
99
99
|
"asn1js": "^3.0.6",
|
|
100
100
|
"benchmark": "^2.1.4",
|
|
101
|
-
"protons": "^7.6.
|
|
101
|
+
"protons": "^7.6.1"
|
|
102
102
|
},
|
|
103
103
|
"browser": {
|
|
104
104
|
"./dist/src/ciphers/aes-gcm.js": "./dist/src/ciphers/aes-gcm.browser.js",
|
package/src/keys/ecdsa/ecdsa.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
|
5
5
|
import { publicKeyToProtobuf } from '../index.js'
|
|
6
6
|
import { privateKeyToPKIMessage, publicKeyToPKIMessage } from './utils.js'
|
|
7
7
|
import { hashAndVerify, hashAndSign } from './index.js'
|
|
8
|
-
import type { ECDSAPublicKey as ECDSAPublicKeyInterface, ECDSAPrivateKey as ECDSAPrivateKeyInterface } from '@libp2p/interface'
|
|
8
|
+
import type { ECDSAPublicKey as ECDSAPublicKeyInterface, ECDSAPrivateKey as ECDSAPrivateKeyInterface, AbortOptions } from '@libp2p/interface'
|
|
9
9
|
import type { Digest } from 'multiformats/hashes/digest'
|
|
10
10
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
11
11
|
|
|
@@ -46,8 +46,8 @@ export class ECDSAPublicKey implements ECDSAPublicKeyInterface {
|
|
|
46
46
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
async verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): Promise<boolean> {
|
|
50
|
-
return hashAndVerify(this.jwk, sig, data)
|
|
49
|
+
async verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array, options?: AbortOptions): Promise<boolean> {
|
|
50
|
+
return hashAndVerify(this.jwk, sig, data, options)
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -85,7 +85,7 @@ export class ECDSAPrivateKey implements ECDSAPrivateKeyInterface {
|
|
|
85
85
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
async sign (message: Uint8Array | Uint8ArrayList): Promise<Uint8Array> {
|
|
89
|
-
return hashAndSign(this.jwk, message)
|
|
88
|
+
async sign (message: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<Uint8Array> {
|
|
89
|
+
return hashAndSign(this.jwk, message, options)
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/keys/ecdsa/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JWKKeyPair } from '../interface.js'
|
|
2
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
2
3
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
3
4
|
|
|
4
5
|
export type Curve = 'P-256' | 'P-384' | 'P-521'
|
|
@@ -19,11 +20,12 @@ export async function generateECDSAKey (curve: Curve = 'P-256'): Promise<JWKKeyP
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList): Promise<Uint8Array> {
|
|
23
|
+
export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<Uint8Array> {
|
|
23
24
|
const privateKey = await crypto.subtle.importKey('jwk', key, {
|
|
24
25
|
name: 'ECDSA',
|
|
25
26
|
namedCurve: key.crv ?? 'P-256'
|
|
26
27
|
}, false, ['sign'])
|
|
28
|
+
options?.signal?.throwIfAborted()
|
|
27
29
|
|
|
28
30
|
const signature = await crypto.subtle.sign({
|
|
29
31
|
name: 'ECDSA',
|
|
@@ -31,20 +33,25 @@ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8Array
|
|
|
31
33
|
name: 'SHA-256'
|
|
32
34
|
}
|
|
33
35
|
}, privateKey, msg.subarray())
|
|
36
|
+
options?.signal?.throwIfAborted()
|
|
34
37
|
|
|
35
38
|
return new Uint8Array(signature, 0, signature.byteLength)
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): Promise<boolean> {
|
|
41
|
+
export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<boolean> {
|
|
39
42
|
const publicKey = await crypto.subtle.importKey('jwk', key, {
|
|
40
43
|
name: 'ECDSA',
|
|
41
44
|
namedCurve: key.crv ?? 'P-256'
|
|
42
45
|
}, false, ['verify'])
|
|
46
|
+
options?.signal?.throwIfAborted()
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
const result = await crypto.subtle.verify({
|
|
45
49
|
name: 'ECDSA',
|
|
46
50
|
hash: {
|
|
47
51
|
name: 'SHA-256'
|
|
48
52
|
}
|
|
49
53
|
}, publicKey, sig, msg.subarray())
|
|
54
|
+
options?.signal?.throwIfAborted()
|
|
55
|
+
|
|
56
|
+
return result
|
|
50
57
|
}
|
|
@@ -5,7 +5,7 @@ import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
|
5
5
|
import { publicKeyToProtobuf } from '../index.js'
|
|
6
6
|
import { ensureEd25519Key } from './utils.js'
|
|
7
7
|
import * as crypto from './index.js'
|
|
8
|
-
import type { Ed25519PublicKey as Ed25519PublicKeyInterface, Ed25519PrivateKey as Ed25519PrivateKeyInterface } from '@libp2p/interface'
|
|
8
|
+
import type { Ed25519PublicKey as Ed25519PublicKeyInterface, Ed25519PrivateKey as Ed25519PrivateKeyInterface, AbortOptions } from '@libp2p/interface'
|
|
9
9
|
import type { Digest } from 'multiformats/hashes/digest'
|
|
10
10
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
11
11
|
|
|
@@ -37,7 +37,8 @@ export class Ed25519PublicKey implements Ed25519PublicKeyInterface {
|
|
|
37
37
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean {
|
|
40
|
+
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array, options?: AbortOptions): boolean {
|
|
41
|
+
options?.signal?.throwIfAborted()
|
|
41
42
|
return crypto.hashAndVerify(this.raw, sig, data)
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -62,7 +63,8 @@ export class Ed25519PrivateKey implements Ed25519PrivateKeyInterface {
|
|
|
62
63
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
sign (message: Uint8Array | Uint8ArrayList): Uint8Array {
|
|
66
|
+
sign (message: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array {
|
|
67
|
+
options?.signal?.throwIfAborted()
|
|
66
68
|
return crypto.hashAndSign(this.raw, message)
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -72,7 +72,7 @@ export function generateKeyFromSeed (seed: Uint8Array): Uint8ArrayKeyPair {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList):
|
|
75
|
+
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList): Uint8Array {
|
|
76
76
|
if (!(key instanceof Uint8Array)) {
|
|
77
77
|
throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.')
|
|
78
78
|
}
|
|
@@ -4,12 +4,13 @@ import randomBytes from '../../random-bytes.js'
|
|
|
4
4
|
import webcrypto from '../../webcrypto/index.js'
|
|
5
5
|
import * as utils from './utils.js'
|
|
6
6
|
import type { JWKKeyPair } from '../interface.js'
|
|
7
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
7
8
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
8
9
|
|
|
9
10
|
export const RSAES_PKCS1_V1_5_OID = '1.2.840.113549.1.1.1'
|
|
10
11
|
export { utils }
|
|
11
12
|
|
|
12
|
-
export async function generateRSAKey (bits: number): Promise<JWKKeyPair> {
|
|
13
|
+
export async function generateRSAKey (bits: number, options?: AbortOptions): Promise<JWKKeyPair> {
|
|
13
14
|
const pair = await webcrypto.get().subtle.generateKey(
|
|
14
15
|
{
|
|
15
16
|
name: 'RSASSA-PKCS1-v1_5',
|
|
@@ -20,8 +21,9 @@ export async function generateRSAKey (bits: number): Promise<JWKKeyPair> {
|
|
|
20
21
|
true,
|
|
21
22
|
['sign', 'verify']
|
|
22
23
|
)
|
|
24
|
+
options?.signal?.throwIfAborted()
|
|
23
25
|
|
|
24
|
-
const keys = await exportKey(pair)
|
|
26
|
+
const keys = await exportKey(pair, options)
|
|
25
27
|
|
|
26
28
|
return {
|
|
27
29
|
privateKey: keys[0],
|
|
@@ -31,7 +33,7 @@ export async function generateRSAKey (bits: number): Promise<JWKKeyPair> {
|
|
|
31
33
|
|
|
32
34
|
export { randomBytes as getRandomValues }
|
|
33
35
|
|
|
34
|
-
export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList): Promise<Uint8Array> {
|
|
36
|
+
export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<Uint8Array> {
|
|
35
37
|
const privateKey = await webcrypto.get().subtle.importKey(
|
|
36
38
|
'jwk',
|
|
37
39
|
key,
|
|
@@ -42,17 +44,19 @@ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8Array
|
|
|
42
44
|
false,
|
|
43
45
|
['sign']
|
|
44
46
|
)
|
|
47
|
+
options?.signal?.throwIfAborted()
|
|
45
48
|
|
|
46
49
|
const sig = await webcrypto.get().subtle.sign(
|
|
47
50
|
{ name: 'RSASSA-PKCS1-v1_5' },
|
|
48
51
|
privateKey,
|
|
49
52
|
msg instanceof Uint8Array ? msg : msg.subarray()
|
|
50
53
|
)
|
|
54
|
+
options?.signal?.throwIfAborted()
|
|
51
55
|
|
|
52
56
|
return new Uint8Array(sig, 0, sig.byteLength)
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): Promise<boolean> {
|
|
59
|
+
export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Promise<boolean> {
|
|
56
60
|
const publicKey = await webcrypto.get().subtle.importKey(
|
|
57
61
|
'jwk',
|
|
58
62
|
key,
|
|
@@ -63,24 +67,31 @@ export async function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint
|
|
|
63
67
|
false,
|
|
64
68
|
['verify']
|
|
65
69
|
)
|
|
70
|
+
options?.signal?.throwIfAborted()
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
const result = await webcrypto.get().subtle.verify(
|
|
68
73
|
{ name: 'RSASSA-PKCS1-v1_5' },
|
|
69
74
|
publicKey,
|
|
70
75
|
sig,
|
|
71
76
|
msg instanceof Uint8Array ? msg : msg.subarray()
|
|
72
77
|
)
|
|
78
|
+
options?.signal?.throwIfAborted()
|
|
79
|
+
|
|
80
|
+
return result
|
|
73
81
|
}
|
|
74
82
|
|
|
75
|
-
async function exportKey (pair: CryptoKeyPair): Promise<[JsonWebKey, JsonWebKey]> {
|
|
83
|
+
async function exportKey (pair: CryptoKeyPair, options?: AbortOptions): Promise<[JsonWebKey, JsonWebKey]> {
|
|
76
84
|
if (pair.privateKey == null || pair.publicKey == null) {
|
|
77
85
|
throw new InvalidParametersError('Private and public key are required')
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
|
|
88
|
+
const result = await Promise.all([
|
|
81
89
|
webcrypto.get().subtle.exportKey('jwk', pair.privateKey),
|
|
82
90
|
webcrypto.get().subtle.exportKey('jwk', pair.publicKey)
|
|
83
91
|
])
|
|
92
|
+
options?.signal?.throwIfAborted()
|
|
93
|
+
|
|
94
|
+
return result
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
export function rsaKeySize (jwk: JsonWebKey): number {
|
package/src/keys/rsa/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
2
|
-
import { promisify } from 'util'
|
|
1
|
+
import crypto from 'node:crypto'
|
|
2
|
+
import { promisify } from 'node:util'
|
|
3
3
|
import { InvalidParametersError } from '@libp2p/interface'
|
|
4
4
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
5
5
|
import randomBytes from '../../random-bytes.js'
|
|
6
6
|
import * as utils from './utils.js'
|
|
7
7
|
import type { JWKKeyPair } from '../interface.js'
|
|
8
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
8
9
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
9
10
|
|
|
10
11
|
const keypair = promisify(crypto.generateKeyPair)
|
|
@@ -13,13 +14,14 @@ export const RSAES_PKCS1_V1_5_OID = '1.2.840.113549.1.1.1'
|
|
|
13
14
|
|
|
14
15
|
export { utils }
|
|
15
16
|
|
|
16
|
-
export async function generateRSAKey (bits: number): Promise<JWKKeyPair> {
|
|
17
|
+
export async function generateRSAKey (bits: number, options?: AbortOptions): Promise<JWKKeyPair> {
|
|
17
18
|
// @ts-expect-error node types are missing jwk as a format
|
|
18
19
|
const key = await keypair('rsa', {
|
|
19
20
|
modulusLength: bits,
|
|
20
21
|
publicKeyEncoding: { type: 'pkcs1', format: 'jwk' },
|
|
21
22
|
privateKeyEncoding: { type: 'pkcs1', format: 'jwk' }
|
|
22
23
|
})
|
|
24
|
+
options?.signal?.throwIfAborted()
|
|
23
25
|
|
|
24
26
|
return {
|
|
25
27
|
// @ts-expect-error node types are missing jwk as a format
|
|
@@ -31,7 +33,9 @@ export async function generateRSAKey (bits: number): Promise<JWKKeyPair> {
|
|
|
31
33
|
|
|
32
34
|
export { randomBytes as getRandomValues }
|
|
33
35
|
|
|
34
|
-
export
|
|
36
|
+
export function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array {
|
|
37
|
+
options?.signal?.throwIfAborted()
|
|
38
|
+
|
|
35
39
|
const hash = crypto.createSign('RSA-SHA256')
|
|
36
40
|
|
|
37
41
|
if (msg instanceof Uint8Array) {
|
|
@@ -46,7 +50,9 @@ export async function hashAndSign (key: JsonWebKey, msg: Uint8Array | Uint8Array
|
|
|
46
50
|
return hash.sign({ format: 'jwk', key })
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export
|
|
53
|
+
export function hashAndVerify (key: JsonWebKey, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): boolean {
|
|
54
|
+
options?.signal?.throwIfAborted()
|
|
55
|
+
|
|
50
56
|
const hash = crypto.createVerify('RSA-SHA256')
|
|
51
57
|
|
|
52
58
|
if (msg instanceof Uint8Array) {
|
package/src/keys/rsa/rsa.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { base58btc } from 'multiformats/bases/base58'
|
|
|
2
2
|
import { CID } from 'multiformats/cid'
|
|
3
3
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
4
4
|
import { hashAndSign, utils, hashAndVerify } from './index.js'
|
|
5
|
-
import type { RSAPublicKey as RSAPublicKeyInterface, RSAPrivateKey as RSAPrivateKeyInterface } from '@libp2p/interface'
|
|
5
|
+
import type { RSAPublicKey as RSAPublicKeyInterface, RSAPrivateKey as RSAPrivateKeyInterface, AbortOptions } from '@libp2p/interface'
|
|
6
6
|
import type { Digest } from 'multiformats/hashes/digest'
|
|
7
7
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
8
8
|
|
|
@@ -45,8 +45,8 @@ export class RSAPublicKey implements RSAPublicKeyInterface {
|
|
|
45
45
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean> {
|
|
49
|
-
return hashAndVerify(this.jwk, sig, data)
|
|
48
|
+
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array, options?: AbortOptions): boolean | Promise<boolean> {
|
|
49
|
+
return hashAndVerify(this.jwk, sig, data, options)
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -77,7 +77,7 @@ export class RSAPrivateKey implements RSAPrivateKeyInterface {
|
|
|
77
77
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
sign (message: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
|
|
81
|
-
return hashAndSign(this.jwk, message)
|
|
80
|
+
sign (message: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array | Promise<Uint8Array> {
|
|
81
|
+
return hashAndSign(this.jwk, message, options)
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -2,6 +2,7 @@ import { secp256k1 as secp } from '@noble/curves/secp256k1'
|
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
3
|
import { SigningError, VerificationError } from '../../errors.js'
|
|
4
4
|
import { isPromise } from '../../util.js'
|
|
5
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
5
6
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
6
7
|
|
|
7
8
|
const PUBLIC_KEY_BYTE_LENGTH = 33
|
|
@@ -13,12 +14,20 @@ export { PRIVATE_KEY_BYTE_LENGTH as privateKeyLength }
|
|
|
13
14
|
/**
|
|
14
15
|
* Hash and sign message with private key
|
|
15
16
|
*/
|
|
16
|
-
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
|
|
17
|
+
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array | Promise<Uint8Array> {
|
|
17
18
|
const p = sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray())
|
|
18
19
|
|
|
19
20
|
if (isPromise(p)) {
|
|
20
|
-
return p
|
|
21
|
+
return p
|
|
22
|
+
.then(({ digest }) => {
|
|
23
|
+
options?.signal?.throwIfAborted()
|
|
24
|
+
return secp.sign(digest, key).toDERRawBytes()
|
|
25
|
+
})
|
|
21
26
|
.catch(err => {
|
|
27
|
+
if (err.name === 'AbortError') {
|
|
28
|
+
throw err
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
throw new SigningError(String(err))
|
|
23
32
|
})
|
|
24
33
|
}
|
|
@@ -33,17 +42,26 @@ export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList):
|
|
|
33
42
|
/**
|
|
34
43
|
* Hash message and verify signature with public key
|
|
35
44
|
*/
|
|
36
|
-
export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): boolean | Promise<boolean> {
|
|
45
|
+
export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): boolean | Promise<boolean> {
|
|
37
46
|
const p = sha256.digest(msg instanceof Uint8Array ? msg : msg.subarray())
|
|
38
47
|
|
|
39
48
|
if (isPromise(p)) {
|
|
40
|
-
return p
|
|
49
|
+
return p
|
|
50
|
+
.then(({ digest }) => {
|
|
51
|
+
options?.signal?.throwIfAborted()
|
|
52
|
+
return secp.verify(sig, digest, key)
|
|
53
|
+
})
|
|
41
54
|
.catch(err => {
|
|
55
|
+
if (err.name === 'AbortError') {
|
|
56
|
+
throw err
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
throw new VerificationError(String(err))
|
|
43
60
|
})
|
|
44
61
|
}
|
|
45
62
|
|
|
46
63
|
try {
|
|
64
|
+
options?.signal?.throwIfAborted()
|
|
47
65
|
return secp.verify(sig, p.digest, key)
|
|
48
66
|
} catch (err) {
|
|
49
67
|
throw new VerificationError(String(err))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
2
|
import { secp256k1 as secp } from '@noble/curves/secp256k1'
|
|
3
3
|
import { SigningError, VerificationError } from '../../errors.js'
|
|
4
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
4
5
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
5
6
|
|
|
6
7
|
const PUBLIC_KEY_BYTE_LENGTH = 33
|
|
@@ -12,7 +13,9 @@ export { PRIVATE_KEY_BYTE_LENGTH as privateKeyLength }
|
|
|
12
13
|
/**
|
|
13
14
|
* Hash and sign message with private key
|
|
14
15
|
*/
|
|
15
|
-
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList): Uint8Array {
|
|
16
|
+
export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array {
|
|
17
|
+
options?.signal?.throwIfAborted()
|
|
18
|
+
|
|
16
19
|
const hash = crypto.createHash('sha256')
|
|
17
20
|
|
|
18
21
|
if (msg instanceof Uint8Array) {
|
|
@@ -36,7 +39,8 @@ export function hashAndSign (key: Uint8Array, msg: Uint8Array | Uint8ArrayList):
|
|
|
36
39
|
/**
|
|
37
40
|
* Hash message and verify signature with public key
|
|
38
41
|
*/
|
|
39
|
-
export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList): boolean {
|
|
42
|
+
export function hashAndVerify (key: Uint8Array, sig: Uint8Array, msg: Uint8Array | Uint8ArrayList, options?: AbortOptions): boolean {
|
|
43
|
+
options?.signal?.throwIfAborted()
|
|
40
44
|
const hash = crypto.createHash('sha256')
|
|
41
45
|
|
|
42
46
|
if (msg instanceof Uint8Array) {
|
|
@@ -5,7 +5,7 @@ import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
|
5
5
|
import { publicKeyToProtobuf } from '../index.js'
|
|
6
6
|
import { validateSecp256k1PublicKey, compressSecp256k1PublicKey, computeSecp256k1PublicKey, validateSecp256k1PrivateKey } from './utils.js'
|
|
7
7
|
import { hashAndVerify, hashAndSign } from './index.js'
|
|
8
|
-
import type { Secp256k1PublicKey as Secp256k1PublicKeyInterface, Secp256k1PrivateKey as Secp256k1PrivateKeyInterface } from '@libp2p/interface'
|
|
8
|
+
import type { Secp256k1PublicKey as Secp256k1PublicKeyInterface, Secp256k1PrivateKey as Secp256k1PrivateKeyInterface, AbortOptions } from '@libp2p/interface'
|
|
9
9
|
import type { Digest } from 'multiformats/hashes/digest'
|
|
10
10
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
11
11
|
|
|
@@ -39,8 +39,8 @@ export class Secp256k1PublicKey implements Secp256k1PublicKeyInterface {
|
|
|
39
39
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean {
|
|
43
|
-
return hashAndVerify(this._key, sig, data)
|
|
42
|
+
verify (data: Uint8Array | Uint8ArrayList, sig: Uint8Array, options?: AbortOptions): boolean {
|
|
43
|
+
return hashAndVerify(this._key, sig, data, options)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -62,7 +62,7 @@ export class Secp256k1PrivateKey implements Secp256k1PrivateKeyInterface {
|
|
|
62
62
|
return uint8ArrayEquals(this.raw, key.raw)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
sign (message: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array> {
|
|
66
|
-
return hashAndSign(this.raw, message)
|
|
65
|
+
sign (message: Uint8Array | Uint8ArrayList, options?: AbortOptions): Uint8Array | Promise<Uint8Array> {
|
|
66
|
+
return hashAndSign(this.raw, message, options)
|
|
67
67
|
}
|
|
68
68
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"AESCipher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.ciphers.AES_GCM.AESCipher.html",
|
|
3
|
-
"CreateAESCipherOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.ciphers.AES_GCM.CreateAESCipherOptions.html",
|
|
4
|
-
"create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.ciphers.AES_GCM.create.html",
|
|
5
|
-
"HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
|
|
6
|
-
"./hmac:HMAC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.hmac.HMAC.html",
|
|
7
|
-
"./hmac:create": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.hmac.create.html",
|
|
8
|
-
"pbkdf2": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.pbkdf2.html",
|
|
9
|
-
"randomBytes": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.index.randomBytes.html",
|
|
10
|
-
"ECDHKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.ECDHKey.html",
|
|
11
|
-
"ECDHKeyPair": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.ECDHKeyPair.html",
|
|
12
|
-
"EnhancedKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.EnhancedKey.html",
|
|
13
|
-
"EnhancedKeyPair": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_crypto.keys.EnhancedKeyPair.html",
|
|
14
|
-
"Curve": "https://libp2p.github.io/js-libp2p/types/_libp2p_crypto.keys.Curve.html",
|
|
15
|
-
"generateEphemeralKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateEphemeralKeyPair.html",
|
|
16
|
-
"generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
|
|
17
|
-
"./keys:generateKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPair.html",
|
|
18
|
-
"generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
|
|
19
|
-
"./keys:generateKeyPairFromSeed": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.generateKeyPairFromSeed.html",
|
|
20
|
-
"keyStretcher": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.keyStretcher.html",
|
|
21
|
-
"privateKeyFromCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromCryptoKeyPair.html",
|
|
22
|
-
"./keys:privateKeyFromCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromCryptoKeyPair.html",
|
|
23
|
-
"privateKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromProtobuf.html",
|
|
24
|
-
"./keys:privateKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromProtobuf.html",
|
|
25
|
-
"privateKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromRaw.html",
|
|
26
|
-
"./keys:privateKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyFromRaw.html",
|
|
27
|
-
"privateKeyToCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToCryptoKeyPair.html",
|
|
28
|
-
"./keys:privateKeyToCryptoKeyPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToCryptoKeyPair.html",
|
|
29
|
-
"privateKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToProtobuf.html",
|
|
30
|
-
"./keys:privateKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.privateKeyToProtobuf.html",
|
|
31
|
-
"publicKeyFromMultihash": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromMultihash.html",
|
|
32
|
-
"./keys:publicKeyFromMultihash": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromMultihash.html",
|
|
33
|
-
"publicKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromProtobuf.html",
|
|
34
|
-
"./keys:publicKeyFromProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromProtobuf.html",
|
|
35
|
-
"publicKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromRaw.html",
|
|
36
|
-
"./keys:publicKeyFromRaw": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyFromRaw.html",
|
|
37
|
-
"publicKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyToProtobuf.html",
|
|
38
|
-
"./keys:publicKeyToProtobuf": "https://libp2p.github.io/js-libp2p/functions/_libp2p_crypto.keys.publicKeyToProtobuf.html",
|
|
39
|
-
"default": "https://libp2p.github.io/js-libp2p/variables/_libp2p_crypto.webcrypto.default.html"
|
|
40
|
-
}
|