@taquito/signer 24.2.0 → 24.3.0-beta.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 +2 -2
- package/dist/lib/derivation-tools/ed25519.js +2 -2
- package/dist/lib/ec-key.js +2 -2
- package/dist/lib/ed-key.js +2 -2
- package/dist/lib/errors.js +8 -9
- package/dist/lib/helpers.js +1 -1
- package/dist/lib/in-memory-signer.js +31 -51
- package/dist/lib/version.js +2 -2
- package/dist/taquito-signer.es6.js +50 -72
- package/dist/taquito-signer.es6.js.map +1 -1
- package/dist/taquito-signer.umd.js +50 -72
- package/dist/taquito-signer.umd.js.map +1 -1
- package/dist/types/derivation-tools/ecdsa.d.ts +2 -2
- package/dist/types/derivation-tools/ed25519.d.ts +2 -2
- package/dist/types/ec-key.d.ts +2 -2
- package/dist/types/ed-key.d.ts +2 -2
- package/dist/types/errors.d.ts +11 -8
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/in-memory-signer.d.ts +7 -11
- package/dist/types/key-interface.d.ts +7 -7
- package/package.json +23 -11
- package/LICENSE +0 -202
|
@@ -43,7 +43,7 @@ class PrivateKey {
|
|
|
43
43
|
* @param seedSrc result of Bip39.mnemonicToSeed
|
|
44
44
|
* @param curve known supported curve p256 or secp256k1
|
|
45
45
|
* @returns instance of PrivateKey non-HD keys derived
|
|
46
|
-
* @throws
|
|
46
|
+
* @throws InvalidBitSize | InvalidCurveError | InvalidSeedLengthError
|
|
47
47
|
*/
|
|
48
48
|
static fromSeed(seedSrc, curve) {
|
|
49
49
|
let seed = typeof seedSrc === 'string' ? (0, utils_1.parseHex)(seedSrc) : seedSrc;
|
|
@@ -137,7 +137,7 @@ class PrivateKey {
|
|
|
137
137
|
/**
|
|
138
138
|
*
|
|
139
139
|
* @returns Uint8Array (if contains a private key)
|
|
140
|
-
* @throws
|
|
140
|
+
* @throws InvalidKeyError
|
|
141
141
|
*/
|
|
142
142
|
bytes() {
|
|
143
143
|
if (!this.keyPair.secretKey) {
|
|
@@ -28,7 +28,7 @@ class PrivateKey {
|
|
|
28
28
|
*
|
|
29
29
|
* @param seedSrc result of Bip39.mnemonicToSeed
|
|
30
30
|
* @returns instance of PrivateKey
|
|
31
|
-
* @throws
|
|
31
|
+
* @throws InvalidSeedLengthError
|
|
32
32
|
*/
|
|
33
33
|
static fromSeed(seedSrc) {
|
|
34
34
|
const seed = typeof seedSrc === 'string' ? (0, utils_1.parseHex)(seedSrc) : seedSrc;
|
|
@@ -47,7 +47,7 @@ class PrivateKey {
|
|
|
47
47
|
return this.priv.subarray(0, 32);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
|
|
50
|
+
\* @remarks index: current derivation path item ie: 1729'
|
|
51
51
|
* @returns derivation path child of original private key pair
|
|
52
52
|
*/
|
|
53
53
|
derive(index) {
|
package/dist/lib/ec-key.js
CHANGED
|
@@ -35,14 +35,14 @@ const pref = {
|
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Provide signing logic for elliptic curve based key (tz2, tz3)
|
|
39
39
|
*/
|
|
40
40
|
class ECKey {
|
|
41
41
|
/**
|
|
42
42
|
*
|
|
43
43
|
* @param key Encoded private key
|
|
44
44
|
* @param decrypt Decrypt function
|
|
45
|
-
* @throws
|
|
45
|
+
* @throws InvalidKeyError
|
|
46
46
|
*/
|
|
47
47
|
constructor(key, decrypt) {
|
|
48
48
|
_ECKey_keyPair.set(this, void 0);
|
package/dist/lib/ed-key.js
CHANGED
|
@@ -17,7 +17,7 @@ const blake2b_1 = require("@stablelib/blake2b");
|
|
|
17
17
|
const ed25519_1 = require("@stablelib/ed25519");
|
|
18
18
|
const utils_1 = require("@taquito/utils");
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Provide signing logic for ed25519 curve based key (tz1)
|
|
21
21
|
*/
|
|
22
22
|
class EdKey {
|
|
23
23
|
/**
|
|
@@ -25,7 +25,7 @@ class EdKey {
|
|
|
25
25
|
* @param key Encoded private key
|
|
26
26
|
* @param encrypted Is the private key encrypted
|
|
27
27
|
* @param decrypt Decrypt function
|
|
28
|
-
* @throws
|
|
28
|
+
* @throws InvalidKeyError
|
|
29
29
|
*/
|
|
30
30
|
constructor(key, decrypt) {
|
|
31
31
|
_EdKey_keyPair.set(this, void 0);
|
package/dist/lib/errors.js
CHANGED
|
@@ -4,20 +4,19 @@ exports.InvalidPassphraseError = exports.ToBeImplemented = exports.InvalidSeedLe
|
|
|
4
4
|
const core_1 = require("@taquito/core");
|
|
5
5
|
/**
|
|
6
6
|
* @category Error
|
|
7
|
-
*
|
|
7
|
+
* Error that indicates an invalid Mnemonic being passed or used
|
|
8
8
|
*/
|
|
9
9
|
class InvalidMnemonicError extends core_1.ParameterValidationError {
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(_mnemonic) {
|
|
11
11
|
super();
|
|
12
|
-
this.mnemonic = mnemonic;
|
|
13
12
|
this.name = 'InvalidMnemonicError';
|
|
14
|
-
this.message =
|
|
13
|
+
this.message = 'Invalid mnemonic';
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
exports.InvalidMnemonicError = InvalidMnemonicError;
|
|
18
17
|
/**
|
|
19
18
|
* @category Error
|
|
20
|
-
*
|
|
19
|
+
* Error that indicates a curve with incorrect bit size being passed or used
|
|
21
20
|
*/
|
|
22
21
|
class InvalidBitSize extends core_1.ParameterValidationError {
|
|
23
22
|
constructor(message) {
|
|
@@ -29,7 +28,7 @@ class InvalidBitSize extends core_1.ParameterValidationError {
|
|
|
29
28
|
exports.InvalidBitSize = InvalidBitSize;
|
|
30
29
|
/**
|
|
31
30
|
* @category Error
|
|
32
|
-
*
|
|
31
|
+
* Error that indicates an unsupported cureve being passed or used
|
|
33
32
|
*/
|
|
34
33
|
class InvalidCurveError extends core_1.ParameterValidationError {
|
|
35
34
|
constructor(message) {
|
|
@@ -41,7 +40,7 @@ class InvalidCurveError extends core_1.ParameterValidationError {
|
|
|
41
40
|
exports.InvalidCurveError = InvalidCurveError;
|
|
42
41
|
/**
|
|
43
42
|
* @category Error
|
|
44
|
-
*
|
|
43
|
+
* Error that indicates a seed with invalid length being passed or used
|
|
45
44
|
*/
|
|
46
45
|
class InvalidSeedLengthError extends core_1.ParameterValidationError {
|
|
47
46
|
constructor(seedLength) {
|
|
@@ -54,7 +53,7 @@ class InvalidSeedLengthError extends core_1.ParameterValidationError {
|
|
|
54
53
|
exports.InvalidSeedLengthError = InvalidSeedLengthError;
|
|
55
54
|
/**
|
|
56
55
|
* @category Error
|
|
57
|
-
*
|
|
56
|
+
* Error that indicates a feature still under developement
|
|
58
57
|
*/
|
|
59
58
|
class ToBeImplemented extends core_1.UnsupportedActionError {
|
|
60
59
|
constructor() {
|
|
@@ -66,7 +65,7 @@ class ToBeImplemented extends core_1.UnsupportedActionError {
|
|
|
66
65
|
exports.ToBeImplemented = ToBeImplemented;
|
|
67
66
|
/**
|
|
68
67
|
* @category Error
|
|
69
|
-
*
|
|
68
|
+
* Error that indicates an invalid passphrase being passed or used
|
|
70
69
|
*/
|
|
71
70
|
class InvalidPassphraseError extends core_1.ParameterValidationError {
|
|
72
71
|
constructor(message) {
|
package/dist/lib/helpers.js
CHANGED
|
@@ -13,7 +13,7 @@ const errors_1 = require("./errors");
|
|
|
13
13
|
* @param derivationPath Tezos Requirement 44'/1729' for HD key address default 44'/1729'/0'/0'
|
|
14
14
|
* @param curve 'ed25519' | 'secp256k1' | 'p256''
|
|
15
15
|
* @returns final Derivation of HD keys tezos Secret key
|
|
16
|
-
* @throws
|
|
16
|
+
* @throws InvalidCurveError | ToBeImplemented
|
|
17
17
|
*/
|
|
18
18
|
const generateSecretKey = (seed, derivationPath, curve) => {
|
|
19
19
|
const path = derivation_tools_1.Path.fromString(derivationPath);
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
3
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
4
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -36,40 +27,33 @@ const core_1 = require("@taquito/core");
|
|
|
36
27
|
const key_interface_1 = require("./key-interface");
|
|
37
28
|
const bls_key_1 = require("./bls-key");
|
|
38
29
|
/**
|
|
39
|
-
*
|
|
30
|
+
* A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
|
|
40
31
|
*
|
|
41
|
-
* @
|
|
42
|
-
* @throws
|
|
32
|
+
* @remarks 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
|
|
33
|
+
* @throws InvalidMnemonicError
|
|
43
34
|
*/
|
|
44
35
|
class InMemorySigner {
|
|
45
36
|
static fromFundraiser(email, password, mnemonic) {
|
|
46
37
|
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
47
|
-
throw new errors_1.InvalidMnemonicError(
|
|
38
|
+
throw new errors_1.InvalidMnemonicError();
|
|
48
39
|
}
|
|
49
40
|
const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);
|
|
50
41
|
const key = (0, utils_1.b58Encode)(seed.subarray(0, 32), utils_1.PrefixV2.Ed25519Seed);
|
|
51
42
|
return new InMemorySigner(key);
|
|
52
43
|
}
|
|
53
|
-
static fromSecretKey(key, passphrase) {
|
|
54
|
-
return
|
|
55
|
-
return new InMemorySigner(key, passphrase);
|
|
56
|
-
});
|
|
44
|
+
static async fromSecretKey(key, passphrase) {
|
|
45
|
+
return new InMemorySigner(key, passphrase);
|
|
57
46
|
}
|
|
58
47
|
/**
|
|
59
48
|
*
|
|
60
|
-
*
|
|
61
|
-
* @param mnemonic 12-24 word mnemonic
|
|
62
|
-
* @param password password used to encrypt the mnemonic to seed value
|
|
63
|
-
* @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
|
|
64
|
-
* @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
|
|
49
|
+
* Instantiation of an InMemorySigner instance from a mnemonic
|
|
65
50
|
* @returns InMemorySigner
|
|
66
|
-
* @throws
|
|
51
|
+
* @throws InvalidMnemonicError
|
|
67
52
|
*/
|
|
68
53
|
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
|
|
69
54
|
// check if curve is defined if not default tz1
|
|
70
55
|
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
71
|
-
|
|
72
|
-
throw new errors_1.InvalidMnemonicError(mnemonic);
|
|
56
|
+
throw new errors_1.InvalidMnemonicError();
|
|
73
57
|
}
|
|
74
58
|
const seed = Bip39.mnemonicToSeedSync(mnemonic, password);
|
|
75
59
|
const sk = (0, helpers_1.generateSecretKey)(seed, derivationPath, curve);
|
|
@@ -79,7 +63,7 @@ class InMemorySigner {
|
|
|
79
63
|
*
|
|
80
64
|
* @param key Encoded private key
|
|
81
65
|
* @param passphrase Passphrase to decrypt the private key if it is encrypted
|
|
82
|
-
* @throws
|
|
66
|
+
* @throws InvalidKeyError
|
|
83
67
|
*
|
|
84
68
|
*/
|
|
85
69
|
constructor(key, passphrase) {
|
|
@@ -100,7 +84,7 @@ class InMemorySigner {
|
|
|
100
84
|
const [, pre] = (0, utils_1.b58DecodeAndCheckPrefix)(key, keyPrefixes);
|
|
101
85
|
return pre;
|
|
102
86
|
}
|
|
103
|
-
catch
|
|
87
|
+
catch {
|
|
104
88
|
throw new core_1.InvalidKeyError(`Invalid private key, expecting one of the following prefixes '${keyPrefixes}'.`);
|
|
105
89
|
}
|
|
106
90
|
})();
|
|
@@ -149,33 +133,29 @@ class InMemorySigner {
|
|
|
149
133
|
}
|
|
150
134
|
/**
|
|
151
135
|
*
|
|
152
|
-
* @param
|
|
136
|
+
* @param message Bytes to sign
|
|
153
137
|
* @param watermark Watermark to append to the bytes
|
|
154
138
|
*/
|
|
155
|
-
sign(message, watermark) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
};
|
|
168
|
-
});
|
|
139
|
+
async sign(message, watermark) {
|
|
140
|
+
const msg = typeof message == 'string' ? (0, utils_1.hex2buf)(message) : message;
|
|
141
|
+
const watermarkMsg = watermark !== undefined ? (0, utils_1.mergebuf)(watermark, msg) : msg;
|
|
142
|
+
const { rawSignature, sig: signature, prefixSig: prefixedSignature, } = await __classPrivateFieldGet(this, _InMemorySigner_key, "f").sign(watermarkMsg);
|
|
143
|
+
return {
|
|
144
|
+
bytes: (0, utils_1.buf2hex)(msg),
|
|
145
|
+
sig: signature,
|
|
146
|
+
prefixSig: prefixedSignature,
|
|
147
|
+
sbytes: (0, utils_1.buf2hex)((0, utils_1.mergebuf)(msg,
|
|
148
|
+
// bls only Signature_prefix ff03 ref:https://octez.tezos.com/docs/shell/p2p_api.html#signature-prefix-tag-255 & https://octez.tezos.com/docs/shell/p2p_api.html#bls-prefix-tag-3
|
|
149
|
+
(0, key_interface_1.isPOP)(__classPrivateFieldGet(this, _InMemorySigner_key, "f")) ? (0, utils_1.mergebuf)(new Uint8Array([255, 3]), rawSignature) : rawSignature)),
|
|
150
|
+
};
|
|
169
151
|
}
|
|
170
|
-
provePossession() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
});
|
|
152
|
+
async provePossession() {
|
|
153
|
+
if ((0, key_interface_1.isPOP)(__classPrivateFieldGet(this, _InMemorySigner_key, "f"))) {
|
|
154
|
+
return __classPrivateFieldGet(this, _InMemorySigner_key, "f").provePossession();
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
throw new core_1.ProhibitedActionError('Only BLS keys can prove possession');
|
|
158
|
+
}
|
|
179
159
|
}
|
|
180
160
|
get canProvePossession() {
|
|
181
161
|
return (0, key_interface_1.isPOP)(__classPrivateFieldGet(this, _InMemorySigner_key, "f"));
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +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!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.
|
|
6
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
7
|
+
"version": "24.3.0-beta.0"
|
|
8
8
|
};
|
|
@@ -31,16 +31,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
31
31
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
35
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
45
35
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
46
36
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
@@ -61,7 +51,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
61
51
|
|
|
62
52
|
var _EdKey_keyPair, _EdPublicKey_key;
|
|
63
53
|
/**
|
|
64
|
-
*
|
|
54
|
+
* Provide signing logic for ed25519 curve based key (tz1)
|
|
65
55
|
*/
|
|
66
56
|
class EdKey {
|
|
67
57
|
/**
|
|
@@ -69,7 +59,7 @@ class EdKey {
|
|
|
69
59
|
* @param key Encoded private key
|
|
70
60
|
* @param encrypted Is the private key encrypted
|
|
71
61
|
* @param decrypt Decrypt function
|
|
72
|
-
* @throws
|
|
62
|
+
* @throws InvalidKeyError
|
|
73
63
|
*/
|
|
74
64
|
constructor(key, decrypt) {
|
|
75
65
|
_EdKey_keyPair.set(this, void 0);
|
|
@@ -165,19 +155,18 @@ _EdPublicKey_key = new WeakMap();
|
|
|
165
155
|
|
|
166
156
|
/**
|
|
167
157
|
* @category Error
|
|
168
|
-
*
|
|
158
|
+
* Error that indicates an invalid Mnemonic being passed or used
|
|
169
159
|
*/
|
|
170
160
|
class InvalidMnemonicError extends ParameterValidationError {
|
|
171
|
-
constructor(
|
|
161
|
+
constructor(_mnemonic) {
|
|
172
162
|
super();
|
|
173
|
-
this.mnemonic = mnemonic;
|
|
174
163
|
this.name = 'InvalidMnemonicError';
|
|
175
|
-
this.message =
|
|
164
|
+
this.message = 'Invalid mnemonic';
|
|
176
165
|
}
|
|
177
166
|
}
|
|
178
167
|
/**
|
|
179
168
|
* @category Error
|
|
180
|
-
*
|
|
169
|
+
* Error that indicates a curve with incorrect bit size being passed or used
|
|
181
170
|
*/
|
|
182
171
|
class InvalidBitSize extends ParameterValidationError {
|
|
183
172
|
constructor(message) {
|
|
@@ -188,7 +177,7 @@ class InvalidBitSize extends ParameterValidationError {
|
|
|
188
177
|
}
|
|
189
178
|
/**
|
|
190
179
|
* @category Error
|
|
191
|
-
*
|
|
180
|
+
* Error that indicates an unsupported cureve being passed or used
|
|
192
181
|
*/
|
|
193
182
|
class InvalidCurveError extends ParameterValidationError {
|
|
194
183
|
constructor(message) {
|
|
@@ -199,7 +188,7 @@ class InvalidCurveError extends ParameterValidationError {
|
|
|
199
188
|
}
|
|
200
189
|
/**
|
|
201
190
|
* @category Error
|
|
202
|
-
*
|
|
191
|
+
* Error that indicates a seed with invalid length being passed or used
|
|
203
192
|
*/
|
|
204
193
|
class InvalidSeedLengthError extends ParameterValidationError {
|
|
205
194
|
constructor(seedLength) {
|
|
@@ -211,7 +200,7 @@ class InvalidSeedLengthError extends ParameterValidationError {
|
|
|
211
200
|
}
|
|
212
201
|
/**
|
|
213
202
|
* @category Error
|
|
214
|
-
*
|
|
203
|
+
* Error that indicates a feature still under developement
|
|
215
204
|
*/
|
|
216
205
|
class ToBeImplemented extends UnsupportedActionError {
|
|
217
206
|
constructor() {
|
|
@@ -222,7 +211,7 @@ class ToBeImplemented extends UnsupportedActionError {
|
|
|
222
211
|
}
|
|
223
212
|
/**
|
|
224
213
|
* @category Error
|
|
225
|
-
*
|
|
214
|
+
* Error that indicates an invalid passphrase being passed or used
|
|
226
215
|
*/
|
|
227
216
|
class InvalidPassphraseError extends ParameterValidationError {
|
|
228
217
|
constructor(message) {
|
|
@@ -250,14 +239,14 @@ const pref = {
|
|
|
250
239
|
},
|
|
251
240
|
};
|
|
252
241
|
/**
|
|
253
|
-
*
|
|
242
|
+
* Provide signing logic for elliptic curve based key (tz2, tz3)
|
|
254
243
|
*/
|
|
255
244
|
class ECKey {
|
|
256
245
|
/**
|
|
257
246
|
*
|
|
258
247
|
* @param key Encoded private key
|
|
259
248
|
* @param decrypt Decrypt function
|
|
260
|
-
* @throws
|
|
249
|
+
* @throws InvalidKeyError
|
|
261
250
|
*/
|
|
262
251
|
constructor(key, decrypt) {
|
|
263
252
|
_ECKey_keyPair.set(this, void 0);
|
|
@@ -443,7 +432,7 @@ let PrivateKey$1 = class PrivateKey {
|
|
|
443
432
|
*
|
|
444
433
|
* @param seedSrc result of Bip39.mnemonicToSeed
|
|
445
434
|
* @returns instance of PrivateKey
|
|
446
|
-
* @throws
|
|
435
|
+
* @throws InvalidSeedLengthError
|
|
447
436
|
*/
|
|
448
437
|
static fromSeed(seedSrc) {
|
|
449
438
|
const seed = typeof seedSrc === 'string' ? parseHex(seedSrc) : seedSrc;
|
|
@@ -462,7 +451,7 @@ let PrivateKey$1 = class PrivateKey {
|
|
|
462
451
|
return this.priv.subarray(0, 32);
|
|
463
452
|
}
|
|
464
453
|
/**
|
|
465
|
-
|
|
454
|
+
\* @remarks index: current derivation path item ie: 1729'
|
|
466
455
|
* @returns derivation path child of original private key pair
|
|
467
456
|
*/
|
|
468
457
|
derive(index) {
|
|
@@ -526,7 +515,7 @@ class PrivateKey {
|
|
|
526
515
|
* @param seedSrc result of Bip39.mnemonicToSeed
|
|
527
516
|
* @param curve known supported curve p256 or secp256k1
|
|
528
517
|
* @returns instance of PrivateKey non-HD keys derived
|
|
529
|
-
* @throws
|
|
518
|
+
* @throws InvalidBitSize | InvalidCurveError | InvalidSeedLengthError
|
|
530
519
|
*/
|
|
531
520
|
static fromSeed(seedSrc, curve) {
|
|
532
521
|
let seed = typeof seedSrc === 'string' ? parseHex(seedSrc) : seedSrc;
|
|
@@ -620,7 +609,7 @@ class PrivateKey {
|
|
|
620
609
|
/**
|
|
621
610
|
*
|
|
622
611
|
* @returns Uint8Array (if contains a private key)
|
|
623
|
-
* @throws
|
|
612
|
+
* @throws InvalidKeyError
|
|
624
613
|
*/
|
|
625
614
|
bytes() {
|
|
626
615
|
if (!this.keyPair.secretKey) {
|
|
@@ -681,7 +670,7 @@ class Path extends Array {
|
|
|
681
670
|
* @param derivationPath Tezos Requirement 44'/1729' for HD key address default 44'/1729'/0'/0'
|
|
682
671
|
* @param curve 'ed25519' | 'secp256k1' | 'p256''
|
|
683
672
|
* @returns final Derivation of HD keys tezos Secret key
|
|
684
|
-
* @throws
|
|
673
|
+
* @throws InvalidCurveError | ToBeImplemented
|
|
685
674
|
*/
|
|
686
675
|
const generateSecretKey = (seed, derivationPath, curve) => {
|
|
687
676
|
const path = Path.fromString(derivationPath);
|
|
@@ -802,40 +791,33 @@ _BLSPublicKey_key = new WeakMap();
|
|
|
802
791
|
|
|
803
792
|
var _InMemorySigner_key;
|
|
804
793
|
/**
|
|
805
|
-
*
|
|
794
|
+
* A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
|
|
806
795
|
*
|
|
807
|
-
* @
|
|
808
|
-
* @throws
|
|
796
|
+
* @remarks 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
|
|
797
|
+
* @throws InvalidMnemonicError
|
|
809
798
|
*/
|
|
810
799
|
class InMemorySigner {
|
|
811
800
|
static fromFundraiser(email, password, mnemonic) {
|
|
812
801
|
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
813
|
-
throw new InvalidMnemonicError(
|
|
802
|
+
throw new InvalidMnemonicError();
|
|
814
803
|
}
|
|
815
804
|
const seed = Bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);
|
|
816
805
|
const key = b58Encode(seed.subarray(0, 32), PrefixV2.Ed25519Seed);
|
|
817
806
|
return new InMemorySigner(key);
|
|
818
807
|
}
|
|
819
|
-
static fromSecretKey(key, passphrase) {
|
|
820
|
-
return
|
|
821
|
-
return new InMemorySigner(key, passphrase);
|
|
822
|
-
});
|
|
808
|
+
static async fromSecretKey(key, passphrase) {
|
|
809
|
+
return new InMemorySigner(key, passphrase);
|
|
823
810
|
}
|
|
824
811
|
/**
|
|
825
812
|
*
|
|
826
|
-
*
|
|
827
|
-
* @param mnemonic 12-24 word mnemonic
|
|
828
|
-
* @param password password used to encrypt the mnemonic to seed value
|
|
829
|
-
* @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
|
|
830
|
-
* @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
|
|
813
|
+
* Instantiation of an InMemorySigner instance from a mnemonic
|
|
831
814
|
* @returns InMemorySigner
|
|
832
|
-
* @throws
|
|
815
|
+
* @throws InvalidMnemonicError
|
|
833
816
|
*/
|
|
834
817
|
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
|
|
835
818
|
// check if curve is defined if not default tz1
|
|
836
819
|
if (!Bip39.validateMnemonic(mnemonic)) {
|
|
837
|
-
|
|
838
|
-
throw new InvalidMnemonicError(mnemonic);
|
|
820
|
+
throw new InvalidMnemonicError();
|
|
839
821
|
}
|
|
840
822
|
const seed = Bip39.mnemonicToSeedSync(mnemonic, password);
|
|
841
823
|
const sk = generateSecretKey(seed, derivationPath, curve);
|
|
@@ -845,7 +827,7 @@ class InMemorySigner {
|
|
|
845
827
|
*
|
|
846
828
|
* @param key Encoded private key
|
|
847
829
|
* @param passphrase Passphrase to decrypt the private key if it is encrypted
|
|
848
|
-
* @throws
|
|
830
|
+
* @throws InvalidKeyError
|
|
849
831
|
*
|
|
850
832
|
*/
|
|
851
833
|
constructor(key, passphrase) {
|
|
@@ -866,7 +848,7 @@ class InMemorySigner {
|
|
|
866
848
|
const [, pre] = b58DecodeAndCheckPrefix(key, keyPrefixes);
|
|
867
849
|
return pre;
|
|
868
850
|
}
|
|
869
|
-
catch
|
|
851
|
+
catch {
|
|
870
852
|
throw new InvalidKeyError(`Invalid private key, expecting one of the following prefixes '${keyPrefixes}'.`);
|
|
871
853
|
}
|
|
872
854
|
})();
|
|
@@ -915,33 +897,29 @@ class InMemorySigner {
|
|
|
915
897
|
}
|
|
916
898
|
/**
|
|
917
899
|
*
|
|
918
|
-
* @param
|
|
900
|
+
* @param message Bytes to sign
|
|
919
901
|
* @param watermark Watermark to append to the bytes
|
|
920
902
|
*/
|
|
921
|
-
sign(message, watermark) {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
};
|
|
934
|
-
});
|
|
903
|
+
async sign(message, watermark) {
|
|
904
|
+
const msg = typeof message == 'string' ? hex2buf(message) : message;
|
|
905
|
+
const watermarkMsg = watermark !== undefined ? mergebuf(watermark, msg) : msg;
|
|
906
|
+
const { rawSignature, sig: signature, prefixSig: prefixedSignature, } = await __classPrivateFieldGet(this, _InMemorySigner_key, "f").sign(watermarkMsg);
|
|
907
|
+
return {
|
|
908
|
+
bytes: buf2hex(msg),
|
|
909
|
+
sig: signature,
|
|
910
|
+
prefixSig: prefixedSignature,
|
|
911
|
+
sbytes: buf2hex(mergebuf(msg,
|
|
912
|
+
// bls only Signature_prefix ff03 ref:https://octez.tezos.com/docs/shell/p2p_api.html#signature-prefix-tag-255 & https://octez.tezos.com/docs/shell/p2p_api.html#bls-prefix-tag-3
|
|
913
|
+
isPOP(__classPrivateFieldGet(this, _InMemorySigner_key, "f")) ? mergebuf(new Uint8Array([255, 3]), rawSignature) : rawSignature)),
|
|
914
|
+
};
|
|
935
915
|
}
|
|
936
|
-
provePossession() {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
944
|
-
});
|
|
916
|
+
async provePossession() {
|
|
917
|
+
if (isPOP(__classPrivateFieldGet(this, _InMemorySigner_key, "f"))) {
|
|
918
|
+
return __classPrivateFieldGet(this, _InMemorySigner_key, "f").provePossession();
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
throw new ProhibitedActionError('Only BLS keys can prove possession');
|
|
922
|
+
}
|
|
945
923
|
}
|
|
946
924
|
get canProvePossession() {
|
|
947
925
|
return isPOP(__classPrivateFieldGet(this, _InMemorySigner_key, "f"));
|
|
@@ -987,8 +965,8 @@ function publicKeyFromString(src) {
|
|
|
987
965
|
|
|
988
966
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
989
967
|
const VERSION = {
|
|
990
|
-
"commitHash": "
|
|
991
|
-
"version": "24.
|
|
968
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
969
|
+
"version": "24.3.0-beta.0"
|
|
992
970
|
};
|
|
993
971
|
|
|
994
972
|
export { ecdsa as ECDSA, ed25519 as Ed25519, Hard, InMemorySigner, InvalidPassphraseError, Path, VERSION, generateSecretKey, publicKeyFromString };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-signer.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taquito-signer.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|