@nmshd/crypto 1.0.9 → 2.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/dist/CoreBuffer.d.ts +0 -1
- package/dist/CoreBuffer.js +1 -4
- package/dist/CoreBuffer.js.map +1 -1
- package/dist/CryptoDerivation.js +2 -2
- package/dist/CryptoDerivation.js.map +1 -1
- package/dist/CryptoPrivateKey.d.ts +7 -10
- package/dist/CryptoPrivateKey.js +18 -33
- package/dist/CryptoPrivateKey.js.map +1 -1
- package/dist/CryptoPublicKey.d.ts +6 -9
- package/dist/CryptoPublicKey.js +16 -31
- package/dist/CryptoPublicKey.js.map +1 -1
- package/dist/CryptoSerializable.js.map +1 -1
- package/dist/CryptoValidation.d.ts +4 -6
- package/dist/CryptoValidation.js +16 -29
- package/dist/CryptoValidation.js.map +1 -1
- package/dist/buildInformation.js +4 -4
- package/dist/encryption/CryptoCipher.d.ts +5 -6
- package/dist/encryption/CryptoCipher.js +59 -56
- package/dist/encryption/CryptoCipher.js.map +1 -1
- package/dist/encryption/CryptoEncryption.js +10 -12
- package/dist/encryption/CryptoEncryption.js.map +1 -1
- package/dist/encryption/CryptoSecretKey.d.ts +3 -4
- package/dist/encryption/CryptoSecretKey.js +34 -30
- package/dist/encryption/CryptoSecretKey.js.map +1 -1
- package/dist/exchange/CryptoExchange.d.ts +0 -2
- package/dist/exchange/CryptoExchange.js +3 -20
- package/dist/exchange/CryptoExchange.js.map +1 -1
- package/dist/exchange/CryptoExchangeKeypair.d.ts +3 -4
- package/dist/exchange/CryptoExchangeKeypair.js +29 -22
- package/dist/exchange/CryptoExchangeKeypair.js.map +1 -1
- package/dist/exchange/CryptoExchangePrivateKey.d.ts +3 -5
- package/dist/exchange/CryptoExchangePrivateKey.js +50 -31
- package/dist/exchange/CryptoExchangePrivateKey.js.map +1 -1
- package/dist/exchange/CryptoExchangePublicKey.d.ts +3 -4
- package/dist/exchange/CryptoExchangePublicKey.js +28 -29
- package/dist/exchange/CryptoExchangePublicKey.js.map +1 -1
- package/dist/exchange/CryptoExchangeSecrets.d.ts +4 -5
- package/dist/exchange/CryptoExchangeSecrets.js +32 -34
- package/dist/exchange/CryptoExchangeSecrets.js.map +1 -1
- package/dist/exchange/CryptoExchangeValidation.d.ts +7 -10
- package/dist/exchange/CryptoExchangeValidation.js +9 -36
- package/dist/exchange/CryptoExchangeValidation.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/relationship/CryptoRelationshipPublicRequest.d.ts +1 -2
- package/dist/relationship/CryptoRelationshipPublicRequest.js +19 -34
- package/dist/relationship/CryptoRelationshipPublicRequest.js.map +1 -1
- package/dist/relationship/CryptoRelationshipPublicResponse.d.ts +1 -2
- package/dist/relationship/CryptoRelationshipPublicResponse.js +20 -30
- package/dist/relationship/CryptoRelationshipPublicResponse.js.map +1 -1
- package/dist/relationship/CryptoRelationshipRequestSecrets.d.ts +0 -1
- package/dist/relationship/CryptoRelationshipRequestSecrets.js +1 -4
- package/dist/relationship/CryptoRelationshipRequestSecrets.js.map +1 -1
- package/dist/relationship/CryptoRelationshipSecrets.d.ts +0 -1
- package/dist/relationship/CryptoRelationshipSecrets.js +1 -4
- package/dist/relationship/CryptoRelationshipSecrets.js.map +1 -1
- package/dist/signature/CryptoSignature.d.ts +5 -6
- package/dist/signature/CryptoSignature.js +36 -32
- package/dist/signature/CryptoSignature.js.map +1 -1
- package/dist/signature/CryptoSignatureAlgorithm.d.ts +5 -0
- package/dist/signature/CryptoSignatureAlgorithm.js +3 -0
- package/dist/signature/CryptoSignatureAlgorithm.js.map +1 -0
- package/dist/signature/CryptoSignatureKeypair.d.ts +3 -4
- package/dist/signature/CryptoSignatureKeypair.js +32 -30
- package/dist/signature/CryptoSignatureKeypair.js.map +1 -1
- package/dist/signature/CryptoSignaturePrivateKey.d.ts +5 -8
- package/dist/signature/CryptoSignaturePrivateKey.js +24 -35
- package/dist/signature/CryptoSignaturePrivateKey.js.map +1 -1
- package/dist/signature/CryptoSignaturePublicKey.d.ts +4 -7
- package/dist/signature/CryptoSignaturePublicKey.js +19 -41
- package/dist/signature/CryptoSignaturePublicKey.js.map +1 -1
- package/dist/signature/CryptoSignatureValidation.d.ts +10 -12
- package/dist/signature/CryptoSignatureValidation.js +13 -35
- package/dist/signature/CryptoSignatureValidation.js.map +1 -1
- package/dist/signature/CryptoSignatures.d.ts +1 -5
- package/dist/signature/CryptoSignatures.js +4 -4
- package/dist/signature/CryptoSignatures.js.map +1 -1
- package/dist/state/CryptoPrivateState.d.ts +7 -15
- package/dist/state/CryptoPrivateState.js +72 -76
- package/dist/state/CryptoPrivateState.js.map +1 -1
- package/dist/state/CryptoPrivateStateReceive.d.ts +2 -4
- package/dist/state/CryptoPrivateStateReceive.js +27 -39
- package/dist/state/CryptoPrivateStateReceive.js.map +1 -1
- package/dist/state/CryptoPrivateStateTransmit.d.ts +1 -2
- package/dist/state/CryptoPrivateStateTransmit.js +14 -40
- package/dist/state/CryptoPrivateStateTransmit.js.map +1 -1
- package/dist/state/CryptoPublicState.d.ts +5 -10
- package/dist/state/CryptoPublicState.js +42 -51
- package/dist/state/CryptoPublicState.js.map +1 -1
- package/dist/stream/CryptoStream.js +5 -2
- package/dist/stream/CryptoStream.js.map +1 -1
- package/dist/stream/CryptoStreamAddress.d.ts +3 -6
- package/dist/stream/CryptoStreamAddress.js +13 -29
- package/dist/stream/CryptoStreamAddress.js.map +1 -1
- package/dist/stream/CryptoStreamHeader.d.ts +5 -8
- package/dist/stream/CryptoStreamHeader.js +15 -18
- package/dist/stream/CryptoStreamHeader.js.map +1 -1
- package/dist/stream/CryptoStreamState.d.ts +3 -7
- package/dist/stream/CryptoStreamState.js +14 -32
- package/dist/stream/CryptoStreamState.js.map +1 -1
- package/lib-web/nmshd.crypto.js +701 -914
- package/lib-web/nmshd.crypto.js.map +1 -1
- package/lib-web/nmshd.crypto.min.js +1 -1
- package/lib-web/nmshd.crypto.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -18,81 +18,84 @@ const CryptoErrorCode_1 = require("../CryptoErrorCode");
|
|
|
18
18
|
const CryptoSerializable_1 = require("../CryptoSerializable");
|
|
19
19
|
const CryptoValidation_1 = require("../CryptoValidation");
|
|
20
20
|
let CryptoCipher = CryptoCipher_1 = class CryptoCipher extends CryptoSerializable_1.CryptoSerializable {
|
|
21
|
-
constructor(cipher, algorithm, nonce, counter) {
|
|
22
|
-
if (!nonce && typeof counter === "undefined") {
|
|
23
|
-
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionNoNonceNorCounter, "No nonce nor counter property set.");
|
|
24
|
-
}
|
|
25
|
-
if (nonce && typeof counter !== "undefined") {
|
|
26
|
-
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionNonceAndCounter, "Nonce and counter properties are set.");
|
|
27
|
-
}
|
|
28
|
-
CryptoValidation_1.CryptoValidation.checkBuffer(cipher, CryptoCipher_1.MIN_CIPHER_BYTES, CryptoCipher_1.MAX_CIPHER_BYTES, "cipher");
|
|
29
|
-
CryptoValidation_1.CryptoValidation.checkEncryptionAlgorithm(algorithm);
|
|
30
|
-
if (typeof counter !== "undefined") {
|
|
31
|
-
CryptoValidation_1.CryptoValidation.checkCounter(counter);
|
|
32
|
-
}
|
|
33
|
-
if (typeof nonce !== "undefined") {
|
|
34
|
-
CryptoValidation_1.CryptoValidation.checkNonceForAlgorithm(nonce, algorithm);
|
|
35
|
-
}
|
|
36
|
-
super();
|
|
37
|
-
this.cipher = cipher;
|
|
38
|
-
this.nonce = nonce;
|
|
39
|
-
this.counter = counter;
|
|
40
|
-
this.algorithm = algorithm;
|
|
41
|
-
}
|
|
42
21
|
toJSON(verbose = true) {
|
|
43
|
-
|
|
22
|
+
return {
|
|
44
23
|
cph: this.cipher.toBase64URL(),
|
|
45
|
-
alg: this.algorithm
|
|
24
|
+
alg: this.algorithm,
|
|
25
|
+
nnc: this.nonce ? this.nonce.toBase64URL() : undefined,
|
|
26
|
+
cnt: this.counter,
|
|
27
|
+
"@type": verbose ? "CryptoCipher" : undefined
|
|
46
28
|
};
|
|
47
|
-
if (this.nonce) {
|
|
48
|
-
obj.nnc = this.nonce.toBase64URL();
|
|
49
|
-
}
|
|
50
|
-
if (typeof this.counter !== "undefined") {
|
|
51
|
-
obj.cnt = this.counter;
|
|
52
|
-
}
|
|
53
|
-
if (verbose) {
|
|
54
|
-
obj["@type"] = "CryptoCipher";
|
|
55
|
-
}
|
|
56
|
-
return obj;
|
|
57
29
|
}
|
|
58
30
|
clear() {
|
|
31
|
+
var _a;
|
|
59
32
|
this.cipher.clear();
|
|
60
|
-
|
|
61
|
-
this.nonce.clear();
|
|
33
|
+
(_a = this.nonce) === null || _a === void 0 ? void 0 : _a.clear();
|
|
62
34
|
}
|
|
63
35
|
static from(value) {
|
|
64
|
-
return
|
|
36
|
+
return this.fromAny(value);
|
|
65
37
|
}
|
|
66
|
-
static
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
static preFrom(value) {
|
|
39
|
+
if (value.cph) {
|
|
40
|
+
value = {
|
|
41
|
+
cipher: value.cph,
|
|
42
|
+
algorithm: value.alg,
|
|
43
|
+
nonce: value.nnc,
|
|
44
|
+
counter: value.cnt
|
|
45
|
+
};
|
|
74
46
|
}
|
|
75
|
-
if (typeof value.
|
|
76
|
-
|
|
77
|
-
|
|
47
|
+
if (!value.nonce && typeof value.counter === "undefined") {
|
|
48
|
+
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionNoNonceNorCounter, "No nonce nor counter property set.");
|
|
49
|
+
}
|
|
50
|
+
if (value.nonce && typeof value.counter !== "undefined") {
|
|
51
|
+
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionNonceAndCounter, "Nonce and counter properties are set.");
|
|
52
|
+
}
|
|
53
|
+
if (typeof value.cipher === "string") {
|
|
54
|
+
CryptoValidation_1.CryptoValidation.checkSerializedBuffer(value.cipher, this.MIN_CIPHER_BYTES, this.MAX_CIPHER_BYTES, "cipher");
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
CryptoValidation_1.CryptoValidation.checkBuffer(value.cipher, CryptoCipher_1.MIN_CIPHER_BYTES, CryptoCipher_1.MAX_CIPHER_BYTES, "cipher");
|
|
78
58
|
}
|
|
79
|
-
CryptoValidation_1.CryptoValidation.
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
CryptoValidation_1.CryptoValidation.checkEncryptionAlgorithm(value.algorithm);
|
|
60
|
+
if (value.counter) {
|
|
61
|
+
CryptoValidation_1.CryptoValidation.checkCounter(value.counter);
|
|
62
|
+
}
|
|
63
|
+
if (value.nonce) {
|
|
64
|
+
CryptoValidation_1.CryptoValidation.checkNonce(value.nonce, value.algorithm);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
static fromJSON(value) {
|
|
69
|
+
return this.fromAny(value);
|
|
82
70
|
}
|
|
83
71
|
static fromBase64(value) {
|
|
84
72
|
return this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
|
|
85
73
|
}
|
|
86
|
-
static deserialize(value) {
|
|
87
|
-
const obj = JSON.parse(value);
|
|
88
|
-
return this.fromJSON(obj);
|
|
89
|
-
}
|
|
90
74
|
};
|
|
91
75
|
CryptoCipher.MIN_CIPHER_BYTES = 2;
|
|
92
76
|
CryptoCipher.MAX_CIPHER_BYTES = 100 * 1024 * 1024;
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, ts_serval_1.validate)(),
|
|
79
|
+
(0, ts_serval_1.serialize)(),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], CryptoCipher.prototype, "algorithm", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, ts_serval_1.validate)(),
|
|
84
|
+
(0, ts_serval_1.serialize)(),
|
|
85
|
+
__metadata("design:type", CoreBuffer_1.CoreBuffer)
|
|
86
|
+
], CryptoCipher.prototype, "cipher", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
89
|
+
(0, ts_serval_1.serialize)(),
|
|
90
|
+
__metadata("design:type", Number)
|
|
91
|
+
], CryptoCipher.prototype, "counter", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
94
|
+
(0, ts_serval_1.serialize)(),
|
|
95
|
+
__metadata("design:type", CoreBuffer_1.CoreBuffer)
|
|
96
|
+
], CryptoCipher.prototype, "nonce", void 0);
|
|
93
97
|
CryptoCipher = CryptoCipher_1 = __decorate([
|
|
94
|
-
(0, ts_serval_1.type)("CryptoCipher")
|
|
95
|
-
__metadata("design:paramtypes", [CoreBuffer_1.CoreBuffer, Number, CoreBuffer_1.CoreBuffer, Number])
|
|
98
|
+
(0, ts_serval_1.type)("CryptoCipher")
|
|
96
99
|
], CryptoCipher);
|
|
97
100
|
exports.CryptoCipher = CryptoCipher;
|
|
98
101
|
//# sourceMappingURL=CryptoCipher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoCipher.js","sourceRoot":"","sources":["../../src/encryption/CryptoCipher.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CryptoCipher.js","sourceRoot":"","sources":["../../src/encryption/CryptoCipher.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAA2F;AAC3F,8CAAoE;AACpE,gDAA6C;AAC7C,wDAAqD;AACrD,8DAA2D;AAC3D,0DAAuD;AAkBvD,IAAa,YAAY,oBAAzB,MAAa,YAAa,SAAQ,uCAAkB;IAoBhC,MAAM,CAAC,OAAO,GAAG,IAAI;QACjC,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;YAC9B,GAAG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jB,YAAY;IADxB,IAAA,gBAAI,EAAC,cAAc,CAAC;GACR,YAAY,CA2FxB;AA3FY,oCAAY"}
|
|
@@ -24,8 +24,7 @@ class CryptoEncryption {
|
|
|
24
24
|
default:
|
|
25
25
|
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.NotYetImplemented);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
return secretKey;
|
|
27
|
+
return CryptoSecretKey_1.CryptoSecretKey.from({ secretKey: buffer, algorithm });
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Encrypts a given plaintext [[CoreBuffer]] object with the given secretKey. If a nonce is set,
|
|
@@ -38,11 +37,9 @@ class CryptoEncryption {
|
|
|
38
37
|
* @param algorithm
|
|
39
38
|
*/
|
|
40
39
|
static async encrypt(plaintext, secretKey, nonce, algorithm = 3 /* XCHACHA20_POLY1305 */) {
|
|
41
|
-
CryptoValidation_1.CryptoValidation.checkPlaintext(plaintext);
|
|
42
40
|
let correctAlgorithm;
|
|
43
41
|
let secretKeyBuffer;
|
|
44
42
|
if (secretKey instanceof CryptoSecretKey_1.CryptoSecretKey) {
|
|
45
|
-
CryptoValidation_1.CryptoValidation.checkSecretKey(secretKey);
|
|
46
43
|
correctAlgorithm = secretKey.algorithm;
|
|
47
44
|
secretKeyBuffer = secretKey.secretKey.buffer;
|
|
48
45
|
}
|
|
@@ -64,26 +61,29 @@ class CryptoEncryption {
|
|
|
64
61
|
else {
|
|
65
62
|
publicnonce = sodium.randombytes_buf(24);
|
|
66
63
|
}
|
|
67
|
-
let
|
|
64
|
+
let cipher;
|
|
68
65
|
switch (correctAlgorithm) {
|
|
69
66
|
case 3 /* XCHACHA20_POLY1305 */:
|
|
70
67
|
try {
|
|
71
|
-
|
|
72
|
-
cipherbuffer = new CoreBuffer_1.CoreBuffer(cipher);
|
|
73
|
-
return new CryptoCipher_1.CryptoCipher(cipherbuffer, correctAlgorithm, new CoreBuffer_1.CoreBuffer(publicnonce));
|
|
68
|
+
cipher = sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(plaintext.buffer, "", new Uint8Array(), publicnonce, secretKeyBuffer);
|
|
74
69
|
}
|
|
75
70
|
catch (e) {
|
|
76
71
|
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionEncrypt, `${e}`);
|
|
77
72
|
}
|
|
73
|
+
break;
|
|
78
74
|
default:
|
|
79
75
|
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.NotYetImplemented);
|
|
80
76
|
}
|
|
77
|
+
return CryptoCipher_1.CryptoCipher.from({
|
|
78
|
+
cipher: CoreBuffer_1.CoreBuffer.from(cipher),
|
|
79
|
+
algorithm: correctAlgorithm,
|
|
80
|
+
nonce: CoreBuffer_1.CoreBuffer.from(publicnonce)
|
|
81
|
+
});
|
|
81
82
|
}
|
|
82
83
|
static async encryptWithCounter(plaintext, secretKey, nonce, counter, algorithm = 3 /* XCHACHA20_POLY1305 */) {
|
|
83
84
|
let correctAlgorithm;
|
|
84
85
|
let secretKeyBuffer;
|
|
85
86
|
if (secretKey instanceof CryptoSecretKey_1.CryptoSecretKey) {
|
|
86
|
-
CryptoValidation_1.CryptoValidation.checkSecretKey(secretKey);
|
|
87
87
|
correctAlgorithm = secretKey.algorithm;
|
|
88
88
|
secretKeyBuffer = secretKey.secretKey.buffer;
|
|
89
89
|
}
|
|
@@ -104,7 +104,7 @@ class CryptoEncryption {
|
|
|
104
104
|
try {
|
|
105
105
|
const cipher = (await SodiumWrapper_1.SodiumWrapper.ready()).crypto_aead_xchacha20poly1305_ietf_encrypt(plaintext.buffer, "", new Uint8Array(), publicnonce.buffer, secretKeyBuffer);
|
|
106
106
|
cipherbuffer = new CoreBuffer_1.CoreBuffer(cipher);
|
|
107
|
-
return
|
|
107
|
+
return CryptoCipher_1.CryptoCipher.from({ cipher: cipherbuffer, algorithm, counter });
|
|
108
108
|
}
|
|
109
109
|
catch (e) {
|
|
110
110
|
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.EncryptionEncrypt, `${e}`);
|
|
@@ -114,11 +114,9 @@ class CryptoEncryption {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
static async decrypt(cipher, secretKey, nonce, algorithm = 3 /* XCHACHA20_POLY1305 */) {
|
|
117
|
-
CryptoValidation_1.CryptoValidation.checkCipher(cipher);
|
|
118
117
|
let correctAlgorithm;
|
|
119
118
|
let secretKeyBuffer;
|
|
120
119
|
if (secretKey instanceof CryptoSecretKey_1.CryptoSecretKey) {
|
|
121
|
-
CryptoValidation_1.CryptoValidation.checkSecretKey(secretKey);
|
|
122
120
|
correctAlgorithm = secretKey.algorithm;
|
|
123
121
|
secretKeyBuffer = secretKey.secretKey.buffer;
|
|
124
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoEncryption.js","sourceRoot":"","sources":["../../src/encryption/CryptoEncryption.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,gDAA6C;AAC7C,wDAAqD;AACrD,0DAAuD;AACvD,oDAAiD;AACjD,iDAA8C;AAC9C,uDAAoD;AAwBpD,MAAsB,gBAAgB;IAC3B,MAAM,CAAC,KAAK,CAAC,WAAW,CAC3B,sCAAmF;QAEnF,mCAAgB,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QAErD,IAAI,MAAkB,CAAC;QACvB,QAAQ,SAAS,EAAE;YACf;gBACI,IAAI;oBACA,MAAM,GAAG,IAAI,uBAAU,CAAC,CAAC,MAAM,6BAAa,CAAC,KAAK,EAAE,CAAC,CAAC,yCAAyC,EAAE,CAAC,CAAC;iBACtG;gBAAC,OAAO,CAAC,EAAE;oBACR,MAAM,IAAI,yBAAW,CAAC,iCAAe,CAAC,uBAAuB,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;iBAC1E;gBAED,MAAM;YACV;gBACI,MAAM,IAAI,yBAAW,CAAC,iCAAe,CAAC,iBAAiB,CAAC,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AgB,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QAErD,IAAI,WAAW,CAAC;QAChB,QAAQ,SAAS,EAAE;YACf,wBAA0C;YAC1C;gBACI,WAAW,GAAG,EAAE,CAAC;gBACjB,MAAM;YACV;gBACI,WAAW,GAAG,EAAE,CAAC;gBACjB,MAAM;YACV;gBACI,MAAM,IAAI,yBAAW,CACjB,iCAAe,CAAC,wBAAwB,EACxC,wCAAwC,CAC3C,CAAC;SACT;QACD,OAAO,uBAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,WAAW,CAAC,KAA8B,EAAE,OAAe;QACtE,IAAI,MAAM,CAAC;QACX,IAAI,KAAK,YAAY,UAAU,EAAE;YAC7B,MAAM,GAAG,IAAI,uBAAU,CAAC,KAAK,CAAC,CAAC;SAClC;aAAM,IAAI,KAAK,YAAY,uBAAU,EAAE;YACpC,MAAM,GAAG,KAAK,CAAC;SAClB;aAAM;YACH,MAAM,IAAI,yBAAW,CAAC,iCAAe,CAAC,oBAAoB,CAAC,CAAC;SAC/D;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE1C,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAhRD,4CAgRC"}
|
|
@@ -11,13 +11,12 @@ export interface ICryptoSecretKey extends ISerializable {
|
|
|
11
11
|
secretKey: ICoreBuffer;
|
|
12
12
|
}
|
|
13
13
|
export declare class CryptoSecretKey extends CryptoSerializable implements ICryptoSecretKey, IClearable {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(secretKey: CoreBuffer, algorithm?: CryptoEncryptionAlgorithm);
|
|
14
|
+
algorithm: CryptoEncryptionAlgorithm;
|
|
15
|
+
secretKey: CoreBuffer;
|
|
17
16
|
toJSON(verbose?: boolean): ICryptoSecretKeySerialized;
|
|
18
17
|
clear(): void;
|
|
19
18
|
static from(value: CryptoSecretKey | ICryptoSecretKey): CryptoSecretKey;
|
|
19
|
+
protected static preFrom(value: any): any;
|
|
20
20
|
static fromJSON(value: ICryptoSecretKeySerialized): CryptoSecretKey;
|
|
21
21
|
static fromBase64(value: string): CryptoSecretKey;
|
|
22
|
-
static deserialize(value: string): CryptoSecretKey;
|
|
23
22
|
}
|
|
@@ -8,57 +8,61 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var CryptoSecretKey_1;
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
exports.CryptoSecretKey = void 0;
|
|
14
13
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
15
14
|
const CoreBuffer_1 = require("../CoreBuffer");
|
|
16
15
|
const CryptoSerializable_1 = require("../CryptoSerializable");
|
|
17
16
|
const CryptoValidation_1 = require("../CryptoValidation");
|
|
18
|
-
let CryptoSecretKey =
|
|
19
|
-
constructor(secretKey, algorithm = 3 /* XCHACHA20_POLY1305 */) {
|
|
20
|
-
CryptoValidation_1.CryptoValidation.checkEncryptionAlgorithm(algorithm);
|
|
21
|
-
CryptoValidation_1.CryptoValidation.checkSecretKeyForAlgorithm(secretKey, algorithm);
|
|
22
|
-
super();
|
|
23
|
-
this.algorithm = algorithm;
|
|
24
|
-
this.secretKey = secretKey;
|
|
25
|
-
}
|
|
17
|
+
let CryptoSecretKey = class CryptoSecretKey extends CryptoSerializable_1.CryptoSerializable {
|
|
26
18
|
toJSON(verbose = true) {
|
|
27
|
-
|
|
19
|
+
return {
|
|
28
20
|
key: this.secretKey.toBase64URL(),
|
|
29
|
-
alg: this.algorithm
|
|
21
|
+
alg: this.algorithm,
|
|
22
|
+
"@type": verbose ? "CryptoSecretKey" : undefined
|
|
30
23
|
};
|
|
31
|
-
if (verbose) {
|
|
32
|
-
obj["@type"] = "CryptoSecretKey";
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
35
24
|
}
|
|
36
25
|
clear() {
|
|
37
26
|
this.secretKey.clear();
|
|
38
27
|
}
|
|
39
28
|
static from(value) {
|
|
40
|
-
return
|
|
29
|
+
return this.fromAny(value);
|
|
30
|
+
}
|
|
31
|
+
static preFrom(value) {
|
|
32
|
+
if (value.alg) {
|
|
33
|
+
value = {
|
|
34
|
+
algorithm: value.alg,
|
|
35
|
+
secretKey: value.key
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
CryptoValidation_1.CryptoValidation.checkEncryptionAlgorithm(value.algorithm);
|
|
39
|
+
if (typeof value.secretKey === "string") {
|
|
40
|
+
CryptoValidation_1.CryptoValidation.checkSerializedSecretKeyForAlgorithm(value.secretKey, value.algorithm);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
CryptoValidation_1.CryptoValidation.checkSecretKeyForAlgorithm(value.secretKey, value.algorithm);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
41
46
|
}
|
|
42
47
|
static fromJSON(value) {
|
|
43
|
-
|
|
44
|
-
CryptoValidation_1.CryptoValidation.checkSerializedSecretKeyForAlgorithm(value.key, value.alg);
|
|
45
|
-
const buffer = CoreBuffer_1.CoreBuffer.fromBase64URL(value.key);
|
|
46
|
-
return this.from({
|
|
47
|
-
algorithm: value.alg,
|
|
48
|
-
secretKey: buffer
|
|
49
|
-
});
|
|
48
|
+
return this.fromAny(value);
|
|
50
49
|
}
|
|
51
50
|
static fromBase64(value) {
|
|
52
51
|
return this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
|
|
53
52
|
}
|
|
54
|
-
static deserialize(value) {
|
|
55
|
-
const obj = JSON.parse(value);
|
|
56
|
-
return this.fromJSON(obj);
|
|
57
|
-
}
|
|
58
53
|
};
|
|
59
|
-
|
|
60
|
-
(0, ts_serval_1.
|
|
61
|
-
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, ts_serval_1.validate)(),
|
|
56
|
+
(0, ts_serval_1.serialize)(),
|
|
57
|
+
__metadata("design:type", Number)
|
|
58
|
+
], CryptoSecretKey.prototype, "algorithm", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, ts_serval_1.validate)(),
|
|
61
|
+
(0, ts_serval_1.serialize)(),
|
|
62
|
+
__metadata("design:type", CoreBuffer_1.CoreBuffer)
|
|
63
|
+
], CryptoSecretKey.prototype, "secretKey", void 0);
|
|
64
|
+
CryptoSecretKey = __decorate([
|
|
65
|
+
(0, ts_serval_1.type)("CryptoSecretKey")
|
|
62
66
|
], CryptoSecretKey);
|
|
63
67
|
exports.CryptoSecretKey = CryptoSecretKey;
|
|
64
68
|
//# sourceMappingURL=CryptoSecretKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoSecretKey.js","sourceRoot":"","sources":["../../src/encryption/CryptoSecretKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CryptoSecretKey.js","sourceRoot":"","sources":["../../src/encryption/CryptoSecretKey.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,8CAAoE;AACpE,8DAA2D;AAC3D,0DAAuD;AAcvD,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,uCAAkB;IAQnC,MAAM,CAAC,OAAO,GAAG,IAAI;QACjC,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACjC,GAAG,EAAE,IAAI,CAAC,SAAS;YACnB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;SACnD,CAAC;IACN,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,KAAyC;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAES,MAAM,CAAU,OAAO,CAAC,KAAU;QACxC,IAAI,KAAK,CAAC,GAAG,EAAE;YACX,KAAK,GAAG;gBACJ,SAAS,EAAE,KAAK,CAAC,GAAG;gBACpB,SAAS,EAAE,KAAK,CAAC,GAAG;aACvB,CAAC;SACL;QAED,mCAAgB,CAAC,wBAAwB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE3D,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,EAAE;YACrC,mCAAgB,CAAC,oCAAoC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;SAC3F;aAAM;YACH,mCAAgB,CAAC,0BAA0B,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;SACjF;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,KAAiC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AA/CG;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;;kDACgC;AAG5C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACM,uBAAU;kDAAC;AANpB,eAAe;IAD3B,IAAA,gBAAI,EAAC,iBAAiB,CAAC;GACX,eAAe,CAkD3B;AAlDY,0CAAe"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CryptoEncryptionAlgorithm } from "../encryption/CryptoEncryption";
|
|
2
2
|
import { CryptoExchangeKeypair } from "./CryptoExchangeKeypair";
|
|
3
|
-
import { CryptoExchangePrivateKey } from "./CryptoExchangePrivateKey";
|
|
4
3
|
import { CryptoExchangePublicKey } from "./CryptoExchangePublicKey";
|
|
5
4
|
import { CryptoExchangeSecrets } from "./CryptoExchangeSecrets";
|
|
6
5
|
export declare const enum CryptoExchangeAlgorithm {
|
|
@@ -9,7 +8,6 @@ export declare const enum CryptoExchangeAlgorithm {
|
|
|
9
8
|
ECDH_X25519 = 3
|
|
10
9
|
}
|
|
11
10
|
export declare class CryptoExchange {
|
|
12
|
-
static privateKeyToPublicKey(privateKey: CryptoExchangePrivateKey): Promise<CryptoExchangePublicKey>;
|
|
13
11
|
/**
|
|
14
12
|
* Generates a keypair for the specified key exchange algorithm
|
|
15
13
|
*
|
|
@@ -10,23 +10,6 @@ const CryptoExchangePrivateKey_1 = require("./CryptoExchangePrivateKey");
|
|
|
10
10
|
const CryptoExchangePublicKey_1 = require("./CryptoExchangePublicKey");
|
|
11
11
|
const CryptoExchangeSecrets_1 = require("./CryptoExchangeSecrets");
|
|
12
12
|
class CryptoExchange {
|
|
13
|
-
static async privateKeyToPublicKey(privateKey) {
|
|
14
|
-
switch (privateKey.algorithm) {
|
|
15
|
-
case 3 /* ECDH_X25519 */:
|
|
16
|
-
try {
|
|
17
|
-
const publicKey = (await SodiumWrapper_1.SodiumWrapper.ready()).crypto_scalarmult_base(privateKey.privateKey.buffer);
|
|
18
|
-
return CryptoExchangePublicKey_1.CryptoExchangePublicKey.from({
|
|
19
|
-
algorithm: privateKey.algorithm,
|
|
20
|
-
publicKey: CoreBuffer_1.CoreBuffer.from(publicKey)
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.ExchangeKeyGeneration, `${e}`);
|
|
25
|
-
}
|
|
26
|
-
default:
|
|
27
|
-
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.NotYetImplemented);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
13
|
/**
|
|
31
14
|
* Generates a keypair for the specified key exchange algorithm
|
|
32
15
|
*
|
|
@@ -51,9 +34,9 @@ class CryptoExchange {
|
|
|
51
34
|
default:
|
|
52
35
|
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.NotYetImplemented);
|
|
53
36
|
}
|
|
54
|
-
const privateKey =
|
|
55
|
-
const publicKey =
|
|
56
|
-
const keypair =
|
|
37
|
+
const privateKey = CryptoExchangePrivateKey_1.CryptoExchangePrivateKey.from({ algorithm, privateKey: CoreBuffer_1.CoreBuffer.from(privateKeyBuffer) });
|
|
38
|
+
const publicKey = CryptoExchangePublicKey_1.CryptoExchangePublicKey.from({ algorithm, publicKey: CoreBuffer_1.CoreBuffer.from(publicKeyBuffer) });
|
|
39
|
+
const keypair = CryptoExchangeKeypair_1.CryptoExchangeKeypair.from({ publicKey, privateKey });
|
|
57
40
|
return keypair;
|
|
58
41
|
}
|
|
59
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoExchange.js","sourceRoot":"","sources":["../../src/exchange/CryptoExchange.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,gDAA6C;AAC7C,wDAAqD;AAErD,oDAAiD;AACjD,mEAAgE;AAChE,yEAAsE;AACtE,uEAAoE;AACpE,mEAAgE;AAWhE,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"CryptoExchange.js","sourceRoot":"","sources":["../../src/exchange/CryptoExchange.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,gDAA6C;AAC7C,wDAAqD;AAErD,oDAAiD;AACjD,mEAAgE;AAChE,yEAAsE;AACtE,uEAAoE;AACpE,mEAAgE;AAWhE,MAAa,cAAc;IACvB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,eAAe,CAC/B,+BAAwE;QAExE,IAAI,gBAAgB,CAAC;QACrB,IAAI,eAAe,CAAC;QAEpB,QAAQ,SAAmB,EAAE;YACzB;gBACI,IAAI,IAAI,CAAC;gBACT,IAAI;oB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class CryptoExchangeKeypair extends CryptoSerializable implements ICryptoExchangeKeypair, IClearable {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
constructor(publicKey: CryptoExchangePublicKey, privateKey: CryptoExchangePrivateKey);
|
|
15
|
+
publicKey: CryptoExchangePublicKey;
|
|
16
|
+
privateKey: CryptoExchangePrivateKey;
|
|
18
17
|
toJSON(verbose?: boolean): ICryptoExchangeKeypairSerialized;
|
|
19
18
|
clear(): void;
|
|
19
|
+
protected static preFrom(value: any): any;
|
|
20
20
|
static from(value: CryptoExchangeKeypair | ICryptoExchangeKeypair): CryptoExchangeKeypair;
|
|
21
21
|
static fromJSON(value: ICryptoExchangeKeypairSerialized): CryptoExchangeKeypair;
|
|
22
22
|
static fromBase64(value: string): CryptoExchangeKeypair;
|
|
23
|
-
static deserialize(value: string): CryptoExchangeKeypair;
|
|
24
23
|
}
|
|
@@ -8,22 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var CryptoExchangeKeypair_1;
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
exports.CryptoExchangeKeypair = void 0;
|
|
14
13
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
15
14
|
const CoreBuffer_1 = require("../CoreBuffer");
|
|
15
|
+
const CryptoError_1 = require("../CryptoError");
|
|
16
|
+
const CryptoErrorCode_1 = require("../CryptoErrorCode");
|
|
16
17
|
const CryptoSerializable_1 = require("../CryptoSerializable");
|
|
17
18
|
const CryptoExchangePrivateKey_1 = require("./CryptoExchangePrivateKey");
|
|
18
19
|
const CryptoExchangePublicKey_1 = require("./CryptoExchangePublicKey");
|
|
19
|
-
|
|
20
|
-
let CryptoExchangeKeypair = CryptoExchangeKeypair_1 = class CryptoExchangeKeypair extends CryptoSerializable_1.CryptoSerializable {
|
|
21
|
-
constructor(publicKey, privateKey) {
|
|
22
|
-
CryptoExchangeValidation_1.CryptoExchangeValidation.checkExchangeKeypair(privateKey, publicKey);
|
|
23
|
-
super();
|
|
24
|
-
this.publicKey = publicKey;
|
|
25
|
-
this.privateKey = privateKey;
|
|
26
|
-
}
|
|
20
|
+
let CryptoExchangeKeypair = class CryptoExchangeKeypair extends CryptoSerializable_1.CryptoSerializable {
|
|
27
21
|
toJSON(verbose = true) {
|
|
28
22
|
const obj = {
|
|
29
23
|
pub: this.publicKey.toJSON(false),
|
|
@@ -38,27 +32,40 @@ let CryptoExchangeKeypair = CryptoExchangeKeypair_1 = class CryptoExchangeKeypai
|
|
|
38
32
|
this.publicKey.clear();
|
|
39
33
|
this.privateKey.clear();
|
|
40
34
|
}
|
|
35
|
+
static preFrom(value) {
|
|
36
|
+
if (value.pub) {
|
|
37
|
+
value = {
|
|
38
|
+
publicKey: value.pub,
|
|
39
|
+
privateKey: value.prv
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (value.privateKey.algorithm !== value.publicKey.algorithm) {
|
|
43
|
+
throw new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.ExchangeWrongAlgorithm, "Algorithms of private and public key do not match.");
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
41
47
|
static from(value) {
|
|
42
|
-
|
|
43
|
-
const publicKey = CryptoExchangePublicKey_1.CryptoExchangePublicKey.from(value.publicKey);
|
|
44
|
-
return new CryptoExchangeKeypair_1(publicKey, privateKey);
|
|
48
|
+
return this.fromAny(value);
|
|
45
49
|
}
|
|
46
50
|
static fromJSON(value) {
|
|
47
|
-
|
|
48
|
-
const publicKey = CryptoExchangePublicKey_1.CryptoExchangePublicKey.fromJSON(value.pub);
|
|
49
|
-
return new CryptoExchangeKeypair_1(publicKey, privateKey);
|
|
51
|
+
return this.fromAny(value);
|
|
50
52
|
}
|
|
51
53
|
static fromBase64(value) {
|
|
52
54
|
return this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
|
|
53
55
|
}
|
|
54
|
-
static deserialize(value) {
|
|
55
|
-
const obj = JSON.parse(value);
|
|
56
|
-
return this.fromJSON(obj);
|
|
57
|
-
}
|
|
58
56
|
};
|
|
59
|
-
|
|
60
|
-
(0, ts_serval_1.
|
|
61
|
-
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, ts_serval_1.validate)(),
|
|
59
|
+
(0, ts_serval_1.serialize)(),
|
|
60
|
+
__metadata("design:type", CryptoExchangePublicKey_1.CryptoExchangePublicKey)
|
|
61
|
+
], CryptoExchangeKeypair.prototype, "publicKey", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, ts_serval_1.validate)(),
|
|
64
|
+
(0, ts_serval_1.serialize)(),
|
|
65
|
+
__metadata("design:type", CryptoExchangePrivateKey_1.CryptoExchangePrivateKey)
|
|
66
|
+
], CryptoExchangeKeypair.prototype, "privateKey", void 0);
|
|
67
|
+
CryptoExchangeKeypair = __decorate([
|
|
68
|
+
(0, ts_serval_1.type)("CryptoExchangeKeypair")
|
|
62
69
|
], CryptoExchangeKeypair);
|
|
63
70
|
exports.CryptoExchangeKeypair = CryptoExchangeKeypair;
|
|
64
71
|
//# sourceMappingURL=CryptoExchangeKeypair.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoExchangeKeypair.js","sourceRoot":"","sources":["../../src/exchange/CryptoExchangeKeypair.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CryptoExchangeKeypair.js","sourceRoot":"","sources":["../../src/exchange/CryptoExchangeKeypair.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,8CAAuD;AACvD,gDAA6C;AAC7C,wDAAqD;AACrD,8DAA2D;AAC3D,yEAIoC;AACpC,uEAImC;AAanC,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,uCAAkB;IASzC,MAAM,C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DAAuB;wDAAC;AAI1C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACO,mDAAwB;yDAAC;AAPnC,qBAAqB;IADjC,IAAA,gBAAI,EAAC,uBAAuB,CAAC;GACjB,qBAAqB,CAuDjC;AAvDY,sDAAqB"}
|
|
@@ -12,16 +12,14 @@ export interface ICryptoExchangePrivateKey extends ISerializable {
|
|
|
12
12
|
privateKey: ICoreBuffer;
|
|
13
13
|
}
|
|
14
14
|
export declare class CryptoExchangePrivateKey extends CryptoPrivateKey implements ICryptoExchangePrivateKey, IClearable {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
constructor(algorithm: CryptoExchangeAlgorithm, privateKey: CoreBuffer);
|
|
15
|
+
algorithm: CryptoExchangeAlgorithm;
|
|
16
|
+
privateKey: CoreBuffer;
|
|
18
17
|
toJSON(verbose?: boolean): ICryptoExchangePrivateKeySerialized;
|
|
19
18
|
clear(): void;
|
|
20
|
-
serialize(verbose?: boolean): string;
|
|
21
19
|
toBase64(verbose?: boolean): string;
|
|
22
20
|
toPublicKey(): Promise<CryptoExchangePublicKey>;
|
|
23
21
|
static from(value: CryptoExchangePrivateKey | ICryptoExchangePrivateKey): CryptoExchangePrivateKey;
|
|
22
|
+
protected static preFrom(value: any): any;
|
|
24
23
|
static fromJSON(value: ICryptoExchangePrivateKeySerialized): CryptoExchangePrivateKey;
|
|
25
24
|
static fromBase64(value: string): CryptoExchangePrivateKey;
|
|
26
|
-
static deserialize(value: string): CryptoExchangePrivateKey;
|
|
27
25
|
}
|