@taquito/signer 17.3.2 → 17.4.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/lib/derivation-tools/ecdsa.js +1 -2
- package/dist/lib/derivation-tools/ed25519.js +3 -4
- package/dist/lib/derivation-tools/index.js +0 -1
- package/dist/lib/derivation-tools/utils.js +0 -1
- package/dist/lib/ec-key.js +9 -10
- package/dist/lib/ed-key.js +14 -15
- package/dist/lib/errors.js +0 -1
- package/dist/lib/helpers.js +2 -3
- package/dist/lib/import-key.js +0 -1
- package/dist/lib/taquito-signer.js +44 -41
- package/dist/lib/version.js +2 -3
- package/dist/taquito-signer.es6.js +666 -664
- package/dist/taquito-signer.es6.js.map +1 -1
- package/dist/taquito-signer.umd.js +669 -676
- package/dist/taquito-signer.umd.js.map +1 -1
- package/dist/types/derivation-tools/ecdsa.d.ts +44 -44
- package/dist/types/derivation-tools/ed25519.d.ts +33 -33
- package/dist/types/derivation-tools/index.d.ts +21 -21
- package/dist/types/derivation-tools/utils.d.ts +1 -1
- package/dist/types/ec-key.d.ts +49 -49
- package/dist/types/ed-key.d.ts +41 -41
- package/dist/types/errors.d.ts +48 -48
- package/dist/types/helpers.d.ts +10 -10
- package/dist/types/import-key.d.ts +13 -13
- package/dist/types/taquito-signer.d.ts +65 -65
- package/dist/types/version.d.ts +4 -4
- package/package.json +30 -32
- package/signature.json +3 -5
- package/dist/lib/derivation-tools/ecdsa.js.map +0 -1
- package/dist/lib/derivation-tools/ed25519.js.map +0 -1
- package/dist/lib/derivation-tools/index.js.map +0 -1
- package/dist/lib/derivation-tools/utils.js.map +0 -1
- package/dist/lib/ec-key.js.map +0 -1
- package/dist/lib/ed-key.js.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/helpers.js.map +0 -1
- package/dist/lib/import-key.js.map +0 -1
- package/dist/lib/taquito-signer.js.map +0 -1
- package/dist/lib/version.js.map +0 -1
|
@@ -36,7 +36,7 @@ class PrivateKey {
|
|
|
36
36
|
*/
|
|
37
37
|
static fromSeed(seedSrc, curve) {
|
|
38
38
|
var _a, _b;
|
|
39
|
-
let seed = typeof seedSrc === 'string' ? utils_1.parseHex(seedSrc) : seedSrc;
|
|
39
|
+
let seed = typeof seedSrc === 'string' ? (0, utils_1.parseHex)(seedSrc) : seedSrc;
|
|
40
40
|
if (seed.length < minSeedSize || seed.length > maxSeedSize) {
|
|
41
41
|
throw new errors_1.InvalidSeedLengthError(seed.length);
|
|
42
42
|
}
|
|
@@ -130,4 +130,3 @@ class PrivateKey {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
exports.PrivateKey = PrivateKey;
|
|
133
|
-
//# sourceMappingURL=ecdsa.js.map
|
|
@@ -31,13 +31,13 @@ class PrivateKey {
|
|
|
31
31
|
* @throws {@link InvalidSeedLengthError}
|
|
32
32
|
*/
|
|
33
33
|
static fromSeed(seedSrc) {
|
|
34
|
-
const seed = typeof seedSrc === 'string' ? utils_1.parseHex(seedSrc) : seedSrc;
|
|
34
|
+
const seed = typeof seedSrc === 'string' ? (0, utils_1.parseHex)(seedSrc) : seedSrc;
|
|
35
35
|
if (seed.length < minSeedSize || seed.length > maxSeedSize) {
|
|
36
36
|
throw new errors_1.InvalidSeedLengthError(seed.length);
|
|
37
37
|
}
|
|
38
38
|
const key = new TextEncoder().encode(ed25519Key);
|
|
39
39
|
const sum = new hmac_1.HMAC(sha512_1.SHA512, key).update(seed).digest();
|
|
40
|
-
return new PrivateKey(ed25519_1.generateKeyPairFromSeed(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
40
|
+
return new PrivateKey((0, ed25519_1.generateKeyPairFromSeed)(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
*
|
|
@@ -58,7 +58,7 @@ class PrivateKey {
|
|
|
58
58
|
data.set(this.seed(), 1);
|
|
59
59
|
new DataView(data.buffer).setUint32(33, index);
|
|
60
60
|
const sum = new hmac_1.HMAC(sha512_1.SHA512, this.chainCode).update(data).digest();
|
|
61
|
-
return new PrivateKey(ed25519_1.generateKeyPairFromSeed(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
61
|
+
return new PrivateKey((0, ed25519_1.generateKeyPairFromSeed)(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* @param path array of numbers pre adjusted for hardened paths ie: 44' -> 2^31 + 44
|
|
@@ -73,4 +73,3 @@ class PrivateKey {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
exports.PrivateKey = PrivateKey;
|
|
76
|
-
//# sourceMappingURL=ed25519.js.map
|
package/dist/lib/ec-key.js
CHANGED
|
@@ -45,17 +45,17 @@ class ECKey {
|
|
|
45
45
|
this.curve = curve;
|
|
46
46
|
this.key = key;
|
|
47
47
|
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
|
|
48
|
-
if (!utils_1.isValidPrefix(keyPrefix)) {
|
|
49
|
-
throw new core_1.InvalidKeyError(utils_1.invalidDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
48
|
+
if (!(0, utils_1.isValidPrefix)(keyPrefix)) {
|
|
49
|
+
throw new core_1.InvalidKeyError((0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
50
50
|
` expecting one of the following prefix '${utils_1.Prefix.SPSK}', '${utils_1.Prefix.SPESK}', '${utils_1.Prefix.P2SK}' or '${utils_1.Prefix.P2ESK}'.`);
|
|
51
51
|
}
|
|
52
|
-
this._key = decrypt(utils_1.b58cdecode(this.key, utils_1.prefix[keyPrefix]));
|
|
52
|
+
this._key = decrypt((0, utils_1.b58cdecode)(this.key, utils_1.prefix[keyPrefix]));
|
|
53
53
|
const keyPair = new elliptic_1.default.ec(this.curve).keyFromPrivate(this._key);
|
|
54
54
|
const keyPairY = keyPair.getPublic().getY().toArray();
|
|
55
55
|
const parityByte = keyPairY.length < 32 ? keyPairY[keyPairY.length - 1] : keyPairY[31];
|
|
56
56
|
const pref = parityByte % 2 ? 3 : 2;
|
|
57
57
|
const pad = new Array(32).fill(0);
|
|
58
|
-
this._publicKey = typedarray_to_buffer_1.default(new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32))));
|
|
58
|
+
this._publicKey = (0, typedarray_to_buffer_1.default)(new Uint8Array([pref].concat(pad.concat(keyPair.getPublic().getX().toArray()).slice(-32))));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
*
|
|
@@ -70,8 +70,8 @@ class ECKey {
|
|
|
70
70
|
const sbytes = bytes + signature;
|
|
71
71
|
return {
|
|
72
72
|
bytes,
|
|
73
|
-
sig: utils_1.b58cencode(signature, utils_1.prefix.sig),
|
|
74
|
-
prefixSig: utils_1.b58cencode(signature, pref[this.curve].sig),
|
|
73
|
+
sig: (0, utils_1.b58cencode)(signature, utils_1.prefix.sig),
|
|
74
|
+
prefixSig: (0, utils_1.b58cencode)(signature, pref[this.curve].sig),
|
|
75
75
|
sbytes,
|
|
76
76
|
};
|
|
77
77
|
});
|
|
@@ -81,7 +81,7 @@ class ECKey {
|
|
|
81
81
|
*/
|
|
82
82
|
publicKey() {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return utils_1.b58cencode(this._publicKey, pref[this.curve].pk);
|
|
84
|
+
return (0, utils_1.b58cencode)(this._publicKey, pref[this.curve].pk);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -89,7 +89,7 @@ class ECKey {
|
|
|
89
89
|
*/
|
|
90
90
|
publicKeyHash() {
|
|
91
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
return utils_1.b58cencode(blake2b_1.hash(new Uint8Array(this._publicKey), 20), pref[this.curve].pkh);
|
|
92
|
+
return (0, utils_1.b58cencode)((0, blake2b_1.hash)(new Uint8Array(this._publicKey), 20), pref[this.curve].pkh);
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
@@ -98,7 +98,7 @@ class ECKey {
|
|
|
98
98
|
secretKey() {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
100
|
const key = this._key;
|
|
101
|
-
return utils_1.b58cencode(key, pref[this.curve].sk);
|
|
101
|
+
return (0, utils_1.b58cencode)(key, pref[this.curve].sk);
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -111,4 +111,3 @@ exports.Tz3 = ECKey.bind(null, 'p256');
|
|
|
111
111
|
* @description Tz2 key class using the secp256k1 curve
|
|
112
112
|
*/
|
|
113
113
|
exports.Tz2 = ECKey.bind(null, 'secp256k1');
|
|
114
|
-
//# sourceMappingURL=ec-key.js.map
|
package/dist/lib/ed-key.js
CHANGED
|
@@ -29,10 +29,10 @@ class Tz1 {
|
|
|
29
29
|
constructor(key, encrypted, decrypt) {
|
|
30
30
|
this.key = key;
|
|
31
31
|
const keyPrefix = key.substring(0, encrypted ? 5 : 4);
|
|
32
|
-
if (!utils_1.isValidPrefix(keyPrefix)) {
|
|
33
|
-
throw new core_1.InvalidKeyError(`${utils_1.invalidDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting either '${utils_1.Prefix.EDESK}' or '${utils_1.Prefix.EDSK}'.`);
|
|
32
|
+
if (!(0, utils_1.isValidPrefix)(keyPrefix)) {
|
|
33
|
+
throw new core_1.InvalidKeyError(`${(0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting either '${utils_1.Prefix.EDESK}' or '${utils_1.Prefix.EDSK}'.`);
|
|
34
34
|
}
|
|
35
|
-
this._key = decrypt(utils_1.b58cdecode(this.key, utils_1.prefix[keyPrefix]));
|
|
35
|
+
this._key = decrypt((0, utils_1.b58cdecode)(this.key, utils_1.prefix[keyPrefix]));
|
|
36
36
|
this._publicKey = this._key.slice(32);
|
|
37
37
|
if (!this._key) {
|
|
38
38
|
throw new core_1.InvalidKeyError('unable to decode');
|
|
@@ -42,7 +42,7 @@ class Tz1 {
|
|
|
42
42
|
init() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
44
|
if (this._key.length !== 64) {
|
|
45
|
-
const { publicKey, secretKey } = ed25519_1.generateKeyPairFromSeed(new Uint8Array(this._key));
|
|
45
|
+
const { publicKey, secretKey } = (0, ed25519_1.generateKeyPairFromSeed)(new Uint8Array(this._key));
|
|
46
46
|
this._publicKey = publicKey;
|
|
47
47
|
this._key = secretKey;
|
|
48
48
|
}
|
|
@@ -57,13 +57,13 @@ class Tz1 {
|
|
|
57
57
|
sign(bytes, bytesHash) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
yield this.isInit;
|
|
60
|
-
const signature = ed25519_1.sign(new Uint8Array(this._key), new Uint8Array(bytesHash));
|
|
61
|
-
const signatureBuffer = typedarray_to_buffer_1.default(signature);
|
|
62
|
-
const sbytes = bytes + utils_1.buf2hex(signatureBuffer);
|
|
60
|
+
const signature = (0, ed25519_1.sign)(new Uint8Array(this._key), new Uint8Array(bytesHash));
|
|
61
|
+
const signatureBuffer = (0, typedarray_to_buffer_1.default)(signature);
|
|
62
|
+
const sbytes = bytes + (0, utils_1.buf2hex)(signatureBuffer);
|
|
63
63
|
return {
|
|
64
64
|
bytes,
|
|
65
|
-
sig: utils_1.b58cencode(signature, utils_1.prefix.sig),
|
|
66
|
-
prefixSig: utils_1.b58cencode(signature, utils_1.prefix.edsig),
|
|
65
|
+
sig: (0, utils_1.b58cencode)(signature, utils_1.prefix.sig),
|
|
66
|
+
prefixSig: (0, utils_1.b58cencode)(signature, utils_1.prefix.edsig),
|
|
67
67
|
sbytes,
|
|
68
68
|
};
|
|
69
69
|
});
|
|
@@ -74,7 +74,7 @@ class Tz1 {
|
|
|
74
74
|
publicKey() {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
yield this.isInit;
|
|
77
|
-
return utils_1.b58cencode(this._publicKey, utils_1.prefix['edpk']);
|
|
77
|
+
return (0, utils_1.b58cencode)(this._publicKey, utils_1.prefix['edpk']);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -83,7 +83,7 @@ class Tz1 {
|
|
|
83
83
|
publicKeyHash() {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
yield this.isInit;
|
|
86
|
-
return utils_1.b58cencode(blake2b_1.hash(new Uint8Array(this._publicKey), 20), utils_1.prefix.tz1);
|
|
86
|
+
return (0, utils_1.b58cencode)((0, blake2b_1.hash)(new Uint8Array(this._publicKey), 20), utils_1.prefix.tz1);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
@@ -93,11 +93,10 @@ class Tz1 {
|
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
94
|
yield this.isInit;
|
|
95
95
|
let key = this._key;
|
|
96
|
-
const { secretKey } = ed25519_1.generateKeyPairFromSeed(new Uint8Array(key).slice(0, 32));
|
|
97
|
-
key = typedarray_to_buffer_1.default(secretKey);
|
|
98
|
-
return utils_1.b58cencode(key, utils_1.prefix[`edsk`]);
|
|
96
|
+
const { secretKey } = (0, ed25519_1.generateKeyPairFromSeed)(new Uint8Array(key).slice(0, 32));
|
|
97
|
+
key = (0, typedarray_to_buffer_1.default)(secretKey);
|
|
98
|
+
return (0, utils_1.b58cencode)(key, utils_1.prefix[`edsk`]);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
exports.Tz1 = Tz1;
|
|
103
|
-
//# sourceMappingURL=ed-key.js.map
|
package/dist/lib/errors.js
CHANGED
package/dist/lib/helpers.js
CHANGED
|
@@ -21,7 +21,7 @@ const generateSecretKey = (seed, derivationPath, curve) => {
|
|
|
21
21
|
switch (curve) {
|
|
22
22
|
case 'ed25519': {
|
|
23
23
|
node = ed25519_1.PrivateKey.fromSeed(seed).derivePath(path);
|
|
24
|
-
const sk = utils_1.b58cencode(node.seed().slice(0, 32), utils_1.prefix.edsk2);
|
|
24
|
+
const sk = (0, utils_1.b58cencode)(node.seed().slice(0, 32), utils_1.prefix.edsk2);
|
|
25
25
|
return sk;
|
|
26
26
|
}
|
|
27
27
|
case 'secp256k1':
|
|
@@ -30,7 +30,7 @@ const generateSecretKey = (seed, derivationPath, curve) => {
|
|
|
30
30
|
let privKey = ecdsa_1.PrivateKey.fromSeed(seed, curve);
|
|
31
31
|
privKey = privKey.derivePath(path);
|
|
32
32
|
const uint8arr = new Uint8Array(privKey.keyPair.getPrivate().toArray());
|
|
33
|
-
const sk = utils_1.b58cencode(uint8arr, prefixType);
|
|
33
|
+
const sk = (0, utils_1.b58cencode)(uint8arr, prefixType);
|
|
34
34
|
return sk;
|
|
35
35
|
}
|
|
36
36
|
case 'bip25519': {
|
|
@@ -42,4 +42,3 @@ const generateSecretKey = (seed, derivationPath, curve) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
exports.generateSecretKey = generateSecretKey;
|
|
45
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/lib/import-key.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -49,6 +53,39 @@ Object.defineProperty(exports, "InvalidPassphraseError", { enumerable: true, get
|
|
|
49
53
|
* @throws {@link InvalidMnemonicError}
|
|
50
54
|
*/
|
|
51
55
|
class InMemorySigner {
|
|
56
|
+
static fromFundraiser(email, password, mnemonic) {
|
|
57
|
+
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
58
|
+
throw new errors_1.InvalidMnemonicError(mnemonic);
|
|
59
|
+
}
|
|
60
|
+
const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);
|
|
61
|
+
const key = (0, utils_1.b58cencode)(seed.slice(0, 32), utils_1.prefix.edsk2);
|
|
62
|
+
return new InMemorySigner(key);
|
|
63
|
+
}
|
|
64
|
+
static fromSecretKey(key, passphrase) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return new InMemorySigner(key, passphrase);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @description Instantiation of an InMemorySigner instance from a mnemonic
|
|
72
|
+
* @param mnemonic 12-24 word mnemonic
|
|
73
|
+
* @param password password used to encrypt the mnemonic to seed value
|
|
74
|
+
* @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
|
|
75
|
+
* @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
|
|
76
|
+
* @returns InMemorySigner
|
|
77
|
+
* @throws {@link InvalidMnemonicError}
|
|
78
|
+
*/
|
|
79
|
+
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
|
|
80
|
+
// check if curve is defined if not default tz1
|
|
81
|
+
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
82
|
+
// avoiding exposing mnemonic again in case of mistake making invalid
|
|
83
|
+
throw new errors_1.InvalidMnemonicError(mnemonic);
|
|
84
|
+
}
|
|
85
|
+
const seed = Bip39.mnemonicToSeedSync(mnemonic, password);
|
|
86
|
+
const sk = (0, helpers_1.generateSecretKey)(seed, derivationPath, curve);
|
|
87
|
+
return new InMemorySigner(sk);
|
|
88
|
+
}
|
|
52
89
|
/**
|
|
53
90
|
*
|
|
54
91
|
* @param key Encoded private key
|
|
@@ -64,10 +101,10 @@ class InMemorySigner {
|
|
|
64
101
|
throw new errors_1.InvalidPassphraseError('No passphrase provided to decrypt encrypted key');
|
|
65
102
|
}
|
|
66
103
|
decrypt = (constructedKey) => {
|
|
67
|
-
const salt = typedarray_to_buffer_1.default(constructedKey.slice(0, 8));
|
|
104
|
+
const salt = (0, typedarray_to_buffer_1.default)(constructedKey.slice(0, 8));
|
|
68
105
|
const encryptedSk = constructedKey.slice(8);
|
|
69
106
|
const encryptionKey = pbkdf2_1.default.pbkdf2Sync(passphrase, salt, 32768, 32, 'sha512');
|
|
70
|
-
return nacl_1.openSecretBox(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
|
|
107
|
+
return (0, nacl_1.openSecretBox)(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
|
|
71
108
|
};
|
|
72
109
|
}
|
|
73
110
|
switch (key.substring(0, 4)) {
|
|
@@ -84,42 +121,9 @@ class InMemorySigner {
|
|
|
84
121
|
this._key = new ec_key_1.Tz3(key, encrypted, decrypt);
|
|
85
122
|
break;
|
|
86
123
|
default:
|
|
87
|
-
throw new core_1.InvalidKeyError(`${utils_1.invalidDetail(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting one of the following '${utils_1.Prefix.EDESK}', '${utils_1.Prefix.EDSK}', '${utils_1.Prefix.SPSK}', '${utils_1.Prefix.SPESK}', '${utils_1.Prefix.P2SK}' or '${utils_1.Prefix.P2ESK}'.`);
|
|
124
|
+
throw new core_1.InvalidKeyError(`${(0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED)} expecting one of the following '${utils_1.Prefix.EDESK}', '${utils_1.Prefix.EDSK}', '${utils_1.Prefix.SPSK}', '${utils_1.Prefix.SPESK}', '${utils_1.Prefix.P2SK}' or '${utils_1.Prefix.P2ESK}'.`);
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
|
-
static fromFundraiser(email, password, mnemonic) {
|
|
91
|
-
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
92
|
-
throw new errors_1.InvalidMnemonicError(mnemonic);
|
|
93
|
-
}
|
|
94
|
-
const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);
|
|
95
|
-
const key = utils_1.b58cencode(seed.slice(0, 32), utils_1.prefix.edsk2);
|
|
96
|
-
return new InMemorySigner(key);
|
|
97
|
-
}
|
|
98
|
-
static fromSecretKey(key, passphrase) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
return new InMemorySigner(key, passphrase);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @description Instantiation of an InMemorySigner instance from a mnemonic
|
|
106
|
-
* @param mnemonic 12-24 word mnemonic
|
|
107
|
-
* @param password password used to encrypt the mnemonic to seed value
|
|
108
|
-
* @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
|
|
109
|
-
* @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
|
|
110
|
-
* @returns InMemorySigner
|
|
111
|
-
* @throws {@link InvalidMnemonicError}
|
|
112
|
-
*/
|
|
113
|
-
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
|
|
114
|
-
// check if curve is defined if not default tz1
|
|
115
|
-
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
116
|
-
// avoiding exposing mnemonic again in case of mistake making invalid
|
|
117
|
-
throw new errors_1.InvalidMnemonicError(mnemonic);
|
|
118
|
-
}
|
|
119
|
-
const seed = Bip39.mnemonicToSeedSync(mnemonic, password);
|
|
120
|
-
const sk = helpers_1.generateSecretKey(seed, derivationPath, curve);
|
|
121
|
-
return new InMemorySigner(sk);
|
|
122
|
-
}
|
|
123
127
|
/**
|
|
124
128
|
*
|
|
125
129
|
* @param bytes Bytes to sign
|
|
@@ -127,11 +131,11 @@ class InMemorySigner {
|
|
|
127
131
|
*/
|
|
128
132
|
sign(bytes, watermark) {
|
|
129
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
let bb = utils_1.hex2buf(bytes);
|
|
134
|
+
let bb = (0, utils_1.hex2buf)(bytes);
|
|
131
135
|
if (typeof watermark !== 'undefined') {
|
|
132
|
-
bb = utils_1.mergebuf(watermark, bb);
|
|
136
|
+
bb = (0, utils_1.mergebuf)(watermark, bb);
|
|
133
137
|
}
|
|
134
|
-
const bytesHash = blake2b_1.hash(bb, 32);
|
|
138
|
+
const bytesHash = (0, blake2b_1.hash)(bb, 32);
|
|
135
139
|
return this._key.sign(bytes, bytesHash);
|
|
136
140
|
});
|
|
137
141
|
}
|
|
@@ -161,4 +165,3 @@ class InMemorySigner {
|
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
exports.InMemorySigner = InMemorySigner;
|
|
164
|
-
//# sourceMappingURL=taquito-signer.js.map
|
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,6 @@ 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": "
|
|
7
|
-
"version": "17.
|
|
6
|
+
"commitHash": "a908ab176a8c52c025fd43e7acd452415396f54e",
|
|
7
|
+
"version": "17.4.0"
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=version.js.map
|