@libp2p/crypto 0.22.7 → 0.22.10
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/src/keys/ecdh-browser.d.ts.map +1 -1
- package/dist/src/keys/ecdh-browser.js +0 -1
- package/dist/src/keys/ecdh-browser.js.map +1 -1
- package/dist/src/keys/ed25519-class.js +2 -2
- package/dist/src/keys/ed25519-class.js.map +1 -1
- package/dist/src/keys/keys.d.ts +22 -220
- package/dist/src/keys/keys.d.ts.map +1 -1
- package/dist/src/keys/keys.js +44 -344
- package/dist/src/keys/keys.js.map +1 -1
- package/dist/src/keys/rsa-class.js +2 -2
- package/dist/src/keys/rsa-class.js.map +1 -1
- package/dist/src/keys/secp256k1-class.js +2 -2
- package/dist/src/keys/secp256k1-class.js.map +1 -1
- package/dist/src/pbkdf2.d.ts +1 -1
- package/dist/src/pbkdf2.d.ts.map +1 -1
- package/package.json +18 -19
- package/src/keys/ecdh-browser.ts +0 -1
- package/src/keys/ed25519-class.ts +2 -2
- package/src/keys/keys.ts +60 -0
- package/src/keys/rsa-class.ts +2 -2
- package/src/keys/secp256k1-class.ts +2 -2
- package/src/pbkdf2.ts +1 -1
- package/src/keys/keys.d.ts +0 -146
- package/src/keys/keys.js +0 -366
package/dist/src/keys/keys.js
CHANGED
|
@@ -1,345 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
/*eslint-disable*/
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
* PublicKey Type.
|
|
46
|
-
* @member {KeyType} Type
|
|
47
|
-
* @memberof PublicKey
|
|
48
|
-
* @instance
|
|
49
|
-
*/
|
|
50
|
-
PublicKey.prototype.Type = 0;
|
|
51
|
-
/**
|
|
52
|
-
* PublicKey Data.
|
|
53
|
-
* @member {Uint8Array} Data
|
|
54
|
-
* @memberof PublicKey
|
|
55
|
-
* @instance
|
|
56
|
-
*/
|
|
57
|
-
PublicKey.prototype.Data = $util.newBuffer([]);
|
|
58
|
-
/**
|
|
59
|
-
* Encodes the specified PublicKey message. Does not implicitly {@link PublicKey.verify|verify} messages.
|
|
60
|
-
* @function encode
|
|
61
|
-
* @memberof PublicKey
|
|
62
|
-
* @static
|
|
63
|
-
* @param {IPublicKey} m PublicKey message or plain object to encode
|
|
64
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
65
|
-
* @returns {$protobuf.Writer} Writer
|
|
66
|
-
*/
|
|
67
|
-
PublicKey.encode = function encode(m, w) {
|
|
68
|
-
if (!w)
|
|
69
|
-
w = $Writer.create();
|
|
70
|
-
w.uint32(8).int32(m.Type);
|
|
71
|
-
w.uint32(18).bytes(m.Data);
|
|
72
|
-
return w;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Decodes a PublicKey message from the specified reader or buffer.
|
|
76
|
-
* @function decode
|
|
77
|
-
* @memberof PublicKey
|
|
78
|
-
* @static
|
|
79
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
80
|
-
* @param {number} [l] Message length if known beforehand
|
|
81
|
-
* @returns {PublicKey} PublicKey
|
|
82
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
83
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
84
|
-
*/
|
|
85
|
-
PublicKey.decode = function decode(r, l) {
|
|
86
|
-
if (!(r instanceof $Reader))
|
|
87
|
-
r = $Reader.create(r);
|
|
88
|
-
var c = l === undefined ? r.len : r.pos + l, m = new PublicKey();
|
|
89
|
-
while (r.pos < c) {
|
|
90
|
-
var t = r.uint32();
|
|
91
|
-
switch (t >>> 3) {
|
|
92
|
-
case 1:
|
|
93
|
-
m.Type = r.int32();
|
|
94
|
-
break;
|
|
95
|
-
case 2:
|
|
96
|
-
m.Data = r.bytes();
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
r.skipType(t & 7);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!m.hasOwnProperty("Type"))
|
|
104
|
-
throw $util.ProtocolError("missing required 'Type'", { instance: m });
|
|
105
|
-
if (!m.hasOwnProperty("Data"))
|
|
106
|
-
throw $util.ProtocolError("missing required 'Data'", { instance: m });
|
|
107
|
-
return m;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Creates a PublicKey message from a plain object. Also converts values to their respective internal types.
|
|
111
|
-
* @function fromObject
|
|
112
|
-
* @memberof PublicKey
|
|
113
|
-
* @static
|
|
114
|
-
* @param {Object.<string,*>} d Plain object
|
|
115
|
-
* @returns {PublicKey} PublicKey
|
|
116
|
-
*/
|
|
117
|
-
PublicKey.fromObject = function fromObject(d) {
|
|
118
|
-
if (d instanceof PublicKey)
|
|
119
|
-
return d;
|
|
120
|
-
var m = new PublicKey();
|
|
121
|
-
switch (d.Type) {
|
|
122
|
-
case "RSA":
|
|
123
|
-
case 0:
|
|
124
|
-
m.Type = 0;
|
|
125
|
-
break;
|
|
126
|
-
case "Ed25519":
|
|
127
|
-
case 1:
|
|
128
|
-
m.Type = 1;
|
|
129
|
-
break;
|
|
130
|
-
case "Secp256k1":
|
|
131
|
-
case 2:
|
|
132
|
-
m.Type = 2;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (d.Data != null) {
|
|
136
|
-
if (typeof d.Data === "string")
|
|
137
|
-
$util.base64.decode(d.Data, m.Data = $util.newBuffer($util.base64.length(d.Data)), 0);
|
|
138
|
-
else if (d.Data.length)
|
|
139
|
-
m.Data = d.Data;
|
|
140
|
-
}
|
|
141
|
-
return m;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Creates a plain object from a PublicKey message. Also converts values to other types if specified.
|
|
145
|
-
* @function toObject
|
|
146
|
-
* @memberof PublicKey
|
|
147
|
-
* @static
|
|
148
|
-
* @param {PublicKey} m PublicKey
|
|
149
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
150
|
-
* @returns {Object.<string,*>} Plain object
|
|
151
|
-
*/
|
|
152
|
-
PublicKey.toObject = function toObject(m, o) {
|
|
153
|
-
if (!o)
|
|
154
|
-
o = {};
|
|
155
|
-
var d = {};
|
|
156
|
-
if (o.defaults) {
|
|
157
|
-
d.Type = o.enums === String ? "RSA" : 0;
|
|
158
|
-
if (o.bytes === String)
|
|
159
|
-
d.Data = "";
|
|
160
|
-
else {
|
|
161
|
-
d.Data = [];
|
|
162
|
-
if (o.bytes !== Array)
|
|
163
|
-
d.Data = $util.newBuffer(d.Data);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (m.Type != null && m.hasOwnProperty("Type")) {
|
|
167
|
-
d.Type = o.enums === String ? $root.KeyType[m.Type] : m.Type;
|
|
168
|
-
}
|
|
169
|
-
if (m.Data != null && m.hasOwnProperty("Data")) {
|
|
170
|
-
d.Data = o.bytes === String ? $util.base64.encode(m.Data, 0, m.Data.length) : o.bytes === Array ? Array.prototype.slice.call(m.Data) : m.Data;
|
|
171
|
-
}
|
|
172
|
-
return d;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Converts this PublicKey to JSON.
|
|
176
|
-
* @function toJSON
|
|
177
|
-
* @memberof PublicKey
|
|
178
|
-
* @instance
|
|
179
|
-
* @returns {Object.<string,*>} JSON object
|
|
180
|
-
*/
|
|
181
|
-
PublicKey.prototype.toJSON = function toJSON() {
|
|
182
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Properties of a PrivateKey.
|
|
186
|
-
* @exports IPrivateKey
|
|
187
|
-
* @interface IPrivateKey
|
|
188
|
-
* @property {KeyType} Type PrivateKey Type
|
|
189
|
-
* @property {Uint8Array} Data PrivateKey Data
|
|
190
|
-
*/
|
|
191
|
-
/**
|
|
192
|
-
* Constructs a new PrivateKey.
|
|
193
|
-
* @exports PrivateKey
|
|
194
|
-
* @classdesc Represents a PrivateKey.
|
|
195
|
-
* @implements IPrivateKey
|
|
196
|
-
* @constructor
|
|
197
|
-
* @param {IPrivateKey=} [p] Properties to set
|
|
198
|
-
*/
|
|
199
|
-
export function PrivateKey(p) {
|
|
200
|
-
if (p)
|
|
201
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
202
|
-
if (p[ks[i]] != null)
|
|
203
|
-
this[ks[i]] = p[ks[i]];
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* PrivateKey Type.
|
|
207
|
-
* @member {KeyType} Type
|
|
208
|
-
* @memberof PrivateKey
|
|
209
|
-
* @instance
|
|
210
|
-
*/
|
|
211
|
-
PrivateKey.prototype.Type = 0;
|
|
212
|
-
/**
|
|
213
|
-
* PrivateKey Data.
|
|
214
|
-
* @member {Uint8Array} Data
|
|
215
|
-
* @memberof PrivateKey
|
|
216
|
-
* @instance
|
|
217
|
-
*/
|
|
218
|
-
PrivateKey.prototype.Data = $util.newBuffer([]);
|
|
219
|
-
/**
|
|
220
|
-
* Encodes the specified PrivateKey message. Does not implicitly {@link PrivateKey.verify|verify} messages.
|
|
221
|
-
* @function encode
|
|
222
|
-
* @memberof PrivateKey
|
|
223
|
-
* @static
|
|
224
|
-
* @param {IPrivateKey} m PrivateKey message or plain object to encode
|
|
225
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
226
|
-
* @returns {$protobuf.Writer} Writer
|
|
227
|
-
*/
|
|
228
|
-
PrivateKey.encode = function encode(m, w) {
|
|
229
|
-
if (!w)
|
|
230
|
-
w = $Writer.create();
|
|
231
|
-
w.uint32(8).int32(m.Type);
|
|
232
|
-
w.uint32(18).bytes(m.Data);
|
|
233
|
-
return w;
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Decodes a PrivateKey message from the specified reader or buffer.
|
|
237
|
-
* @function decode
|
|
238
|
-
* @memberof PrivateKey
|
|
239
|
-
* @static
|
|
240
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
241
|
-
* @param {number} [l] Message length if known beforehand
|
|
242
|
-
* @returns {PrivateKey} PrivateKey
|
|
243
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
244
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
245
|
-
*/
|
|
246
|
-
PrivateKey.decode = function decode(r, l) {
|
|
247
|
-
if (!(r instanceof $Reader))
|
|
248
|
-
r = $Reader.create(r);
|
|
249
|
-
var c = l === undefined ? r.len : r.pos + l, m = new PrivateKey();
|
|
250
|
-
while (r.pos < c) {
|
|
251
|
-
var t = r.uint32();
|
|
252
|
-
switch (t >>> 3) {
|
|
253
|
-
case 1:
|
|
254
|
-
m.Type = r.int32();
|
|
255
|
-
break;
|
|
256
|
-
case 2:
|
|
257
|
-
m.Data = r.bytes();
|
|
258
|
-
break;
|
|
259
|
-
default:
|
|
260
|
-
r.skipType(t & 7);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (!m.hasOwnProperty("Type"))
|
|
265
|
-
throw $util.ProtocolError("missing required 'Type'", { instance: m });
|
|
266
|
-
if (!m.hasOwnProperty("Data"))
|
|
267
|
-
throw $util.ProtocolError("missing required 'Data'", { instance: m });
|
|
268
|
-
return m;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Creates a PrivateKey message from a plain object. Also converts values to their respective internal types.
|
|
272
|
-
* @function fromObject
|
|
273
|
-
* @memberof PrivateKey
|
|
274
|
-
* @static
|
|
275
|
-
* @param {Object.<string,*>} d Plain object
|
|
276
|
-
* @returns {PrivateKey} PrivateKey
|
|
277
|
-
*/
|
|
278
|
-
PrivateKey.fromObject = function fromObject(d) {
|
|
279
|
-
if (d instanceof PrivateKey)
|
|
280
|
-
return d;
|
|
281
|
-
var m = new PrivateKey();
|
|
282
|
-
switch (d.Type) {
|
|
283
|
-
case "RSA":
|
|
284
|
-
case 0:
|
|
285
|
-
m.Type = 0;
|
|
286
|
-
break;
|
|
287
|
-
case "Ed25519":
|
|
288
|
-
case 1:
|
|
289
|
-
m.Type = 1;
|
|
290
|
-
break;
|
|
291
|
-
case "Secp256k1":
|
|
292
|
-
case 2:
|
|
293
|
-
m.Type = 2;
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
if (d.Data != null) {
|
|
297
|
-
if (typeof d.Data === "string")
|
|
298
|
-
$util.base64.decode(d.Data, m.Data = $util.newBuffer($util.base64.length(d.Data)), 0);
|
|
299
|
-
else if (d.Data.length)
|
|
300
|
-
m.Data = d.Data;
|
|
301
|
-
}
|
|
302
|
-
return m;
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Creates a plain object from a PrivateKey message. Also converts values to other types if specified.
|
|
306
|
-
* @function toObject
|
|
307
|
-
* @memberof PrivateKey
|
|
308
|
-
* @static
|
|
309
|
-
* @param {PrivateKey} m PrivateKey
|
|
310
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
311
|
-
* @returns {Object.<string,*>} Plain object
|
|
312
|
-
*/
|
|
313
|
-
PrivateKey.toObject = function toObject(m, o) {
|
|
314
|
-
if (!o)
|
|
315
|
-
o = {};
|
|
316
|
-
var d = {};
|
|
317
|
-
if (o.defaults) {
|
|
318
|
-
d.Type = o.enums === String ? "RSA" : 0;
|
|
319
|
-
if (o.bytes === String)
|
|
320
|
-
d.Data = "";
|
|
321
|
-
else {
|
|
322
|
-
d.Data = [];
|
|
323
|
-
if (o.bytes !== Array)
|
|
324
|
-
d.Data = $util.newBuffer(d.Data);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if (m.Type != null && m.hasOwnProperty("Type")) {
|
|
328
|
-
d.Type = o.enums === String ? $root.KeyType[m.Type] : m.Type;
|
|
329
|
-
}
|
|
330
|
-
if (m.Data != null && m.hasOwnProperty("Data")) {
|
|
331
|
-
d.Data = o.bytes === String ? $util.base64.encode(m.Data, 0, m.Data.length) : o.bytes === Array ? Array.prototype.slice.call(m.Data) : m.Data;
|
|
332
|
-
}
|
|
333
|
-
return d;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Converts this PrivateKey to JSON.
|
|
337
|
-
* @function toJSON
|
|
338
|
-
* @memberof PrivateKey
|
|
339
|
-
* @instance
|
|
340
|
-
* @returns {Object.<string,*>} JSON object
|
|
341
|
-
*/
|
|
342
|
-
PrivateKey.prototype.toJSON = function toJSON() {
|
|
343
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
344
|
-
};
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { enumeration, encodeMessage, decodeMessage, message, bytes } from 'protons-runtime';
|
|
4
|
+
export var KeyType;
|
|
5
|
+
(function (KeyType) {
|
|
6
|
+
KeyType["RSA"] = "RSA";
|
|
7
|
+
KeyType["Ed25519"] = "Ed25519";
|
|
8
|
+
KeyType["Secp256k1"] = "Secp256k1";
|
|
9
|
+
})(KeyType || (KeyType = {}));
|
|
10
|
+
(function (KeyType) {
|
|
11
|
+
KeyType.codec = () => {
|
|
12
|
+
return enumeration(KeyType);
|
|
13
|
+
};
|
|
14
|
+
})(KeyType || (KeyType = {}));
|
|
15
|
+
export var PublicKey;
|
|
16
|
+
(function (PublicKey) {
|
|
17
|
+
PublicKey.codec = () => {
|
|
18
|
+
return message({
|
|
19
|
+
1: { name: 'Type', codec: KeyType.codec() },
|
|
20
|
+
2: { name: 'Data', codec: bytes }
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
PublicKey.encode = (obj) => {
|
|
24
|
+
return encodeMessage(obj, PublicKey.codec());
|
|
25
|
+
};
|
|
26
|
+
PublicKey.decode = (buf) => {
|
|
27
|
+
return decodeMessage(buf, PublicKey.codec());
|
|
28
|
+
};
|
|
29
|
+
})(PublicKey || (PublicKey = {}));
|
|
30
|
+
export var PrivateKey;
|
|
31
|
+
(function (PrivateKey) {
|
|
32
|
+
PrivateKey.codec = () => {
|
|
33
|
+
return message({
|
|
34
|
+
1: { name: 'Type', codec: KeyType.codec() },
|
|
35
|
+
2: { name: 'Data', codec: bytes }
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
PrivateKey.encode = (obj) => {
|
|
39
|
+
return encodeMessage(obj, PrivateKey.codec());
|
|
40
|
+
};
|
|
41
|
+
PrivateKey.decode = (buf) => {
|
|
42
|
+
return decodeMessage(buf, PrivateKey.codec());
|
|
43
|
+
};
|
|
44
|
+
})(PrivateKey || (PrivateKey = {}));
|
|
345
45
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/keys/keys.
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/keys/keys.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oDAAoD;AAEpD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE3F,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,sBAAW,CAAA;IACX,8BAAmB,CAAA;IACnB,kCAAuB,CAAA;AACzB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIl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C,GAAe,EAAc,EAAE;QACpD,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAA;IAC/C,CAAC,CAAA;AACH,CAAC,EAfgB,UAAU,KAAV,UAAU,QAe1B"}
|
|
@@ -22,7 +22,7 @@ export class RsaPublicKey {
|
|
|
22
22
|
return pbm.PublicKey.encode({
|
|
23
23
|
Type: pbm.KeyType.RSA,
|
|
24
24
|
Data: this.marshal()
|
|
25
|
-
})
|
|
25
|
+
});
|
|
26
26
|
}
|
|
27
27
|
encrypt(bytes) {
|
|
28
28
|
return crypto.encrypt(this._key, bytes);
|
|
@@ -62,7 +62,7 @@ export class RsaPrivateKey {
|
|
|
62
62
|
return pbm.PrivateKey.encode({
|
|
63
63
|
Type: pbm.KeyType.RSA,
|
|
64
64
|
Data: this.marshal()
|
|
65
|
-
})
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
67
|
equals(key) {
|
|
68
68
|
return uint8ArrayEquals(this.bytes, key.bytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsa-class.js","sourceRoot":"","sources":["../../../src/keys/rsa-class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,0BAA0B,CAAA;AACjC,qCAAqC;AACrC,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,OAAO,YAAY;IAGvB,YAAa,GAAe;QAC1B,IAAI,CAAC,IAAI,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KAAK,UAAU,eAAe,CAAE,IAAY;IACjD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC3C,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;AAC3D,CAAC"}
|
|
@@ -20,7 +20,7 @@ export class Secp256k1PublicKey {
|
|
|
20
20
|
return keysProtobuf.PublicKey.encode({
|
|
21
21
|
Type: keysProtobuf.KeyType.Secp256k1,
|
|
22
22
|
Data: this.marshal()
|
|
23
|
-
})
|
|
23
|
+
});
|
|
24
24
|
}
|
|
25
25
|
equals(key) {
|
|
26
26
|
return uint8ArrayEquals(this.bytes, key.bytes);
|
|
@@ -50,7 +50,7 @@ export class Secp256k1PrivateKey {
|
|
|
50
50
|
return keysProtobuf.PrivateKey.encode({
|
|
51
51
|
Type: keysProtobuf.KeyType.Secp256k1,
|
|
52
52
|
Data: this.marshal()
|
|
53
|
-
})
|
|
53
|
+
});
|
|
54
54
|
}
|
|
55
55
|
equals(key) {
|
|
56
56
|
return uint8ArrayEquals(this.bytes, key.bytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1-class.js","sourceRoot":"","sources":["../../../src/keys/secp256k1-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,YAAY,MAAM,WAAW,CAAA;AAEzC,MAAM,OAAO,kBAAkB;IAG7B,YAAa,GAAe;QAC1B,MAAM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mB,CAAC,eAAe,CAAC,CAAA;AACjD,CAAC"}
|
package/dist/src/pbkdf2.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Computes the Password-Based Key Derivation Function 2.
|
|
3
3
|
*/
|
|
4
|
-
export default function pbkdf2(password: string, salt: string, iterations: number, keySize: number, hash: string):
|
|
4
|
+
export default function pbkdf2(password: string, salt: string, iterations: number, keySize: number, hash: string): string;
|
|
5
5
|
//# sourceMappingURL=pbkdf2.d.ts.map
|
package/dist/src/pbkdf2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../src/pbkdf2.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../src/pbkdf2.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBzH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/crypto",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.10",
|
|
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",
|
|
@@ -154,36 +154,35 @@
|
|
|
154
154
|
]
|
|
155
155
|
},
|
|
156
156
|
"scripts": {
|
|
157
|
+
"clean": "aegir clean",
|
|
157
158
|
"lint": "aegir lint",
|
|
158
|
-
"dep-check": "aegir dep-check
|
|
159
|
-
"build": "
|
|
160
|
-
"
|
|
161
|
-
"test": "aegir test -
|
|
162
|
-
"test:chrome": "
|
|
163
|
-
"test:
|
|
164
|
-
"test:firefox": "
|
|
165
|
-
"test:
|
|
166
|
-
"test:
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"build:proto": "npm run build:proto:js && npm run build:proto:types",
|
|
170
|
-
"build:proto:js": "pbjs -t static-module -w es6 --es6 -r libp2p-crypto-keys --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/keys/keys.js ./src/keys/keys.proto",
|
|
171
|
-
"build:proto:types": "pbts -o src/keys/keys.d.ts src/keys/keys.js"
|
|
159
|
+
"dep-check": "aegir dep-check",
|
|
160
|
+
"build": "aegir build",
|
|
161
|
+
"test": "aegir test",
|
|
162
|
+
"test:chrome": "aegir test -t browser",
|
|
163
|
+
"test:chrome-webworker": "aegir test -t webworker",
|
|
164
|
+
"test:firefox": "aegir test -t browser -- --browser firefox",
|
|
165
|
+
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
|
|
166
|
+
"test:node": "aegir test -t node --cov",
|
|
167
|
+
"test:electron-main": "aegir test -t electron-main",
|
|
168
|
+
"release": "aegir release",
|
|
169
|
+
"generate": "protons ./src/keys/keys.proto"
|
|
172
170
|
},
|
|
173
171
|
"dependencies": {
|
|
174
|
-
"@noble/ed25519": "^1.
|
|
175
|
-
"@noble/secp256k1": "^1.
|
|
172
|
+
"@noble/ed25519": "^1.6.0",
|
|
173
|
+
"@noble/secp256k1": "^1.5.4",
|
|
176
174
|
"err-code": "^3.0.1",
|
|
177
175
|
"iso-random-stream": "^2.0.0",
|
|
178
176
|
"multiformats": "^9.4.5",
|
|
179
177
|
"node-forge": "^1.1.0",
|
|
180
|
-
"
|
|
178
|
+
"protons-runtime": "^1.0.2",
|
|
181
179
|
"uint8arrays": "^3.0.0"
|
|
182
180
|
},
|
|
183
181
|
"devDependencies": {
|
|
184
182
|
"@types/mocha": "^9.0.0",
|
|
185
|
-
"aegir": "^
|
|
183
|
+
"aegir": "^37.0.12",
|
|
186
184
|
"benchmark": "^2.1.4",
|
|
185
|
+
"protons": "^3.0.2",
|
|
187
186
|
"sinon": "^13.0.1",
|
|
188
187
|
"util": "^0.12.3",
|
|
189
188
|
"wherearewe": "^1.0.0"
|
package/src/keys/ecdh-browser.ts
CHANGED
|
@@ -73,7 +73,6 @@ export async function generateEphmeralKeyPair (curve: string) {
|
|
|
73
73
|
return new Uint8Array(buffer, 0, buffer.byteLength)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// @ts-expect-error jwk is missing from the types
|
|
77
76
|
const publicKey = await webcrypto.get().subtle.exportKey('jwk', pair.publicKey)
|
|
78
77
|
|
|
79
78
|
const ecdhKey: ECDHKey = {
|
|
@@ -26,7 +26,7 @@ export class Ed25519PublicKey {
|
|
|
26
26
|
return pbm.PublicKey.encode({
|
|
27
27
|
Type: pbm.KeyType.Ed25519,
|
|
28
28
|
Data: this.marshal()
|
|
29
|
-
})
|
|
29
|
+
})
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
equals (key: any) {
|
|
@@ -67,7 +67,7 @@ export class Ed25519PrivateKey {
|
|
|
67
67
|
return pbm.PrivateKey.encode({
|
|
68
68
|
Type: pbm.KeyType.Ed25519,
|
|
69
69
|
Data: this.marshal()
|
|
70
|
-
})
|
|
70
|
+
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
equals (key: any) {
|
package/src/keys/keys.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
|
|
4
|
+
import { enumeration, encodeMessage, decodeMessage, message, bytes } from 'protons-runtime'
|
|
5
|
+
|
|
6
|
+
export enum KeyType {
|
|
7
|
+
RSA = 'RSA',
|
|
8
|
+
Ed25519 = 'Ed25519',
|
|
9
|
+
Secp256k1 = 'Secp256k1'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export namespace KeyType {
|
|
13
|
+
export const codec = () => {
|
|
14
|
+
return enumeration<typeof KeyType>(KeyType)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PublicKey {
|
|
19
|
+
Type: KeyType
|
|
20
|
+
Data: Uint8Array
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export namespace PublicKey {
|
|
24
|
+
export const codec = () => {
|
|
25
|
+
return message<PublicKey>({
|
|
26
|
+
1: { name: 'Type', codec: KeyType.codec() },
|
|
27
|
+
2: { name: 'Data', codec: bytes }
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const encode = (obj: PublicKey): Uint8Array => {
|
|
32
|
+
return encodeMessage(obj, PublicKey.codec())
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const decode = (buf: Uint8Array): PublicKey => {
|
|
36
|
+
return decodeMessage(buf, PublicKey.codec())
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PrivateKey {
|
|
41
|
+
Type: KeyType
|
|
42
|
+
Data: Uint8Array
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export namespace PrivateKey {
|
|
46
|
+
export const codec = () => {
|
|
47
|
+
return message<PrivateKey>({
|
|
48
|
+
1: { name: 'Type', codec: KeyType.codec() },
|
|
49
|
+
2: { name: 'Data', codec: bytes }
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const encode = (obj: PrivateKey): Uint8Array => {
|
|
54
|
+
return encodeMessage(obj, PrivateKey.codec())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const decode = (buf: Uint8Array): PrivateKey => {
|
|
58
|
+
return decodeMessage(buf, PrivateKey.codec())
|
|
59
|
+
}
|
|
60
|
+
}
|