@taquito/signer 11.2.0-beta-RC.0 → 12.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.
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Tz2 = exports.Tz3 = exports.ECKey = void 0;
13
- const libsodium_wrappers_1 = require("libsodium-wrappers");
13
+ const blake2b_1 = require("@stablelib/blake2b");
14
14
  const utils_1 = require("@taquito/utils");
15
15
  const typedarray_to_buffer_1 = require("typedarray-to-buffer");
16
16
  const elliptic_1 = require("elliptic");
@@ -86,8 +86,7 @@ class ECKey {
86
86
  */
87
87
  publicKeyHash() {
88
88
  return __awaiter(this, void 0, void 0, function* () {
89
- yield libsodium_wrappers_1.default.ready;
90
- return utils_1.b58cencode(libsodium_wrappers_1.default.crypto_generichash(20, new Uint8Array(this._publicKey)), pref[this.curve].pkh);
89
+ return utils_1.b58cencode(blake2b_1.hash(new Uint8Array(this._publicKey), 20), pref[this.curve].pkh);
91
90
  });
92
91
  }
93
92
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ec-key.js","sourceRoot":"","sources":["../../src/ec-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAwC;AACxC,0CAA+E;AAC/E,+DAA4C;AAC5C,uCAAgC;AAEhC,MAAM,IAAI,GAAG;IACX,IAAI,EAAE;QACJ,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE,cAAM,CAAC,GAAG;QACf,GAAG,EAAE,cAAM,CAAC,KAAK;KAClB;IACD,SAAS,EAAE;QACT,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE,cAAM,CAAC,GAAG;QACf,GAAG,EA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AAK,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAE5C;;GAEG;AACU,QAAA,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC"}
@@ -10,7 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Tz1 = void 0;
13
- const libsodium_wrappers_1 = require("libsodium-wrappers");
13
+ const blake2b_1 = require("@stablelib/blake2b");
14
+ const ed25519_1 = require("@stablelib/ed25519");
14
15
  const utils_1 = require("@taquito/utils");
15
16
  const typedarray_to_buffer_1 = require("typedarray-to-buffer");
16
17
  /**
@@ -38,11 +39,10 @@ class Tz1 {
38
39
  }
39
40
  init() {
40
41
  return __awaiter(this, void 0, void 0, function* () {
41
- yield libsodium_wrappers_1.default.ready;
42
42
  if (this._key.length !== 64) {
43
- const { publicKey, privateKey } = libsodium_wrappers_1.default.crypto_sign_seed_keypair(new Uint8Array(this._key), 'uint8array');
43
+ const { publicKey, secretKey } = ed25519_1.generateKeyPairFromSeed(new Uint8Array(this._key));
44
44
  this._publicKey = publicKey;
45
- this._key = privateKey;
45
+ this._key = secretKey;
46
46
  }
47
47
  return true;
48
48
  });
@@ -55,7 +55,7 @@ class Tz1 {
55
55
  sign(bytes, bytesHash) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
57
  yield this.isInit;
58
- const signature = libsodium_wrappers_1.default.crypto_sign_detached(new Uint8Array(bytesHash), new Uint8Array(this._key));
58
+ const signature = ed25519_1.sign(new Uint8Array(this._key), new Uint8Array(bytesHash));
59
59
  const signatureBuffer = typedarray_to_buffer_1.default(signature);
60
60
  const sbytes = bytes + utils_1.buf2hex(signatureBuffer);
61
61
  return {
@@ -81,8 +81,7 @@ class Tz1 {
81
81
  publicKeyHash() {
82
82
  return __awaiter(this, void 0, void 0, function* () {
83
83
  yield this.isInit;
84
- yield libsodium_wrappers_1.default.ready;
85
- return utils_1.b58cencode(libsodium_wrappers_1.default.crypto_generichash(20, new Uint8Array(this._publicKey)), utils_1.prefix.tz1);
84
+ return utils_1.b58cencode(blake2b_1.hash(new Uint8Array(this._publicKey), 20), utils_1.prefix.tz1);
86
85
  });
87
86
  }
88
87
  /**
@@ -91,10 +90,9 @@ class Tz1 {
91
90
  secretKey() {
92
91
  return __awaiter(this, void 0, void 0, function* () {
93
92
  yield this.isInit;
94
- yield libsodium_wrappers_1.default.ready;
95
93
  let key = this._key;
96
- const { privateKey } = libsodium_wrappers_1.default.crypto_sign_seed_keypair(new Uint8Array(key).slice(0, 32), 'uint8array');
97
- key = typedarray_to_buffer_1.default(privateKey);
94
+ const { secretKey } = ed25519_1.generateKeyPairFromSeed(new Uint8Array(key).slice(0, 32));
95
+ key = typedarray_to_buffer_1.default(secretKey);
98
96
  return utils_1.b58cencode(key, utils_1.prefix[`edsk`]);
99
97
  });
100
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ed-key.js","sourceRoot":"","sources":["../../src/ed-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAwC;AACxC,0CAAwF;AACxF,+DAA4C;AAE5C;;GAEG;AACH,MAAa,GAAG;IAKd;;;;;OAKG;IACH,YAAoB,GAAW,EAAE,SAAkB,EAAE,OAAwB;QAAzD,QAAG,GAAH,GAAG,CAAQ;QAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,qBAAa,CAAC,SAAS,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,kBAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,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M,CAAC,GAAG,CAAC;gBACtC,SAAS,EAAE,kBAAU,CAAC,SAAS,EAAE,cAAM,CAAC,KAAK,CAAC;gBAC9C,MAAM;aACP,CAAC;QACJ,CAAC;KAAA;IAED;;OAEG;IACG,SAAS;;YACb,MAAM,IAAI,CAAC,MAAM,CAAC;YAClB,OAAO,kBAAU,CAAC,IAAI,CAAC,UAAU,EAAE,cAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;KAAA;IAED;;OAEG;IACG,aAAa;;YACjB,MAAM,IAAI,CAAC,MAAM,CAAC;YAClB,OAAO,kBAAU,CAAC,cAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,EAAE,cAAM,CAAC,GAAG,CAAC,CAAC;QAC3E,CAAC;KAAA;IAED;;OAEG;IACG,SAAS;;YACb,MAAM,IAAI,CAAC,MAAM,CAAC;YAClB,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YACpB,MAAM,EAAE,SAAS,EAAE,GAAG,iCAAuB,CAC3C,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CACjC,CAAC;YACF,GAAG,GAAG,8BAAQ,CAAC,SAAS,CAAC,CAAC;YAE1B,OAAO,kBAAU,CAAC,GAAG,EAAE,cAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KAAA;CACF;AAvFD,kBAuFC"}
@@ -24,7 +24,8 @@ exports.InMemorySigner = exports.VERSION = void 0;
24
24
  * @packageDocumentation
25
25
  * @module @taquito/signer
26
26
  */
27
- const libsodium_wrappers_1 = require("libsodium-wrappers");
27
+ const nacl_1 = require("@stablelib/nacl");
28
+ const blake2b_1 = require("@stablelib/blake2b");
28
29
  const utils_1 = require("@taquito/utils");
29
30
  const typedarray_to_buffer_1 = require("typedarray-to-buffer");
30
31
  const ed_key_1 = require("./ed-key");
@@ -39,13 +40,6 @@ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () {
39
40
  *
40
41
  * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
41
42
  *
42
- * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.
43
- *
44
- * Consider doing:
45
- *
46
- * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```
47
- *
48
- * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')
49
43
  */
50
44
  class InMemorySigner {
51
45
  /**
@@ -65,7 +59,7 @@ class InMemorySigner {
65
59
  const salt = typedarray_to_buffer_1.default(constructedKey.slice(0, 8));
66
60
  const encryptedSk = constructedKey.slice(8);
67
61
  const encryptionKey = pbkdf2_1.default.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');
68
- return libsodium_wrappers_1.default.crypto_secretbox_open_easy(new Uint8Array(encryptedSk), new Uint8Array(24), new Uint8Array(encryptionKey));
62
+ return nacl_1.openSecretBox(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
69
63
  };
70
64
  }
71
65
  switch (key.substr(0, 4)) {
@@ -92,7 +86,6 @@ class InMemorySigner {
92
86
  }
93
87
  static fromSecretKey(key, passphrase) {
94
88
  return __awaiter(this, void 0, void 0, function* () {
95
- yield libsodium_wrappers_1.default.ready;
96
89
  return new InMemorySigner(key, passphrase);
97
90
  });
98
91
  }
@@ -107,9 +100,7 @@ class InMemorySigner {
107
100
  if (typeof watermark !== 'undefined') {
108
101
  bb = utils_1.mergebuf(watermark, bb);
109
102
  }
110
- // Ensure sodium is ready before calling crypto_generichash otherwise the function do not exists
111
- yield libsodium_wrappers_1.default.ready;
112
- const bytesHash = typedarray_to_buffer_1.default(libsodium_wrappers_1.default.crypto_generichash(32, bb));
103
+ const bytesHash = blake2b_1.hash(bb, 32);
113
104
  return this._key.sign(bytes, bytesHash);
114
105
  });
115
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-signer.js","sourceRo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AE,EAAE,CAAC,EAAE,cAAM,CAAC,KAAK,CAAC,CAAC;QACxD,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAO,aAAa,CAAC,GAAW,EAAE,UAAmB;;YACzD,OAAO,IAAI,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC7C,CAAC;KAAA;IAiDD;;;;OAIG;IACG,IAAI,CAAC,KAAa,EAAE,SAAsB;;YAC9C,IAAI,EAAE,GAAG,eAAO,CAAC,KAAK,CAAC,CAAC;YACxB,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;gBACpC,EAAE,GAAG,gBAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;aAC9B;YAED,MAAM,SAAS,GAAG,cAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;KAAA;IAED;;OAEG;IACG,SAAS;;YACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,CAAC;KAAA;IAED;;OAEG;IACG,aAAa;;YACjB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC;KAAA;IAED;;OAEG;IACG,SAAS;;YACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,CAAC;KAAA;CACF;AAhGD,wCAgGC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
7
- "version": "11.2.0-beta-RC.0"
6
+ "commitHash": "222db56e9550fff784a819406d8bdc1110787440",
7
+ "version": "12.0.0"
8
8
  };
9
9
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,kBAAkB;CAChC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AACA,2EAA2E;AAC9D,QAAA,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;CACtB,CAAC"}
@@ -1,6 +1,8 @@
1
- import sodium from 'libsodium-wrappers';
1
+ import { openSecretBox } from '@stablelib/nacl';
2
+ import { hash } from '@stablelib/blake2b';
2
3
  import { isValidPrefix, b58cdecode, prefix, buf2hex, b58cencode, hex2buf, mergebuf } from '@taquito/utils';
3
4
  import toBuffer from 'typedarray-to-buffer';
5
+ import { generateKeyPairFromSeed, sign } from '@stablelib/ed25519';
4
6
  import elliptic from 'elliptic';
5
7
  import pbkdf2 from 'pbkdf2';
6
8
 
@@ -54,11 +56,10 @@ class Tz1 {
54
56
  }
55
57
  init() {
56
58
  return __awaiter(this, void 0, void 0, function* () {
57
- yield sodium.ready;
58
59
  if (this._key.length !== 64) {
59
- const { publicKey, privateKey } = sodium.crypto_sign_seed_keypair(new Uint8Array(this._key), 'uint8array');
60
+ const { publicKey, secretKey } = generateKeyPairFromSeed(new Uint8Array(this._key));
60
61
  this._publicKey = publicKey;
61
- this._key = privateKey;
62
+ this._key = secretKey;
62
63
  }
63
64
  return true;
64
65
  });
@@ -71,7 +72,7 @@ class Tz1 {
71
72
  sign(bytes, bytesHash) {
72
73
  return __awaiter(this, void 0, void 0, function* () {
73
74
  yield this.isInit;
74
- const signature = sodium.crypto_sign_detached(new Uint8Array(bytesHash), new Uint8Array(this._key));
75
+ const signature = sign(new Uint8Array(this._key), new Uint8Array(bytesHash));
75
76
  const signatureBuffer = toBuffer(signature);
76
77
  const sbytes = bytes + buf2hex(signatureBuffer);
77
78
  return {
@@ -97,8 +98,7 @@ class Tz1 {
97
98
  publicKeyHash() {
98
99
  return __awaiter(this, void 0, void 0, function* () {
99
100
  yield this.isInit;
100
- yield sodium.ready;
101
- return b58cencode(sodium.crypto_generichash(20, new Uint8Array(this._publicKey)), prefix.tz1);
101
+ return b58cencode(hash(new Uint8Array(this._publicKey), 20), prefix.tz1);
102
102
  });
103
103
  }
104
104
  /**
@@ -107,10 +107,9 @@ class Tz1 {
107
107
  secretKey() {
108
108
  return __awaiter(this, void 0, void 0, function* () {
109
109
  yield this.isInit;
110
- yield sodium.ready;
111
110
  let key = this._key;
112
- const { privateKey } = sodium.crypto_sign_seed_keypair(new Uint8Array(key).slice(0, 32), 'uint8array');
113
- key = toBuffer(privateKey);
111
+ const { secretKey } = generateKeyPairFromSeed(new Uint8Array(key).slice(0, 32));
112
+ key = toBuffer(secretKey);
114
113
  return b58cencode(key, prefix[`edsk`]);
115
114
  });
116
115
  }
@@ -188,8 +187,7 @@ class ECKey {
188
187
  */
189
188
  publicKeyHash() {
190
189
  return __awaiter(this, void 0, void 0, function* () {
191
- yield sodium.ready;
192
- return b58cencode(sodium.crypto_generichash(20, new Uint8Array(this._publicKey)), pref[this.curve].pkh);
190
+ return b58cencode(hash(new Uint8Array(this._publicKey), 20), pref[this.curve].pkh);
193
191
  });
194
192
  }
195
193
  /**
@@ -268,8 +266,8 @@ function importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
268
266
 
269
267
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
270
268
  const VERSION = {
271
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
272
- "version": "11.2.0-beta-RC.0"
269
+ "commitHash": "222db56e9550fff784a819406d8bdc1110787440",
270
+ "version": "12.0.0"
273
271
  };
274
272
 
275
273
  /**
@@ -277,13 +275,6 @@ const VERSION = {
277
275
  *
278
276
  * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
279
277
  *
280
- * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.
281
- *
282
- * Consider doing:
283
- *
284
- * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```
285
- *
286
- * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')
287
278
  */
288
279
  class InMemorySigner {
289
280
  /**
@@ -303,7 +294,7 @@ class InMemorySigner {
303
294
  const salt = toBuffer(constructedKey.slice(0, 8));
304
295
  const encryptedSk = constructedKey.slice(8);
305
296
  const encryptionKey = pbkdf2.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');
306
- return sodium.crypto_secretbox_open_easy(new Uint8Array(encryptedSk), new Uint8Array(24), new Uint8Array(encryptionKey));
297
+ return openSecretBox(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
307
298
  };
308
299
  }
309
300
  switch (key.substr(0, 4)) {
@@ -330,7 +321,6 @@ class InMemorySigner {
330
321
  }
331
322
  static fromSecretKey(key, passphrase) {
332
323
  return __awaiter(this, void 0, void 0, function* () {
333
- yield sodium.ready;
334
324
  return new InMemorySigner(key, passphrase);
335
325
  });
336
326
  }
@@ -345,9 +335,7 @@ class InMemorySigner {
345
335
  if (typeof watermark !== 'undefined') {
346
336
  bb = mergebuf(watermark, bb);
347
337
  }
348
- // Ensure sodium is ready before calling crypto_generichash otherwise the function do not exists
349
- yield sodium.ready;
350
- const bytesHash = toBuffer(sodium.crypto_generichash(32, bb));
338
+ const bytesHash = hash(bb, 32);
351
339
  return this._key.sign(bytes, bytesHash);
352
340
  });
353
341
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-signer.es6.js","sources":["../src/ed-key.ts","../src/ec-key.ts","../src/mnemonicToSeedSync.ts","../src/import-key.ts","../src/version.ts","../src/taquito-signer.ts"],"sourcesContent":["import sodium from 'libsodium-wrappers';\nimport { b58cencode, b58cdecode, prefix, buf2hex, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\n\n/**\n * @description Provide signing logic for ed25519 curve based key (tz1)\n */\nexport class Tz1 {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n private isInit: Promise<boolean>;\n\n /**\n *\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(private key: string, encrypted: boolean, decrypt: (k: any) => any) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n this._publicKey = this._key.slice(32);\n\n if (!this._key) {\n throw new Error('Unable to decode key');\n }\n\n this.isInit = this.init();\n }\n\n private async init() {\n await sodium.ready;\n if (this._key.length !== 64) {\n const { publicKey, privateKey } = sodium.crypto_sign_seed_keypair(\n new Uint8Array(this._key),\n 'uint8array'\n );\n this._publicKey = publicKey;\n this._key = privateKey;\n }\n return true;\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n await this.isInit;\n const signature = sodium.crypto_sign_detached(\n new Uint8Array(bytesHash),\n new Uint8Array(this._key)\n );\n const signatureBuffer = toBuffer(signature);\n const sbytes = bytes + buf2hex(signatureBuffer);\n\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, prefix.edsig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n await this.isInit;\n return b58cencode(this._publicKey, prefix['edpk']);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await this.isInit;\n await sodium.ready;\n return b58cencode(sodium.crypto_generichash(20, new Uint8Array(this._publicKey)), prefix.tz1);\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n await this.isInit;\n await sodium.ready;\n let key = this._key;\n const { privateKey } = sodium.crypto_sign_seed_keypair(\n new Uint8Array(key).slice(0, 32),\n 'uint8array'\n );\n key = toBuffer(privateKey);\n\n return b58cencode(key, prefix[`edsk`]);\n }\n}\n","import sodium from 'libsodium-wrappers';\nimport { b58cencode, b58cdecode, prefix, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport elliptic from 'elliptic';\n\nconst pref = {\n p256: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n secp256k1: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\n/**\n * @description Provide signing logic for elliptic curve based key (tz2, tz3)\n */\nexport class ECKey {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n\n /**\n *\n * @param curve Curve to use with the key\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(\n private curve: 'p256' | 'secp256k1',\n private key: string,\n encrypted: boolean,\n decrypt: (k: any) => any\n ) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n const keyPair = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const keyPairY = keyPair.getPublic().getY().toArray();\n const parityByte = keyPairY.length < 32 ? keyPairY[keyPairY.length - 1] : keyPairY[31];\n const pref = parityByte % 2 ? 3 : 2;\n const pad = new Array(32).fill(0);\n this._publicKey = toBuffer(\n new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32)))\n );\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const sig = key.sign(bytesHash, { canonical: true });\n const signature = sig.r.toString('hex', 64) + sig.s.toString('hex', 64);\n\n const sbytes = bytes + signature;\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, pref[this.curve].sig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return b58cencode(this._publicKey, pref[this.curve].pk);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await sodium.ready;\n return b58cencode(\n sodium.crypto_generichash(20, new Uint8Array(this._publicKey)),\n pref[this.curve].pkh\n );\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n const key = this._key;\n\n return b58cencode(key, pref[this.curve].sk);\n }\n}\n\n/**\n * @description Tz3 key class using the p256 curve\n */\nexport const Tz3 = ECKey.bind(null, 'p256');\n\n/**\n * @description Tz3 key class using the secp256k1 curve\n */\nexport const Tz2 = ECKey.bind(null, 'secp256k1');\n","/* Copyright (c) 2014, Wei Lu <luwei.here@gmail.com> and Daniel Cousens <email@dcousens.com>\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies. */\n\nimport pbkdf2 from 'pbkdf2';\n\nexport function mnemonicToSeedSync(mnemonic: string, password: string) {\n const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');\n const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');\n return pbkdf2.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');\n}\n\nfunction normalize(str: string) {\n return (str || '').normalize('NFKD');\n}\nfunction salt(password: string) {\n return 'mnemonic' + (password || '');\n}\n","import { InMemorySigner } from './taquito-signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\n/**\n *\n * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider\n *\n * @param toolkit The toolkit instance to attach a signer\n * @param privateKeyOrEmail Key to load in memory\n * @param passphrase If the key is encrypted passphrase to decrypt it\n * @param mnemonic Faucet mnemonic\n * @param secret Faucet secret\n */\nexport async function importKey(\n toolkit: TezosToolkit,\n privateKeyOrEmail: string,\n passphrase?: string,\n mnemonic?: string,\n secret?: string\n) {\n if (privateKeyOrEmail && passphrase && mnemonic && secret) {\n const signer = InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);\n toolkit.setProvider({ signer });\n const pkh = await signer.publicKeyHash();\n let op;\n try {\n op = await toolkit.tz.activate(pkh, secret);\n } catch (ex: any) {\n const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);\n if (!isInvalidActivationError) {\n throw ex;\n }\n }\n if (op) {\n await op.confirmation();\n }\n } else {\n // Fallback to regular import\n const signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);\n toolkit.setProvider({ signer });\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/signer\n */\nimport sodium from 'libsodium-wrappers';\nimport { hex2buf, mergebuf, b58cencode, prefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport { Tz1 } from './ed-key';\nimport { Tz2, ECKey, Tz3 } from './ec-key';\nimport pbkdf2 from 'pbkdf2';\nimport { mnemonicToSeedSync } from './mnemonicToSeedSync';\n\nexport * from './import-key';\nexport { VERSION } from './version';\n\n/**\n * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf\n *\n * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk\n *\n * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.\n *\n * Consider doing:\n *\n * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```\n *\n * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')\n */\nexport class InMemorySigner {\n private _key!: Tz1 | ECKey;\n\n static fromFundraiser(email: string, password: string, mnemonic: string) {\n const seed = mnemonicToSeedSync(mnemonic, `${email}${password}`);\n const key = b58cencode(seed.slice(0, 32), prefix.edsk2);\n return new InMemorySigner(key);\n }\n\n static async fromSecretKey(key: string, passphrase?: string) {\n await sodium.ready;\n return new InMemorySigner(key, passphrase);\n }\n\n /**\n *\n * @param key Encoded private key\n * @param passphrase Passphrase to decrypt the private key if it is encrypted\n *\n */\n constructor(key: string, passphrase?: string) {\n const encrypted = key.substring(2, 3) === 'e';\n\n let decrypt = (k: any) => k;\n\n if (encrypted) {\n if (!passphrase) {\n throw new Error('Encrypted key provided without a passphrase.');\n }\n\n decrypt = (constructedKey: Uint8Array) => {\n const salt = toBuffer(constructedKey.slice(0, 8));\n const encryptedSk = constructedKey.slice(8);\n const encryptionKey = pbkdf2.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');\n\n return sodium.crypto_secretbox_open_easy(\n new Uint8Array(encryptedSk),\n new Uint8Array(24),\n new Uint8Array(encryptionKey)\n );\n };\n }\n\n switch (key.substr(0, 4)) {\n case 'edes':\n case 'edsk':\n this._key = new Tz1(key, encrypted, decrypt);\n break;\n case 'spsk':\n case 'spes':\n this._key = new Tz2(key, encrypted, decrypt);\n break;\n case 'p2sk':\n case 'p2es':\n this._key = new Tz3(key, encrypted, decrypt);\n break;\n default:\n throw new Error('Unsupported key type');\n }\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param watermark Watermark to append to the bytes\n */\n async sign(bytes: string, watermark?: Uint8Array) {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n\n // Ensure sodium is ready before calling crypto_generichash otherwise the function do not exists\n await sodium.ready;\n const bytesHash = toBuffer(sodium.crypto_generichash(32, bb));\n\n return this._key.sign(bytes, bytesHash);\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return this._key.publicKey();\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return this._key.publicKeyHash();\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n return this._key.secretKey();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;MAGa,GAAG;;;;;;;IAWd,YAAoB,GAAW,EAAE,SAAkB,EAAE,OAAwB;QAAzD,QAAG,GAAH,GAAG,CAAQ;QAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B;IAEa,IAAI;;YAChB,MAAM,MAAM,CAAC,KAAK,CAAC;YACnB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE;gBAC3B,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,wBAAwB,CAC/D,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EACzB,YAAY,CACb,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;gBAC5B,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,CAAC;SAClC;KAAA;;;;IAKK,SAAS;;YACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;SAC9B;KAAA;;;;;"}
1
+ {"version":3,"file":"taquito-signer.es6.js","sources":["../src/ed-key.ts","../src/ec-key.ts","../src/mnemonicToSeedSync.ts","../src/import-key.ts","../src/version.ts","../src/taquito-signer.ts"],"sourcesContent":["import { hash } from '@stablelib/blake2b';\nimport { generateKeyPairFromSeed, sign } from '@stablelib/ed25519';\nimport { b58cencode, b58cdecode, prefix, buf2hex, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\n\n/**\n * @description Provide signing logic for ed25519 curve based key (tz1)\n */\nexport class Tz1 {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n private isInit: Promise<boolean>;\n\n /**\n *\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(private key: string, encrypted: boolean, decrypt: (k: any) => any) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n this._publicKey = this._key.slice(32);\n\n if (!this._key) {\n throw new Error('Unable to decode key');\n }\n\n this.isInit = this.init();\n }\n\n private async init() {\n if (this._key.length !== 64) {\n const { publicKey, secretKey } = generateKeyPairFromSeed(new Uint8Array(this._key));\n this._publicKey = publicKey;\n this._key = secretKey;\n }\n return true;\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n await this.isInit;\n const signature = sign(\n new Uint8Array(this._key), \n new Uint8Array(bytesHash)\n );\n const signatureBuffer = toBuffer(signature);\n const sbytes = bytes + buf2hex(signatureBuffer);\n\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, prefix.edsig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n await this.isInit;\n return b58cencode(this._publicKey, prefix['edpk']);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await this.isInit;\n return b58cencode(hash(new Uint8Array(this._publicKey), 20), prefix.tz1);\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n await this.isInit;\n let key = this._key;\n const { secretKey } = generateKeyPairFromSeed(\n new Uint8Array(key).slice(0, 32)\n );\n key = toBuffer(secretKey);\n\n return b58cencode(key, prefix[`edsk`]);\n }\n}\n","import { hash } from '@stablelib/blake2b';\nimport { b58cencode, b58cdecode, prefix, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport elliptic from 'elliptic';\n\nconst pref = {\n p256: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n secp256k1: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\n/**\n * @description Provide signing logic for elliptic curve based key (tz2, tz3)\n */\nexport class ECKey {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n\n /**\n *\n * @param curve Curve to use with the key\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(\n private curve: 'p256' | 'secp256k1',\n private key: string,\n encrypted: boolean,\n decrypt: (k: any) => any\n ) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n const keyPair = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const keyPairY = keyPair.getPublic().getY().toArray();\n const parityByte = keyPairY.length < 32 ? keyPairY[keyPairY.length - 1] : keyPairY[31];\n const pref = parityByte % 2 ? 3 : 2;\n const pad = new Array(32).fill(0);\n this._publicKey = toBuffer(\n new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32)))\n );\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const sig = key.sign(bytesHash, { canonical: true });\n const signature = sig.r.toString('hex', 64) + sig.s.toString('hex', 64);\n\n const sbytes = bytes + signature;\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, pref[this.curve].sig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return b58cencode(this._publicKey, pref[this.curve].pk);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return b58cencode(\n hash(new Uint8Array(this._publicKey), 20), \n pref[this.curve].pkh\n );\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n const key = this._key;\n\n return b58cencode(key, pref[this.curve].sk);\n }\n}\n\n/**\n * @description Tz3 key class using the p256 curve\n */\nexport const Tz3 = ECKey.bind(null, 'p256');\n\n/**\n * @description Tz3 key class using the secp256k1 curve\n */\nexport const Tz2 = ECKey.bind(null, 'secp256k1');\n","/* Copyright (c) 2014, Wei Lu <luwei.here@gmail.com> and Daniel Cousens <email@dcousens.com>\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies. */\n\nimport pbkdf2 from 'pbkdf2';\n\nexport function mnemonicToSeedSync(mnemonic: string, password: string) {\n const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');\n const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');\n return pbkdf2.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');\n}\n\nfunction normalize(str: string) {\n return (str || '').normalize('NFKD');\n}\nfunction salt(password: string) {\n return 'mnemonic' + (password || '');\n}\n","import { InMemorySigner } from './taquito-signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\n/**\n *\n * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider\n *\n * @param toolkit The toolkit instance to attach a signer\n * @param privateKeyOrEmail Key to load in memory\n * @param passphrase If the key is encrypted passphrase to decrypt it\n * @param mnemonic Faucet mnemonic\n * @param secret Faucet secret\n */\nexport async function importKey(\n toolkit: TezosToolkit,\n privateKeyOrEmail: string,\n passphrase?: string,\n mnemonic?: string,\n secret?: string\n) {\n if (privateKeyOrEmail && passphrase && mnemonic && secret) {\n const signer = InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);\n toolkit.setProvider({ signer });\n const pkh = await signer.publicKeyHash();\n let op;\n try {\n op = await toolkit.tz.activate(pkh, secret);\n } catch (ex: any) {\n const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);\n if (!isInvalidActivationError) {\n throw ex;\n }\n }\n if (op) {\n await op.confirmation();\n }\n } else {\n // Fallback to regular import\n const signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);\n toolkit.setProvider({ signer });\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"222db56e9550fff784a819406d8bdc1110787440\",\n \"version\": \"12.0.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/signer\n */\nimport { openSecretBox } from '@stablelib/nacl';\nimport { hash } from '@stablelib/blake2b';\nimport { hex2buf, mergebuf, b58cencode, prefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport { Tz1 } from './ed-key';\nimport { Tz2, ECKey, Tz3 } from './ec-key';\nimport pbkdf2 from 'pbkdf2';\nimport { mnemonicToSeedSync } from './mnemonicToSeedSync';\n\nexport * from './import-key';\nexport { VERSION } from './version';\n\n/**\n * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf\n *\n * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk\n *\n */\nexport class InMemorySigner {\n private _key!: Tz1 | ECKey;\n\n static fromFundraiser(email: string, password: string, mnemonic: string) {\n const seed = mnemonicToSeedSync(mnemonic, `${email}${password}`);\n const key = b58cencode(seed.slice(0, 32), prefix.edsk2);\n return new InMemorySigner(key);\n }\n\n static async fromSecretKey(key: string, passphrase?: string) {\n return new InMemorySigner(key, passphrase);\n }\n\n /**\n *\n * @param key Encoded private key\n * @param passphrase Passphrase to decrypt the private key if it is encrypted\n *\n */\n constructor(key: string, passphrase?: string) {\n const encrypted = key.substring(2, 3) === 'e';\n\n let decrypt = (k: any) => k;\n\n if (encrypted) {\n if (!passphrase) {\n throw new Error('Encrypted key provided without a passphrase.');\n }\n\n decrypt = (constructedKey: Uint8Array) => {\n const salt = toBuffer(constructedKey.slice(0, 8));\n const encryptedSk = constructedKey.slice(8);\n const encryptionKey = pbkdf2.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');\n\n return openSecretBox(\n new Uint8Array(encryptionKey), \n new Uint8Array(24), \n new Uint8Array(encryptedSk)\n );\n };\n }\n\n switch (key.substr(0, 4)) {\n case 'edes':\n case 'edsk':\n this._key = new Tz1(key, encrypted, decrypt);\n break;\n case 'spsk':\n case 'spes':\n this._key = new Tz2(key, encrypted, decrypt);\n break;\n case 'p2sk':\n case 'p2es':\n this._key = new Tz3(key, encrypted, decrypt);\n break;\n default:\n throw new Error('Unsupported key type');\n }\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param watermark Watermark to append to the bytes\n */\n async sign(bytes: string, watermark?: Uint8Array) {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n\n const bytesHash = hash(bb, 32);\n\n return this._key.sign(bytes, bytesHash);\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return this._key.publicKey();\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return this._key.publicKeyHash();\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n return this._key.secretKey();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;MAGa,GAAG;;;;;;;IAWd,YAAoB,GAAW,EAAE,SAAkB,EAAE,OAAwB;QAAzD,QAAG,GAAH,GAAG,CAAQ;QAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;KAC3B;IAEa,IAAI;;YAChB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE;gBAC3B,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBACpF,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;gBAC5B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;aACvB;YACD,OAAO,IAAI,CAAC;SACb;KAAA;;;;;;IAO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GAAG,QAAQ,EAAE,CAAC,CAAC;QACjE,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;KAChC;IAED,OAAa,aAAa,CAAC,GAAW,EAAE,UAAmB;;YACzD,OAAO,IAAI,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;SAC5C;KAAA;;;;;;IAsDK,IAAI,CAAC,KAAa,EAAE,SAAsB;;YAC9C,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YACxB,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;gBACpC,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;aAC9B;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;SACzC;KAAA;;;;IAKK,SAAS;;YACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;SAC9B;KAAA;;;;IAKK,aAAa;;YACjB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;SAClC;KAAA;;;;IAKK,SAAS;;YACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;SAC9B;KAAA;;;;;"}
@@ -1,12 +1,11 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('libsodium-wrappers'), require('@taquito/utils'), require('typedarray-to-buffer'), require('elliptic'), require('pbkdf2')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'libsodium-wrappers', '@taquito/utils', 'typedarray-to-buffer', 'elliptic', 'pbkdf2'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoSigner = {}, global.sodium, global.utils, global.toBuffer, global.elliptic, global.pbkdf2));
5
- })(this, (function (exports, sodium, utils, toBuffer, elliptic, pbkdf2) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@stablelib/nacl'), require('@stablelib/blake2b'), require('@taquito/utils'), require('typedarray-to-buffer'), require('@stablelib/ed25519'), require('elliptic'), require('pbkdf2')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@stablelib/nacl', '@stablelib/blake2b', '@taquito/utils', 'typedarray-to-buffer', '@stablelib/ed25519', 'elliptic', 'pbkdf2'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoSigner = {}, global.nacl, global.blake2b, global.utils, global.toBuffer, global.ed25519, global.elliptic, global.pbkdf2));
5
+ })(this, (function (exports, nacl, blake2b, utils, toBuffer, ed25519, elliptic, pbkdf2) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var sodium__default = /*#__PURE__*/_interopDefaultLegacy(sodium);
10
9
  var toBuffer__default = /*#__PURE__*/_interopDefaultLegacy(toBuffer);
11
10
  var elliptic__default = /*#__PURE__*/_interopDefaultLegacy(elliptic);
12
11
  var pbkdf2__default = /*#__PURE__*/_interopDefaultLegacy(pbkdf2);
@@ -61,11 +60,10 @@
61
60
  }
62
61
  init() {
63
62
  return __awaiter(this, void 0, void 0, function* () {
64
- yield sodium__default["default"].ready;
65
63
  if (this._key.length !== 64) {
66
- const { publicKey, privateKey } = sodium__default["default"].crypto_sign_seed_keypair(new Uint8Array(this._key), 'uint8array');
64
+ const { publicKey, secretKey } = ed25519.generateKeyPairFromSeed(new Uint8Array(this._key));
67
65
  this._publicKey = publicKey;
68
- this._key = privateKey;
66
+ this._key = secretKey;
69
67
  }
70
68
  return true;
71
69
  });
@@ -78,7 +76,7 @@
78
76
  sign(bytes, bytesHash) {
79
77
  return __awaiter(this, void 0, void 0, function* () {
80
78
  yield this.isInit;
81
- const signature = sodium__default["default"].crypto_sign_detached(new Uint8Array(bytesHash), new Uint8Array(this._key));
79
+ const signature = ed25519.sign(new Uint8Array(this._key), new Uint8Array(bytesHash));
82
80
  const signatureBuffer = toBuffer__default["default"](signature);
83
81
  const sbytes = bytes + utils.buf2hex(signatureBuffer);
84
82
  return {
@@ -104,8 +102,7 @@
104
102
  publicKeyHash() {
105
103
  return __awaiter(this, void 0, void 0, function* () {
106
104
  yield this.isInit;
107
- yield sodium__default["default"].ready;
108
- return utils.b58cencode(sodium__default["default"].crypto_generichash(20, new Uint8Array(this._publicKey)), utils.prefix.tz1);
105
+ return utils.b58cencode(blake2b.hash(new Uint8Array(this._publicKey), 20), utils.prefix.tz1);
109
106
  });
110
107
  }
111
108
  /**
@@ -114,10 +111,9 @@
114
111
  secretKey() {
115
112
  return __awaiter(this, void 0, void 0, function* () {
116
113
  yield this.isInit;
117
- yield sodium__default["default"].ready;
118
114
  let key = this._key;
119
- const { privateKey } = sodium__default["default"].crypto_sign_seed_keypair(new Uint8Array(key).slice(0, 32), 'uint8array');
120
- key = toBuffer__default["default"](privateKey);
115
+ const { secretKey } = ed25519.generateKeyPairFromSeed(new Uint8Array(key).slice(0, 32));
116
+ key = toBuffer__default["default"](secretKey);
121
117
  return utils.b58cencode(key, utils.prefix[`edsk`]);
122
118
  });
123
119
  }
@@ -195,8 +191,7 @@
195
191
  */
196
192
  publicKeyHash() {
197
193
  return __awaiter(this, void 0, void 0, function* () {
198
- yield sodium__default["default"].ready;
199
- return utils.b58cencode(sodium__default["default"].crypto_generichash(20, new Uint8Array(this._publicKey)), pref[this.curve].pkh);
194
+ return utils.b58cencode(blake2b.hash(new Uint8Array(this._publicKey), 20), pref[this.curve].pkh);
200
195
  });
201
196
  }
202
197
  /**
@@ -275,8 +270,8 @@
275
270
 
276
271
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
277
272
  const VERSION = {
278
- "commitHash": "e03d983c780c7f96d8291ddd1251ea82f4581858",
279
- "version": "11.2.0-beta-RC.0"
273
+ "commitHash": "222db56e9550fff784a819406d8bdc1110787440",
274
+ "version": "12.0.0"
280
275
  };
281
276
 
282
277
  /**
@@ -284,13 +279,6 @@
284
279
  *
285
280
  * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
286
281
  *
287
- * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.
288
- *
289
- * Consider doing:
290
- *
291
- * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```
292
- *
293
- * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')
294
282
  */
295
283
  class InMemorySigner {
296
284
  /**
@@ -310,7 +298,7 @@
310
298
  const salt = toBuffer__default["default"](constructedKey.slice(0, 8));
311
299
  const encryptedSk = constructedKey.slice(8);
312
300
  const encryptionKey = pbkdf2__default["default"].pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');
313
- return sodium__default["default"].crypto_secretbox_open_easy(new Uint8Array(encryptedSk), new Uint8Array(24), new Uint8Array(encryptionKey));
301
+ return nacl.openSecretBox(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
314
302
  };
315
303
  }
316
304
  switch (key.substr(0, 4)) {
@@ -337,7 +325,6 @@
337
325
  }
338
326
  static fromSecretKey(key, passphrase) {
339
327
  return __awaiter(this, void 0, void 0, function* () {
340
- yield sodium__default["default"].ready;
341
328
  return new InMemorySigner(key, passphrase);
342
329
  });
343
330
  }
@@ -352,9 +339,7 @@
352
339
  if (typeof watermark !== 'undefined') {
353
340
  bb = utils.mergebuf(watermark, bb);
354
341
  }
355
- // Ensure sodium is ready before calling crypto_generichash otherwise the function do not exists
356
- yield sodium__default["default"].ready;
357
- const bytesHash = toBuffer__default["default"](sodium__default["default"].crypto_generichash(32, bb));
342
+ const bytesHash = blake2b.hash(bb, 32);
358
343
  return this._key.sign(bytes, bytesHash);
359
344
  });
360
345
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-signer.umd.js","sources":["../src/ed-key.ts","../src/ec-key.ts","../src/mnemonicToSeedSync.ts","../src/import-key.ts","../src/version.ts","../src/taquito-signer.ts"],"sourcesContent":["import sodium from 'libsodium-wrappers';\nimport { b58cencode, b58cdecode, prefix, buf2hex, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\n\n/**\n * @description Provide signing logic for ed25519 curve based key (tz1)\n */\nexport class Tz1 {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n private isInit: Promise<boolean>;\n\n /**\n *\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(private key: string, encrypted: boolean, decrypt: (k: any) => any) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n this._publicKey = this._key.slice(32);\n\n if (!this._key) {\n throw new Error('Unable to decode key');\n }\n\n this.isInit = this.init();\n }\n\n private async init() {\n await sodium.ready;\n if (this._key.length !== 64) {\n const { publicKey, privateKey } = sodium.crypto_sign_seed_keypair(\n new Uint8Array(this._key),\n 'uint8array'\n );\n this._publicKey = publicKey;\n this._key = privateKey;\n }\n return true;\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n await this.isInit;\n const signature = sodium.crypto_sign_detached(\n new Uint8Array(bytesHash),\n new Uint8Array(this._key)\n );\n const signatureBuffer = toBuffer(signature);\n const sbytes = bytes + buf2hex(signatureBuffer);\n\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, prefix.edsig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n await this.isInit;\n return b58cencode(this._publicKey, prefix['edpk']);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await this.isInit;\n await sodium.ready;\n return b58cencode(sodium.crypto_generichash(20, new Uint8Array(this._publicKey)), prefix.tz1);\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n await this.isInit;\n await sodium.ready;\n let key = this._key;\n const { privateKey } = sodium.crypto_sign_seed_keypair(\n new Uint8Array(key).slice(0, 32),\n 'uint8array'\n );\n key = toBuffer(privateKey);\n\n return b58cencode(key, prefix[`edsk`]);\n }\n}\n","import sodium from 'libsodium-wrappers';\nimport { b58cencode, b58cdecode, prefix, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport elliptic from 'elliptic';\n\nconst pref = {\n p256: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n secp256k1: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\n/**\n * @description Provide signing logic for elliptic curve based key (tz2, tz3)\n */\nexport class ECKey {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n\n /**\n *\n * @param curve Curve to use with the key\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(\n private curve: 'p256' | 'secp256k1',\n private key: string,\n encrypted: boolean,\n decrypt: (k: any) => any\n ) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n const keyPair = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const keyPairY = keyPair.getPublic().getY().toArray();\n const parityByte = keyPairY.length < 32 ? keyPairY[keyPairY.length - 1] : keyPairY[31];\n const pref = parityByte % 2 ? 3 : 2;\n const pad = new Array(32).fill(0);\n this._publicKey = toBuffer(\n new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32)))\n );\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const sig = key.sign(bytesHash, { canonical: true });\n const signature = sig.r.toString('hex', 64) + sig.s.toString('hex', 64);\n\n const sbytes = bytes + signature;\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, pref[this.curve].sig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return b58cencode(this._publicKey, pref[this.curve].pk);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await sodium.ready;\n return b58cencode(\n sodium.crypto_generichash(20, new Uint8Array(this._publicKey)),\n pref[this.curve].pkh\n );\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n const key = this._key;\n\n return b58cencode(key, pref[this.curve].sk);\n }\n}\n\n/**\n * @description Tz3 key class using the p256 curve\n */\nexport const Tz3 = ECKey.bind(null, 'p256');\n\n/**\n * @description Tz3 key class using the secp256k1 curve\n */\nexport const Tz2 = ECKey.bind(null, 'secp256k1');\n","/* Copyright (c) 2014, Wei Lu <luwei.here@gmail.com> and Daniel Cousens <email@dcousens.com>\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies. */\n\nimport pbkdf2 from 'pbkdf2';\n\nexport function mnemonicToSeedSync(mnemonic: string, password: string) {\n const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');\n const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');\n return pbkdf2.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');\n}\n\nfunction normalize(str: string) {\n return (str || '').normalize('NFKD');\n}\nfunction salt(password: string) {\n return 'mnemonic' + (password || '');\n}\n","import { InMemorySigner } from './taquito-signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\n/**\n *\n * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider\n *\n * @param toolkit The toolkit instance to attach a signer\n * @param privateKeyOrEmail Key to load in memory\n * @param passphrase If the key is encrypted passphrase to decrypt it\n * @param mnemonic Faucet mnemonic\n * @param secret Faucet secret\n */\nexport async function importKey(\n toolkit: TezosToolkit,\n privateKeyOrEmail: string,\n passphrase?: string,\n mnemonic?: string,\n secret?: string\n) {\n if (privateKeyOrEmail && passphrase && mnemonic && secret) {\n const signer = InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);\n toolkit.setProvider({ signer });\n const pkh = await signer.publicKeyHash();\n let op;\n try {\n op = await toolkit.tz.activate(pkh, secret);\n } catch (ex: any) {\n const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);\n if (!isInvalidActivationError) {\n throw ex;\n }\n }\n if (op) {\n await op.confirmation();\n }\n } else {\n // Fallback to regular import\n const signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);\n toolkit.setProvider({ signer });\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"e03d983c780c7f96d8291ddd1251ea82f4581858\",\n \"version\": \"11.2.0-beta-RC.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/signer\n */\nimport sodium from 'libsodium-wrappers';\nimport { hex2buf, mergebuf, b58cencode, prefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport { Tz1 } from './ed-key';\nimport { Tz2, ECKey, Tz3 } from './ec-key';\nimport pbkdf2 from 'pbkdf2';\nimport { mnemonicToSeedSync } from './mnemonicToSeedSync';\n\nexport * from './import-key';\nexport { VERSION } from './version';\n\n/**\n * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf\n *\n * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk\n *\n * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.\n *\n * Consider doing:\n *\n * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```\n *\n * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')\n */\nexport class InMemorySigner {\n private _key!: Tz1 | ECKey;\n\n static fromFundraiser(email: string, password: string, mnemonic: string) {\n const seed = mnemonicToSeedSync(mnemonic, `${email}${password}`);\n const key = b58cencode(seed.slice(0, 32), prefix.edsk2);\n return new InMemorySigner(key);\n }\n\n static async fromSecretKey(key: string, passphrase?: string) {\n await sodium.ready;\n return new InMemorySigner(key, passphrase);\n }\n\n /**\n *\n * @param key Encoded private key\n * @param passphrase Passphrase to decrypt the private key if it is encrypted\n *\n */\n constructor(key: string, passphrase?: string) {\n const encrypted = key.substring(2, 3) === 'e';\n\n let decrypt = (k: any) => k;\n\n if (encrypted) {\n if (!passphrase) {\n throw new Error('Encrypted key provided without a passphrase.');\n }\n\n decrypt = (constructedKey: Uint8Array) => {\n const salt = toBuffer(constructedKey.slice(0, 8));\n const encryptedSk = constructedKey.slice(8);\n const encryptionKey = pbkdf2.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');\n\n return sodium.crypto_secretbox_open_easy(\n new Uint8Array(encryptedSk),\n new Uint8Array(24),\n new Uint8Array(encryptionKey)\n );\n };\n }\n\n switch (key.substr(0, 4)) {\n case 'edes':\n case 'edsk':\n this._key = new Tz1(key, encrypted, decrypt);\n break;\n case 'spsk':\n case 'spes':\n this._key = new Tz2(key, encrypted, decrypt);\n break;\n case 'p2sk':\n case 'p2es':\n this._key = new Tz3(key, encrypted, decrypt);\n break;\n default:\n throw new Error('Unsupported key type');\n }\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param watermark Watermark to append to the bytes\n */\n async sign(bytes: string, watermark?: Uint8Array) {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n\n // Ensure sodium is ready before calling crypto_generichash otherwise the function do not exists\n await sodium.ready;\n const bytesHash = toBuffer(sodium.crypto_generichash(32, bb));\n\n return this._key.sign(bytes, bytesHash);\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return this._key.publicKey();\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return this._key.publicKeyHash();\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n return this._key.secretKey();\n }\n}\n"],"names":["isValidPrefix","b58cdecode","prefix","sodium","toBuffer","buf2hex","b58cencode","elliptic","pbkdf2","hex2buf","mergebuf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIA;;;UAGa,GAAG;;;;;;;QAWd,YAAoB,GAAW,EAAE,SAAkB,EAAE,OAAwB;YAAzD,QAAG,GAAH,GAAG,CAAQ;YAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,CAACA,mBAAa,CAAC,SAAS,CAAC,EAAE;gBAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;aAChD;YAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAACC,gBAAU,CAAC,IAAI,CAAC,GAAG,EAAEC,YAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAEtC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;aACzC;YAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAA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BACxB,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;oBACpC,EAAE,GAAGC,cAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;iBAC9B;;gBAGD,MAAMP,0BAAM,CAAC,KAAK,CAAC;gBACnB,MAAM,SAAS,GAAGC,4BAAQ,CAACD,0BAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;gBAE9D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;aACzC;SAAA;;;;QAKK,SAAS;;gBACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;aAC9B;SAAA;;;;QAKK,aAAa;;gBACjB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;aAClC;SAAA;;;;QAKK,SAAS;;gBACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;aAC9B;SAAA;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-signer.umd.js","sources":["../src/ed-key.ts","../src/ec-key.ts","../src/mnemonicToSeedSync.ts","../src/import-key.ts","../src/version.ts","../src/taquito-signer.ts"],"sourcesContent":["import { hash } from '@stablelib/blake2b';\nimport { generateKeyPairFromSeed, sign } from '@stablelib/ed25519';\nimport { b58cencode, b58cdecode, prefix, buf2hex, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\n\n/**\n * @description Provide signing logic for ed25519 curve based key (tz1)\n */\nexport class Tz1 {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n private isInit: Promise<boolean>;\n\n /**\n *\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(private key: string, encrypted: boolean, decrypt: (k: any) => any) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n this._publicKey = this._key.slice(32);\n\n if (!this._key) {\n throw new Error('Unable to decode key');\n }\n\n this.isInit = this.init();\n }\n\n private async init() {\n if (this._key.length !== 64) {\n const { publicKey, secretKey } = generateKeyPairFromSeed(new Uint8Array(this._key));\n this._publicKey = publicKey;\n this._key = secretKey;\n }\n return true;\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n await this.isInit;\n const signature = sign(\n new Uint8Array(this._key), \n new Uint8Array(bytesHash)\n );\n const signatureBuffer = toBuffer(signature);\n const sbytes = bytes + buf2hex(signatureBuffer);\n\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, prefix.edsig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n await this.isInit;\n return b58cencode(this._publicKey, prefix['edpk']);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n await this.isInit;\n return b58cencode(hash(new Uint8Array(this._publicKey), 20), prefix.tz1);\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n await this.isInit;\n let key = this._key;\n const { secretKey } = generateKeyPairFromSeed(\n new Uint8Array(key).slice(0, 32)\n );\n key = toBuffer(secretKey);\n\n return b58cencode(key, prefix[`edsk`]);\n }\n}\n","import { hash } from '@stablelib/blake2b';\nimport { b58cencode, b58cdecode, prefix, isValidPrefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport elliptic from 'elliptic';\n\nconst pref = {\n p256: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n secp256k1: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\n/**\n * @description Provide signing logic for elliptic curve based key (tz2, tz3)\n */\nexport class ECKey {\n private _key: Uint8Array;\n private _publicKey: Uint8Array;\n\n /**\n *\n * @param curve Curve to use with the key\n * @param key Encoded private key\n * @param encrypted Is the private key encrypted\n * @param decrypt Decrypt function\n */\n constructor(\n private curve: 'p256' | 'secp256k1',\n private key: string,\n encrypted: boolean,\n decrypt: (k: any) => any\n ) {\n const keyPrefix = key.substr(0, encrypted ? 5 : 4);\n if (!isValidPrefix(keyPrefix)) {\n throw new Error('key contains invalid prefix');\n }\n\n this._key = decrypt(b58cdecode(this.key, prefix[keyPrefix]));\n const keyPair = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const keyPairY = keyPair.getPublic().getY().toArray();\n const parityByte = keyPairY.length < 32 ? keyPairY[keyPairY.length - 1] : keyPairY[31];\n const pref = parityByte % 2 ? 3 : 2;\n const pad = new Array(32).fill(0);\n this._publicKey = toBuffer(\n new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32)))\n );\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param bytesHash Blake2b hash of the bytes to sign\n */\n async sign(bytes: string, bytesHash: Uint8Array) {\n const key = new elliptic.ec(this.curve).keyFromPrivate(this._key);\n const sig = key.sign(bytesHash, { canonical: true });\n const signature = sig.r.toString('hex', 64) + sig.s.toString('hex', 64);\n\n const sbytes = bytes + signature;\n return {\n bytes,\n sig: b58cencode(signature, prefix.sig),\n prefixSig: b58cencode(signature, pref[this.curve].sig),\n sbytes,\n };\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return b58cencode(this._publicKey, pref[this.curve].pk);\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return b58cencode(\n hash(new Uint8Array(this._publicKey), 20), \n pref[this.curve].pkh\n );\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n const key = this._key;\n\n return b58cencode(key, pref[this.curve].sk);\n }\n}\n\n/**\n * @description Tz3 key class using the p256 curve\n */\nexport const Tz3 = ECKey.bind(null, 'p256');\n\n/**\n * @description Tz3 key class using the secp256k1 curve\n */\nexport const Tz2 = ECKey.bind(null, 'secp256k1');\n","/* Copyright (c) 2014, Wei Lu <luwei.here@gmail.com> and Daniel Cousens <email@dcousens.com>\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies. */\n\nimport pbkdf2 from 'pbkdf2';\n\nexport function mnemonicToSeedSync(mnemonic: string, password: string) {\n const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');\n const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');\n return pbkdf2.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');\n}\n\nfunction normalize(str: string) {\n return (str || '').normalize('NFKD');\n}\nfunction salt(password: string) {\n return 'mnemonic' + (password || '');\n}\n","import { InMemorySigner } from './taquito-signer';\nimport { TezosToolkit } from '@taquito/taquito';\n\n/**\n *\n * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider\n *\n * @param toolkit The toolkit instance to attach a signer\n * @param privateKeyOrEmail Key to load in memory\n * @param passphrase If the key is encrypted passphrase to decrypt it\n * @param mnemonic Faucet mnemonic\n * @param secret Faucet secret\n */\nexport async function importKey(\n toolkit: TezosToolkit,\n privateKeyOrEmail: string,\n passphrase?: string,\n mnemonic?: string,\n secret?: string\n) {\n if (privateKeyOrEmail && passphrase && mnemonic && secret) {\n const signer = InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);\n toolkit.setProvider({ signer });\n const pkh = await signer.publicKeyHash();\n let op;\n try {\n op = await toolkit.tz.activate(pkh, secret);\n } catch (ex: any) {\n const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);\n if (!isInvalidActivationError) {\n throw ex;\n }\n }\n if (op) {\n await op.confirmation();\n }\n } else {\n // Fallback to regular import\n const signer = await InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);\n toolkit.setProvider({ signer });\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"222db56e9550fff784a819406d8bdc1110787440\",\n \"version\": \"12.0.0\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/signer\n */\nimport { openSecretBox } from '@stablelib/nacl';\nimport { hash } from '@stablelib/blake2b';\nimport { hex2buf, mergebuf, b58cencode, prefix } from '@taquito/utils';\nimport toBuffer from 'typedarray-to-buffer';\nimport { Tz1 } from './ed-key';\nimport { Tz2, ECKey, Tz3 } from './ec-key';\nimport pbkdf2 from 'pbkdf2';\nimport { mnemonicToSeedSync } from './mnemonicToSeedSync';\n\nexport * from './import-key';\nexport { VERSION } from './version';\n\n/**\n * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf\n *\n * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk\n *\n */\nexport class InMemorySigner {\n private _key!: Tz1 | ECKey;\n\n static fromFundraiser(email: string, password: string, mnemonic: string) {\n const seed = mnemonicToSeedSync(mnemonic, `${email}${password}`);\n const key = b58cencode(seed.slice(0, 32), prefix.edsk2);\n return new InMemorySigner(key);\n }\n\n static async fromSecretKey(key: string, passphrase?: string) {\n return new InMemorySigner(key, passphrase);\n }\n\n /**\n *\n * @param key Encoded private key\n * @param passphrase Passphrase to decrypt the private key if it is encrypted\n *\n */\n constructor(key: string, passphrase?: string) {\n const encrypted = key.substring(2, 3) === 'e';\n\n let decrypt = (k: any) => k;\n\n if (encrypted) {\n if (!passphrase) {\n throw new Error('Encrypted key provided without a passphrase.');\n }\n\n decrypt = (constructedKey: Uint8Array) => {\n const salt = toBuffer(constructedKey.slice(0, 8));\n const encryptedSk = constructedKey.slice(8);\n const encryptionKey = pbkdf2.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');\n\n return openSecretBox(\n new Uint8Array(encryptionKey), \n new Uint8Array(24), \n new Uint8Array(encryptedSk)\n );\n };\n }\n\n switch (key.substr(0, 4)) {\n case 'edes':\n case 'edsk':\n this._key = new Tz1(key, encrypted, decrypt);\n break;\n case 'spsk':\n case 'spes':\n this._key = new Tz2(key, encrypted, decrypt);\n break;\n case 'p2sk':\n case 'p2es':\n this._key = new Tz3(key, encrypted, decrypt);\n break;\n default:\n throw new Error('Unsupported key type');\n }\n }\n\n /**\n *\n * @param bytes Bytes to sign\n * @param watermark Watermark to append to the bytes\n */\n async sign(bytes: string, watermark?: Uint8Array) {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n\n const bytesHash = hash(bb, 32);\n\n return this._key.sign(bytes, bytesHash);\n }\n\n /**\n * @returns Encoded public key\n */\n async publicKey(): Promise<string> {\n return this._key.publicKey();\n }\n\n /**\n * @returns Encoded public key hash\n */\n async publicKeyHash(): Promise<string> {\n return this._key.publicKeyHash();\n }\n\n /**\n * @returns Encoded private key\n */\n async secretKey(): Promise<string> {\n return this._key.secretKey();\n }\n}\n"],"names":["isValidPrefix","b58cdecode","prefix","generateKeyPairFromSeed","sign","toBuffer","buf2hex","b58cencode","hash","elliptic","pbkdf2","openSecretBox","hex2buf","mergebuf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKA;;;UAGa,GAAG;;;;;;;QAWd,YAAoB,GAAW,EAAE,SAAkB,EAAE,OAAwB;YAAzD,QAAG,GAAH,GAAG,CAAQ;YAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,CAACA,mBAAa,CAAC,SAAS,CAAC,EAAE;gBAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;aAChD;YAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAACC,gBAAU,CAAC,IAAI,CAAC,GAAG,EA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,EAAE;oBACpC,EAAE,GAAGC,cAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;iBAC9B;gBAED,MAAM,SAAS,GAAGL,YAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;aACzC;SAAA;;;;QAKK,SAAS;;gBACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;aAC9B;SAAA;;;;QAKK,aAAa;;gBACjB,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;aAClC;SAAA;;;;QAKK,SAAS;;gBACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;aAC9B;SAAA;;;;;;;;;;;;;"}
@@ -5,13 +5,6 @@ export { VERSION } from './version';
5
5
  *
6
6
  * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
7
7
  *
8
- * @warn Calling this constructor directly is discouraged as it do not await for sodium library to be loaded.
9
- *
10
- * Consider doing:
11
- *
12
- * ```const sodium = require('libsodium-wrappers'); await sodium.ready;```
13
- *
14
- * The recommended usage is to use InMemorySigner.fromSecretKey('edsk', 'passphrase')
15
8
  */
16
9
  export declare class InMemorySigner {
17
10
  private _key;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/signer",
3
- "version": "11.2.0-beta-RC.0",
3
+ "version": "12.0.0",
4
4
  "description": "Provide signing functionality to be with taquito",
5
5
  "keywords": [
6
6
  "tezos",
@@ -67,10 +67,12 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@taquito/taquito": "^11.2.0-beta-RC.0",
71
- "@taquito/utils": "^11.2.0-beta-RC.0",
70
+ "@stablelib/blake2b": "^1.0.1",
71
+ "@stablelib/ed25519": "^1.0.2",
72
+ "@stablelib/nacl": "^1.0.2",
73
+ "@taquito/taquito": "^12.0.0",
74
+ "@taquito/utils": "^12.0.0",
72
75
  "elliptic": "^6.5.4",
73
- "libsodium-wrappers": "0.7.8",
74
76
  "pbkdf2": "^3.1.2",
75
77
  "typedarray-to-buffer": "^4.0.0"
76
78
  },
@@ -78,7 +80,6 @@
78
80
  "@types/bluebird": "^3.5.36",
79
81
  "@types/elliptic": "^6.4.14",
80
82
  "@types/jest": "^26.0.23",
81
- "@types/libsodium-wrappers": "0.7.8",
82
83
  "@types/node": "^17.0.0",
83
84
  "@types/pbkdf2": "^3.1.0",
84
85
  "@typescript-eslint/eslint-plugin": "^5.7.0",
@@ -106,5 +107,5 @@
106
107
  "typedoc": "^0.20.36",
107
108
  "typescript": "~4.1.5"
108
109
  },
109
- "gitHead": "7cc9152cdad01bacca4a1b682c7cb0a33a24f544"
110
+ "gitHead": "5ec8d17b7ad47452ec616723c08ad18b128bf94c"
110
111
  }