@taquito/signer 24.3.0-beta.1 → 24.3.0-beta.2
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/bls-key.js +2 -2
- package/dist/lib/derivation-tools/ecdsa.js +4 -4
- package/dist/lib/derivation-tools/ed25519.js +14 -7
- package/dist/lib/ec-key.js +3 -3
- package/dist/lib/ed-key.js +14 -6
- package/dist/lib/in-memory-signer.js +10 -7
- package/dist/lib/version.js +2 -2
- package/dist/taquito-signer.es6.js +3565 -26
- package/dist/taquito-signer.es6.js.map +1 -1
- package/dist/taquito-signer.umd.js +3662 -137
- package/dist/taquito-signer.umd.js.map +1 -1
- package/dist/types/node_modules/@scure/base/index.d.ts +293 -0
- package/package.json +12 -41
package/dist/lib/bls-key.js
CHANGED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.BLSPublicKey = exports.BLSKey = void 0;
|
|
16
16
|
const utils_1 = require("@taquito/utils");
|
|
17
17
|
const bls12_381_1 = require("@noble/curves/bls12-381");
|
|
18
|
-
const
|
|
18
|
+
const blake2_js_1 = require("@noble/hashes/blake2.js");
|
|
19
19
|
const bls = bls12_381_1.bls12_381.longSignatures; // AKA MinPK
|
|
20
20
|
class BLSKey {
|
|
21
21
|
constructor(key, decrypt) {
|
|
@@ -85,7 +85,7 @@ class BLSPublicKey {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
hash() {
|
|
88
|
-
return (0, utils_1.b58Encode)((0,
|
|
88
|
+
return (0, utils_1.b58Encode)((0, blake2_js_1.blake2b)(__classPrivateFieldGet(this, _BLSPublicKey_key, "f"), { dkLen: 20 }), utils_1.PrefixV2.BLS12_381PublicKeyHash);
|
|
89
89
|
}
|
|
90
90
|
bytes() {
|
|
91
91
|
return __classPrivateFieldGet(this, _BLSPublicKey_key, "f");
|
|
@@ -5,8 +5,8 @@ exports.PrivateKey = void 0;
|
|
|
5
5
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
6
6
|
const nist_1 = require("@noble/curves/nist");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const hmac_js_1 = require("@noble/hashes/hmac.js");
|
|
9
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
10
10
|
const bn_js_1 = require("bn.js");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
12
|
const errors_1 = require("../errors");
|
|
@@ -69,7 +69,7 @@ class PrivateKey {
|
|
|
69
69
|
let chain = new Uint8Array();
|
|
70
70
|
let i = 0;
|
|
71
71
|
while (i === 0) {
|
|
72
|
-
const sum =
|
|
72
|
+
const sum = (0, hmac_js_1.hmac)(sha2_js_1.sha512, key, seed);
|
|
73
73
|
d = new bn_js_1.default(sum.subarray(0, 32));
|
|
74
74
|
chain = sum.subarray(32);
|
|
75
75
|
if (d.isZero() || d.cmp(curveOrder) >= 0) {
|
|
@@ -100,7 +100,7 @@ class PrivateKey {
|
|
|
100
100
|
let chain = new Uint8Array();
|
|
101
101
|
let i = 0;
|
|
102
102
|
while (i === 0) {
|
|
103
|
-
const sum =
|
|
103
|
+
const sum = (0, hmac_js_1.hmac)(sha2_js_1.sha512, this.chainCode, data);
|
|
104
104
|
d = new bn_js_1.default(sum.subarray(0, 32));
|
|
105
105
|
chain = sum.subarray(32);
|
|
106
106
|
// Get curve order for comparison
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PrivateKey = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const ed25519_1 = require("@
|
|
5
|
+
const hmac_js_1 = require("@noble/hashes/hmac.js");
|
|
6
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
7
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
const errors_1 = require("../errors");
|
|
11
11
|
const core_1 = require("@taquito/core");
|
|
12
|
+
function generateKeyPairFromSeed(seed) {
|
|
13
|
+
const publicKey = ed25519_1.ed25519.getPublicKey(seed);
|
|
14
|
+
const secretKey = new Uint8Array(64);
|
|
15
|
+
secretKey.set(seed);
|
|
16
|
+
secretKey.set(publicKey, 32);
|
|
17
|
+
return { secretKey, publicKey };
|
|
18
|
+
}
|
|
12
19
|
// MinSeedSize is the minimal allowed seed byte length
|
|
13
20
|
const minSeedSize = 16;
|
|
14
21
|
// MaxSeedSize is the maximal allowed seed byte length
|
|
@@ -36,8 +43,8 @@ class PrivateKey {
|
|
|
36
43
|
throw new errors_1.InvalidSeedLengthError(seed.length);
|
|
37
44
|
}
|
|
38
45
|
const key = new TextEncoder().encode(ed25519Key);
|
|
39
|
-
const sum =
|
|
40
|
-
return new PrivateKey(
|
|
46
|
+
const sum = (0, hmac_js_1.hmac)(sha2_js_1.sha512, key, seed);
|
|
47
|
+
return new PrivateKey(generateKeyPairFromSeed(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
*
|
|
@@ -57,8 +64,8 @@ class PrivateKey {
|
|
|
57
64
|
const data = new Uint8Array(37);
|
|
58
65
|
data.set(this.seed(), 1);
|
|
59
66
|
new DataView(data.buffer).setUint32(33, index);
|
|
60
|
-
const sum =
|
|
61
|
-
return new PrivateKey(
|
|
67
|
+
const sum = (0, hmac_js_1.hmac)(sha2_js_1.sha512, this.chainCode, data);
|
|
68
|
+
return new PrivateKey(generateKeyPairFromSeed(sum.subarray(0, 32)).secretKey, sum.subarray(32));
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* @param path array of numbers pre adjusted for hardened paths ie: 44' -> 2^31 + 44
|
package/dist/lib/ec-key.js
CHANGED
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _ECKey_keyPair, _ECPublicKey_key;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ECPublicKey = exports.ECKey = void 0;
|
|
16
|
-
const
|
|
16
|
+
const blake2_js_1 = require("@noble/hashes/blake2.js");
|
|
17
17
|
const utils_1 = require("@taquito/utils");
|
|
18
18
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
19
19
|
const nist_js_1 = require("@noble/curves/nist.js");
|
|
@@ -85,7 +85,7 @@ class ECKey {
|
|
|
85
85
|
* @param bytesHash Blake2b hash of the bytes to sign
|
|
86
86
|
*/
|
|
87
87
|
sign(bytes) {
|
|
88
|
-
const hash = (0,
|
|
88
|
+
const hash = (0, blake2_js_1.blake2b)(bytes, { dkLen: 32 });
|
|
89
89
|
let signature;
|
|
90
90
|
if (__classPrivateFieldGet(this, _ECKey_keyPair, "f").curve === 'secp256k1') {
|
|
91
91
|
signature = secp256k1_1.secp256k1
|
|
@@ -164,7 +164,7 @@ class ECPublicKey {
|
|
|
164
164
|
}
|
|
165
165
|
hash() {
|
|
166
166
|
const key = this.bytes();
|
|
167
|
-
return (0, utils_1.b58Encode)((0,
|
|
167
|
+
return (0, utils_1.b58Encode)((0, blake2_js_1.blake2b)(key, { dkLen: 20 }), pref[this.curve].pkh);
|
|
168
168
|
}
|
|
169
169
|
bytes(compress = true) {
|
|
170
170
|
// @noble/curves supports both compressed and uncompressed formats
|
package/dist/lib/ed-key.js
CHANGED
|
@@ -13,9 +13,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _EdKey_keyPair, _EdPublicKey_key;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EdPublicKey = exports.EdKey = void 0;
|
|
16
|
-
const
|
|
17
|
-
const ed25519_1 = require("@
|
|
16
|
+
const blake2_js_1 = require("@noble/hashes/blake2.js");
|
|
17
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
18
18
|
const utils_1 = require("@taquito/utils");
|
|
19
|
+
function generateKeyPairFromSeed(seed) {
|
|
20
|
+
const publicKey = ed25519_1.ed25519.getPublicKey(seed);
|
|
21
|
+
const secretKey = new Uint8Array(64);
|
|
22
|
+
secretKey.set(seed);
|
|
23
|
+
secretKey.set(publicKey, 32);
|
|
24
|
+
return { secretKey, publicKey };
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* Provide signing logic for ed25519 curve based key (tz1)
|
|
21
28
|
*/
|
|
@@ -51,7 +58,7 @@ class EdKey {
|
|
|
51
58
|
throw new Error('decryption function is not provided');
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
|
-
__classPrivateFieldSet(this, _EdKey_keyPair,
|
|
61
|
+
__classPrivateFieldSet(this, _EdKey_keyPair, generateKeyPairFromSeed(keyData), "f");
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
@@ -60,8 +67,9 @@ class EdKey {
|
|
|
60
67
|
* @param bytesHash Blake2b hash of the bytes to sign
|
|
61
68
|
*/
|
|
62
69
|
sign(bytes) {
|
|
63
|
-
const hash = (0,
|
|
64
|
-
const
|
|
70
|
+
const hash = (0, blake2_js_1.blake2b)(bytes, { dkLen: 32 });
|
|
71
|
+
const seed = __classPrivateFieldGet(this, _EdKey_keyPair, "f").secretKey.subarray(0, 32);
|
|
72
|
+
const signature = ed25519_1.ed25519.sign(hash, seed);
|
|
65
73
|
return {
|
|
66
74
|
rawSignature: signature,
|
|
67
75
|
sig: (0, utils_1.b58Encode)(signature, utils_1.PrefixV2.GenericSignature),
|
|
@@ -103,7 +111,7 @@ class EdPublicKey {
|
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
113
|
hash() {
|
|
106
|
-
return (0, utils_1.b58Encode)((0,
|
|
114
|
+
return (0, utils_1.b58Encode)((0, blake2_js_1.blake2b)(__classPrivateFieldGet(this, _EdPublicKey_key, "f"), { dkLen: 20 }), utils_1.PrefixV2.Ed25519PublicKeyHash);
|
|
107
115
|
}
|
|
108
116
|
bytes() {
|
|
109
117
|
return __classPrivateFieldGet(this, _EdPublicKey_key, "f");
|
|
@@ -19,13 +19,15 @@ const utils_1 = require("@taquito/utils");
|
|
|
19
19
|
const typedarray_to_buffer_1 = require("typedarray-to-buffer");
|
|
20
20
|
const ed_key_1 = require("./ed-key");
|
|
21
21
|
const ec_key_1 = require("./ec-key");
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const bip39 = require("@scure/bip39");
|
|
23
|
+
const english_js_1 = require("@scure/bip39/wordlists/english.js");
|
|
24
|
+
const pbkdf2_js_1 = require("@noble/hashes/pbkdf2.js");
|
|
24
25
|
const helpers_1 = require("./helpers");
|
|
25
26
|
const errors_1 = require("./errors");
|
|
26
27
|
const core_1 = require("@taquito/core");
|
|
27
28
|
const key_interface_1 = require("./key-interface");
|
|
28
29
|
const bls_key_1 = require("./bls-key");
|
|
30
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
29
31
|
/**
|
|
30
32
|
* A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
|
|
31
33
|
*
|
|
@@ -34,10 +36,10 @@ const bls_key_1 = require("./bls-key");
|
|
|
34
36
|
*/
|
|
35
37
|
class InMemorySigner {
|
|
36
38
|
static fromFundraiser(email, password, mnemonic) {
|
|
37
|
-
if (!
|
|
39
|
+
if (!bip39.validateMnemonic(mnemonic, english_js_1.wordlist)) {
|
|
38
40
|
throw new errors_1.InvalidMnemonicError();
|
|
39
41
|
}
|
|
40
|
-
const seed =
|
|
42
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic, `${email}${password}`);
|
|
41
43
|
const key = (0, utils_1.b58Encode)(seed.subarray(0, 32), utils_1.PrefixV2.Ed25519Seed);
|
|
42
44
|
return new InMemorySigner(key);
|
|
43
45
|
}
|
|
@@ -52,10 +54,11 @@ class InMemorySigner {
|
|
|
52
54
|
*/
|
|
53
55
|
static fromMnemonic({ mnemonic, password = '', derivationPath = "44'/1729'/0'/0'", curve = 'ed25519', }) {
|
|
54
56
|
// check if curve is defined if not default tz1
|
|
55
|
-
if (!
|
|
57
|
+
if (!bip39.validateMnemonic(mnemonic, english_js_1.wordlist)) {
|
|
58
|
+
// avoiding exposing mnemonic again in case of mistake making invalid
|
|
56
59
|
throw new errors_1.InvalidMnemonicError();
|
|
57
60
|
}
|
|
58
|
-
const seed =
|
|
61
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic, password);
|
|
59
62
|
const sk = (0, helpers_1.generateSecretKey)(seed, derivationPath, curve);
|
|
60
63
|
return new InMemorySigner(sk);
|
|
61
64
|
}
|
|
@@ -100,7 +103,7 @@ class InMemorySigner {
|
|
|
100
103
|
decrypt = (data) => {
|
|
101
104
|
const salt = (0, typedarray_to_buffer_1.default)(data.slice(0, 8));
|
|
102
105
|
const encryptedSk = data.slice(8);
|
|
103
|
-
const encryptionKey =
|
|
106
|
+
const encryptionKey = (0, pbkdf2_js_1.pbkdf2)(sha2_js_1.sha512, passphrase, salt, { c: 32768, dkLen: 32 });
|
|
104
107
|
// Zero nonce is safe here: Tezos encrypted key format uses a fresh random salt per
|
|
105
108
|
// encryption, producing a unique PBKDF2-derived key each time. The (key, nonce) pair
|
|
106
109
|
// never repeats, satisfying NaCl secretbox requirements. This matches octez-client.
|
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.3.0-beta.
|
|
6
|
+
"commitHash": "fb73f1546d3dff2fbba7741ca6006680212bef16",
|
|
7
|
+
"version": "24.3.0-beta.2"
|
|
8
8
|
};
|