@taquito/sapling 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/constants.js +0 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js +8 -9
- package/dist/lib/sapling-keys/helpers.js +6 -7
- package/dist/lib/sapling-keys/in-memory-proving-key.js +15 -18
- package/dist/lib/sapling-keys/in-memory-spending-key.js +22 -25
- package/dist/lib/sapling-keys/in-memory-viewing-key.js +18 -21
- package/dist/lib/sapling-module-wrapper.js +1 -2
- package/dist/lib/sapling-state/sapling-state.js +6 -7
- package/dist/lib/sapling-state/utils.js +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js +78 -80
- package/dist/lib/sapling-tx-viewer/helpers.js +2 -3
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js +36 -39
- package/dist/lib/taquito-sapling.js +55 -58
- package/dist/lib/types.js +0 -1
- package/dist/lib/version.js +2 -3
- package/dist/taquito-sapling.es6.js +1383 -1380
- package/dist/taquito-sapling.es6.js.map +1 -1
- package/dist/taquito-sapling.umd.js +1387 -1393
- package/dist/taquito-sapling.umd.js.map +1 -1
- package/dist/types/constants.d.ts +5 -5
- package/dist/types/errors.d.ts +52 -52
- package/dist/types/sapling-forger/sapling-forger.d.ts +30 -30
- package/dist/types/sapling-keys/helpers.d.ts +2 -2
- package/dist/types/sapling-keys/in-memory-proving-key.d.ts +35 -35
- package/dist/types/sapling-keys/in-memory-spending-key.d.ts +53 -53
- package/dist/types/sapling-keys/in-memory-viewing-key.d.ts +48 -48
- package/dist/types/sapling-module-wrapper.d.ts +19 -19
- package/dist/types/sapling-state/sapling-state.d.ts +56 -56
- package/dist/types/sapling-state/utils.d.ts +22 -22
- package/dist/types/sapling-tx-builder/sapling-transactions-builder.d.ts +32 -32
- package/dist/types/sapling-tx-viewer/helpers.d.ts +11 -11
- package/dist/types/sapling-tx-viewer/sapling-transaction-viewer.d.ts +50 -50
- package/dist/types/taquito-sapling.d.ts +81 -81
- package/dist/types/types.d.ts +147 -147
- package/dist/types/version.d.ts +4 -4
- package/package.json +33 -35
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js.map +0 -1
- package/dist/lib/sapling-keys/helpers.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-proving-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-spending-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-viewing-key.js.map +0 -1
- package/dist/lib/sapling-module-wrapper.js.map +0 -1
- package/dist/lib/sapling-state/sapling-state.js.map +0 -1
- package/dist/lib/sapling-state/utils.js.map +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/helpers.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js.map +0 -1
- package/dist/lib/taquito-sapling.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/version.js.map +0 -1
package/dist/lib/constants.js
CHANGED
package/dist/lib/errors.js
CHANGED
|
@@ -15,17 +15,17 @@ class SaplingForger {
|
|
|
15
15
|
*/
|
|
16
16
|
forgeSaplingTransaction(tx) {
|
|
17
17
|
const spendBuf = this.forgeSpendDescriptions(tx.inputs);
|
|
18
|
-
const spend = Buffer.concat([utils_1.toHexBuf(spendBuf.length, 32), spendBuf]);
|
|
18
|
+
const spend = Buffer.concat([(0, utils_1.toHexBuf)(spendBuf.length, 32), spendBuf]);
|
|
19
19
|
const outputBuf = this.forgeOutputDescriptions(tx.outputs);
|
|
20
|
-
const output = Buffer.concat([utils_1.toHexBuf(outputBuf.length, 32), outputBuf]);
|
|
20
|
+
const output = Buffer.concat([(0, utils_1.toHexBuf)(outputBuf.length, 32), outputBuf]);
|
|
21
21
|
const root = Buffer.from(tx.root, 'hex');
|
|
22
22
|
return Buffer.concat([
|
|
23
23
|
spend,
|
|
24
24
|
output,
|
|
25
25
|
tx.signature,
|
|
26
|
-
utils_1.toHexBuf(tx.balance, 64),
|
|
26
|
+
(0, utils_1.toHexBuf)(tx.balance, 64),
|
|
27
27
|
root,
|
|
28
|
-
utils_1.toHexBuf(tx.boundData.length, 32),
|
|
28
|
+
(0, utils_1.toHexBuf)(tx.boundData.length, 32),
|
|
29
29
|
tx.boundData,
|
|
30
30
|
]);
|
|
31
31
|
}
|
|
@@ -71,7 +71,7 @@ class SaplingForger {
|
|
|
71
71
|
desc.proof,
|
|
72
72
|
ct.commitmentValue,
|
|
73
73
|
ct.ephemeralPublicKey,
|
|
74
|
-
utils_1.toHexBuf(ct.payloadEnc.length, 32),
|
|
74
|
+
(0, utils_1.toHexBuf)(ct.payloadEnc.length, 32),
|
|
75
75
|
ct.payloadEnc,
|
|
76
76
|
ct.nonceEnc,
|
|
77
77
|
ct.payloadOut,
|
|
@@ -87,15 +87,14 @@ class SaplingForger {
|
|
|
87
87
|
]);
|
|
88
88
|
}
|
|
89
89
|
forgeTransactionPlaintext(txPlainText) {
|
|
90
|
-
const encodedMemo = Buffer.from(utils_1.char2Bytes(txPlainText.memo).padEnd(txPlainText.memoSize, '0'), 'hex');
|
|
90
|
+
const encodedMemo = Buffer.from((0, utils_1.char2Bytes)(txPlainText.memo).padEnd(txPlainText.memoSize, '0'), 'hex');
|
|
91
91
|
return Buffer.concat([
|
|
92
92
|
txPlainText.diversifier,
|
|
93
|
-
utils_1.toHexBuf(new bignumber_js_1.default(txPlainText.amount), 64),
|
|
93
|
+
(0, utils_1.toHexBuf)(new bignumber_js_1.default(txPlainText.amount), 64),
|
|
94
94
|
txPlainText.randomCommitmentTrapdoor,
|
|
95
|
-
utils_1.toHexBuf(txPlainText.memoSize, 32),
|
|
95
|
+
(0, utils_1.toHexBuf)(txPlainText.memoSize, 32),
|
|
96
96
|
encodedMemo,
|
|
97
97
|
]);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
exports.SaplingForger = SaplingForger;
|
|
101
|
-
//# sourceMappingURL=sapling-forger.js.map
|
|
@@ -7,24 +7,23 @@ const nacl_1 = require("@stablelib/nacl");
|
|
|
7
7
|
const pbkdf2_1 = require("pbkdf2");
|
|
8
8
|
const utils_1 = require("@taquito/utils");
|
|
9
9
|
function decryptKey(spendingKey, password) {
|
|
10
|
-
const keyArr = utils_1.b58cdecode(spendingKey, utils_1.prefix[utils_1.Prefix.SASK]);
|
|
10
|
+
const keyArr = (0, utils_1.b58cdecode)(spendingKey, utils_1.prefix[utils_1.Prefix.SASK]);
|
|
11
11
|
// exit first if no password and key is encrypted
|
|
12
12
|
if (!password && spendingKey.slice(0, 4) !== 'sask') {
|
|
13
13
|
throw new errors_1.InvalidSpendingKey(spendingKey, 'no password provided to decrypt');
|
|
14
14
|
}
|
|
15
15
|
if (password && spendingKey.slice(0, 4) !== 'sask') {
|
|
16
|
-
const salt = typedarray_to_buffer_1.default(keyArr.slice(0, 8));
|
|
17
|
-
const encryptedSk = typedarray_to_buffer_1.default(keyArr.slice(8));
|
|
16
|
+
const salt = (0, typedarray_to_buffer_1.default)(keyArr.slice(0, 8));
|
|
17
|
+
const encryptedSk = (0, typedarray_to_buffer_1.default)(keyArr.slice(8));
|
|
18
18
|
const encryptionKey = pbkdf2_1.default.pbkdf2Sync(password, salt, 32768, 32, 'sha512');
|
|
19
|
-
const decrypted = nacl_1.openSecretBox(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
|
|
19
|
+
const decrypted = (0, nacl_1.openSecretBox)(new Uint8Array(encryptionKey), new Uint8Array(24), new Uint8Array(encryptedSk));
|
|
20
20
|
if (!decrypted) {
|
|
21
21
|
throw new errors_1.InvalidSpendingKey(spendingKey, 'incorrect password or unable to decrypt');
|
|
22
22
|
}
|
|
23
|
-
return typedarray_to_buffer_1.default(decrypted);
|
|
23
|
+
return (0, typedarray_to_buffer_1.default)(decrypted);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
return typedarray_to_buffer_1.default(keyArr);
|
|
26
|
+
return (0, typedarray_to_buffer_1.default)(keyArr);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.decryptKey = decryptKey;
|
|
30
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -8,20 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return value;
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
16
|
};
|
|
18
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
19
|
-
if (!
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return privateMap.get(receiver);
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
21
|
};
|
|
24
|
-
var
|
|
22
|
+
var _InMemoryProvingKey_provingKey;
|
|
25
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
24
|
exports.InMemoryProvingKey = void 0;
|
|
27
25
|
const sapling = require("@airgap/sapling-wasm");
|
|
@@ -32,8 +30,8 @@ const helpers_1 = require("./helpers");
|
|
|
32
30
|
*/
|
|
33
31
|
class InMemoryProvingKey {
|
|
34
32
|
constructor(provingKey) {
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
33
|
+
_InMemoryProvingKey_provingKey.set(this, void 0);
|
|
34
|
+
__classPrivateFieldSet(this, _InMemoryProvingKey_provingKey, Buffer.from(provingKey, 'hex'), "f");
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* @description Allows to instantiate the InMemoryProvingKey from an encrypted/unencrypted spending key
|
|
@@ -48,7 +46,7 @@ class InMemoryProvingKey {
|
|
|
48
46
|
*/
|
|
49
47
|
static fromSpendingKey(spendingKey, password) {
|
|
50
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const decodedSpendingKey = helpers_1.decryptKey(spendingKey, password);
|
|
49
|
+
const decodedSpendingKey = (0, helpers_1.decryptKey)(spendingKey, password);
|
|
52
50
|
const provingKey = yield sapling.getProofAuthorizingKey(decodedSpendingKey);
|
|
53
51
|
return new InMemoryProvingKey(provingKey.toString('hex'));
|
|
54
52
|
});
|
|
@@ -68,7 +66,7 @@ class InMemoryProvingKey {
|
|
|
68
66
|
*/
|
|
69
67
|
prepareSpendDescription(parametersSpendProof) {
|
|
70
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const spendDescription = yield sapling.prepareSpendDescriptionWithAuthorizingKey(parametersSpendProof.saplingContext, __classPrivateFieldGet(this,
|
|
69
|
+
const spendDescription = yield sapling.prepareSpendDescriptionWithAuthorizingKey(parametersSpendProof.saplingContext, __classPrivateFieldGet(this, _InMemoryProvingKey_provingKey, "f"), parametersSpendProof.address, parametersSpendProof.randomCommitmentTrapdoor, parametersSpendProof.publicKeyReRandomization, parametersSpendProof.amount, parametersSpendProof.root, parametersSpendProof.witness);
|
|
72
70
|
return {
|
|
73
71
|
commitmentValue: spendDescription.cv,
|
|
74
72
|
nullifier: spendDescription.nf,
|
|
@@ -80,5 +78,4 @@ class InMemoryProvingKey {
|
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
exports.InMemoryProvingKey = InMemoryProvingKey;
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=in-memory-proving-key.js.map
|
|
81
|
+
_InMemoryProvingKey_provingKey = new WeakMap();
|
|
@@ -8,20 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return value;
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
16
|
};
|
|
18
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
19
|
-
if (!
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return privateMap.get(receiver);
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
21
|
};
|
|
24
|
-
var
|
|
22
|
+
var _InMemorySpendingKey_spendingKeyBuf, _InMemorySpendingKey_saplingViewingKey;
|
|
25
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
24
|
exports.InMemorySpendingKey = void 0;
|
|
27
25
|
const in_memory_viewing_key_1 = require("./in-memory-viewing-key");
|
|
@@ -41,9 +39,9 @@ class InMemorySpendingKey {
|
|
|
41
39
|
* @param password required for MMXj encrypted keys
|
|
42
40
|
*/
|
|
43
41
|
constructor(spendingKey, password) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
__classPrivateFieldSet(this,
|
|
42
|
+
_InMemorySpendingKey_spendingKeyBuf.set(this, void 0);
|
|
43
|
+
_InMemorySpendingKey_saplingViewingKey.set(this, void 0);
|
|
44
|
+
__classPrivateFieldSet(this, _InMemorySpendingKey_spendingKeyBuf, (0, helpers_1.decryptKey)(spendingKey, password), "f");
|
|
47
45
|
}
|
|
48
46
|
/**
|
|
49
47
|
*
|
|
@@ -60,7 +58,7 @@ class InMemorySpendingKey {
|
|
|
60
58
|
// reduce seed bytes must be 32 bytes reflecting both halves
|
|
61
59
|
const seed = Buffer.from(first32.map((byte, index) => byte ^ second32[index]));
|
|
62
60
|
const spendingKeyArr = new Uint8Array(yield sapling.getExtendedSpendingKey(seed, derivationPath));
|
|
63
|
-
const spendingKey = utils_1.b58cencode(spendingKeyArr, utils_1.prefix[utils_1.Prefix.SASK]);
|
|
61
|
+
const spendingKey = (0, utils_1.b58cencode)(spendingKeyArr, utils_1.prefix[utils_1.Prefix.SASK]);
|
|
64
62
|
return new InMemorySpendingKey(spendingKey);
|
|
65
63
|
});
|
|
66
64
|
}
|
|
@@ -71,11 +69,11 @@ class InMemorySpendingKey {
|
|
|
71
69
|
getSaplingViewingKeyProvider() {
|
|
72
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
71
|
let viewingKey;
|
|
74
|
-
if (!__classPrivateFieldGet(this,
|
|
75
|
-
viewingKey = yield sapling.getExtendedFullViewingKeyFromSpendingKey(__classPrivateFieldGet(this,
|
|
76
|
-
__classPrivateFieldSet(this,
|
|
72
|
+
if (!__classPrivateFieldGet(this, _InMemorySpendingKey_saplingViewingKey, "f")) {
|
|
73
|
+
viewingKey = yield sapling.getExtendedFullViewingKeyFromSpendingKey(__classPrivateFieldGet(this, _InMemorySpendingKey_spendingKeyBuf, "f"));
|
|
74
|
+
__classPrivateFieldSet(this, _InMemorySpendingKey_saplingViewingKey, new in_memory_viewing_key_1.InMemoryViewingKey(viewingKey.toString('hex')), "f");
|
|
77
75
|
}
|
|
78
|
-
return __classPrivateFieldGet(this,
|
|
76
|
+
return __classPrivateFieldGet(this, _InMemorySpendingKey_saplingViewingKey, "f");
|
|
79
77
|
});
|
|
80
78
|
}
|
|
81
79
|
/**
|
|
@@ -92,7 +90,7 @@ class InMemorySpendingKey {
|
|
|
92
90
|
*/
|
|
93
91
|
prepareSpendDescription(parametersSpendProof) {
|
|
94
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const spendDescription = yield sapling.prepareSpendDescriptionWithSpendingKey(parametersSpendProof.saplingContext, __classPrivateFieldGet(this,
|
|
93
|
+
const spendDescription = yield sapling.prepareSpendDescriptionWithSpendingKey(parametersSpendProof.saplingContext, __classPrivateFieldGet(this, _InMemorySpendingKey_spendingKeyBuf, "f"), parametersSpendProof.address, parametersSpendProof.randomCommitmentTrapdoor, parametersSpendProof.publicKeyReRandomization, parametersSpendProof.amount, parametersSpendProof.root, parametersSpendProof.witness);
|
|
96
94
|
return {
|
|
97
95
|
commitmentValue: spendDescription.cv,
|
|
98
96
|
nullifier: spendDescription.nf,
|
|
@@ -117,7 +115,7 @@ class InMemorySpendingKey {
|
|
|
117
115
|
nf: parametersSpendSig.unsignedSpendDescription.nullifier,
|
|
118
116
|
rk: parametersSpendSig.unsignedSpendDescription.publicKeyReRandomization,
|
|
119
117
|
proof: parametersSpendSig.unsignedSpendDescription.proof,
|
|
120
|
-
}, __classPrivateFieldGet(this,
|
|
118
|
+
}, __classPrivateFieldGet(this, _InMemorySpendingKey_spendingKeyBuf, "f"), parametersSpendSig.publicKeyReRandomization, parametersSpendSig.hash);
|
|
121
119
|
return {
|
|
122
120
|
commitmentValue: signedSpendDescription.cv,
|
|
123
121
|
nullifier: signedSpendDescription.nf,
|
|
@@ -132,11 +130,10 @@ class InMemorySpendingKey {
|
|
|
132
130
|
*/
|
|
133
131
|
getProvingKey() {
|
|
134
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
const provingKey = yield sapling.getProofAuthorizingKey(__classPrivateFieldGet(this,
|
|
133
|
+
const provingKey = yield sapling.getProofAuthorizingKey(__classPrivateFieldGet(this, _InMemorySpendingKey_spendingKeyBuf, "f"));
|
|
136
134
|
return provingKey.toString('hex');
|
|
137
135
|
});
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
exports.InMemorySpendingKey = InMemorySpendingKey;
|
|
141
|
-
|
|
142
|
-
//# sourceMappingURL=in-memory-spending-key.js.map
|
|
139
|
+
_InMemorySpendingKey_spendingKeyBuf = new WeakMap(), _InMemorySpendingKey_saplingViewingKey = new WeakMap();
|
|
@@ -8,20 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return value;
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
16
|
};
|
|
18
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
19
|
-
if (!
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return privateMap.get(receiver);
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
21
|
};
|
|
24
|
-
var
|
|
22
|
+
var _InMemoryViewingKey_fullViewingKey;
|
|
25
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
24
|
exports.InMemoryViewingKey = void 0;
|
|
27
25
|
const utils_1 = require("@taquito/utils");
|
|
@@ -32,8 +30,8 @@ const in_memory_spending_key_1 = require("./in-memory-spending-key");
|
|
|
32
30
|
*/
|
|
33
31
|
class InMemoryViewingKey {
|
|
34
32
|
constructor(fullViewingKey) {
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
33
|
+
_InMemoryViewingKey_fullViewingKey.set(this, void 0);
|
|
34
|
+
__classPrivateFieldSet(this, _InMemoryViewingKey_fullViewingKey, Buffer.from(fullViewingKey, 'hex'), "f");
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* @description Allows to instantiate the InMemoryViewingKey from an encrypted/unencrypted spending key
|
|
@@ -58,7 +56,7 @@ class InMemoryViewingKey {
|
|
|
58
56
|
*
|
|
59
57
|
*/
|
|
60
58
|
getFullViewingKey() {
|
|
61
|
-
return __classPrivateFieldGet(this,
|
|
59
|
+
return __classPrivateFieldGet(this, _InMemoryViewingKey_fullViewingKey, "f");
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* @description Retrieve the outgoing viewing key
|
|
@@ -67,7 +65,7 @@ class InMemoryViewingKey {
|
|
|
67
65
|
*/
|
|
68
66
|
getOutgoingViewingKey() {
|
|
69
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
return sapling.getOutgoingViewingKey(__classPrivateFieldGet(this,
|
|
68
|
+
return sapling.getOutgoingViewingKey(__classPrivateFieldGet(this, _InMemoryViewingKey_fullViewingKey, "f"));
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
/**
|
|
@@ -77,7 +75,7 @@ class InMemoryViewingKey {
|
|
|
77
75
|
*/
|
|
78
76
|
getIncomingViewingKey() {
|
|
79
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
return sapling.getIncomingViewingKey(__classPrivateFieldGet(this,
|
|
78
|
+
return sapling.getIncomingViewingKey(__classPrivateFieldGet(this, _InMemoryViewingKey_fullViewingKey, "f"));
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
@@ -88,14 +86,13 @@ class InMemoryViewingKey {
|
|
|
88
86
|
*/
|
|
89
87
|
getAddress(addressIndex) {
|
|
90
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
const { index, raw } = yield sapling.getPaymentAddressFromViewingKey(__classPrivateFieldGet(this,
|
|
89
|
+
const { index, raw } = yield sapling.getPaymentAddressFromViewingKey(__classPrivateFieldGet(this, _InMemoryViewingKey_fullViewingKey, "f"), addressIndex);
|
|
92
90
|
return {
|
|
93
|
-
address: utils_1.b58cencode(raw, utils_1.prefix[utils_1.Prefix.ZET1]),
|
|
91
|
+
address: (0, utils_1.b58cencode)(raw, utils_1.prefix[utils_1.Prefix.ZET1]),
|
|
94
92
|
addressIndex: index.readInt32LE(),
|
|
95
93
|
};
|
|
96
94
|
});
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
exports.InMemoryViewingKey = InMemoryViewingKey;
|
|
100
|
-
|
|
101
|
-
//# sourceMappingURL=in-memory-viewing-key.js.map
|
|
98
|
+
_InMemoryViewingKey_fullViewingKey = new WeakMap();
|
|
@@ -24,7 +24,7 @@ class SaplingWrapper {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
getRandomBytes(length) {
|
|
27
|
-
return random_1.randomBytes(length);
|
|
27
|
+
return (0, random_1.randomBytes)(length);
|
|
28
28
|
}
|
|
29
29
|
randR() {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -80,4 +80,3 @@ class SaplingWrapper {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
exports.SaplingWrapper = SaplingWrapper;
|
|
83
|
-
//# sourceMappingURL=sapling-module-wrapper.js.map
|
|
@@ -58,11 +58,11 @@ class SaplingState {
|
|
|
58
58
|
*/
|
|
59
59
|
getWitness(stateTree, position) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const heightBuffer = utils_2.hex2Bytes(utils_1.changeEndianness(utils_2.num2PaddedHex(stateTree.height)));
|
|
62
|
-
const posBuffer = utils_2.hex2Bytes(utils_1.changeEndianness(utils_2.num2PaddedHex(position, 64)));
|
|
61
|
+
const heightBuffer = (0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(stateTree.height)));
|
|
62
|
+
const posBuffer = (0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(position, 64)));
|
|
63
63
|
const neighbouringHashes = yield this.getNeighbouringHashes([], stateTree.height, position, stateTree.tree);
|
|
64
64
|
const witness = neighbouringHashes
|
|
65
|
-
.map((hash) => Buffer.concat([utils_2.hex2Bytes(utils_1.changeEndianness(utils_2.num2PaddedHex(hash.length))), hash]))
|
|
65
|
+
.map((hash) => Buffer.concat([(0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(hash.length))), hash]))
|
|
66
66
|
.reverse()
|
|
67
67
|
.reduce((acc, next) => Buffer.concat([acc, next]));
|
|
68
68
|
return Buffer.concat([heightBuffer, witness, posBuffer]).toString('hex');
|
|
@@ -82,11 +82,11 @@ class SaplingState {
|
|
|
82
82
|
if (height === this.height || leaves.length > Math.pow(2, this.height - 1 - height)) {
|
|
83
83
|
throw new errors_1.TreeConstructionFailure('Children length exceeds maximum number of nodes in a merkle tree');
|
|
84
84
|
}
|
|
85
|
-
const pairedLeaves = utils_1.pairNodes(leaves);
|
|
85
|
+
const pairedLeaves = (0, utils_1.pairNodes)(leaves);
|
|
86
86
|
const updatedLeaves = yield Promise.all(pairedLeaves.map((chunk) => __awaiter(this, void 0, void 0, function* () {
|
|
87
87
|
const left = yield this.getMerkleHash(chunk[0], height);
|
|
88
88
|
const right = yield this.getMerkleHash(chunk[1], height);
|
|
89
|
-
const parentHash = yield sapling_wasm_1.merkleHash(height, left, right);
|
|
89
|
+
const parentHash = yield (0, sapling_wasm_1.merkleHash)(height, left, right);
|
|
90
90
|
return [parentHash.toString('hex'), chunk[0], chunk[1]];
|
|
91
91
|
})));
|
|
92
92
|
return this.constructMerkleTree(updatedLeaves, height + 1);
|
|
@@ -115,7 +115,7 @@ class SaplingState {
|
|
|
115
115
|
res[0] = Buffer.from(this.uncommittedMerkleHash, 'hex');
|
|
116
116
|
for (let i = 0; i < this.height; i++) {
|
|
117
117
|
const hash = res[i];
|
|
118
|
-
res[i + 1] = yield sapling_wasm_1.merkleHash(i, hash, hash);
|
|
118
|
+
res[i + 1] = yield (0, sapling_wasm_1.merkleHash)(i, hash, hash);
|
|
119
119
|
}
|
|
120
120
|
return res;
|
|
121
121
|
});
|
|
@@ -169,4 +169,3 @@ class SaplingState {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
exports.SaplingState = SaplingState;
|
|
172
|
-
//# sourceMappingURL=sapling-state.js.map
|