@lfdecentralizedtrust/zeto-contracts 0.2.2 → 0.5.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/README.md +70 -162
- package/contracts/factory.sol +30 -34
- package/contracts/factory_upgradeable.sol +11 -7
- package/contracts/lib/common/util.sol +40 -0
- package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
- package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
- package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
- package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
- package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
- package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
- package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
- package/contracts/lib/registry.sol +74 -26
- package/contracts/lib/storage/base.sol +210 -0
- package/contracts/lib/storage/nullifier.sol +166 -0
- package/contracts/lib/zeto_common.sol +277 -28
- package/contracts/lib/zeto_fungible.sol +451 -33
- package/contracts/lib/zeto_fungible_base.sol +69 -0
- package/contracts/lib/zeto_fungible_burn.sol +83 -53
- package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
- package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
- package/contracts/lib/zeto_lockable.sol +613 -0
- package/contracts/lib/zeto_non_fungible.sol +236 -0
- package/contracts/lib/zeto_non_fungible_base.sol +61 -0
- package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
- package/contracts/test/escrow1.sol +90 -34
- package/contracts/test/escrow2.sol +64 -29
- package/contracts/test/qurrency.sol +10 -2
- package/contracts/test/smt.sol +6 -1
- package/contracts/test/tendecimals.sol +14 -12
- package/contracts/verifiers/impl/anon.sol +189 -0
- package/contracts/verifiers/impl/anon_batch.sol +301 -0
- package/contracts/verifiers/impl/anon_enc.sol +266 -0
- package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
- package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
- package/contracts/verifiers/impl/burn.sol +182 -0
- package/contracts/verifiers/impl/burn_batch.sol +238 -0
- package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
- package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
- package/contracts/verifiers/impl/deposit.sol +182 -0
- package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
- package/contracts/verifiers/impl/nf_anon.sol +175 -0
- package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
- package/contracts/verifiers/impl/withdraw.sol +189 -0
- package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
- package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
- package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
- package/contracts/verifiers/verifier_anon.sol +31 -186
- package/contracts/verifiers/verifier_anon_batch.sol +31 -298
- package/contracts/verifiers/verifier_anon_enc.sol +31 -263
- package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
- package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
- package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
- package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
- package/contracts/verifiers/verifier_burn.sol +31 -179
- package/contracts/verifiers/verifier_burn_batch.sol +31 -235
- package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
- package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
- package/contracts/verifiers/verifier_deposit.sol +31 -179
- package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
- package/contracts/verifiers/verifier_nf_anon.sol +31 -172
- package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
- package/contracts/verifiers/verifier_withdraw.sol +31 -186
- package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
- package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
- package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
- package/contracts/zeto_anon.sol +77 -231
- package/contracts/zeto_anon_burnable.sol +56 -12
- package/contracts/zeto_anon_enc.sol +93 -190
- package/contracts/zeto_anon_enc_nullifier.sol +249 -195
- package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
- package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
- package/contracts/zeto_anon_nullifier.sol +164 -298
- package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
- package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
- package/contracts/zeto_anon_nullifier_qurrency.sol +217 -361
- package/contracts/zeto_nf_anon.sol +55 -130
- package/contracts/zeto_nf_anon_nullifier.sol +90 -152
- package/hardhat.config.ts +9 -3
- package/ignition/modules/lib/deps.ts +8 -0
- package/ignition/modules/zeto_anon_burnable.ts +8 -7
- package/ignition/modules/zeto_anon_enc_nullifier.ts +31 -0
- package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +2 -2
- package/ignition/modules/zeto_anon_nullifier.ts +28 -4
- package/ignition/modules/zeto_anon_nullifier_burnable.ts +50 -16
- package/ignition/modules/zeto_anon_nullifier_kyc.ts +27 -12
- package/ignition/modules/zeto_nf_anon_nullifier.ts +14 -10
- package/package.json +4 -2
- package/scripts/deploy_cloneable.ts +19 -10
- package/scripts/deploy_upgradeable.ts +9 -5
- package/scripts/tokens/Zeto_Anon.ts +3 -3
- package/scripts/tokens/Zeto_AnonBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonEnc.ts +12 -3
- package/scripts/tokens/Zeto_AnonEncNullifier.ts +5 -3
- package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifier.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +1 -1
- package/scripts/tokens/Zeto_NfAnon.ts +2 -2
- package/scripts/tokens/Zeto_NfAnonNullifier.ts +1 -1
- package/test/factory.ts +46 -73
- package/test/lib/anon_nullifier_helpers.ts +89 -0
- package/test/lib/anon_zeto_helpers.ts +76 -0
- package/test/lib/deploy.ts +3 -2
- package/test/lib/utils.ts +74 -35
- package/test/test/escrow1.ts +185 -58
- package/test/test/escrow2.ts +200 -107
- package/test/test/qurrency.ts +13 -33
- package/test/usdc-shielding.ts +39 -26
- package/test/utils.ts +144 -21
- package/test/zeto_anon.ts +956 -465
- package/test/zeto_anon_enc.ts +881 -142
- package/test/zeto_anon_enc_nullifier.ts +847 -38
- package/test/zeto_anon_enc_nullifier_kyc.ts +120 -181
- package/test/zeto_anon_enc_nullifier_non_repudiation.ts +77 -46
- package/test/zeto_anon_nullifier.ts +1212 -953
- package/test/zeto_anon_nullifier_kyc.ts +674 -655
- package/test/zeto_anon_nullifier_qurrency.ts +452 -306
- package/test/zeto_nf_anon.ts +737 -137
- package/test/zeto_nf_anon_nullifier.ts +876 -246
- package/contracts/lib/zeto_base.sol +0 -293
- package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
- package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
- package/contracts/lib/zeto_nullifier.sol +0 -340
- package/contracts/zkDvP.sol_ +0 -273
- package/test/zkDvP.ts_ +0 -455
- /package/contracts/lib/{common.sol → common/common.sol} +0 -0
package/test/utils.ts
CHANGED
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import { readFileSync } from "fs";
|
|
18
18
|
import * as path from "path";
|
|
19
|
-
import
|
|
20
|
-
import { BigNumberish } from "ethers";
|
|
19
|
+
import { AbiCoder, BigNumberish, keccak256, toUtf8Bytes } from "ethers";
|
|
21
20
|
import { groth16 } from "snarkjs";
|
|
22
|
-
import { loadCircuit, encodeProof
|
|
23
|
-
import { User, UTXO } from "./lib/utils";
|
|
24
|
-
import { formatPrivKeyForBabyJub, stringifyBigInts } from "maci-crypto";
|
|
21
|
+
import { loadCircuit, encodeProof } from "zeto-js";
|
|
22
|
+
import { User, UTXO, ZERO_UTXO, logger } from "./lib/utils";
|
|
25
23
|
|
|
26
24
|
function provingKeysRoot() {
|
|
27
25
|
const PROVING_KEYS_ROOT = process.env.PROVING_KEYS_ROOT;
|
|
@@ -44,6 +42,24 @@ export function loadProvingKeys(type: string) {
|
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
44
|
|
|
45
|
+
export function inflateUtxos(outputUtxos: UTXO[]) {
|
|
46
|
+
const desiredLength = outputUtxos.length > 2 ? 10 : 2;
|
|
47
|
+
const inflatedOutputUtxos = [...outputUtxos];
|
|
48
|
+
for (let i = 0; i < desiredLength - outputUtxos.length; i++) {
|
|
49
|
+
inflatedOutputUtxos.push(ZERO_UTXO);
|
|
50
|
+
}
|
|
51
|
+
return inflatedOutputUtxos;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function inflateOwners(owners: User[]) {
|
|
55
|
+
const desiredLength = owners.length > 2 ? 10 : 2;
|
|
56
|
+
const inflatedOwners = [...owners];
|
|
57
|
+
for (let i = 0; i < desiredLength - owners.length; i++) {
|
|
58
|
+
inflatedOwners.push(owners[0]); // use a random owner for the extra utxos
|
|
59
|
+
}
|
|
60
|
+
return inflatedOwners;
|
|
61
|
+
}
|
|
62
|
+
|
|
47
63
|
export async function prepareDepositProof(signer: User, outputs: [UTXO, UTXO]) {
|
|
48
64
|
const outputCommitments: [BigNumberish, BigNumberish] = [
|
|
49
65
|
outputs[0].hash,
|
|
@@ -60,10 +76,10 @@ export async function prepareDepositProof(signer: User, outputs: [UTXO, UTXO]) {
|
|
|
60
76
|
const outputOwnerPublicKeys: [
|
|
61
77
|
[BigNumberish, BigNumberish],
|
|
62
78
|
[BigNumberish, BigNumberish],
|
|
63
|
-
] = [
|
|
64
|
-
|
|
65
|
-
[
|
|
66
|
-
];
|
|
79
|
+
] = [
|
|
80
|
+
signer.babyJubPublicKey,
|
|
81
|
+
outputs[1].hash ? signer.babyJubPublicKey : [0n, 0n],
|
|
82
|
+
] as [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]];
|
|
67
83
|
|
|
68
84
|
const inputObj = {
|
|
69
85
|
outputCommitments,
|
|
@@ -86,7 +102,67 @@ export async function prepareDepositProof(signer: User, outputs: [UTXO, UTXO]) {
|
|
|
86
102
|
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
87
103
|
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
88
104
|
|
|
89
|
-
|
|
105
|
+
logger.debug(
|
|
106
|
+
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const encodedProof = encodeProof(proof);
|
|
110
|
+
return {
|
|
111
|
+
outputCommitments,
|
|
112
|
+
encodedProof,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function prepareDepositKycProof(
|
|
117
|
+
signer: User,
|
|
118
|
+
outputs: [UTXO, UTXO],
|
|
119
|
+
identitiesRoot: BigInt,
|
|
120
|
+
identitiesMerkleProof: BigInt[][],
|
|
121
|
+
) {
|
|
122
|
+
const outputCommitments: [BigNumberish, BigNumberish] = [
|
|
123
|
+
outputs[0].hash,
|
|
124
|
+
outputs[1].hash,
|
|
125
|
+
] as [BigNumberish, BigNumberish];
|
|
126
|
+
const outputValues = [
|
|
127
|
+
BigInt(outputs[0].value || 0),
|
|
128
|
+
BigInt(outputs[1].value || 0),
|
|
129
|
+
];
|
|
130
|
+
const outputSalts = [
|
|
131
|
+
BigInt(outputs[0].salt || 0n),
|
|
132
|
+
BigInt(outputs[1].salt || 0n),
|
|
133
|
+
];
|
|
134
|
+
const outputOwnerPublicKeys: [
|
|
135
|
+
[BigNumberish, BigNumberish],
|
|
136
|
+
[BigNumberish, BigNumberish],
|
|
137
|
+
] = [
|
|
138
|
+
signer.babyJubPublicKey,
|
|
139
|
+
outputs[1].hash ? signer.babyJubPublicKey : [0n, 0n],
|
|
140
|
+
] as [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]];
|
|
141
|
+
|
|
142
|
+
const inputObj = {
|
|
143
|
+
outputCommitments,
|
|
144
|
+
outputValues,
|
|
145
|
+
outputSalts,
|
|
146
|
+
outputOwnerPublicKeys,
|
|
147
|
+
identitiesRoot,
|
|
148
|
+
identitiesMerkleProof,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const circuit = await loadCircuit("deposit_kyc");
|
|
152
|
+
const { provingKeyFile } = loadProvingKeys("deposit_kyc");
|
|
153
|
+
|
|
154
|
+
const startWitnessCalculation = Date.now();
|
|
155
|
+
const witness = await circuit.calculateWTNSBin(inputObj, true);
|
|
156
|
+
const timeWithnessCalculation = Date.now() - startWitnessCalculation;
|
|
157
|
+
|
|
158
|
+
const startProofGeneration = Date.now();
|
|
159
|
+
const { proof, publicSignals } = (await groth16.prove(
|
|
160
|
+
provingKeyFile,
|
|
161
|
+
witness,
|
|
162
|
+
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
163
|
+
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
164
|
+
|
|
165
|
+
logger.debug(
|
|
90
166
|
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
91
167
|
);
|
|
92
168
|
|
|
@@ -142,7 +218,7 @@ export async function prepareWithdrawProof(
|
|
|
142
218
|
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
143
219
|
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
144
220
|
|
|
145
|
-
|
|
221
|
+
logger.debug(
|
|
146
222
|
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
147
223
|
);
|
|
148
224
|
|
|
@@ -208,7 +284,7 @@ export async function prepareNullifierWithdrawProof(
|
|
|
208
284
|
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
209
285
|
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
210
286
|
|
|
211
|
-
|
|
287
|
+
logger.debug(
|
|
212
288
|
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
213
289
|
);
|
|
214
290
|
|
|
@@ -259,7 +335,7 @@ export async function prepareBurnProof(
|
|
|
259
335
|
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
260
336
|
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
261
337
|
|
|
262
|
-
|
|
338
|
+
logger.debug(
|
|
263
339
|
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
264
340
|
);
|
|
265
341
|
|
|
@@ -320,7 +396,7 @@ export async function prepareNullifierBurnProof(
|
|
|
320
396
|
)) as { proof: BigNumberish[]; publicSignals: BigNumberish[] };
|
|
321
397
|
const timeProofGeneration = Date.now() - startProofGeneration;
|
|
322
398
|
|
|
323
|
-
|
|
399
|
+
logger.debug(
|
|
324
400
|
`Witness calculation time: ${timeWithnessCalculation}ms. Proof generation time: ${timeProofGeneration}ms.`,
|
|
325
401
|
);
|
|
326
402
|
|
|
@@ -333,11 +409,58 @@ export async function prepareNullifierBurnProof(
|
|
|
333
409
|
};
|
|
334
410
|
}
|
|
335
411
|
|
|
336
|
-
export function
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
412
|
+
export function encodeToBytesForDeposit(proof: any) {
|
|
413
|
+
return new AbiCoder().encode(
|
|
414
|
+
["tuple(uint256[2] pA, uint256[2][2] pB, uint256[2] pC)"],
|
|
415
|
+
[proof],
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function encodeToBytesForWithdraw(root: any, proof: any) {
|
|
420
|
+
return new AbiCoder().encode(
|
|
421
|
+
["uint256 root", "tuple(uint256[2] pA, uint256[2][2] pB, uint256[2] pC)"],
|
|
422
|
+
[root, proof],
|
|
423
|
+
);
|
|
343
424
|
}
|
|
425
|
+
|
|
426
|
+
// Domain-separation tags mirroring `_SPEND_HASH_DOMAIN` /
|
|
427
|
+
// `_CANCEL_HASH_DOMAIN` in `lib/zeto_fungible.sol`. Keep these strings
|
|
428
|
+
// in sync with the on-chain constants; otherwise computed commitments
|
|
429
|
+
// will not match what the contract expects.
|
|
430
|
+
const SPEND_HASH_DOMAIN = keccak256(toUtf8Bytes("Zeto.spendCommitment.v1"));
|
|
431
|
+
const CANCEL_HASH_DOMAIN = keccak256(toUtf8Bytes("Zeto.cancelCommitment.v1"));
|
|
432
|
+
|
|
433
|
+
function buildUnlockHash(
|
|
434
|
+
lockedInputs: UTXO[],
|
|
435
|
+
lockedOutputs: UTXO[],
|
|
436
|
+
outputs: UTXO[],
|
|
437
|
+
data: any,
|
|
438
|
+
domain: string,
|
|
439
|
+
) {
|
|
440
|
+
const abiCoder = new AbiCoder();
|
|
441
|
+
// Hash each dynamic component with `abi.encode` rather than
|
|
442
|
+
// `abi.encodePacked` so dynamic-length arrays cannot collide
|
|
443
|
+
// (mirrors `_buildUnlockHash` in zeto_fungible.sol).
|
|
444
|
+
return keccak256(
|
|
445
|
+
abiCoder.encode(
|
|
446
|
+
["bytes32", "bytes32", "bytes32", "bytes32", "bytes32"],
|
|
447
|
+
[
|
|
448
|
+
domain,
|
|
449
|
+
keccak256(abiCoder.encode(["uint256[]"], [lockedInputs.map((utxo) => utxo.hash)])),
|
|
450
|
+
keccak256(abiCoder.encode(["uint256[]"], [lockedOutputs.map((utxo) => utxo.hash)])),
|
|
451
|
+
keccak256(abiCoder.encode(["uint256[]"], [outputs.map((utxo) => utxo.hash)])),
|
|
452
|
+
keccak256(data),
|
|
453
|
+
],
|
|
454
|
+
),
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/// Mirror of `IZetoLockableCapability.computeSpendHash`.
|
|
459
|
+
export function calculateSpendHash(lockedInputs: UTXO[], lockedOutputs: UTXO[], outputs: UTXO[], data: any) {
|
|
460
|
+
return buildUnlockHash(lockedInputs, lockedOutputs, outputs, data, SPEND_HASH_DOMAIN);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/// Mirror of `IZetoLockableCapability.computeCancelHash`.
|
|
464
|
+
export function calculateCancelHash(lockedInputs: UTXO[], lockedOutputs: UTXO[], outputs: UTXO[], data: any) {
|
|
465
|
+
return buildUnlockHash(lockedInputs, lockedOutputs, outputs, data, CANCEL_HASH_DOMAIN);
|
|
466
|
+
}
|