@permissionless-technologies/upp-sdk 0.4.0 → 0.4.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/{chunk-ZTVXII74.js → chunk-6BHF4HOB.js} +14 -24
- package/dist/chunk-6BHF4HOB.js.map +1 -0
- package/dist/{chunk-UYE2JASE.cjs → chunk-ZQ5LLJQC.cjs} +14 -24
- package/dist/chunk-ZQ5LLJQC.cjs.map +1 -0
- package/dist/index.cjs +59 -59
- package/dist/index.js +2 -2
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.js +1 -1
- package/dist/react/index.cjs +17 -68
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +25 -10
- package/dist/react/index.d.ts +25 -10
- package/dist/react/index.js +17 -68
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-UYE2JASE.cjs.map +0 -1
- package/dist/chunk-ZTVXII74.js.map +0 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -253,8 +253,11 @@ interface PoolTransferParams {
|
|
|
253
253
|
interface PoolTransferBuildData {
|
|
254
254
|
/** Circuit used: 'transfer' for UPP 1-in-2-out */
|
|
255
255
|
circuit: 'transfer';
|
|
256
|
-
/**
|
|
257
|
-
proof:
|
|
256
|
+
/** PLONK proof bytes for contract call */
|
|
257
|
+
proof: {
|
|
258
|
+
proofBytes: `0x${string}`;
|
|
259
|
+
publicSignals: bigint[];
|
|
260
|
+
};
|
|
258
261
|
/** Nullifier */
|
|
259
262
|
nullifier: Hex;
|
|
260
263
|
/** Merkle state root */
|
|
@@ -333,8 +336,11 @@ interface WithdrawParams {
|
|
|
333
336
|
* Withdraw build data - everything needed to call the contract
|
|
334
337
|
*/
|
|
335
338
|
interface WithdrawBuildData {
|
|
336
|
-
/**
|
|
337
|
-
proof:
|
|
339
|
+
/** PLONK proof bytes for contract call */
|
|
340
|
+
proof: {
|
|
341
|
+
proofBytes: `0x${string}`;
|
|
342
|
+
publicSignals: bigint[];
|
|
343
|
+
};
|
|
338
344
|
/** Nullifier of the note being spent */
|
|
339
345
|
nullifier: Hex;
|
|
340
346
|
/** Merkle state root */
|
|
@@ -539,8 +545,11 @@ interface SwapConfig {
|
|
|
539
545
|
* Build data returned by buildPlaceOrder — everything needed for the contract call
|
|
540
546
|
*/
|
|
541
547
|
interface PlaceOrderBuildData {
|
|
542
|
-
/**
|
|
543
|
-
proof:
|
|
548
|
+
/** PLONK proof bytes for contract call */
|
|
549
|
+
proof: {
|
|
550
|
+
proofBytes: `0x${string}`;
|
|
551
|
+
publicSignals: bigint[];
|
|
552
|
+
};
|
|
544
553
|
/** Nullifier (= orderId) */
|
|
545
554
|
nullifier: Hex;
|
|
546
555
|
/** Merkle state root */
|
|
@@ -572,8 +581,11 @@ interface PlaceOrderBuildData {
|
|
|
572
581
|
* Build data returned by buildFillOrder
|
|
573
582
|
*/
|
|
574
583
|
interface FillOrderBuildData {
|
|
575
|
-
/**
|
|
576
|
-
proof:
|
|
584
|
+
/** PLONK proof bytes for contract call */
|
|
585
|
+
proof: {
|
|
586
|
+
proofBytes: `0x${string}`;
|
|
587
|
+
publicSignals: bigint[];
|
|
588
|
+
};
|
|
577
589
|
/** Filler's nullifier */
|
|
578
590
|
nullifier: Hex;
|
|
579
591
|
/** Merkle state root */
|
|
@@ -642,8 +654,11 @@ interface SplitNoteParams {
|
|
|
642
654
|
aspProof?: ASPProofParam;
|
|
643
655
|
}
|
|
644
656
|
interface SplitNoteBuildData {
|
|
645
|
-
/**
|
|
646
|
-
proof:
|
|
657
|
+
/** PLONK proof bytes for contract call */
|
|
658
|
+
proof: {
|
|
659
|
+
proofBytes: `0x${string}`;
|
|
660
|
+
publicSignals: bigint[];
|
|
661
|
+
};
|
|
647
662
|
/** Nullifier */
|
|
648
663
|
nullifier: Hex;
|
|
649
664
|
/** Merkle state root */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -253,8 +253,11 @@ interface PoolTransferParams {
|
|
|
253
253
|
interface PoolTransferBuildData {
|
|
254
254
|
/** Circuit used: 'transfer' for UPP 1-in-2-out */
|
|
255
255
|
circuit: 'transfer';
|
|
256
|
-
/**
|
|
257
|
-
proof:
|
|
256
|
+
/** PLONK proof bytes for contract call */
|
|
257
|
+
proof: {
|
|
258
|
+
proofBytes: `0x${string}`;
|
|
259
|
+
publicSignals: bigint[];
|
|
260
|
+
};
|
|
258
261
|
/** Nullifier */
|
|
259
262
|
nullifier: Hex;
|
|
260
263
|
/** Merkle state root */
|
|
@@ -333,8 +336,11 @@ interface WithdrawParams {
|
|
|
333
336
|
* Withdraw build data - everything needed to call the contract
|
|
334
337
|
*/
|
|
335
338
|
interface WithdrawBuildData {
|
|
336
|
-
/**
|
|
337
|
-
proof:
|
|
339
|
+
/** PLONK proof bytes for contract call */
|
|
340
|
+
proof: {
|
|
341
|
+
proofBytes: `0x${string}`;
|
|
342
|
+
publicSignals: bigint[];
|
|
343
|
+
};
|
|
338
344
|
/** Nullifier of the note being spent */
|
|
339
345
|
nullifier: Hex;
|
|
340
346
|
/** Merkle state root */
|
|
@@ -539,8 +545,11 @@ interface SwapConfig {
|
|
|
539
545
|
* Build data returned by buildPlaceOrder — everything needed for the contract call
|
|
540
546
|
*/
|
|
541
547
|
interface PlaceOrderBuildData {
|
|
542
|
-
/**
|
|
543
|
-
proof:
|
|
548
|
+
/** PLONK proof bytes for contract call */
|
|
549
|
+
proof: {
|
|
550
|
+
proofBytes: `0x${string}`;
|
|
551
|
+
publicSignals: bigint[];
|
|
552
|
+
};
|
|
544
553
|
/** Nullifier (= orderId) */
|
|
545
554
|
nullifier: Hex;
|
|
546
555
|
/** Merkle state root */
|
|
@@ -572,8 +581,11 @@ interface PlaceOrderBuildData {
|
|
|
572
581
|
* Build data returned by buildFillOrder
|
|
573
582
|
*/
|
|
574
583
|
interface FillOrderBuildData {
|
|
575
|
-
/**
|
|
576
|
-
proof:
|
|
584
|
+
/** PLONK proof bytes for contract call */
|
|
585
|
+
proof: {
|
|
586
|
+
proofBytes: `0x${string}`;
|
|
587
|
+
publicSignals: bigint[];
|
|
588
|
+
};
|
|
577
589
|
/** Filler's nullifier */
|
|
578
590
|
nullifier: Hex;
|
|
579
591
|
/** Merkle state root */
|
|
@@ -642,8 +654,11 @@ interface SplitNoteParams {
|
|
|
642
654
|
aspProof?: ASPProofParam;
|
|
643
655
|
}
|
|
644
656
|
interface SplitNoteBuildData {
|
|
645
|
-
/**
|
|
646
|
-
proof:
|
|
657
|
+
/** PLONK proof bytes for contract call */
|
|
658
|
+
proof: {
|
|
659
|
+
proofBytes: `0x${string}`;
|
|
660
|
+
publicSignals: bigint[];
|
|
661
|
+
};
|
|
647
662
|
/** Nullifier */
|
|
648
663
|
nullifier: Hex;
|
|
649
664
|
/** Merkle state root */
|
package/dist/react/index.js
CHANGED
|
@@ -511,11 +511,10 @@ function UPPAccountProvider({
|
|
|
511
511
|
const tokenRaw = "0x" + Array.from(ptBytes.slice(84, 104)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
512
512
|
const origin = getAddress(originRaw);
|
|
513
513
|
const token = getAddress(tokenRaw);
|
|
514
|
-
const
|
|
514
|
+
const ownerHash = await sdk.poseidon([spendingSecret]);
|
|
515
515
|
const expectedCommitment = await sdk.poseidon([
|
|
516
516
|
amount,
|
|
517
|
-
|
|
518
|
-
pubkey.y,
|
|
517
|
+
ownerHash,
|
|
519
518
|
blinding,
|
|
520
519
|
BigInt(origin),
|
|
521
520
|
BigInt(token)
|
|
@@ -1606,7 +1605,7 @@ function usePoolTransfer(config) {
|
|
|
1606
1605
|
getMerkleProofsForNotes,
|
|
1607
1606
|
buildUPPTransferCircuitInputs
|
|
1608
1607
|
} = transferModule;
|
|
1609
|
-
const { generateUPPProof,
|
|
1608
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
1610
1609
|
const { generateASPProof: generateASPProof2, DEMO_ASP_ID } = aspModule;
|
|
1611
1610
|
setStage("syncing_merkle");
|
|
1612
1611
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -1640,20 +1639,10 @@ function usePoolTransfer(config) {
|
|
|
1640
1639
|
circuitInputs,
|
|
1641
1640
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
1642
1641
|
);
|
|
1643
|
-
const formattedProof =
|
|
1644
|
-
const proofArray = [
|
|
1645
|
-
formattedProof.a[0],
|
|
1646
|
-
formattedProof.a[1],
|
|
1647
|
-
formattedProof.b[0][0],
|
|
1648
|
-
formattedProof.b[0][1],
|
|
1649
|
-
formattedProof.b[1][0],
|
|
1650
|
-
formattedProof.b[1][1],
|
|
1651
|
-
formattedProof.c[0],
|
|
1652
|
-
formattedProof.c[1]
|
|
1653
|
-
];
|
|
1642
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
1654
1643
|
return {
|
|
1655
1644
|
circuit: "transfer",
|
|
1656
|
-
proof:
|
|
1645
|
+
proof: formattedProof,
|
|
1657
1646
|
nullifier: toHex(BigInt(circuitInputs.nullifier), { size: 32 }),
|
|
1658
1647
|
stateRoot: BigInt(circuitInputs.stateRoot),
|
|
1659
1648
|
aspRoot: BigInt(circuitInputs.aspRoot),
|
|
@@ -1761,7 +1750,7 @@ function useWithdraw(config) {
|
|
|
1761
1750
|
import('../index.js')
|
|
1762
1751
|
]);
|
|
1763
1752
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
1764
|
-
const { generateUPPProof,
|
|
1753
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
1765
1754
|
setStage("syncing_merkle");
|
|
1766
1755
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
1767
1756
|
const spendableNote = {
|
|
@@ -1826,20 +1815,10 @@ function useWithdraw(config) {
|
|
|
1826
1815
|
circuitInputs,
|
|
1827
1816
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
1828
1817
|
);
|
|
1829
|
-
const formattedProof =
|
|
1818
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
1830
1819
|
const stateRoot = stateRootBI;
|
|
1831
|
-
const proofArray = [
|
|
1832
|
-
formattedProof.a[0],
|
|
1833
|
-
formattedProof.a[1],
|
|
1834
|
-
formattedProof.b[0][0],
|
|
1835
|
-
formattedProof.b[0][1],
|
|
1836
|
-
formattedProof.b[1][0],
|
|
1837
|
-
formattedProof.b[1][1],
|
|
1838
|
-
formattedProof.c[0],
|
|
1839
|
-
formattedProof.c[1]
|
|
1840
|
-
];
|
|
1841
1820
|
return {
|
|
1842
|
-
proof:
|
|
1821
|
+
proof: formattedProof,
|
|
1843
1822
|
nullifier: toHex(nullifier, { size: 32 }),
|
|
1844
1823
|
stateRoot,
|
|
1845
1824
|
aspRoot,
|
|
@@ -2142,7 +2121,7 @@ function useSwap(config) {
|
|
|
2142
2121
|
import('../asp-72WUGTQE.js')
|
|
2143
2122
|
]);
|
|
2144
2123
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
2145
|
-
const { generateUPPProof,
|
|
2124
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2146
2125
|
const { generateASPProof: generateASPProof2 } = aspModule;
|
|
2147
2126
|
setStage("syncing_merkle");
|
|
2148
2127
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -2207,23 +2186,13 @@ function useSwap(config) {
|
|
|
2207
2186
|
circuitInputs,
|
|
2208
2187
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2209
2188
|
);
|
|
2210
|
-
const formattedProof =
|
|
2211
|
-
const proofArray = [
|
|
2212
|
-
formattedProof.a[0],
|
|
2213
|
-
formattedProof.a[1],
|
|
2214
|
-
formattedProof.b[0][0],
|
|
2215
|
-
formattedProof.b[0][1],
|
|
2216
|
-
formattedProof.b[1][0],
|
|
2217
|
-
formattedProof.b[1][1],
|
|
2218
|
-
formattedProof.c[0],
|
|
2219
|
-
formattedProof.c[1]
|
|
2220
|
-
];
|
|
2189
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2221
2190
|
const cancelSecret = generateCancelSecret();
|
|
2222
2191
|
const cancelKeyHash = computeCancelKeyHash(cancelSecret);
|
|
2223
2192
|
const currentBlock = await cfg.publicClient.getBlockNumber();
|
|
2224
2193
|
const expiry = currentBlock + expiryBlocks;
|
|
2225
2194
|
return {
|
|
2226
|
-
proof:
|
|
2195
|
+
proof: formattedProof,
|
|
2227
2196
|
nullifier: toHex(nullifier, { size: 32 }),
|
|
2228
2197
|
stateRoot: stateRootBI,
|
|
2229
2198
|
aspRoot: aspProofData.aspRoot,
|
|
@@ -2294,7 +2263,7 @@ function useSwap(config) {
|
|
|
2294
2263
|
import('../asp-72WUGTQE.js')
|
|
2295
2264
|
]);
|
|
2296
2265
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
2297
|
-
const { generateUPPProof,
|
|
2266
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2298
2267
|
const { generateASPProof: generateASPProof2 } = aspModule;
|
|
2299
2268
|
const fillerOrigin = ethAddress ? BigInt(ethAddress) : BigInt(masterKeys.ownerHash);
|
|
2300
2269
|
const fillerNoteData = await createNoteForSelf(
|
|
@@ -2365,24 +2334,14 @@ function useSwap(config) {
|
|
|
2365
2334
|
circuitInputs,
|
|
2366
2335
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2367
2336
|
);
|
|
2368
|
-
const formattedProof =
|
|
2369
|
-
const proofArray = [
|
|
2370
|
-
formattedProof.a[0],
|
|
2371
|
-
formattedProof.a[1],
|
|
2372
|
-
formattedProof.b[0][0],
|
|
2373
|
-
formattedProof.b[0][1],
|
|
2374
|
-
formattedProof.b[1][0],
|
|
2375
|
-
formattedProof.b[1][1],
|
|
2376
|
-
formattedProof.c[0],
|
|
2377
|
-
formattedProof.c[1]
|
|
2378
|
-
];
|
|
2337
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2379
2338
|
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2380
2339
|
const packedFillerNote = encodePacked3(
|
|
2381
2340
|
["uint64", "uint256", "bytes"],
|
|
2382
2341
|
[fillerNoteData.searchTag, fillerNoteData.ownerHash, fillerNoteData.encryptedNote]
|
|
2383
2342
|
);
|
|
2384
2343
|
return {
|
|
2385
|
-
proof:
|
|
2344
|
+
proof: formattedProof,
|
|
2386
2345
|
nullifier: toHex(nullifier, { size: 32 }),
|
|
2387
2346
|
stateRoot: stateRootBI,
|
|
2388
2347
|
aspRoot: aspProofData.aspRoot,
|
|
@@ -2523,7 +2482,7 @@ function useSwap(config) {
|
|
|
2523
2482
|
import('../asp-72WUGTQE.js')
|
|
2524
2483
|
]);
|
|
2525
2484
|
const { syncMerkleTree, getMerkleProofsForNotes, buildUPPTransferCircuitInputs } = transferModule;
|
|
2526
|
-
const { generateUPPProof,
|
|
2485
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2527
2486
|
const { generateASPProof: generateASPProof2, DEMO_ASP_ID } = aspModule;
|
|
2528
2487
|
setStage("syncing_merkle");
|
|
2529
2488
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -2553,17 +2512,7 @@ function useSwap(config) {
|
|
|
2553
2512
|
circuitInputs,
|
|
2554
2513
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2555
2514
|
);
|
|
2556
|
-
const formattedProof =
|
|
2557
|
-
const proofArray = [
|
|
2558
|
-
formattedProof.a[0],
|
|
2559
|
-
formattedProof.a[1],
|
|
2560
|
-
formattedProof.b[0][0],
|
|
2561
|
-
formattedProof.b[0][1],
|
|
2562
|
-
formattedProof.b[1][0],
|
|
2563
|
-
formattedProof.b[1][1],
|
|
2564
|
-
formattedProof.c[0],
|
|
2565
|
-
formattedProof.c[1]
|
|
2566
|
-
];
|
|
2515
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2567
2516
|
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2568
2517
|
const packNote = (n) => encodePacked3(
|
|
2569
2518
|
["uint64", "uint256", "bytes"],
|
|
@@ -2597,7 +2546,7 @@ function useSwap(config) {
|
|
|
2597
2546
|
timestamp: Date.now()
|
|
2598
2547
|
};
|
|
2599
2548
|
return {
|
|
2600
|
-
proof:
|
|
2549
|
+
proof: formattedProof,
|
|
2601
2550
|
nullifier: toHex(BigInt(circuitInputs.nullifier), { size: 32 }),
|
|
2602
2551
|
stateRoot: BigInt(circuitInputs.stateRoot),
|
|
2603
2552
|
aspRoot: BigInt(circuitInputs.aspRoot),
|