@taquito/sapling 24.3.0-beta.5 → 24.3.0-beta.7
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 +2 -1
- package/dist/lib/sapling-forger/sapling-forger.js +12 -11
- package/dist/lib/sapling-keys/in-memory-proving-key.js +3 -2
- package/dist/lib/sapling-keys/in-memory-spending-key.js +3 -2
- package/dist/lib/sapling-keys/in-memory-viewing-key.js +3 -2
- package/dist/lib/sapling-module-wrapper.js +6 -7
- package/dist/lib/sapling-output-params.js +12 -0
- package/dist/lib/sapling-state/sapling-state.js +8 -7
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js +10 -9
- package/dist/lib/sapling-tx-viewer/helpers.js +3 -2
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js +5 -4
- package/dist/lib/sapling-wasm.js +22 -0
- package/dist/lib/taquito-sapling.js +2 -1
- package/dist/lib/version.js +2 -2
- package/dist/taquito-sapling.es6.js +2454 -71
- package/dist/taquito-sapling.es6.js.map +1 -1
- package/dist/taquito-sapling.umd.js +2457 -94
- package/dist/taquito-sapling.umd.js.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/sapling-forger/sapling-forger.d.ts +1 -0
- package/dist/types/sapling-keys/in-memory-viewing-key.d.ts +1 -0
- package/dist/types/sapling-module-wrapper.d.ts +1 -0
- package/dist/types/sapling-output-params.d.ts +6 -0
- package/dist/types/sapling-tx-builder/sapling-transactions-builder.d.ts +1 -0
- package/dist/types/sapling-tx-viewer/helpers.d.ts +1 -0
- package/dist/types/sapling-wasm.d.ts +1 -0
- package/package.json +8 -6
- package/saplingOutputParams.d.ts +5 -0
- package/saplingOutputParams.js +8 -5
package/dist/lib/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_BOUND_DATA = exports.DEFAULT_MEMO = exports.OCK_KEY = exports.KDF_KEY = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
4
5
|
exports.KDF_KEY = 'KDFSaplingForTezosV1';
|
|
5
6
|
exports.OCK_KEY = 'OCK_keystringderivation_TEZOS';
|
|
6
7
|
exports.DEFAULT_MEMO = '';
|
|
7
|
-
exports.DEFAULT_BOUND_DATA = Buffer.from('', 'hex');
|
|
8
|
+
exports.DEFAULT_BOUND_DATA = buffer_1.Buffer.from('', 'hex');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SaplingForger = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
4
5
|
const utils_1 = require("@taquito/utils");
|
|
5
6
|
const bignumber_js_1 = require("bignumber.js");
|
|
6
7
|
class SaplingForger {
|
|
@@ -15,11 +16,11 @@ class SaplingForger {
|
|
|
15
16
|
*/
|
|
16
17
|
forgeSaplingTransaction(tx) {
|
|
17
18
|
const spendBuf = this.forgeSpendDescriptions(tx.inputs);
|
|
18
|
-
const spend = Buffer.concat([(0, utils_1.toHexBuf)(spendBuf.length, 32), spendBuf]);
|
|
19
|
+
const spend = buffer_1.Buffer.concat([(0, utils_1.toHexBuf)(spendBuf.length, 32), spendBuf]);
|
|
19
20
|
const outputBuf = this.forgeOutputDescriptions(tx.outputs);
|
|
20
|
-
const output = Buffer.concat([(0, utils_1.toHexBuf)(outputBuf.length, 32), outputBuf]);
|
|
21
|
-
const root = Buffer.from(tx.root, 'hex');
|
|
22
|
-
return Buffer.concat([
|
|
21
|
+
const output = buffer_1.Buffer.concat([(0, utils_1.toHexBuf)(outputBuf.length, 32), outputBuf]);
|
|
22
|
+
const root = buffer_1.Buffer.from(tx.root, 'hex');
|
|
23
|
+
return buffer_1.Buffer.concat([
|
|
23
24
|
spend,
|
|
24
25
|
output,
|
|
25
26
|
tx.signature,
|
|
@@ -40,10 +41,10 @@ class SaplingForger {
|
|
|
40
41
|
const buff = this.forgeSpendDescription(i);
|
|
41
42
|
descriptions.push(buff);
|
|
42
43
|
}
|
|
43
|
-
return Buffer.concat(descriptions);
|
|
44
|
+
return buffer_1.Buffer.concat(descriptions);
|
|
44
45
|
}
|
|
45
46
|
forgeSpendDescription(desc) {
|
|
46
|
-
return Buffer.concat([
|
|
47
|
+
return buffer_1.Buffer.concat([
|
|
47
48
|
desc.commitmentValue,
|
|
48
49
|
desc.nullifier,
|
|
49
50
|
desc.publicKeyReRandomization,
|
|
@@ -62,11 +63,11 @@ class SaplingForger {
|
|
|
62
63
|
const buff = this.forgeOutputDescription(i);
|
|
63
64
|
descriptions.push(buff);
|
|
64
65
|
}
|
|
65
|
-
return Buffer.concat(descriptions);
|
|
66
|
+
return buffer_1.Buffer.concat(descriptions);
|
|
66
67
|
}
|
|
67
68
|
forgeOutputDescription(desc) {
|
|
68
69
|
const ct = desc.ciphertext;
|
|
69
|
-
return Buffer.concat([
|
|
70
|
+
return buffer_1.Buffer.concat([
|
|
70
71
|
desc.commitment,
|
|
71
72
|
desc.proof,
|
|
72
73
|
ct.commitmentValue,
|
|
@@ -79,7 +80,7 @@ class SaplingForger {
|
|
|
79
80
|
]);
|
|
80
81
|
}
|
|
81
82
|
forgeUnsignedTxInput(unsignedSpendDescription) {
|
|
82
|
-
return Buffer.concat([
|
|
83
|
+
return buffer_1.Buffer.concat([
|
|
83
84
|
unsignedSpendDescription.commitmentValue,
|
|
84
85
|
unsignedSpendDescription.nullifier,
|
|
85
86
|
unsignedSpendDescription.publicKeyReRandomization,
|
|
@@ -87,8 +88,8 @@ class SaplingForger {
|
|
|
87
88
|
]);
|
|
88
89
|
}
|
|
89
90
|
forgeTransactionPlaintext(txPlainText) {
|
|
90
|
-
const encodedMemo = Buffer.from((0, utils_1.stringToBytes)(txPlainText.memo).padEnd(txPlainText.memoSize, '0'), 'hex');
|
|
91
|
-
return Buffer.concat([
|
|
91
|
+
const encodedMemo = buffer_1.Buffer.from((0, utils_1.stringToBytes)(txPlainText.memo).padEnd(txPlainText.memoSize, '0'), 'hex');
|
|
92
|
+
return buffer_1.Buffer.concat([
|
|
92
93
|
txPlainText.diversifier,
|
|
93
94
|
(0, utils_1.toHexBuf)(new bignumber_js_1.default(txPlainText.amount), 64),
|
|
94
95
|
txPlainText.randomCommitmentTrapdoor,
|
|
@@ -13,7 +13,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _InMemoryProvingKey_provingKey;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InMemoryProvingKey = void 0;
|
|
16
|
-
const
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
17
|
+
const sapling = require("../sapling-wasm");
|
|
17
18
|
const helpers_1 = require("./helpers");
|
|
18
19
|
/**
|
|
19
20
|
* holds the proving key, create proof for spend descriptions
|
|
@@ -22,7 +23,7 @@ const helpers_1 = require("./helpers");
|
|
|
22
23
|
class InMemoryProvingKey {
|
|
23
24
|
constructor(provingKey) {
|
|
24
25
|
_InMemoryProvingKey_provingKey.set(this, void 0);
|
|
25
|
-
__classPrivateFieldSet(this, _InMemoryProvingKey_provingKey, Buffer.from(provingKey, 'hex'), "f");
|
|
26
|
+
__classPrivateFieldSet(this, _InMemoryProvingKey_provingKey, buffer_1.Buffer.from(provingKey, 'hex'), "f");
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Allows to instantiate the InMemoryProvingKey from an encrypted/unencrypted spending key
|
|
@@ -13,8 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _InMemorySpendingKey_spendingKeyBuf, _InMemorySpendingKey_saplingViewingKey;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InMemorySpendingKey = void 0;
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
16
17
|
const in_memory_viewing_key_1 = require("./in-memory-viewing-key");
|
|
17
|
-
const sapling = require("
|
|
18
|
+
const sapling = require("../sapling-wasm");
|
|
18
19
|
const utils_1 = require("@taquito/utils");
|
|
19
20
|
const bip39 = require("@scure/bip39");
|
|
20
21
|
const helpers_1 = require("./helpers");
|
|
@@ -46,7 +47,7 @@ class InMemorySpendingKey {
|
|
|
46
47
|
const first32 = fullSeed.slice(0, 32);
|
|
47
48
|
const second32 = fullSeed.slice(32);
|
|
48
49
|
// reduce seed bytes must be 32 bytes reflecting both halves
|
|
49
|
-
const seed = Buffer.from(first32.map((byte, index) => byte ^ second32[index]));
|
|
50
|
+
const seed = buffer_1.Buffer.from(first32.map((byte, index) => byte ^ second32[index]));
|
|
50
51
|
const spendingKeyArr = new Uint8Array(await sapling.getExtendedSpendingKey(seed, derivationPath));
|
|
51
52
|
const spendingKey = (0, utils_1.b58Encode)(spendingKeyArr, utils_1.PrefixV2.SaplingSpendingKey);
|
|
52
53
|
return new InMemorySpendingKey(spendingKey);
|
|
@@ -13,8 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _InMemoryViewingKey_fullViewingKey;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InMemoryViewingKey = void 0;
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
16
17
|
const utils_1 = require("@taquito/utils");
|
|
17
|
-
const sapling = require("
|
|
18
|
+
const sapling = require("../sapling-wasm");
|
|
18
19
|
const helpers_1 = require("./helpers");
|
|
19
20
|
/**
|
|
20
21
|
* Holds the viewing key
|
|
@@ -22,7 +23,7 @@ const helpers_1 = require("./helpers");
|
|
|
22
23
|
class InMemoryViewingKey {
|
|
23
24
|
constructor(fullViewingKey) {
|
|
24
25
|
_InMemoryViewingKey_fullViewingKey.set(this, void 0);
|
|
25
|
-
__classPrivateFieldSet(this, _InMemoryViewingKey_fullViewingKey, Buffer.from(fullViewingKey, 'hex'), "f");
|
|
26
|
+
__classPrivateFieldSet(this, _InMemoryViewingKey_fullViewingKey, buffer_1.Buffer.from(fullViewingKey, 'hex'), "f");
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Allows to instantiate the InMemoryViewingKey from an encrypted/unencrypted spending key
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SaplingWrapper = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const saplingSpendParams = require('@taquito/sapling-spend-params');
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
const sapling = require("./sapling-wasm");
|
|
6
|
+
const sapling_output_params_1 = require("./sapling-output-params");
|
|
7
|
+
const sapling_spend_params_1 = require("@taquito/sapling-spend-params");
|
|
9
8
|
let cachedParams;
|
|
10
9
|
const getRandomValueSource = () => {
|
|
11
10
|
const crypto = globalThis.crypto;
|
|
@@ -56,8 +55,8 @@ class SaplingWrapper {
|
|
|
56
55
|
async initSaplingParameters() {
|
|
57
56
|
if (!cachedParams) {
|
|
58
57
|
cachedParams = {
|
|
59
|
-
spend: Buffer.from(
|
|
60
|
-
output: Buffer.from(
|
|
58
|
+
spend: buffer_1.Buffer.from(sapling_spend_params_1.default.saplingSpendParams, 'base64'),
|
|
59
|
+
output: buffer_1.Buffer.from(sapling_output_params_1.default.saplingOutputParams, 'base64'),
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
62
|
return sapling.initParameters(cachedParams.spend, cachedParams.output);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("../saplingOutputParams.js");
|
|
4
|
+
const loadSaplingOutputParams = () => {
|
|
5
|
+
const saplingOutputParams = globalThis.__taquitoVendoredParams
|
|
6
|
+
?.saplingOutputParams;
|
|
7
|
+
if (!saplingOutputParams) {
|
|
8
|
+
throw new Error('Vendored sapling output params failed to load');
|
|
9
|
+
}
|
|
10
|
+
return saplingOutputParams;
|
|
11
|
+
};
|
|
12
|
+
exports.default = loadSaplingOutputParams();
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.SaplingState = void 0;
|
|
9
|
+
const buffer_1 = require("buffer");
|
|
9
10
|
const errors_1 = require("../errors");
|
|
10
|
-
const sapling_wasm_1 = require("
|
|
11
|
+
const sapling_wasm_1 = require("../sapling-wasm");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
13
|
const utils_2 = require("@taquito/utils");
|
|
13
14
|
const bignumber_js_1 = require("bignumber.js");
|
|
@@ -51,10 +52,10 @@ class SaplingState {
|
|
|
51
52
|
const posBuffer = (0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(position, 64)));
|
|
52
53
|
const neighbouringHashes = await this.getNeighbouringHashes([], stateTree.height, position, stateTree.tree);
|
|
53
54
|
const witness = neighbouringHashes
|
|
54
|
-
.map((hash) => Buffer.concat([(0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(hash.length))), hash]))
|
|
55
|
+
.map((hash) => buffer_1.Buffer.concat([(0, utils_2.hex2Bytes)((0, utils_1.changeEndianness)((0, utils_2.num2PaddedHex)(hash.length))), hash]))
|
|
55
56
|
.reverse()
|
|
56
|
-
.reduce((acc, next) => Buffer.concat([acc, next]));
|
|
57
|
-
return Buffer.concat([heightBuffer, witness, posBuffer]).toString('hex');
|
|
57
|
+
.reduce((acc, next) => buffer_1.Buffer.concat([acc, next]));
|
|
58
|
+
return buffer_1.Buffer.concat([heightBuffer, witness, posBuffer]).toString('hex');
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
*
|
|
@@ -83,10 +84,10 @@ class SaplingState {
|
|
|
83
84
|
return (await this.uncommittedMerkleHashes.get())[height];
|
|
84
85
|
}
|
|
85
86
|
else if (typeof tree === 'string') {
|
|
86
|
-
return Buffer.from(tree, 'hex');
|
|
87
|
+
return buffer_1.Buffer.from(tree, 'hex');
|
|
87
88
|
}
|
|
88
89
|
else {
|
|
89
|
-
return Buffer.from(tree[0], 'hex');
|
|
90
|
+
return buffer_1.Buffer.from(tree[0], 'hex');
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
@@ -95,7 +96,7 @@ class SaplingState {
|
|
|
95
96
|
*/
|
|
96
97
|
async createUncommittedMerkleHashes() {
|
|
97
98
|
const res = new Array(this.height);
|
|
98
|
-
res[0] = Buffer.from(this.uncommittedMerkleHash, 'hex');
|
|
99
|
+
res[0] = buffer_1.Buffer.from(this.uncommittedMerkleHash, 'hex');
|
|
99
100
|
for (let i = 0; i < this.height; i++) {
|
|
100
101
|
const hash = res[i];
|
|
101
102
|
res[i + 1] = await (0, sapling_wasm_1.merkleHash)(i, hash, hash);
|
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _SaplingTransactionBuilder_inMemorySpendingKey, _SaplingTransactionBuilder_inMemoryProvingKey, _SaplingTransactionBuilder_saplingForger, _SaplingTransactionBuilder_contractAddress, _SaplingTransactionBuilder_saplingId, _SaplingTransactionBuilder_memoSize, _SaplingTransactionBuilder_readProvider, _SaplingTransactionBuilder_saplingWrapper, _SaplingTransactionBuilder_chainId, _SaplingTransactionBuilder_saplingState;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SaplingTransactionBuilder = void 0;
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
16
17
|
const blakejs_1 = require("blakejs");
|
|
17
18
|
const nacl_1 = require("@stablelib/nacl");
|
|
18
19
|
const constants_1 = require("../constants");
|
|
@@ -148,12 +149,12 @@ class SaplingTransactionBuilder {
|
|
|
148
149
|
const diversifier = await __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getDiversifiedFromRawPaymentAddress(parametersOutputDescription.address);
|
|
149
150
|
const ephemeralPublicKey = await __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").deriveEphemeralPublicKey(diversifier, ephemeralPrivateKey);
|
|
150
151
|
const outgoingCipherKey = parametersOutputDescription.outgoingViewingKey
|
|
151
|
-
? blakejs_1.default.blake2b(Buffer.concat([
|
|
152
|
+
? blakejs_1.default.blake2b(buffer_1.Buffer.concat([
|
|
152
153
|
commitmentValue,
|
|
153
154
|
commitment,
|
|
154
155
|
ephemeralPublicKey,
|
|
155
156
|
parametersOutputDescription.outgoingViewingKey,
|
|
156
|
-
]), Buffer.from(constants_1.OCK_KEY), 32)
|
|
157
|
+
]), buffer_1.Buffer.from(constants_1.OCK_KEY), 32)
|
|
157
158
|
: __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getRandomBytes(32);
|
|
158
159
|
const ciphertext = await this.encryptCiphertext({
|
|
159
160
|
address: parametersOutputDescription.address,
|
|
@@ -224,8 +225,8 @@ class SaplingTransactionBuilder {
|
|
|
224
225
|
async encryptCiphertext(parametersCiphertext) {
|
|
225
226
|
const recipientDiversifiedTransmissionKey = await __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getPkdFromRawPaymentAddress(parametersCiphertext.address);
|
|
226
227
|
const keyAgreement = await __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").keyAgreement(recipientDiversifiedTransmissionKey, parametersCiphertext.ephemeralPrivateKey);
|
|
227
|
-
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, Buffer.from(constants_1.KDF_KEY), 32);
|
|
228
|
-
const nonceEnc = Buffer.from(__classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getRandomBytes(24));
|
|
228
|
+
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, buffer_1.Buffer.from(constants_1.KDF_KEY), 32);
|
|
229
|
+
const nonceEnc = buffer_1.Buffer.from(__classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getRandomBytes(24));
|
|
229
230
|
const transactionPlaintext = __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingForger, "f").forgeTransactionPlaintext({
|
|
230
231
|
diversifier: parametersCiphertext.diversifier,
|
|
231
232
|
amount: parametersCiphertext.amount,
|
|
@@ -233,9 +234,9 @@ class SaplingTransactionBuilder {
|
|
|
233
234
|
memoSize: __classPrivateFieldGet(this, _SaplingTransactionBuilder_memoSize, "f") * 2,
|
|
234
235
|
memo: parametersCiphertext.memo,
|
|
235
236
|
});
|
|
236
|
-
const nonceOut = Buffer.from(__classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getRandomBytes(24));
|
|
237
|
-
const payloadEnc = Buffer.from((0, nacl_1.secretBox)(keyAgreementHash, nonceEnc, transactionPlaintext));
|
|
238
|
-
const payloadOut = Buffer.from((0, nacl_1.secretBox)(parametersCiphertext.outgoingCipherKey, nonceOut, Buffer.concat([
|
|
237
|
+
const nonceOut = buffer_1.Buffer.from(__classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").getRandomBytes(24));
|
|
238
|
+
const payloadEnc = buffer_1.Buffer.from((0, nacl_1.secretBox)(keyAgreementHash, nonceEnc, transactionPlaintext));
|
|
239
|
+
const payloadOut = buffer_1.Buffer.from((0, nacl_1.secretBox)(parametersCiphertext.outgoingCipherKey, nonceOut, buffer_1.Buffer.concat([
|
|
239
240
|
recipientDiversifiedTransmissionKey,
|
|
240
241
|
parametersCiphertext.ephemeralPrivateKey,
|
|
241
242
|
])));
|
|
@@ -256,7 +257,7 @@ class SaplingTransactionBuilder {
|
|
|
256
257
|
async createBindingSignature(parametersBindingSig) {
|
|
257
258
|
const outputs = __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingForger, "f").forgeOutputDescriptions(parametersBindingSig.outputs);
|
|
258
259
|
const inputs = __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingForger, "f").forgeSpendDescriptions(parametersBindingSig.inputs);
|
|
259
|
-
const transactionSigHash = blakejs_1.default.blake2b(Buffer.concat([inputs, outputs, parametersBindingSig.boundData]), await this.getAntiReplay(), 32);
|
|
260
|
+
const transactionSigHash = blakejs_1.default.blake2b(buffer_1.Buffer.concat([inputs, outputs, parametersBindingSig.boundData]), await this.getAntiReplay(), 32);
|
|
260
261
|
return __classPrivateFieldGet(this, _SaplingTransactionBuilder_saplingWrapper, "f").createBindingSignature(parametersBindingSig.saplingContext, parametersBindingSig.balance.toFixed(), transactionSigHash);
|
|
261
262
|
}
|
|
262
263
|
async getAntiReplay() {
|
|
@@ -265,7 +266,7 @@ class SaplingTransactionBuilder {
|
|
|
265
266
|
chainId = await __classPrivateFieldGet(this, _SaplingTransactionBuilder_readProvider, "f").getChainId();
|
|
266
267
|
__classPrivateFieldSet(this, _SaplingTransactionBuilder_chainId, chainId, "f");
|
|
267
268
|
}
|
|
268
|
-
return Buffer.from(`${__classPrivateFieldGet(this, _SaplingTransactionBuilder_contractAddress, "f")}${chainId}`);
|
|
269
|
+
return buffer_1.Buffer.from(`${__classPrivateFieldGet(this, _SaplingTransactionBuilder_contractAddress, "f")}${chainId}`);
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
exports.SaplingTransactionBuilder = SaplingTransactionBuilder;
|
|
@@ -4,6 +4,7 @@ exports.memoHexToUtf8 = memoHexToUtf8;
|
|
|
4
4
|
exports.readableFormat = readableFormat;
|
|
5
5
|
exports.convertValueToBigNumber = convertValueToBigNumber;
|
|
6
6
|
exports.bufToUint8Array = bufToUint8Array;
|
|
7
|
+
const buffer_1 = require("buffer");
|
|
7
8
|
const utils_1 = require("@taquito/utils");
|
|
8
9
|
const bignumber_js_1 = require("bignumber.js");
|
|
9
10
|
function memoHexToUtf8(memo) {
|
|
@@ -17,12 +18,12 @@ function removeZeroPaddedBytesRight(memo) {
|
|
|
17
18
|
function readableFormat(saplingTransactionProperties) {
|
|
18
19
|
return {
|
|
19
20
|
value: convertValueToBigNumber(saplingTransactionProperties.value),
|
|
20
|
-
memo: memoHexToUtf8(Buffer.from(saplingTransactionProperties.memo).toString('hex')),
|
|
21
|
+
memo: memoHexToUtf8(buffer_1.Buffer.from(saplingTransactionProperties.memo).toString('hex')),
|
|
21
22
|
paymentAddress: (0, utils_1.b58Encode)(saplingTransactionProperties.paymentAddress, utils_1.PrefixV2.SaplingAddress),
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
function convertValueToBigNumber(value) {
|
|
25
|
-
return new bignumber_js_1.default(Buffer.from(value).toString('hex'), 16);
|
|
26
|
+
return new bignumber_js_1.default(buffer_1.Buffer.from(value).toString('hex'), 16);
|
|
26
27
|
}
|
|
27
28
|
function bufToUint8Array(buffer) {
|
|
28
29
|
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
@@ -13,7 +13,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _SaplingTransactionViewer_viewingKeyProvider, _SaplingTransactionViewer_readProvider, _SaplingTransactionViewer_saplingContractId;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SaplingTransactionViewer = void 0;
|
|
16
|
-
const
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
17
|
+
const sapling = require("../sapling-wasm");
|
|
17
18
|
const bignumber_js_1 = require("bignumber.js");
|
|
18
19
|
const BigNumber = bignumber_js_1.default;
|
|
19
20
|
const utils_1 = require("@taquito/utils");
|
|
@@ -117,7 +118,7 @@ class SaplingTransactionViewer {
|
|
|
117
118
|
const { epk, payload_enc, nonce_enc } = commitmentsAndCiphertexts[1];
|
|
118
119
|
const incomingViewingKey = await __classPrivateFieldGet(this, _SaplingTransactionViewer_viewingKeyProvider, "f").getIncomingViewingKey();
|
|
119
120
|
const keyAgreement = await sapling.keyAgreement(epk, incomingViewingKey);
|
|
120
|
-
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, Buffer.from(constants_1.KDF_KEY), 32);
|
|
121
|
+
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, buffer_1.Buffer.from(constants_1.KDF_KEY), 32);
|
|
121
122
|
const decrypted = await this.decryptCiphertext(keyAgreementHash, (0, utils_1.hex2buf)(nonce_enc), (0, utils_1.hex2buf)(payload_enc));
|
|
122
123
|
if (decrypted) {
|
|
123
124
|
const { diversifier, value, randomCommitmentTrapdoor: rcm, memo, } = this.extractTransactionProperties(decrypted);
|
|
@@ -140,12 +141,12 @@ class SaplingTransactionViewer {
|
|
|
140
141
|
const { epk, payload_enc, nonce_enc, payload_out, nonce_out, cv } = commitmentsAndCiphertexts[1];
|
|
141
142
|
const outgoingViewingKey = await __classPrivateFieldGet(this, _SaplingTransactionViewer_viewingKeyProvider, "f").getOutgoingViewingKey();
|
|
142
143
|
const concat = cv.concat(commitment, epk, outgoingViewingKey.toString('hex'));
|
|
143
|
-
const outgoingCipherKey = blakejs_1.default.blake2b(Buffer.from(concat, 'hex'), Buffer.from(constants_1.OCK_KEY), 32);
|
|
144
|
+
const outgoingCipherKey = blakejs_1.default.blake2b(buffer_1.Buffer.from(concat, 'hex'), buffer_1.Buffer.from(constants_1.OCK_KEY), 32);
|
|
144
145
|
const decryptedOut = await this.decryptCiphertext(outgoingCipherKey, (0, utils_1.hex2buf)(nonce_out), (0, utils_1.hex2buf)(payload_out));
|
|
145
146
|
if (decryptedOut) {
|
|
146
147
|
const { recipientDiversifiedTransmissionKey: pkd, ephemeralPrivateKey: esk } = this.extractPkdAndEsk(decryptedOut);
|
|
147
148
|
const keyAgreement = await sapling.keyAgreement(pkd, esk);
|
|
148
|
-
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, Buffer.from(constants_1.KDF_KEY), 32);
|
|
149
|
+
const keyAgreementHash = blakejs_1.default.blake2b(keyAgreement, buffer_1.Buffer.from(constants_1.KDF_KEY), 32);
|
|
149
150
|
const decryptedEnc = await this.decryptCiphertext(keyAgreementHash, (0, utils_1.hex2buf)(nonce_enc), (0, utils_1.hex2buf)(payload_enc));
|
|
150
151
|
if (decryptedEnc) {
|
|
151
152
|
const { diversifier, value, randomCommitmentTrapdoor: rcm, memo, } = this.extractTransactionProperties(decryptedEnc);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const buffer_1 = require("buffer");
|
|
18
|
+
const globalWithBuffer = globalThis;
|
|
19
|
+
if (typeof globalWithBuffer.Buffer === 'undefined') {
|
|
20
|
+
globalWithBuffer.Buffer = buffer_1.Buffer;
|
|
21
|
+
}
|
|
22
|
+
__exportStar(require("@taquito/sapling-wasm"), exports);
|
|
@@ -17,6 +17,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
17
17
|
var _SaplingToolkit_inMemorySpendingKey, _SaplingToolkit_saplingId, _SaplingToolkit_contractAddress, _SaplingToolkit_memoSize, _SaplingToolkit_readProvider, _SaplingToolkit_packer, _SaplingToolkit_saplingForger, _SaplingToolkit_saplingTxBuilder, _SaplingToolkit_saplingTransactionViewer;
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.SaplingToolkit = exports.InMemoryProvingKey = exports.InMemorySpendingKey = exports.InMemoryViewingKey = exports.SaplingTransactionViewer = void 0;
|
|
20
|
+
const buffer_1 = require("buffer");
|
|
20
21
|
const bignumber_js_1 = require("bignumber.js");
|
|
21
22
|
const BigNumber = bignumber_js_1.default;
|
|
22
23
|
const taquito_1 = require("@taquito/taquito");
|
|
@@ -191,7 +192,7 @@ class SaplingToolkit {
|
|
|
191
192
|
data: { bytes },
|
|
192
193
|
type: { prim: 'bytes' },
|
|
193
194
|
});
|
|
194
|
-
return Buffer.from(packedDestination.packed, 'hex');
|
|
195
|
+
return buffer_1.Buffer.from(packedDestination.packed, 'hex');
|
|
195
196
|
}
|
|
196
197
|
validateDestinationImplicitAddress(to) {
|
|
197
198
|
const toValidation = (0, utils_1.validateKeyHash)(to);
|
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": "e5181715f96fc1a8e79c0c3a89b5130abe1a3434",
|
|
7
|
+
"version": "24.3.0-beta.7"
|
|
8
8
|
};
|