@tokamak-private-dapps/private-state-cli 0.1.8 → 1.0.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/CHANGELOG.md +85 -0
- package/README.md +87 -26
- package/cli-assistant.html +64 -413
- package/lib/private-state-cli-command-registry.mjs +352 -0
- package/lib/private-state-cli-shared.mjs +7 -7
- package/lib/private-state-note-delivery.mjs +415 -0
- package/lib/private-state-runtime-management.mjs +1311 -0
- package/lib/private-state-tokamak-helpers.mjs +184 -0
- package/package.json +4 -4
- package/private-state-bridge-cli.mjs +2353 -2075
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { AbiCoder, ethers } from "ethers";
|
|
3
|
+
import { deriveL2KeysFromSignature, poseidon } from "tokamak-l2js";
|
|
4
|
+
import { jubjub } from "@noble/curves/jubjub";
|
|
5
|
+
|
|
6
|
+
const abiCoder = AbiCoder.defaultAbiCoder();
|
|
7
|
+
|
|
8
|
+
export const NOTE_RECEIVE_TYPED_DATA_METHOD = "eth_signTypedData_v4";
|
|
9
|
+
export const NOTE_RECEIVE_KEY_DERIVATION_VERSION = 2;
|
|
10
|
+
export const ENCRYPTED_NOTE_SCHEME_TRANSFER = 0;
|
|
11
|
+
export const ENCRYPTED_NOTE_SCHEME_SELF_MINT = 1;
|
|
12
|
+
export const BLS12_381_SCALAR_FIELD_MODULUS =
|
|
13
|
+
ethers.toBigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001");
|
|
14
|
+
|
|
15
|
+
const NOTE_RECEIVE_TYPED_DATA_DOMAIN = {
|
|
16
|
+
name: "TokamakPrivateState",
|
|
17
|
+
version: "1",
|
|
18
|
+
};
|
|
19
|
+
const NOTE_RECEIVE_TYPED_DATA_TYPES = {
|
|
20
|
+
NoteReceiveKey: [
|
|
21
|
+
{ name: "protocol", type: "string" },
|
|
22
|
+
{ name: "dapp", type: "string" },
|
|
23
|
+
{ name: "channelId", type: "uint256" },
|
|
24
|
+
{ name: "channelName", type: "string" },
|
|
25
|
+
{ name: "account", type: "address" },
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
const NOTE_RECEIVE_TYPED_DATA_PROTOCOL = "PRIVATE_STATE_NOTE_RECEIVE_KEY_V2";
|
|
29
|
+
const NOTE_RECEIVE_TYPED_DATA_DAPP = "private-state";
|
|
30
|
+
const TRANSFER_NOTE_FIELD_ENCRYPTION_INFO = "PRIVATE_STATE_NOTE_FIELD_ENCRYPTION_V1";
|
|
31
|
+
const MINT_NOTE_FIELD_ENCRYPTION_INFO = "PRIVATE_STATE_SELF_MINT_NOTE_FIELD_ENCRYPTION_V1";
|
|
32
|
+
const NOTE_COMMITMENT_DOMAIN = ethers.keccak256(ethers.toUtf8Bytes("PRIVATE_STATE_NOTE_COMMITMENT"));
|
|
33
|
+
const NULLIFIER_DOMAIN = ethers.keccak256(ethers.toUtf8Bytes("PRIVATE_STATE_NULLIFIER"));
|
|
34
|
+
const JUBJUB_ORDER = jubjub.CURVE.n;
|
|
35
|
+
const JUBJUB_FP = jubjub.CURVE.Fp;
|
|
36
|
+
const JUBJUB_A = jubjub.CURVE.a;
|
|
37
|
+
const JUBJUB_D = jubjub.CURVE.d;
|
|
38
|
+
|
|
39
|
+
function expect(condition, message) {
|
|
40
|
+
if (!condition) {
|
|
41
|
+
throw new Error(message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function normalizeBytes32Hex(value) {
|
|
46
|
+
return ethers.hexlify(ethers.zeroPadValue(ethers.hexlify(value), 32)).toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function normalizeBytes16Hex(value) {
|
|
50
|
+
return ethers.hexlify(ethers.zeroPadValue(ethers.hexlify(value), 16)).toLowerCase();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function poseidonHexFromBytes(bytesLike) {
|
|
54
|
+
return ethers.hexlify(poseidon(ethers.getBytes(bytesLike))).toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function noteReceivePubKeyFromPoint(point) {
|
|
58
|
+
const affine = point.toAffine();
|
|
59
|
+
return {
|
|
60
|
+
x: normalizeBytes32Hex(ethers.toBeHex(affine.x)),
|
|
61
|
+
yParity: Number(affine.y & 1n),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function pointFromNoteReceivePubKey(noteReceivePubKey) {
|
|
66
|
+
const x = ethers.toBigInt(noteReceivePubKey.x);
|
|
67
|
+
expect(x < JUBJUB_FP.ORDER, "Jubjub note-receive public key x-coordinate is out of range.");
|
|
68
|
+
const xSquared = JUBJUB_FP.mul(x, x);
|
|
69
|
+
const numerator = JUBJUB_FP.sub(1n, JUBJUB_FP.mul(JUBJUB_A, xSquared));
|
|
70
|
+
const denominator = JUBJUB_FP.sub(1n, JUBJUB_FP.mul(JUBJUB_D, xSquared));
|
|
71
|
+
let y = JUBJUB_FP.sqrt(JUBJUB_FP.div(numerator, denominator));
|
|
72
|
+
if (Number(y & 1n) !== Number(noteReceivePubKey.yParity)) {
|
|
73
|
+
y = JUBJUB_FP.neg(y);
|
|
74
|
+
}
|
|
75
|
+
return jubjub.ExtendedPoint.fromAffine({ x, y });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function parseJubjubPrivateScalar(privateKey) {
|
|
79
|
+
const scalar = ethers.toBigInt(privateKey);
|
|
80
|
+
expect(
|
|
81
|
+
scalar > 0n && scalar < JUBJUB_ORDER,
|
|
82
|
+
"Jubjub note-receive private key must be within the scalar field range.",
|
|
83
|
+
);
|
|
84
|
+
return scalar;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function deriveEphemeralJubjubScalar() {
|
|
88
|
+
const raw = ethers.toBigInt(ethers.hexlify(jubjub.utils.randomPrivateKey(randomBytes(32))));
|
|
89
|
+
return (raw % (JUBJUB_ORDER - 1n)) + 1n;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function buildNoteReceiveTypedData({ chainId, channelId, channelName, account }) {
|
|
93
|
+
return {
|
|
94
|
+
domain: {
|
|
95
|
+
...NOTE_RECEIVE_TYPED_DATA_DOMAIN,
|
|
96
|
+
chainId,
|
|
97
|
+
},
|
|
98
|
+
types: NOTE_RECEIVE_TYPED_DATA_TYPES,
|
|
99
|
+
value: {
|
|
100
|
+
protocol: NOTE_RECEIVE_TYPED_DATA_PROTOCOL,
|
|
101
|
+
dapp: NOTE_RECEIVE_TYPED_DATA_DAPP,
|
|
102
|
+
channelId: ethers.toBigInt(channelId).toString(),
|
|
103
|
+
channelName,
|
|
104
|
+
account: ethers.getAddress(account),
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function computeNoteCommitment(note) {
|
|
110
|
+
const data = ethers.getBytes(ethers.concat([
|
|
111
|
+
NOTE_COMMITMENT_DOMAIN,
|
|
112
|
+
ethers.zeroPadValue(ethers.getAddress(note.owner), 32),
|
|
113
|
+
ethers.toBeHex(ethers.toBigInt(note.value), 32),
|
|
114
|
+
normalizeBytes32Hex(note.salt),
|
|
115
|
+
]));
|
|
116
|
+
return normalizeBytes32Hex(poseidonHexFromBytes(data));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function computeNullifier(note) {
|
|
120
|
+
const data = ethers.getBytes(ethers.concat([
|
|
121
|
+
NULLIFIER_DOMAIN,
|
|
122
|
+
ethers.zeroPadValue(ethers.getAddress(note.owner), 32),
|
|
123
|
+
ethers.toBeHex(ethers.toBigInt(note.value), 32),
|
|
124
|
+
normalizeBytes32Hex(note.salt),
|
|
125
|
+
]));
|
|
126
|
+
return normalizeBytes32Hex(poseidonHexFromBytes(data));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function normalizeEncryptedNoteValueWords(encryptedNoteValue) {
|
|
130
|
+
expect(
|
|
131
|
+
Array.isArray(encryptedNoteValue) && encryptedNoteValue.length === 3,
|
|
132
|
+
"Encrypted note value must be a bytes32[3] payload.",
|
|
133
|
+
);
|
|
134
|
+
return encryptedNoteValue.map((word) => normalizeBytes32Hex(word));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function packEncryptedNoteValue({
|
|
138
|
+
ephemeralPubKeyX,
|
|
139
|
+
ephemeralPubKeyYParity,
|
|
140
|
+
nonce,
|
|
141
|
+
ciphertextValue,
|
|
142
|
+
tag,
|
|
143
|
+
scheme = ENCRYPTED_NOTE_SCHEME_TRANSFER,
|
|
144
|
+
}) {
|
|
145
|
+
const parity = Number(ephemeralPubKeyYParity);
|
|
146
|
+
expect(parity === 0 || parity === 1, "Encrypted note value y parity must be 0 or 1.");
|
|
147
|
+
const normalizedScheme = Number(scheme);
|
|
148
|
+
expect(
|
|
149
|
+
Number.isInteger(normalizedScheme) && normalizedScheme >= 0 && normalizedScheme <= 255,
|
|
150
|
+
"Encrypted note value scheme must fit in one byte.",
|
|
151
|
+
);
|
|
152
|
+
return normalizeEncryptedNoteValueWords([
|
|
153
|
+
normalizeBytes32Hex(ephemeralPubKeyX),
|
|
154
|
+
ethers.hexlify(ethers.concat([
|
|
155
|
+
Uint8Array.from([parity]),
|
|
156
|
+
ethers.getBytes(ethers.zeroPadValue(nonce, 12)),
|
|
157
|
+
ethers.getBytes(ethers.zeroPadValue(tag, 16)),
|
|
158
|
+
Uint8Array.from([normalizedScheme, 0, 0]),
|
|
159
|
+
])),
|
|
160
|
+
normalizeBytes32Hex(ciphertextValue),
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function unpackEncryptedNoteValue(encryptedNoteValue) {
|
|
165
|
+
const [ephemeralPubKeyX, packedMeta, ciphertextValue] = normalizeEncryptedNoteValueWords(encryptedNoteValue);
|
|
166
|
+
const packedMetaBytes = ethers.getBytes(packedMeta);
|
|
167
|
+
return {
|
|
168
|
+
ephemeralPubKeyX,
|
|
169
|
+
ephemeralPubKeyYParity: packedMetaBytes[0],
|
|
170
|
+
nonce: ethers.hexlify(packedMetaBytes.slice(1, 13)),
|
|
171
|
+
ciphertextValue,
|
|
172
|
+
tag: ethers.hexlify(packedMetaBytes.slice(13, 29)),
|
|
173
|
+
scheme: packedMetaBytes[29],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function computeEncryptedNoteSalt(encryptedValue) {
|
|
178
|
+
const normalized = normalizeEncryptedNoteValueWords(encryptedValue);
|
|
179
|
+
return normalizeBytes32Hex(poseidonHexFromBytes(ethers.getBytes(ethers.concat(normalized))));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function encodeNoteValuePlaintext(value) {
|
|
183
|
+
const scalar = ethers.toBigInt(value);
|
|
184
|
+
expect(
|
|
185
|
+
scalar >= 0n && scalar < BLS12_381_SCALAR_FIELD_MODULUS,
|
|
186
|
+
"Encrypted note plaintext value must fit within the BLS12-381 scalar field.",
|
|
187
|
+
);
|
|
188
|
+
return scalar;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function decodeNoteValuePlaintext(valueBytes) {
|
|
192
|
+
return ethers.toBigInt(valueBytes).toString();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function fieldElementHex(value) {
|
|
196
|
+
return normalizeBytes32Hex(ethers.toBeHex(value));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function deriveFieldMask({ sharedSecretPoint, chainId, channelId, owner, nonce, encryptionInfo }) {
|
|
200
|
+
const affine = sharedSecretPoint.toAffine();
|
|
201
|
+
return ethers.toBigInt(
|
|
202
|
+
poseidonHexFromBytes(
|
|
203
|
+
abiCoder.encode(
|
|
204
|
+
["string", "uint256", "uint256", "address", "uint256", "uint256", "bytes12"],
|
|
205
|
+
[
|
|
206
|
+
encryptionInfo,
|
|
207
|
+
ethers.toBigInt(chainId),
|
|
208
|
+
ethers.toBigInt(channelId),
|
|
209
|
+
ethers.getAddress(owner),
|
|
210
|
+
affine.x,
|
|
211
|
+
affine.y,
|
|
212
|
+
ethers.zeroPadValue(nonce, 12),
|
|
213
|
+
],
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function deriveCipherTag({ sharedSecretPoint, chainId, channelId, owner, nonce, ciphertextValue, encryptionInfo }) {
|
|
220
|
+
const affine = sharedSecretPoint.toAffine();
|
|
221
|
+
return ethers.dataSlice(
|
|
222
|
+
poseidonHexFromBytes(
|
|
223
|
+
abiCoder.encode(
|
|
224
|
+
["string", "uint256", "uint256", "address", "uint256", "uint256", "bytes12", "bytes32"],
|
|
225
|
+
[
|
|
226
|
+
`${encryptionInfo}:tag`,
|
|
227
|
+
ethers.toBigInt(chainId),
|
|
228
|
+
ethers.toBigInt(channelId),
|
|
229
|
+
ethers.getAddress(owner),
|
|
230
|
+
affine.x,
|
|
231
|
+
affine.y,
|
|
232
|
+
ethers.zeroPadValue(nonce, 12),
|
|
233
|
+
fieldElementHex(ciphertextValue),
|
|
234
|
+
],
|
|
235
|
+
),
|
|
236
|
+
),
|
|
237
|
+
0,
|
|
238
|
+
16,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export async function deriveNoteReceiveKeyMaterial({ signer, chainId, channelId, channelName, account }) {
|
|
243
|
+
const typedData = buildNoteReceiveTypedData({
|
|
244
|
+
chainId,
|
|
245
|
+
channelId,
|
|
246
|
+
channelName,
|
|
247
|
+
account,
|
|
248
|
+
});
|
|
249
|
+
const signature = await signer.signTypedData(typedData.domain, typedData.types, typedData.value);
|
|
250
|
+
const derivedKeys = deriveL2KeysFromSignature(signature);
|
|
251
|
+
const privateKey = ethers.hexlify(derivedKeys.privateKey);
|
|
252
|
+
const noteReceivePoint = jubjub.ExtendedPoint.fromHex(derivedKeys.publicKey);
|
|
253
|
+
return {
|
|
254
|
+
typedData,
|
|
255
|
+
signature,
|
|
256
|
+
privateKey,
|
|
257
|
+
noteReceivePubKey: noteReceivePubKeyFromPoint(noteReceivePoint),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function encryptFieldNoteValue({
|
|
262
|
+
value,
|
|
263
|
+
recipientPoint,
|
|
264
|
+
chainId,
|
|
265
|
+
channelId,
|
|
266
|
+
owner,
|
|
267
|
+
nonce,
|
|
268
|
+
encryptionInfo,
|
|
269
|
+
scheme,
|
|
270
|
+
}) {
|
|
271
|
+
const ephemeralPrivateScalar = deriveEphemeralJubjubScalar();
|
|
272
|
+
const ephemeralPoint = jubjub.ExtendedPoint.BASE.multiply(ephemeralPrivateScalar);
|
|
273
|
+
const sharedSecretPoint = recipientPoint.multiply(ephemeralPrivateScalar);
|
|
274
|
+
const cipherNonce = nonce ? ethers.zeroPadValue(nonce, 12) : ethers.hexlify(randomBytes(12));
|
|
275
|
+
const plaintextValue = encodeNoteValuePlaintext(value);
|
|
276
|
+
const fieldMask = deriveFieldMask({
|
|
277
|
+
sharedSecretPoint,
|
|
278
|
+
chainId,
|
|
279
|
+
channelId,
|
|
280
|
+
owner,
|
|
281
|
+
nonce: cipherNonce,
|
|
282
|
+
encryptionInfo,
|
|
283
|
+
});
|
|
284
|
+
const ciphertextValue = (plaintextValue + fieldMask) % BLS12_381_SCALAR_FIELD_MODULUS;
|
|
285
|
+
const tag = deriveCipherTag({
|
|
286
|
+
sharedSecretPoint,
|
|
287
|
+
chainId,
|
|
288
|
+
channelId,
|
|
289
|
+
owner,
|
|
290
|
+
nonce: cipherNonce,
|
|
291
|
+
ciphertextValue,
|
|
292
|
+
encryptionInfo,
|
|
293
|
+
});
|
|
294
|
+
const parsedEphemeralPubKey = noteReceivePubKeyFromPoint(ephemeralPoint);
|
|
295
|
+
|
|
296
|
+
return packEncryptedNoteValue({
|
|
297
|
+
ephemeralPubKeyX: parsedEphemeralPubKey.x,
|
|
298
|
+
ephemeralPubKeyYParity: parsedEphemeralPubKey.yParity,
|
|
299
|
+
nonce: cipherNonce,
|
|
300
|
+
ciphertextValue: fieldElementHex(ciphertextValue),
|
|
301
|
+
tag,
|
|
302
|
+
scheme,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function encryptNoteValueForRecipient({
|
|
307
|
+
value,
|
|
308
|
+
recipientNoteReceivePubKey,
|
|
309
|
+
chainId,
|
|
310
|
+
channelId,
|
|
311
|
+
owner,
|
|
312
|
+
nonce = null,
|
|
313
|
+
}) {
|
|
314
|
+
return encryptFieldNoteValue({
|
|
315
|
+
value,
|
|
316
|
+
recipientPoint: pointFromNoteReceivePubKey(recipientNoteReceivePubKey),
|
|
317
|
+
chainId,
|
|
318
|
+
channelId,
|
|
319
|
+
owner,
|
|
320
|
+
nonce,
|
|
321
|
+
encryptionInfo: TRANSFER_NOTE_FIELD_ENCRYPTION_INFO,
|
|
322
|
+
scheme: ENCRYPTED_NOTE_SCHEME_TRANSFER,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function encryptMintNoteValueForOwner({
|
|
327
|
+
value,
|
|
328
|
+
ownerNoteReceivePubKey,
|
|
329
|
+
chainId,
|
|
330
|
+
channelId,
|
|
331
|
+
owner,
|
|
332
|
+
nonce = null,
|
|
333
|
+
}) {
|
|
334
|
+
return encryptFieldNoteValue({
|
|
335
|
+
value,
|
|
336
|
+
recipientPoint: pointFromNoteReceivePubKey(ownerNoteReceivePubKey),
|
|
337
|
+
chainId,
|
|
338
|
+
channelId,
|
|
339
|
+
owner,
|
|
340
|
+
nonce,
|
|
341
|
+
encryptionInfo: MINT_NOTE_FIELD_ENCRYPTION_INFO,
|
|
342
|
+
scheme: ENCRYPTED_NOTE_SCHEME_SELF_MINT,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function decryptFieldEncryptedNoteValue({
|
|
347
|
+
encryptedValue,
|
|
348
|
+
privateKey,
|
|
349
|
+
chainId,
|
|
350
|
+
channelId,
|
|
351
|
+
owner,
|
|
352
|
+
encryptionInfo,
|
|
353
|
+
expectedScheme,
|
|
354
|
+
}) {
|
|
355
|
+
const normalized = unpackEncryptedNoteValue(encryptedValue);
|
|
356
|
+
expect(
|
|
357
|
+
normalized.scheme === expectedScheme,
|
|
358
|
+
`Encrypted note value scheme mismatch. Expected ${expectedScheme}, received ${normalized.scheme}.`,
|
|
359
|
+
);
|
|
360
|
+
const sharedSecretPoint = pointFromNoteReceivePubKey({
|
|
361
|
+
x: normalized.ephemeralPubKeyX,
|
|
362
|
+
yParity: normalized.ephemeralPubKeyYParity,
|
|
363
|
+
}).multiply(parseJubjubPrivateScalar(privateKey));
|
|
364
|
+
const expectedTag = deriveCipherTag({
|
|
365
|
+
sharedSecretPoint,
|
|
366
|
+
chainId,
|
|
367
|
+
channelId,
|
|
368
|
+
owner,
|
|
369
|
+
nonce: normalized.nonce,
|
|
370
|
+
ciphertextValue: ethers.toBigInt(normalized.ciphertextValue),
|
|
371
|
+
encryptionInfo,
|
|
372
|
+
});
|
|
373
|
+
expect(
|
|
374
|
+
normalizeBytes16Hex(expectedTag) === normalizeBytes16Hex(normalized.tag),
|
|
375
|
+
"Encrypted note value integrity tag mismatch.",
|
|
376
|
+
);
|
|
377
|
+
const fieldMask = deriveFieldMask({
|
|
378
|
+
sharedSecretPoint,
|
|
379
|
+
chainId,
|
|
380
|
+
channelId,
|
|
381
|
+
owner,
|
|
382
|
+
nonce: normalized.nonce,
|
|
383
|
+
encryptionInfo,
|
|
384
|
+
});
|
|
385
|
+
const plaintext = (
|
|
386
|
+
ethers.toBigInt(normalized.ciphertextValue)
|
|
387
|
+
- fieldMask
|
|
388
|
+
+ BLS12_381_SCALAR_FIELD_MODULUS
|
|
389
|
+
) % BLS12_381_SCALAR_FIELD_MODULUS;
|
|
390
|
+
return decodeNoteValuePlaintext(plaintext);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export function decryptEncryptedNoteValue({ encryptedValue, noteReceivePrivateKey, chainId, channelId, owner }) {
|
|
394
|
+
return decryptFieldEncryptedNoteValue({
|
|
395
|
+
encryptedValue,
|
|
396
|
+
privateKey: noteReceivePrivateKey,
|
|
397
|
+
chainId,
|
|
398
|
+
channelId,
|
|
399
|
+
owner,
|
|
400
|
+
encryptionInfo: TRANSFER_NOTE_FIELD_ENCRYPTION_INFO,
|
|
401
|
+
expectedScheme: ENCRYPTED_NOTE_SCHEME_TRANSFER,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export function decryptMintEncryptedNoteValue({ encryptedValue, noteReceivePrivateKey, chainId, channelId, owner }) {
|
|
406
|
+
return decryptFieldEncryptedNoteValue({
|
|
407
|
+
encryptedValue,
|
|
408
|
+
privateKey: noteReceivePrivateKey,
|
|
409
|
+
chainId,
|
|
410
|
+
channelId,
|
|
411
|
+
owner,
|
|
412
|
+
encryptionInfo: MINT_NOTE_FIELD_ENCRYPTION_INFO,
|
|
413
|
+
expectedScheme: ENCRYPTED_NOTE_SCHEME_SELF_MINT,
|
|
414
|
+
});
|
|
415
|
+
}
|