@permissionless-technologies/upp-sdk 0.4.2 → 0.4.4
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-6BHF4HOB.js → chunk-4UKH6LXH.js} +2 -2
- package/dist/{chunk-6BHF4HOB.js.map → chunk-4UKH6LXH.js.map} +1 -1
- package/dist/{chunk-UTAJSERA.cjs → chunk-5BLMSTFQ.cjs} +2 -2
- package/dist/chunk-5BLMSTFQ.cjs.map +1 -0
- package/dist/{chunk-Q2E432UK.cjs → chunk-A7EORZW7.cjs} +24 -24
- package/dist/{chunk-Q2E432UK.cjs.map → chunk-A7EORZW7.cjs.map} +1 -1
- package/dist/{chunk-W3HLIKC2.js → chunk-KRLRJ3HN.js} +46 -24
- package/dist/chunk-KRLRJ3HN.js.map +1 -0
- package/dist/{chunk-CEJN5ZE5.js → chunk-O6ALW7DB.js} +2 -2
- package/dist/chunk-O6ALW7DB.js.map +1 -0
- package/dist/{chunk-ZQ5LLJQC.cjs → chunk-ROV6WWIS.cjs} +2 -2
- package/dist/{chunk-ZQ5LLJQC.cjs.map → chunk-ROV6WWIS.cjs.map} +1 -1
- package/dist/{chunk-2G22R7AJ.cjs → chunk-RYEYGGE7.cjs} +46 -24
- package/dist/chunk-RYEYGGE7.cjs.map +1 -0
- package/dist/{chunk-OBBSIPEK.js → chunk-UC2QMWGS.js} +16 -16
- package/dist/{chunk-OBBSIPEK.js.map → chunk-UC2QMWGS.js.map} +1 -1
- package/dist/core/index.cjs +29 -29
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +5 -5
- package/dist/{index-D6nvfm59.d.ts → index--eNkOLiP.d.ts} +1 -1
- package/dist/{index-CL4vb3ej.d.cts → index-CRaFsQD3.d.cts} +1 -1
- package/dist/{index-CtcXgof_.d.ts → index-Cxm5E-J5.d.ts} +512 -46
- package/dist/{index-BgPdYxFS.d.cts → index-Mm_cz6Ie.d.cts} +512 -46
- package/dist/index.cjs +829 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +646 -48
- package/dist/index.js.map +1 -1
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.d.cts +5 -5
- package/dist/indexer/index.d.ts +5 -5
- package/dist/indexer/index.js +1 -1
- package/dist/{proof-XR6XE5PJ.cjs → proof-VINVGL4F.cjs} +13 -13
- package/dist/{proof-XR6XE5PJ.cjs.map → proof-VINVGL4F.cjs.map} +1 -1
- package/dist/{proof-JME3IZTX.js → proof-XQG5DN5N.js} +3 -3
- package/dist/{proof-JME3IZTX.js.map → proof-XQG5DN5N.js.map} +1 -1
- package/dist/react/index.cjs +10 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +7 -7
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +10 -10
- package/dist/react/index.js.map +1 -1
- package/dist/{transfer-MQMGSXTH.js → transfer-4XBP4DPQ.js} +5 -5
- package/dist/{transfer-MQMGSXTH.js.map → transfer-4XBP4DPQ.js.map} +1 -1
- package/dist/{transfer-DvIXqHCr.d.ts → transfer-Crvdq4VN.d.ts} +30 -18
- package/dist/{transfer-D111ihqN.d.cts → transfer-CwwsNdGL.d.cts} +30 -18
- package/dist/{transfer-PB6D5VCW.cjs → transfer-Y2RSJS6Y.cjs} +11 -11
- package/dist/{transfer-PB6D5VCW.cjs.map → transfer-Y2RSJS6Y.cjs.map} +1 -1
- package/package.json +1 -1
- package/src/deployments/11155111.json +12 -12
- package/dist/chunk-2G22R7AJ.cjs.map +0 -1
- package/dist/chunk-CEJN5ZE5.js.map +0 -1
- package/dist/chunk-UTAJSERA.cjs.map +0 -1
- package/dist/chunk-W3HLIKC2.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { buildTransfer, buildUPPTransferCircuitInputs, computeNullifier, formatOutputForContract, getMerkleProofsForNotes, syncMerkleTree } from './chunk-
|
|
2
|
-
import './chunk-GPF72JFR.js';
|
|
1
|
+
export { buildTransfer, buildUPPTransferCircuitInputs, computeNullifier, formatOutputForContract, getMerkleProofsForNotes, syncMerkleTree } from './chunk-UC2QMWGS.js';
|
|
3
2
|
import './chunk-6IEYWJVS.js';
|
|
3
|
+
import './chunk-GPF72JFR.js';
|
|
4
4
|
import './chunk-5QSSX3KR.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-KRLRJ3HN.js';
|
|
6
6
|
import './chunk-Z6ZWNWWR.js';
|
|
7
|
-
//# sourceMappingURL=transfer-
|
|
8
|
-
//# sourceMappingURL=transfer-
|
|
7
|
+
//# sourceMappingURL=transfer-4XBP4DPQ.js.map
|
|
8
|
+
//# sourceMappingURL=transfer-4XBP4DPQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-4XBP4DPQ.js"}
|
|
@@ -147,12 +147,8 @@ interface WithdrawParams {
|
|
|
147
147
|
* Proof for ZK operations
|
|
148
148
|
*/
|
|
149
149
|
interface Proof {
|
|
150
|
-
/** Proof
|
|
151
|
-
proof:
|
|
152
|
-
pi_a: [string, string];
|
|
153
|
-
pi_b: [[string, string], [string, string]];
|
|
154
|
-
pi_c: [string, string];
|
|
155
|
-
};
|
|
150
|
+
/** Proof data (format depends on proof system: Groth16 has pi_a/pi_b/pi_c, PLONK has A/B/C/Z/T1-T3/evals/Wxi/Wxiw) */
|
|
151
|
+
proof: Record<string, any>;
|
|
156
152
|
/** Public signals */
|
|
157
153
|
publicSignals: string[];
|
|
158
154
|
}
|
|
@@ -525,24 +521,20 @@ declare function getStealthCircuitArtifacts(circuit: StealthCircuitType, baseUrl
|
|
|
525
521
|
* UPP circuit inputs union type
|
|
526
522
|
*/
|
|
527
523
|
type UPPCircuitInputs = UPPTransferCircuitInputs | UPPWithdrawCircuitInputs | UPPMergeCircuitInputs | UPPJoinSplitCircuitInputs;
|
|
524
|
+
/**
|
|
525
|
+
* PLONK proving stage for progress reporting
|
|
526
|
+
*/
|
|
527
|
+
type PlonkProvingStage = 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
|
|
528
528
|
/**
|
|
529
529
|
* Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)
|
|
530
530
|
*
|
|
531
531
|
* @param circuitType - Which UPP circuit to use
|
|
532
532
|
* @param inputs - Circuit input signals
|
|
533
533
|
* @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
|
|
534
|
+
* @param onProgress - Optional callback for proving progress
|
|
534
535
|
* @returns Generated proof and public signals
|
|
535
|
-
*
|
|
536
|
-
* @example
|
|
537
|
-
* ```ts
|
|
538
|
-
* const { proof, publicSignals } = await generateUPPProof('transfer', {
|
|
539
|
-
* stateRoot: String(currentRoot),
|
|
540
|
-
* aspRoot: String(aspRoot),
|
|
541
|
-
* // ... other inputs
|
|
542
|
-
* })
|
|
543
|
-
* ```
|
|
544
536
|
*/
|
|
545
|
-
declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string): Promise<ProofResult>;
|
|
537
|
+
declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void): Promise<ProofResult>;
|
|
546
538
|
/**
|
|
547
539
|
* @deprecated Use generateUPPProof instead
|
|
548
540
|
*/
|
|
@@ -562,6 +554,26 @@ declare function generateStealthProof(circuit: StealthCircuitType, inputs: Steal
|
|
|
562
554
|
* Verify a ZK proof
|
|
563
555
|
*/
|
|
564
556
|
declare function verifyProof(_circuitType: CircuitType, _proof: Proof): Promise<boolean>;
|
|
557
|
+
/**
|
|
558
|
+
* PLONK proof struct matching PlonkVerifierBLS12381.Proof ABI
|
|
559
|
+
*/
|
|
560
|
+
interface PlonkProofStruct {
|
|
561
|
+
A: `0x${string}`;
|
|
562
|
+
B: `0x${string}`;
|
|
563
|
+
C: `0x${string}`;
|
|
564
|
+
Z: `0x${string}`;
|
|
565
|
+
T1: `0x${string}`;
|
|
566
|
+
T2: `0x${string}`;
|
|
567
|
+
T3: `0x${string}`;
|
|
568
|
+
eval_a: bigint;
|
|
569
|
+
eval_b: bigint;
|
|
570
|
+
eval_c: bigint;
|
|
571
|
+
eval_s1: bigint;
|
|
572
|
+
eval_s2: bigint;
|
|
573
|
+
eval_zw: bigint;
|
|
574
|
+
Wxi: `0x${string}`;
|
|
575
|
+
Wxiw: `0x${string}`;
|
|
576
|
+
}
|
|
565
577
|
/**
|
|
566
578
|
* @deprecated Use formatPlonkProofForContract for PLONK proofs.
|
|
567
579
|
*
|
|
@@ -1222,7 +1234,7 @@ interface TransferBuildResult {
|
|
|
1222
1234
|
circuit: UPPCircuitType;
|
|
1223
1235
|
/** Formatted PLONK proof for contract */
|
|
1224
1236
|
proof: {
|
|
1225
|
-
|
|
1237
|
+
proofStruct: PlonkProofStruct;
|
|
1226
1238
|
publicSignals: bigint[];
|
|
1227
1239
|
};
|
|
1228
1240
|
/** Public signals from proof */
|
|
@@ -1317,4 +1329,4 @@ declare function formatOutputForContract(note: NoteCreationResult): {
|
|
|
1317
1329
|
encryptedNote: Hex;
|
|
1318
1330
|
};
|
|
1319
1331
|
|
|
1320
|
-
export { computeCancelKeyHash as $, type ASPProof as A, type StealthMetaAddress as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SwapFillEvent as F, type SwapFillParams as G, type SwapOrder as H, type SwapOrderEvent as I, type SwapOrderParams as J, type TransferContext as K, type TransferParams as L, type MergeParams as M, NOTE_VERSION as N, type TransferStage as O, type Proof as P, type UPPCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type UPPCircuitInputs as U, type UPPTransferCircuitInputs as V, type UPPWithdrawCircuitInputs as W, type WithdrawParams as X, buildASPTree as Y, buildTransfer as Z, buildUPPTransferCircuitInputs as _, type ASPRoot as a, computeFillPercentage as a0, computeGiveAmount as a1, computeMultiOriginASPRoot as a2, computeNullifier as a3, computeRate as a4, computeSingleOriginASPRoot as a5, computeTakeAmount as a6, computeTotalBuyAmount as a7, createDemoASPRoot as a8, filterOrdersByASP as a9,
|
|
1332
|
+
export { computeCancelKeyHash as $, type ASPProof as A, type StealthMetaAddress as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SwapFillEvent as F, type SwapFillParams as G, type SwapOrder as H, type SwapOrderEvent as I, type SwapOrderParams as J, type TransferContext as K, type TransferParams as L, type MergeParams as M, NOTE_VERSION as N, type TransferStage as O, type Proof as P, type UPPCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type UPPCircuitInputs as U, type UPPTransferCircuitInputs as V, type UPPWithdrawCircuitInputs as W, type WithdrawParams as X, buildASPTree as Y, buildTransfer as Z, buildUPPTransferCircuitInputs as _, type ASPRoot as a, computeFillPercentage as a0, computeGiveAmount as a1, computeMultiOriginASPRoot as a2, computeNullifier as a3, computeRate as a4, computeSingleOriginASPRoot as a5, computeTakeAmount as a6, computeTotalBuyAmount as a7, createDemoASPRoot as a8, filterOrdersByASP as a9, useUPPAccount as aA, UPPAccountProvider as aB, type UPPAccountContextType as aC, type ProofSystemType as aD, type IndexerConfig as aE, type SignTypedDataFn as aF, ASP_TREE_DEPTH as aG, filterOrdersByTokenPair as aa, formatOutputForContract as ab, formatProofForContract as ac, formatRate as ad, generateASPProof as ae, generateCancelSecret as af, generateMultiOriginASPProof as ag, generateProof as ah, generateSingleOriginASPProof as ai, generateStealthProof as aj, generateUPPProof as ak, getCancelSecret as al, getMerkleProofsForNotes as am, getOwnOrderIds as an, getStealthCircuitArtifacts as ao, getUPPCircuitArtifacts as ap, isFillerASPAccepted as aq, isOrderActive as ar, removeCancelSecret as as, storeCancelSecret as at, syncMerkleTree as au, verifyASPProof as av, verifyProof as aw, type NoteCreationResult as ax, type PlonkProofStruct as ay, type ShieldedNote as az, ASP_TREE_DEPTH$1 as b, type CircuitType as c, type Commitment as d, DEMO_ASP_NAME as e, type MergeRecord as f, type MerkleProofWithNote as g, type Note as h, type NoteWithAmount as i, type Nullifier as j, type ProofResult as k, SWAP_EVENTS_ABI as l, SWAP_ORDER_CANCELLED_EVENT as m, SWAP_ORDER_CLAIMED_EVENT as n, SWAP_ORDER_FILLED_EVENT as o, SWAP_ORDER_PLACED_EVENT as p, type ShieldParams as q, type SpendableNote as r, type StarkNote as s, type StarkProof as t, type StarkStealthMetaAddress as u, type Stealth1x2CircuitInputs as v, type Stealth2x2CircuitInputs as w, type StealthAddress as x, type StealthCircuitInputs as y, type StealthCircuitType as z };
|
|
@@ -147,12 +147,8 @@ interface WithdrawParams {
|
|
|
147
147
|
* Proof for ZK operations
|
|
148
148
|
*/
|
|
149
149
|
interface Proof {
|
|
150
|
-
/** Proof
|
|
151
|
-
proof:
|
|
152
|
-
pi_a: [string, string];
|
|
153
|
-
pi_b: [[string, string], [string, string]];
|
|
154
|
-
pi_c: [string, string];
|
|
155
|
-
};
|
|
150
|
+
/** Proof data (format depends on proof system: Groth16 has pi_a/pi_b/pi_c, PLONK has A/B/C/Z/T1-T3/evals/Wxi/Wxiw) */
|
|
151
|
+
proof: Record<string, any>;
|
|
156
152
|
/** Public signals */
|
|
157
153
|
publicSignals: string[];
|
|
158
154
|
}
|
|
@@ -525,24 +521,20 @@ declare function getStealthCircuitArtifacts(circuit: StealthCircuitType, baseUrl
|
|
|
525
521
|
* UPP circuit inputs union type
|
|
526
522
|
*/
|
|
527
523
|
type UPPCircuitInputs = UPPTransferCircuitInputs | UPPWithdrawCircuitInputs | UPPMergeCircuitInputs | UPPJoinSplitCircuitInputs;
|
|
524
|
+
/**
|
|
525
|
+
* PLONK proving stage for progress reporting
|
|
526
|
+
*/
|
|
527
|
+
type PlonkProvingStage = 'loading' | 'witness' | 'round1' | 'round2' | 'round3' | 'round4' | 'round5' | 'done';
|
|
528
528
|
/**
|
|
529
529
|
* Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)
|
|
530
530
|
*
|
|
531
531
|
* @param circuitType - Which UPP circuit to use
|
|
532
532
|
* @param inputs - Circuit input signals
|
|
533
533
|
* @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')
|
|
534
|
+
* @param onProgress - Optional callback for proving progress
|
|
534
535
|
* @returns Generated proof and public signals
|
|
535
|
-
*
|
|
536
|
-
* @example
|
|
537
|
-
* ```ts
|
|
538
|
-
* const { proof, publicSignals } = await generateUPPProof('transfer', {
|
|
539
|
-
* stateRoot: String(currentRoot),
|
|
540
|
-
* aspRoot: String(aspRoot),
|
|
541
|
-
* // ... other inputs
|
|
542
|
-
* })
|
|
543
|
-
* ```
|
|
544
536
|
*/
|
|
545
|
-
declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string): Promise<ProofResult>;
|
|
537
|
+
declare function generateUPPProof(circuitType: UPPCircuitType, inputs: UPPCircuitInputs, baseUrl?: string, onProgress?: (stage: PlonkProvingStage, message: string) => void): Promise<ProofResult>;
|
|
546
538
|
/**
|
|
547
539
|
* @deprecated Use generateUPPProof instead
|
|
548
540
|
*/
|
|
@@ -562,6 +554,26 @@ declare function generateStealthProof(circuit: StealthCircuitType, inputs: Steal
|
|
|
562
554
|
* Verify a ZK proof
|
|
563
555
|
*/
|
|
564
556
|
declare function verifyProof(_circuitType: CircuitType, _proof: Proof): Promise<boolean>;
|
|
557
|
+
/**
|
|
558
|
+
* PLONK proof struct matching PlonkVerifierBLS12381.Proof ABI
|
|
559
|
+
*/
|
|
560
|
+
interface PlonkProofStruct {
|
|
561
|
+
A: `0x${string}`;
|
|
562
|
+
B: `0x${string}`;
|
|
563
|
+
C: `0x${string}`;
|
|
564
|
+
Z: `0x${string}`;
|
|
565
|
+
T1: `0x${string}`;
|
|
566
|
+
T2: `0x${string}`;
|
|
567
|
+
T3: `0x${string}`;
|
|
568
|
+
eval_a: bigint;
|
|
569
|
+
eval_b: bigint;
|
|
570
|
+
eval_c: bigint;
|
|
571
|
+
eval_s1: bigint;
|
|
572
|
+
eval_s2: bigint;
|
|
573
|
+
eval_zw: bigint;
|
|
574
|
+
Wxi: `0x${string}`;
|
|
575
|
+
Wxiw: `0x${string}`;
|
|
576
|
+
}
|
|
565
577
|
/**
|
|
566
578
|
* @deprecated Use formatPlonkProofForContract for PLONK proofs.
|
|
567
579
|
*
|
|
@@ -1222,7 +1234,7 @@ interface TransferBuildResult {
|
|
|
1222
1234
|
circuit: UPPCircuitType;
|
|
1223
1235
|
/** Formatted PLONK proof for contract */
|
|
1224
1236
|
proof: {
|
|
1225
|
-
|
|
1237
|
+
proofStruct: PlonkProofStruct;
|
|
1226
1238
|
publicSignals: bigint[];
|
|
1227
1239
|
};
|
|
1228
1240
|
/** Public signals from proof */
|
|
@@ -1317,4 +1329,4 @@ declare function formatOutputForContract(note: NoteCreationResult): {
|
|
|
1317
1329
|
encryptedNote: Hex;
|
|
1318
1330
|
};
|
|
1319
1331
|
|
|
1320
|
-
export { computeCancelKeyHash as $, type ASPProof as A, type StealthMetaAddress as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SwapFillEvent as F, type SwapFillParams as G, type SwapOrder as H, type SwapOrderEvent as I, type SwapOrderParams as J, type TransferContext as K, type TransferParams as L, type MergeParams as M, NOTE_VERSION as N, type TransferStage as O, type Proof as P, type UPPCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type UPPCircuitInputs as U, type UPPTransferCircuitInputs as V, type UPPWithdrawCircuitInputs as W, type WithdrawParams as X, buildASPTree as Y, buildTransfer as Z, buildUPPTransferCircuitInputs as _, type ASPRoot as a, computeFillPercentage as a0, computeGiveAmount as a1, computeMultiOriginASPRoot as a2, computeNullifier as a3, computeRate as a4, computeSingleOriginASPRoot as a5, computeTakeAmount as a6, computeTotalBuyAmount as a7, createDemoASPRoot as a8, filterOrdersByASP as a9,
|
|
1332
|
+
export { computeCancelKeyHash as $, type ASPProof as A, type StealthMetaAddress as B, type CircuitArtifacts as C, DEMO_ASP_ID as D, type EncryptedNote as E, type SwapFillEvent as F, type SwapFillParams as G, type SwapOrder as H, type SwapOrderEvent as I, type SwapOrderParams as J, type TransferContext as K, type TransferParams as L, type MergeParams as M, NOTE_VERSION as N, type TransferStage as O, type Proof as P, type UPPCircuitType as Q, RATE_PRECISION as R, STATE_TREE_DEPTH as S, type TransferBuildResult as T, type UPPCircuitInputs as U, type UPPTransferCircuitInputs as V, type UPPWithdrawCircuitInputs as W, type WithdrawParams as X, buildASPTree as Y, buildTransfer as Z, buildUPPTransferCircuitInputs as _, type ASPRoot as a, computeFillPercentage as a0, computeGiveAmount as a1, computeMultiOriginASPRoot as a2, computeNullifier as a3, computeRate as a4, computeSingleOriginASPRoot as a5, computeTakeAmount as a6, computeTotalBuyAmount as a7, createDemoASPRoot as a8, filterOrdersByASP as a9, useUPPAccount as aA, UPPAccountProvider as aB, type UPPAccountContextType as aC, type ProofSystemType as aD, type IndexerConfig as aE, type SignTypedDataFn as aF, ASP_TREE_DEPTH as aG, filterOrdersByTokenPair as aa, formatOutputForContract as ab, formatProofForContract as ac, formatRate as ad, generateASPProof as ae, generateCancelSecret as af, generateMultiOriginASPProof as ag, generateProof as ah, generateSingleOriginASPProof as ai, generateStealthProof as aj, generateUPPProof as ak, getCancelSecret as al, getMerkleProofsForNotes as am, getOwnOrderIds as an, getStealthCircuitArtifacts as ao, getUPPCircuitArtifacts as ap, isFillerASPAccepted as aq, isOrderActive as ar, removeCancelSecret as as, storeCancelSecret as at, syncMerkleTree as au, verifyASPProof as av, verifyProof as aw, type NoteCreationResult as ax, type PlonkProofStruct as ay, type ShieldedNote as az, ASP_TREE_DEPTH$1 as b, type CircuitType as c, type Commitment as d, DEMO_ASP_NAME as e, type MergeRecord as f, type MerkleProofWithNote as g, type Note as h, type NoteWithAmount as i, type Nullifier as j, type ProofResult as k, SWAP_EVENTS_ABI as l, SWAP_ORDER_CANCELLED_EVENT as m, SWAP_ORDER_CLAIMED_EVENT as n, SWAP_ORDER_FILLED_EVENT as o, SWAP_ORDER_PLACED_EVENT as p, type ShieldParams as q, type SpendableNote as r, type StarkNote as s, type StarkProof as t, type StarkStealthMetaAddress as u, type Stealth1x2CircuitInputs as v, type Stealth2x2CircuitInputs as w, type StealthAddress as x, type StealthCircuitInputs as y, type StealthCircuitType as z };
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-IIUKM5VE.cjs');
|
|
3
|
+
var chunkA7EORZW7_cjs = require('./chunk-A7EORZW7.cjs');
|
|
5
4
|
require('./chunk-XVIICZKW.cjs');
|
|
5
|
+
require('./chunk-IIUKM5VE.cjs');
|
|
6
6
|
require('./chunk-HEHXSV47.cjs');
|
|
7
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-RYEYGGE7.cjs');
|
|
8
8
|
require('./chunk-G7VZBCD6.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "buildTransfer", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkA7EORZW7_cjs.buildTransfer; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "buildUPPTransferCircuitInputs", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkA7EORZW7_cjs.buildUPPTransferCircuitInputs; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "computeNullifier", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkA7EORZW7_cjs.computeNullifier; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "formatOutputForContract", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkA7EORZW7_cjs.formatOutputForContract; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "getMerkleProofsForNotes", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkA7EORZW7_cjs.getMerkleProofsForNotes; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "syncMerkleTree", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkA7EORZW7_cjs.syncMerkleTree; }
|
|
35
35
|
});
|
|
36
|
-
//# sourceMappingURL=transfer-
|
|
37
|
-
//# sourceMappingURL=transfer-
|
|
36
|
+
//# sourceMappingURL=transfer-Y2RSJS6Y.cjs.map
|
|
37
|
+
//# sourceMappingURL=transfer-Y2RSJS6Y.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"transfer-Y2RSJS6Y.cjs"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
"UniversalPrivatePool": "
|
|
2
|
+
"UniversalPrivatePool": "0xc0af763cd42e03338da6cdde137ce4a59b3c9387",
|
|
3
3
|
"ASPRegistryHub": "0xfd11c56a23314aa88dfbcc36254f33e5e8b010df",
|
|
4
|
-
"TestToken": "
|
|
5
|
-
"TestToken2": "
|
|
4
|
+
"TestToken": "0x8430a59e30e771c6f77f6d3417f591cdc2b83c79",
|
|
5
|
+
"TestToken2": "0x7740ece8e68001e215f9573b0c270d68eeefa875",
|
|
6
6
|
"verifiers": {
|
|
7
|
-
"TransferVerifier": "
|
|
8
|
-
"MergeVerifier": "
|
|
9
|
-
"WithdrawVerifier": "
|
|
10
|
-
"JoinSplitVerifier": "
|
|
11
|
-
"MergeTransfer2x2Verifier": "
|
|
12
|
-
"MergeTransfer4x2Verifier": "
|
|
7
|
+
"TransferVerifier": "0xd384b9192d3de09e306ea2bed0b0e44e2e0756d1",
|
|
8
|
+
"MergeVerifier": "0x4603a9bc05732811970e6dfc4eb5264463fe08e6",
|
|
9
|
+
"WithdrawVerifier": "0x86f86e58bc56eca8947a2e5c074f3a6461e77f8c",
|
|
10
|
+
"JoinSplitVerifier": "0xc31846964ac1492c0c2d95c6792a36f0797f59bc",
|
|
11
|
+
"MergeTransfer2x2Verifier": "0x6e16218283a7796f6d1f6ed3fec591a29fad8c0a",
|
|
12
|
+
"MergeTransfer4x2Verifier": "0xc4f7991eddf0aeaa203457f49d1d3563919dd596"
|
|
13
13
|
},
|
|
14
14
|
"starkVerifiers": {
|
|
15
|
-
"CircleStarkVerifier": "
|
|
15
|
+
"CircleStarkVerifier": "0x4e74980dec35572da4901831dac0a05435aaca6c"
|
|
16
16
|
},
|
|
17
|
-
"deployBlock":
|
|
18
|
-
"deployTimestamp":
|
|
17
|
+
"deployBlock": 10547346,
|
|
18
|
+
"deployTimestamp": 1774796558196,
|
|
19
19
|
"proofSystem": "PLONK",
|
|
20
20
|
"curve": "BLS12-381",
|
|
21
21
|
"verifierType": "PlonkVerifierBLS12381"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/proof.ts"],"names":["snarkjs"],"mappings":";;;AAUA,IAAI,OAAA,GAAe,IAAA;AAKnB,eAAe,WAAA,GAA4B;AACzC,EAAA,IAAI,SAAS,OAAO,OAAA;AACpB,EAAA,OAAA,GAAU,MAAM,OAAO,SAAS,CAAA;AAChC,EAAA,OAAO,OAAA;AACT;AAOO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,cAAA,GAAiB;AA+SvB,SAAS,sBAAA,CACd,OAAA,EACA,OAAA,GAAkB,YAAA,EACA;AAClB,EAAA,MAAM,OAAO,OAAA,CAAQ,QAAA,CAAS,GAAG,CAAA,GAAI,OAAA,GAAU,GAAG,OAAO,CAAA,CAAA,CAAA;AAEzD,EAAA,MAAM,UA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AM,KAAK,CAAA;AACnD,EAAA,MAAM,OAAA,GAAU,UAAA,GACZ,UAAA,CAAW,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAA,CAAE,KAAA,CAAM,KAAK,CAAA,CAAE,GAAA,CAAI,CAAC,MAAc,MAAA,CAAO,CAAC,CAAC,CAAA,GACtE,KAAA,CAAM,aAAA,CAAc,IAAI,CAAC,CAAA,KAAc,MAAA,CAAO,CAAC,CAAC,CAAA;AAEpD,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,QAAA;AAAA,IACZ,aAAA,EAAe;AAAA,GACjB;AACF;AAOO,SAAS,uBAAuB,KAAA,EAIrC;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,KAAS,KAAA,CAAM,KAAA;AAEnC,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,CAAC,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,CAAC,CAAA;AAAA,IACpC,CAAA,EAAG;AAAA,MACD,CAAC,MAAA,CAAO,IAAA,CAAK,CAAC,EAAE,CAAC,CAAC,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC,CAAA;AAAA,MACvC,CAAC,MAAA,CAAO,IAAA,CAAK,CAAC,EAAE,CAAC,CAAC,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;AAAA,KACzC;AAAA,IACA,CAAA,EAAG,CAAC,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,CAAA,EAAG,MAAA,CAAO,IAAA,CAAK,CAAC,CAAC,CAAC;AAAA,GACtC;AACF","file":"chunk-2G22R7AJ.cjs","sourcesContent":["/**\n * ZK Proof Generation and Verification (BLS12-381 PLONK)\n *\n * Uses snarkjs for PLONK proof generation over the BLS12-381 curve.\n * PLONK provides a universal trusted setup (no per-circuit ceremony).\n */\n\nimport type { Proof } from './types.js'\n\n// Lazy-loaded snarkjs reference\nlet snarkjs: any = null\n\n/**\n * Load snarkjs dynamically\n */\nasync function loadSnarkjs(): Promise<any> {\n if (snarkjs) return snarkjs\n snarkjs = await import('snarkjs')\n return snarkjs\n}\n\n// ============================================================================\n// UPP Circuit Constants\n// ============================================================================\n\n/** State tree depth (32 levels = ~4B notes) */\nexport const STATE_TREE_DEPTH = 32\n\n/** ASP tree depth (20 levels = ~1M addresses) */\nexport const ASP_TREE_DEPTH = 20\n\n// ============================================================================\n// UPP Circuit Types\n// ============================================================================\n\n/**\n * Circuit types available in UPP (full protocol)\n */\nexport type UPPCircuitType = 'transfer' | 'merge' | 'withdraw' | 'joinsplit' | 'merge_transfer_2x2' | 'merge_transfer_4x2'\n\n/**\n * @deprecated Use UPPCircuitType instead\n */\nexport type CircuitType = 'shield' | 'transfer' | 'merge' | 'withdraw'\n\n/**\n * @deprecated Stealth circuits are being replaced by UPP circuits\n */\nexport type StealthCircuitType = '1x2' | '2x2'\n\n/**\n * Input signals for UPP transfer circuit (1-in-2-out, BLS12-381 PLONK)\n *\n * Matches transfer.circom: Transfer(32, 20)\n * Public: stateRoot, aspRoot, nullifier, outputCommitment1, outputCommitment2, token\n *\n * Note: Uses hash-based ownership (ownerHash) instead of BabyJubJub pubkeys.\n */\nexport interface UPPTransferCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier: string\n outputCommitment1: string\n outputCommitment2: string\n token: string\n\n // Private inputs - Input Note\n inputAmount: string\n inputOneTimeSecret: string\n inputBlinding: string\n inputOrigin: string\n inputLeafIndex: string\n inputPathElements: string[] // 32 elements\n inputPathIndices: string[] // 32 elements\n\n // Private inputs - ASP Membership Proof\n aspPathElements: string[] // 20 elements\n aspPathIndices: string[] // 20 elements\n\n // Private inputs - Output Notes (hash-based ownership)\n outputAmount1: string\n outputOwnerHash1: string\n outputBlinding1: string\n\n outputAmount2: string\n outputOwnerHash2: string\n outputBlinding2: string\n}\n\n/**\n * Input signals for UPP withdraw circuit (BLS12-381 PLONK)\n *\n * Matches withdraw.circom with optional ASP check (ragequit support)\n */\nexport interface UPPWithdrawCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier: string\n amount: string\n recipient: string\n token: string\n isRagequit: string // '0' or '1'\n\n // Private inputs - Input Note\n inputAmount: string\n inputOneTimeSecret: string\n inputBlinding: string\n inputOrigin: string\n inputLeafIndex: string\n inputPathElements: string[] // 32 elements\n inputPathIndices: string[] // 32 elements\n\n // Private inputs - ASP Membership Proof (can be zeros if ragequit)\n aspPathElements: string[] // 20 elements\n aspPathIndices: string[] // 20 elements\n}\n\n/**\n * Input signals for UPP merge circuit (2-in-1-out, BLS12-381 PLONK)\n */\nexport interface UPPMergeCircuitInputs {\n // Public inputs\n stateRoot: string\n nullifier1: string\n nullifier2: string\n outputCommitment: string\n merger: string\n token: string\n\n // Private inputs - Input Note 1\n inputAmount1: string\n inputOneTimeSecret1: string\n inputBlinding1: string\n inputOrigin1: string\n inputLeafIndex1: string\n inputPathElements1: string[]\n inputPathIndices1: string[]\n\n // Private inputs - Input Note 2\n inputAmount2: string\n inputOneTimeSecret2: string\n inputBlinding2: string\n inputOrigin2: string\n inputLeafIndex2: string\n inputPathElements2: string[]\n inputPathIndices2: string[]\n\n // Private inputs - Output Note\n outputAmount: string\n outputOwnerHash: string\n outputBlinding: string\n}\n\n/**\n * Input signals for UPP joinsplit circuit (4-in-2-out, BLS12-381 PLONK)\n */\nexport interface UPPJoinSplitCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier1: string\n nullifier2: string\n nullifier3: string\n nullifier4: string\n outputCommitment1: string\n outputCommitment2: string\n token: string\n\n // Private inputs - 4 Input Notes\n inputAmount1: string; inputOneTimeSecret1: string; inputBlinding1: string\n inputOrigin1: string; inputLeafIndex1: string\n inputPathElements1: string[]; inputPathIndices1: string[]\n\n inputAmount2: string; inputOneTimeSecret2: string; inputBlinding2: string\n inputOrigin2: string; inputLeafIndex2: string\n inputPathElements2: string[]; inputPathIndices2: string[]\n\n inputAmount3: string; inputOneTimeSecret3: string; inputBlinding3: string\n inputOrigin3: string; inputLeafIndex3: string\n inputPathElements3: string[]; inputPathIndices3: string[]\n\n inputAmount4: string; inputOneTimeSecret4: string; inputBlinding4: string\n inputOrigin4: string; inputLeafIndex4: string\n inputPathElements4: string[]; inputPathIndices4: string[]\n\n // Private inputs - ASP Membership Proof\n aspPathElements: string[]\n aspPathIndices: string[]\n\n // Private inputs - Output Notes\n outputAmount1: string; outputOwnerHash1: string; outputBlinding1: string\n outputAmount2: string; outputOwnerHash2: string; outputBlinding2: string\n}\n\n/**\n * @deprecated Use UPPTransferCircuitInputs instead\n */\nexport interface TransferCircuitInputs {\n stateRoot: bigint\n aspRoot: bigint\n nullifier: bigint\n outputCommitment1: bigint\n outputCommitment2: bigint\n token: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n statePathElements: bigint[]\n statePathIndices: bigint\n aspPathElements: bigint[]\n outAmount1: bigint\n outBlinding1: bigint\n outOrigin1: bigint\n outAmount2: bigint\n outBlinding2: bigint\n outOrigin2: bigint\n}\n\n/**\n * Input signals for shield circuit\n */\nexport interface ShieldCircuitInputs {\n commitment: bigint\n token: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n}\n\n/**\n * Input signals for merge circuit\n */\nexport interface MergeCircuitInputs {\n stateRoot: bigint\n nullifier1: bigint\n nullifier2: bigint\n outputCommitment: bigint\n newOrigin: bigint\n token: bigint\n amount1: bigint\n blinding1: bigint\n origin1: bigint\n token1: bigint\n pathElements1: bigint[]\n pathIndices1: bigint\n amount2: bigint\n blinding2: bigint\n origin2: bigint\n token2: bigint\n pathElements2: bigint[]\n pathIndices2: bigint\n outputAmount: bigint\n outputBlinding: bigint\n}\n\n/**\n * Input signals for withdraw circuit\n */\nexport interface WithdrawCircuitInputs {\n stateRoot: bigint\n aspRoot: bigint\n nullifier: bigint\n withdrawAmount: bigint\n recipient: bigint\n token: bigint\n isRagequit: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n statePathElements: bigint[]\n statePathIndices: bigint\n aspPathElements: bigint[]\n}\n\n/**\n * Circuit inputs union type\n */\nexport type CircuitInputs =\n | ShieldCircuitInputs\n | TransferCircuitInputs\n | MergeCircuitInputs\n | WithdrawCircuitInputs\n\n// ============================================================================\n// Stealth Circuit Types (deprecated)\n// ============================================================================\n\n/**\n * @deprecated\n */\nexport interface Stealth1x2CircuitInputs {\n root: string; nullifierHash: string; publicAmount: string\n recipient: string; extDataHash: string\n inputAmount: string; inputOneTimeSecret: string; inputBlinding: string\n inputLeafIndex: string; inputPathElements: string[]; inputPathIndices: string[]\n outputAmount1: string; outputPubkeyX1: string; outputPubkeyY1: string; outputBlinding1: string\n outputAmount2: string; outputPubkeyX2: string; outputPubkeyY2: string; outputBlinding2: string\n}\n\n/**\n * @deprecated\n */\nexport interface Stealth2x2CircuitInputs {\n root: string; nullifierHash1: string; nullifierHash2: string\n publicAmount: string; recipient: string; extDataHash: string\n inputAmount1: string; inputOneTimeSecret1: string; inputBlinding1: string\n inputLeafIndex1: string; inputPathElements1: string[]; inputPathIndices1: string[]\n inputAmount2: string; inputOneTimeSecret2: string; inputBlinding2: string\n inputLeafIndex2: string; inputPathElements2: string[]; inputPathIndices2: string[]\n outputAmount1: string; outputPubkeyX1: string; outputPubkeyY1: string; outputBlinding1: string\n outputAmount2: string; outputPubkeyX2: string; outputPubkeyY2: string; outputBlinding2: string\n}\n\n/** @deprecated */\nexport type StealthCircuitInputs = Stealth1x2CircuitInputs | Stealth2x2CircuitInputs\n\n/**\n * Circuit artifact paths\n */\nexport interface CircuitArtifacts {\n wasm: string\n zkey: string\n}\n\n/**\n * Get circuit artifacts for a UPP circuit\n *\n * @param circuit - UPP circuit type\n * @param baseUrl - Base URL for circuit files (default: '/circuits/')\n */\nexport function getUPPCircuitArtifacts(\n circuit: UPPCircuitType,\n baseUrl: string = '/circuits/'\n): CircuitArtifacts {\n const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n\n const circuitMap: Record<UPPCircuitType, CircuitArtifacts> = {\n transfer: {\n wasm: `${base}transfer.wasm`,\n zkey: `${base}transfer.zkey`,\n },\n merge: {\n wasm: `${base}merge.wasm`,\n zkey: `${base}merge.zkey`,\n },\n withdraw: {\n wasm: `${base}withdraw.wasm`,\n zkey: `${base}withdraw.zkey`,\n },\n joinsplit: {\n wasm: `${base}joinsplit.wasm`,\n zkey: `${base}joinsplit.zkey`,\n },\n merge_transfer_2x2: {\n wasm: `${base}merge_transfer_2x2.wasm`,\n zkey: `${base}merge_transfer_2x2.zkey`,\n },\n merge_transfer_4x2: {\n wasm: `${base}merge_transfer_4x2.wasm`,\n zkey: `${base}merge_transfer_4x2.zkey`,\n },\n }\n\n return circuitMap[circuit]\n}\n\n/**\n * @deprecated Use getUPPCircuitArtifacts instead\n */\nexport function getStealthCircuitArtifacts(\n circuit: StealthCircuitType,\n baseUrl: string = '/circuits/'\n): CircuitArtifacts {\n const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n\n const circuitMap: Record<StealthCircuitType, CircuitArtifacts> = {\n '1x2': {\n wasm: `${base}shielded_stealth.wasm`,\n zkey: `${base}shielded_stealth_final.zkey`,\n },\n '2x2': {\n wasm: `${base}stealth_2x2.wasm`,\n zkey: `${base}stealth_2x2_final.zkey`,\n },\n }\n\n return circuitMap[circuit]\n}\n\n/**\n * UPP circuit inputs union type\n */\nexport type UPPCircuitInputs =\n | UPPTransferCircuitInputs\n | UPPWithdrawCircuitInputs\n | UPPMergeCircuitInputs\n | UPPJoinSplitCircuitInputs\n\n/**\n * Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)\n *\n * @param circuitType - Which UPP circuit to use\n * @param inputs - Circuit input signals\n * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')\n * @returns Generated proof and public signals\n *\n * @example\n * ```ts\n * const { proof, publicSignals } = await generateUPPProof('transfer', {\n * stateRoot: String(currentRoot),\n * aspRoot: String(aspRoot),\n * // ... other inputs\n * })\n * ```\n */\nexport async function generateUPPProof(\n circuitType: UPPCircuitType,\n inputs: UPPCircuitInputs,\n baseUrl: string = '/circuits/'\n): Promise<ProofResult> {\n const snarkjs = await loadSnarkjs()\n const artifacts = getUPPCircuitArtifacts(circuitType, baseUrl)\n\n // Debug: log key circuit inputs\n if (circuitType === 'transfer') {\n const i = inputs as UPPTransferCircuitInputs\n console.log('[generateUPPProof] === PLONK CIRCUIT INPUTS ===')\n console.log(` circuitType: ${circuitType}`)\n console.log(` stateRoot: ${i.stateRoot}`)\n console.log(` aspRoot: ${i.aspRoot}`)\n console.log(` inputOrigin: ${i.inputOrigin}`)\n console.log(` aspPathElements[0..2]: ${i.aspPathElements?.slice(0, 3).join(', ')}`)\n console.log(` artifacts.wasm: ${artifacts.wasm}`)\n console.log(` artifacts.zkey: ${artifacts.zkey}`)\n }\n\n // Use PLONK prover (not Groth16)\n const result = await snarkjs.plonk.fullProve(inputs, artifacts.wasm, artifacts.zkey)\n\n return {\n proof: {\n proof: result.proof,\n publicSignals: result.publicSignals,\n },\n publicSignals: result.publicSignals,\n }\n}\n\n/**\n * @deprecated Use generateUPPProof instead\n */\nexport async function generateProof(\n _circuitType: CircuitType,\n _inputs: CircuitInputs\n): Promise<Proof> {\n throw new Error('Deprecated: Use generateUPPProof instead')\n}\n\n/**\n * Result from proof generation\n */\nexport interface ProofResult {\n proof: Proof\n publicSignals: string[]\n}\n\n/**\n * @deprecated Stealth circuits use old Groth16 format\n */\nexport async function generateStealthProof(\n circuit: StealthCircuitType,\n inputs: StealthCircuitInputs,\n baseUrl: string = '/circuits/'\n): Promise<ProofResult> {\n const snarkjs = await loadSnarkjs()\n const artifacts = getStealthCircuitArtifacts(circuit, baseUrl)\n\n const result = await snarkjs.groth16.fullProve(inputs, artifacts.wasm, artifacts.zkey)\n\n return {\n proof: {\n proof: result.proof,\n publicSignals: result.publicSignals,\n },\n publicSignals: result.publicSignals,\n }\n}\n\n/**\n * Verify a ZK proof\n */\nexport async function verifyProof(\n _circuitType: CircuitType,\n _proof: Proof\n): Promise<boolean> {\n throw new Error('Not implemented')\n}\n\n/**\n * Format PLONK proof for on-chain verification\n *\n * PLONK proofs use a different format than Groth16:\n * - Groth16: uint256[8] (pi_a, pi_b, pi_c)\n * - PLONK: bytes (encoded proof with commitments and evaluations)\n *\n * Use snarkjs.plonk.exportSolidityCallData() for the exact encoding.\n */\nexport async function formatPlonkProofForContract(proof: Proof): Promise<{\n proofBytes: `0x${string}`\n publicSignals: bigint[]\n}> {\n const snarkjs = await loadSnarkjs()\n const calldata = await snarkjs.plonk.exportSolidityCallData(\n proof.proof,\n proof.publicSignals\n )\n\n // snarkjs returns a comma-separated string: \"0xproof,[sig1,sig2,...]\"\n const [proofHex, signalsStr] = calldata.split(',[\"')\n const signals = signalsStr\n ? signalsStr.replace('\"]', '').split('\",\"').map((s: string) => BigInt(s))\n : proof.publicSignals.map((s: string) => BigInt(s))\n\n return {\n proofBytes: proofHex as `0x${string}`,\n publicSignals: signals,\n }\n}\n\n/**\n * @deprecated Use formatPlonkProofForContract for PLONK proofs.\n *\n * Format Groth16 proof for on-chain verification (old format).\n */\nexport function formatProofForContract(proof: Proof): {\n a: [bigint, bigint]\n b: [[bigint, bigint], [bigint, bigint]]\n c: [bigint, bigint]\n} {\n const { pi_a, pi_b, pi_c } = proof.proof\n\n return {\n a: [BigInt(pi_a[0]), BigInt(pi_a[1])],\n b: [\n [BigInt(pi_b[0][1]), BigInt(pi_b[0][0])],\n [BigInt(pi_b[1][1]), BigInt(pi_b[1][0])],\n ],\n c: [BigInt(pi_c[0]), BigInt(pi_c[1])],\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/client.ts","../src/core/types.ts","../src/core/note.ts","../src/core/index.ts"],"names":[],"mappings":";;;AAoFO,SAAS,gBAAgB,OAAA,EAAqC;AAEnE,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;;;AC9EO,IAAM,YAAA,GAAe;;;ACiCrB,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,QAAQ,MAAA,EAAQ,IAAA,EAAM,UAAS,GAAI,MAAA;AAG1D,EAAA,MAAM,YAAA,GAAe,YAAY,sBAAA,EAAuB;AAExD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,MAAA;AAAA,IACA,QAAA,EAAU,YAAA;AAAA,IACV,MAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAW,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,GAAA,KAAQ,GAAI;AAAA,GACzC;AACF;AASO,SAAS,WAAA,CAAY,OAAa,aAAA,EAA0C;AAEjF,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;AASO,SAAS,WAAA,CAAY,YAA2B,aAAA,EAAwC;AAE7F,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;AAyBA,SAAS,sBAAA,GAAiC;AAExC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA;AAC/B,EAAA,MAAA,CAAO,gBAAgB,KAAK,CAAA;AAC5B,EAAA,OAAO,OAAO,IAAA,GAAO,KAAA,CAAM,KAAK,KAAK,CAAA,CAAE,IAAI,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAC,CAAA;AAC3F;;;ACtGA,YAAA,EAAA","file":"chunk-CEJN5ZE5.js","sourcesContent":["/**\n * Main UPP Client\n *\n * Provides high-level API for interacting with the Universal Private Pool.\n */\n\nimport type { Address, PublicClient, WalletClient } from 'viem'\nimport type {\n ShieldParams,\n TransferParams,\n MergeParams,\n WithdrawParams,\n Note,\n} from './types.js'\n\n/**\n * UPP Client configuration\n */\nexport interface UPPClientConfig {\n /** Viem public client for reading chain state */\n publicClient: PublicClient\n /** Viem wallet client for sending transactions */\n walletClient: WalletClient\n /** Universal Private Pool contract address */\n poolAddress: Address\n /** ASP Registry Hub contract address */\n aspHubAddress: Address\n /** Chain ID (optional, derived from clients if not provided) */\n chainId?: number\n}\n\n/**\n * UPP Client interface\n */\nexport interface UPPClient {\n /** Shield tokens into the private pool */\n shield(params: ShieldParams): Promise<{ commitment: `0x${string}`; note: Note }>\n\n /** Transfer tokens privately */\n transfer(params: TransferParams): Promise<{ nullifier: `0x${string}`; changeNote?: Note }>\n\n /** Merge multiple notes into one */\n merge(params: MergeParams): Promise<{ commitment: `0x${string}`; note: Note }>\n\n /** Withdraw tokens from the private pool */\n withdraw(params: WithdrawParams): Promise<{ txHash: `0x${string}` }>\n\n /** Scan for notes belonging to a viewing key */\n scanNotes(viewingKey: `0x${string}`): Promise<Note[]>\n\n /** Get the current state root */\n getStateRoot(): Promise<bigint>\n\n /** Check if a nullifier has been spent */\n isNullifierSpent(nullifier: `0x${string}`): Promise<boolean>\n}\n\n/**\n * Create a UPP client instance\n *\n * @example\n * ```ts\n * import { createUPPClient } from '@upp/sdk'\n * import { createPublicClient, createWalletClient, http } from 'viem'\n * import { sepolia } from 'viem/chains'\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http(),\n * })\n *\n * const walletClient = createWalletClient({\n * chain: sepolia,\n * transport: http(),\n * })\n *\n * const client = createUPPClient({\n * publicClient,\n * walletClient,\n * poolAddress: '0x...',\n * aspHubAddress: '0x...',\n * })\n * ```\n */\nexport function createUPPClient(_config: UPPClientConfig): UPPClient {\n // TODO: Implement client\n throw new Error('Not implemented')\n}\n","/**\n * Core type definitions for UPP SDK\n */\n\nimport type { Address, Hex } from 'viem'\n\n/**\n * Note version - increment when note structure changes\n */\nexport const NOTE_VERSION = 5\n\n/**\n * A private note in the Universal Private Pool\n */\nexport interface Note {\n /** Note format version */\n version: number\n /** Token amount (in wei) */\n amount: bigint\n /** Random blinding factor */\n blinding: bigint\n /** Current origin - who is responsible for these funds (updated on merge) */\n origin: Address\n /** Sender - who sent this specific note (for payment attribution) */\n sender: Address\n /** ERC20 token address */\n token: Address\n /** Optional memo/message */\n memo?: string\n /** Timestamp when note was created */\n timestamp?: number\n}\n\n/**\n * Encrypted note data stored on-chain (post-quantum, hash-based)\n */\nexport interface EncryptedNote {\n /** AES-GCM encrypted note data */\n ciphertext: Hex\n /** AES-GCM nonce */\n nonce: Hex\n}\n\n/**\n * Stealth meta-address (hash-based, post-quantum)\n * Published once, used by senders to encrypt notes to the recipient\n */\nexport interface StealthMetaAddress {\n /** Owner hash = Poseidon(spendingSecret) */\n ownerHash: bigint\n /** Viewing hash = Poseidon(viewingSecret) */\n viewingHash: bigint\n}\n\n/**\n * One-time address for a specific transaction (simplified for hash-based system)\n */\nexport interface StealthAddress {\n /** Owner hash for this note */\n ownerHash: bigint\n /** Search tag for efficient scanning */\n searchTag?: bigint\n}\n\n/**\n * On-chain merge record for audit trail\n */\nexport interface MergeRecord {\n /** Output commitment (the merged note) */\n outputCommitment: Hex\n /** First input nullifier */\n nullifier1: Hex\n /** Second input nullifier */\n nullifier2: Hex\n /** Who performed the merge (new origin) */\n merger: Address\n /** Token that was merged */\n token: Address\n /** Block timestamp */\n timestamp: number\n}\n\n/**\n * ASP (Association Set Provider) root\n */\nexport interface ASPRoot {\n /** Merkle root of approved addresses */\n root: bigint\n /** IPFS hash for off-chain data */\n ipfsHash: Hex\n /** When this root was published */\n timestamp: number\n /** Number of addresses in the set */\n leafCount: number\n}\n\n/**\n * Shield operation parameters\n */\nexport interface ShieldParams {\n /** ERC20 token to shield */\n token: Address\n /** Amount to shield (in wei) */\n amount: bigint\n /** Optional: recipient owner hash (defaults to self) */\n recipientOwnerHash?: bigint\n /** Optional: memo to include in note */\n memo?: string\n}\n\n/**\n * Transfer operation parameters\n */\nexport interface TransferParams {\n /** Note to spend */\n note: Note\n /** Recipient stealth address */\n recipient: StealthAddress\n /** Amount to send (remainder goes back to sender as change) */\n amount: bigint\n /** Optional: memo to include */\n memo?: string\n}\n\n/**\n * Merge operation parameters\n */\nexport interface MergeParams {\n /** Notes to merge (must be same token) */\n notes: [Note, Note]\n /** Optional: memo for the merged note */\n memo?: string\n}\n\n/**\n * Withdraw operation parameters\n */\nexport interface WithdrawParams {\n /** Note to withdraw */\n note: Note\n /** Amount to withdraw */\n amount: bigint\n /** Recipient address for the tokens */\n recipient: Address\n /** ASP ID to use for compliance check */\n aspId?: number\n /** Use ragequit (origin withdrawing own funds) */\n ragequit?: boolean\n}\n\n/**\n * Proof for ZK operations\n */\nexport interface Proof {\n /** Proof points */\n proof: {\n pi_a: [string, string]\n pi_b: [[string, string], [string, string]]\n pi_c: [string, string]\n }\n /** Public signals */\n publicSignals: string[]\n}\n\n/**\n * Note commitment (hash)\n */\nexport type Commitment = Hex\n\n/**\n * Nullifier (spent note identifier)\n */\nexport type Nullifier = Hex\n\n// =========================================================================\n// STARK Note Types (M31/Keccak-based, post-quantum)\n// =========================================================================\n\nimport type { M31Digest } from '../utils/keccak-m31.js'\n\n// STARK_AMOUNT_SCALE moved to utils/stark.ts\nexport { STARK_AMOUNT_SCALE } from '../utils/stark.js'\n\n/**\n * A private STARK note in the Universal Private Pool.\n *\n * All field values are M31 elements (< 2^31 - 1).\n * Commitment = keccak_m31(amount, ownerHash[0..4], blinding, origin, token).\n */\nexport interface StarkNote {\n /** Amount in STARK units (actual wei = amount * STARK_AMOUNT_SCALE) */\n amount: bigint\n /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */\n ownerHash: M31Digest\n /** Random blinding factor (M31) */\n blinding: bigint\n /** Origin address encoded as M31 (lower 31 bits of address) */\n origin: bigint\n /** Token address encoded as M31 (lower 31 bits of address) */\n token: bigint\n /** The leaf index in the STARK Keccak Merkle tree (set after shielding) */\n leafIndex?: number\n /** The commitment digest (set after computation) */\n commitment?: M31Digest\n /** Optional memo */\n memo?: string\n /** Timestamp when note was created */\n timestamp?: number\n}\n\n/**\n * STARK stealth meta-address (M31/Keccak-based)\n * Published once, used by senders to encrypt notes to the recipient\n */\nexport interface StarkStealthMetaAddress {\n /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */\n ownerHash: M31Digest\n /** Viewing hash = keccak_m31(starkViewingSecret) — 4 M31 elements */\n viewingHash: M31Digest\n}\n\n/**\n * STARK proof for ZK operations (serialized Circle STARK proof)\n */\nexport interface StarkProof {\n /** Raw serialized Stwo Circle STARK proof bytes */\n proofBytes: Hex\n /** Public inputs seed (keccak256 of public parameters) */\n publicInputsSeed: Hex\n}\n","/**\n * Note management utilities\n *\n * Create, encrypt, and decrypt private notes.\n */\n\nimport type { Address, Hex } from 'viem'\nimport type { Note, EncryptedNote } from './types.js'\nimport { NOTE_VERSION } from './types.js'\n\n/**\n * Parameters for creating a new note\n */\nexport interface CreateNoteParams {\n /** Token amount */\n amount: bigint\n /** ERC20 token address */\n token: Address\n /** Origin address (who is responsible) */\n origin: Address\n /** Sender address */\n sender: Address\n /** Optional memo */\n memo?: string\n /** Optional blinding factor (generated if not provided) */\n blinding?: bigint\n}\n\n/**\n * Create a new private note\n *\n * @example\n * ```ts\n * const note = createNote({\n * amount: 1000n * 10n ** 18n,\n * token: '0x...',\n * origin: '0xMyAddress...',\n * sender: '0xMyAddress...',\n * memo: 'Payment for services',\n * })\n * ```\n */\nexport function createNote(params: CreateNoteParams): Note {\n const { amount, token, origin, sender, memo, blinding } = params\n\n // Generate random blinding factor if not provided\n const noteBlinding = blinding ?? generateRandomBlinding()\n\n return {\n version: NOTE_VERSION,\n amount,\n blinding: noteBlinding,\n origin,\n sender,\n token,\n memo,\n timestamp: Math.floor(Date.now() / 1000),\n }\n}\n\n/**\n * Encrypt a note for a recipient\n *\n * @param note - The note to encrypt\n * @param sharedSecret - ECDH shared secret with recipient\n * @returns Encrypted note data\n */\nexport function encryptNote(_note: Note, _sharedSecret: Uint8Array): EncryptedNote {\n // TODO: Implement AES-GCM encryption\n throw new Error('Not implemented')\n}\n\n/**\n * Decrypt a received note\n *\n * @param encrypted - The encrypted note data\n * @param sharedSecret - ECDH shared secret\n * @returns Decrypted note or null if decryption fails\n */\nexport function decryptNote(_encrypted: EncryptedNote, _sharedSecret: Uint8Array): Note | null {\n // TODO: Implement AES-GCM decryption\n throw new Error('Not implemented')\n}\n\n/**\n * Compute the commitment hash for a note\n *\n * commitment = Poseidon(amount, blinding, origin, token)\n */\nexport function computeCommitment(_note: Note): Hex {\n // TODO: Implement Poseidon hash\n throw new Error('Not implemented')\n}\n\n/**\n * Compute the nullifier for spending a note\n *\n * nullifier = Poseidon(blinding, leafIndex)\n */\nexport function computeNullifier(_note: Note, _leafIndex: bigint): Hex {\n // TODO: Implement nullifier computation\n throw new Error('Not implemented')\n}\n\n/**\n * Generate a random blinding factor\n */\nfunction generateRandomBlinding(): bigint {\n // TODO: Use crypto.getRandomValues for secure randomness\n const bytes = new Uint8Array(31) // 31 bytes to stay in field\n crypto.getRandomValues(bytes)\n return BigInt('0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join(''))\n}\n","/**\n * Core UPP SDK functionality\n */\n\nexport { createUPPClient } from './client.js'\nexport type { UPPClient, UPPClientConfig } from './client.js'\n\nexport { createNote, encryptNote, decryptNote } from './note.js'\n\n// Stealth address utilities (post-quantum, hash-based)\nexport {\n STEALTH_ADDRESS_PREFIX,\n ADDRESS_VERSION,\n encodeStealthAddress,\n decodeStealthAddress,\n isValidStealthAddress,\n generateStealthAddress,\n createOneTimeKeys,\n verifyOwnership,\n computeNoteEncryptionKey,\n // STARK stealth addresses (0zs prefix)\n STARK_STEALTH_ADDRESS_PREFIX,\n STARK_ADDRESS_VERSION,\n encodeStarkStealthAddress,\n decodeStarkStealthAddress,\n isValidStarkStealthAddress,\n generateStarkStealthAddress,\n detectAddressType,\n} from './stealth.js'\n\n// Proof generation (UPP circuits)\nexport {\n generateUPPProof,\n formatProofForContract,\n getUPPCircuitArtifacts,\n STATE_TREE_DEPTH,\n ASP_TREE_DEPTH,\n} from './proof.js'\nexport type {\n UPPCircuitType,\n UPPTransferCircuitInputs,\n UPPWithdrawCircuitInputs,\n UPPCircuitInputs,\n CircuitArtifacts,\n ProofResult,\n} from './proof.js'\n\n// Legacy stealth proof exports (deprecated)\nexport {\n generateProof,\n verifyProof,\n generateStealthProof,\n getStealthCircuitArtifacts,\n} from './proof.js'\nexport type {\n CircuitType,\n StealthCircuitType,\n StealthCircuitInputs,\n Stealth1x2CircuitInputs,\n Stealth2x2CircuitInputs,\n} from './proof.js'\n\nexport * from './types.js'\n\n// Swap order book module\nexport {\n computeGiveAmount,\n computeTakeAmount,\n computeRate,\n formatRate,\n computeCancelKeyHash,\n generateCancelSecret,\n filterOrdersByASP,\n filterOrdersByTokenPair,\n isFillerASPAccepted,\n isOrderActive,\n computeTotalBuyAmount,\n computeFillPercentage,\n storeCancelSecret,\n getCancelSecret,\n removeCancelSecret,\n getOwnOrderIds,\n RATE_PRECISION,\n SWAP_EVENTS_ABI,\n SWAP_ORDER_PLACED_EVENT,\n SWAP_ORDER_FILLED_EVENT,\n SWAP_ORDER_CLAIMED_EVENT,\n SWAP_ORDER_CANCELLED_EVENT,\n} from './swap.js'\nexport type {\n SwapOrder,\n SwapOrderParams,\n SwapFillParams,\n SwapOrderEvent,\n SwapFillEvent,\n} from './swap.js'\n\n// Account adapter (pluggable key source + persistence)\nexport { DirectAccountAdapter, StorableAccountAdapter } from './account.js'\nexport type { IAccountAdapter } from './account.js'\n\n// ASP provider (pluggable compliance)\nexport type { IASPProvider, ASPMembershipProof } from './asp-provider.js'\n\n// Note store (single source of truth for note state)\nexport { NoteStore } from './note-store.js'\nexport type { INoteStore, ShieldedNote, NoteStatus, ProofSystem } from './note-store.js'\n\n// ASP (Association Set Provider) module\nexport {\n computeSingleOriginASPRoot,\n generateSingleOriginASPProof,\n verifyASPProof,\n DEMO_ASP_ID,\n DEMO_ASP_NAME,\n createDemoASPRoot,\n // Multi-origin ASP tree\n buildASPTree,\n computeMultiOriginASPRoot,\n generateMultiOriginASPProof,\n generateASPProof,\n} from './asp.js'\nexport type { ASPProof } from './asp.js'\n\n// Transfer module\nexport {\n syncMerkleTree,\n getMerkleProofsForNotes,\n computeNullifier,\n buildUPPTransferCircuitInputs,\n buildTransfer,\n formatOutputForContract,\n} from './transfer.js'\nexport type {\n TransferStage,\n SpendableNote,\n MerkleProofWithNote,\n TransferContext,\n TransferBuildResult,\n NoteWithAmount,\n} from './transfer.js'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/client.ts","../src/core/types.ts","../src/core/note.ts","../src/core/index.ts"],"names":["init_stealth"],"mappings":";;;;;AAoFO,SAAS,gBAAgB,OAAA,EAAqC;AAEnE,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;;;AC9EO,IAAM,YAAA,GAAe;;;ACiCrB,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAO,QAAQ,MAAA,EAAQ,IAAA,EAAM,UAAS,GAAI,MAAA;AAG1D,EAAA,MAAM,YAAA,GAAe,YAAY,sBAAA,EAAuB;AAExD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,YAAA;AAAA,IACT,MAAA;AAAA,IACA,QAAA,EAAU,YAAA;AAAA,IACV,MAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAW,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,GAAA,KAAQ,GAAI;AAAA,GACzC;AACF;AASO,SAAS,WAAA,CAAY,OAAa,aAAA,EAA0C;AAEjF,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;AASO,SAAS,WAAA,CAAY,YAA2B,aAAA,EAAwC;AAE7F,EAAA,MAAM,IAAI,MAAM,iBAAiB,CAAA;AACnC;AAyBA,SAAS,sBAAA,GAAiC;AAExC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA;AAC/B,EAAA,MAAA,CAAO,gBAAgB,KAAK,CAAA;AAC5B,EAAA,OAAO,OAAO,IAAA,GAAO,KAAA,CAAM,KAAK,KAAK,CAAA,CAAE,IAAI,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAC,CAAA;AAC3F;;;ACtGAA,8BAAA,EAAA","file":"chunk-UTAJSERA.cjs","sourcesContent":["/**\n * Main UPP Client\n *\n * Provides high-level API for interacting with the Universal Private Pool.\n */\n\nimport type { Address, PublicClient, WalletClient } from 'viem'\nimport type {\n ShieldParams,\n TransferParams,\n MergeParams,\n WithdrawParams,\n Note,\n} from './types.js'\n\n/**\n * UPP Client configuration\n */\nexport interface UPPClientConfig {\n /** Viem public client for reading chain state */\n publicClient: PublicClient\n /** Viem wallet client for sending transactions */\n walletClient: WalletClient\n /** Universal Private Pool contract address */\n poolAddress: Address\n /** ASP Registry Hub contract address */\n aspHubAddress: Address\n /** Chain ID (optional, derived from clients if not provided) */\n chainId?: number\n}\n\n/**\n * UPP Client interface\n */\nexport interface UPPClient {\n /** Shield tokens into the private pool */\n shield(params: ShieldParams): Promise<{ commitment: `0x${string}`; note: Note }>\n\n /** Transfer tokens privately */\n transfer(params: TransferParams): Promise<{ nullifier: `0x${string}`; changeNote?: Note }>\n\n /** Merge multiple notes into one */\n merge(params: MergeParams): Promise<{ commitment: `0x${string}`; note: Note }>\n\n /** Withdraw tokens from the private pool */\n withdraw(params: WithdrawParams): Promise<{ txHash: `0x${string}` }>\n\n /** Scan for notes belonging to a viewing key */\n scanNotes(viewingKey: `0x${string}`): Promise<Note[]>\n\n /** Get the current state root */\n getStateRoot(): Promise<bigint>\n\n /** Check if a nullifier has been spent */\n isNullifierSpent(nullifier: `0x${string}`): Promise<boolean>\n}\n\n/**\n * Create a UPP client instance\n *\n * @example\n * ```ts\n * import { createUPPClient } from '@upp/sdk'\n * import { createPublicClient, createWalletClient, http } from 'viem'\n * import { sepolia } from 'viem/chains'\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http(),\n * })\n *\n * const walletClient = createWalletClient({\n * chain: sepolia,\n * transport: http(),\n * })\n *\n * const client = createUPPClient({\n * publicClient,\n * walletClient,\n * poolAddress: '0x...',\n * aspHubAddress: '0x...',\n * })\n * ```\n */\nexport function createUPPClient(_config: UPPClientConfig): UPPClient {\n // TODO: Implement client\n throw new Error('Not implemented')\n}\n","/**\n * Core type definitions for UPP SDK\n */\n\nimport type { Address, Hex } from 'viem'\n\n/**\n * Note version - increment when note structure changes\n */\nexport const NOTE_VERSION = 5\n\n/**\n * A private note in the Universal Private Pool\n */\nexport interface Note {\n /** Note format version */\n version: number\n /** Token amount (in wei) */\n amount: bigint\n /** Random blinding factor */\n blinding: bigint\n /** Current origin - who is responsible for these funds (updated on merge) */\n origin: Address\n /** Sender - who sent this specific note (for payment attribution) */\n sender: Address\n /** ERC20 token address */\n token: Address\n /** Optional memo/message */\n memo?: string\n /** Timestamp when note was created */\n timestamp?: number\n}\n\n/**\n * Encrypted note data stored on-chain (post-quantum, hash-based)\n */\nexport interface EncryptedNote {\n /** AES-GCM encrypted note data */\n ciphertext: Hex\n /** AES-GCM nonce */\n nonce: Hex\n}\n\n/**\n * Stealth meta-address (hash-based, post-quantum)\n * Published once, used by senders to encrypt notes to the recipient\n */\nexport interface StealthMetaAddress {\n /** Owner hash = Poseidon(spendingSecret) */\n ownerHash: bigint\n /** Viewing hash = Poseidon(viewingSecret) */\n viewingHash: bigint\n}\n\n/**\n * One-time address for a specific transaction (simplified for hash-based system)\n */\nexport interface StealthAddress {\n /** Owner hash for this note */\n ownerHash: bigint\n /** Search tag for efficient scanning */\n searchTag?: bigint\n}\n\n/**\n * On-chain merge record for audit trail\n */\nexport interface MergeRecord {\n /** Output commitment (the merged note) */\n outputCommitment: Hex\n /** First input nullifier */\n nullifier1: Hex\n /** Second input nullifier */\n nullifier2: Hex\n /** Who performed the merge (new origin) */\n merger: Address\n /** Token that was merged */\n token: Address\n /** Block timestamp */\n timestamp: number\n}\n\n/**\n * ASP (Association Set Provider) root\n */\nexport interface ASPRoot {\n /** Merkle root of approved addresses */\n root: bigint\n /** IPFS hash for off-chain data */\n ipfsHash: Hex\n /** When this root was published */\n timestamp: number\n /** Number of addresses in the set */\n leafCount: number\n}\n\n/**\n * Shield operation parameters\n */\nexport interface ShieldParams {\n /** ERC20 token to shield */\n token: Address\n /** Amount to shield (in wei) */\n amount: bigint\n /** Optional: recipient owner hash (defaults to self) */\n recipientOwnerHash?: bigint\n /** Optional: memo to include in note */\n memo?: string\n}\n\n/**\n * Transfer operation parameters\n */\nexport interface TransferParams {\n /** Note to spend */\n note: Note\n /** Recipient stealth address */\n recipient: StealthAddress\n /** Amount to send (remainder goes back to sender as change) */\n amount: bigint\n /** Optional: memo to include */\n memo?: string\n}\n\n/**\n * Merge operation parameters\n */\nexport interface MergeParams {\n /** Notes to merge (must be same token) */\n notes: [Note, Note]\n /** Optional: memo for the merged note */\n memo?: string\n}\n\n/**\n * Withdraw operation parameters\n */\nexport interface WithdrawParams {\n /** Note to withdraw */\n note: Note\n /** Amount to withdraw */\n amount: bigint\n /** Recipient address for the tokens */\n recipient: Address\n /** ASP ID to use for compliance check */\n aspId?: number\n /** Use ragequit (origin withdrawing own funds) */\n ragequit?: boolean\n}\n\n/**\n * Proof for ZK operations\n */\nexport interface Proof {\n /** Proof points */\n proof: {\n pi_a: [string, string]\n pi_b: [[string, string], [string, string]]\n pi_c: [string, string]\n }\n /** Public signals */\n publicSignals: string[]\n}\n\n/**\n * Note commitment (hash)\n */\nexport type Commitment = Hex\n\n/**\n * Nullifier (spent note identifier)\n */\nexport type Nullifier = Hex\n\n// =========================================================================\n// STARK Note Types (M31/Keccak-based, post-quantum)\n// =========================================================================\n\nimport type { M31Digest } from '../utils/keccak-m31.js'\n\n// STARK_AMOUNT_SCALE moved to utils/stark.ts\nexport { STARK_AMOUNT_SCALE } from '../utils/stark.js'\n\n/**\n * A private STARK note in the Universal Private Pool.\n *\n * All field values are M31 elements (< 2^31 - 1).\n * Commitment = keccak_m31(amount, ownerHash[0..4], blinding, origin, token).\n */\nexport interface StarkNote {\n /** Amount in STARK units (actual wei = amount * STARK_AMOUNT_SCALE) */\n amount: bigint\n /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */\n ownerHash: M31Digest\n /** Random blinding factor (M31) */\n blinding: bigint\n /** Origin address encoded as M31 (lower 31 bits of address) */\n origin: bigint\n /** Token address encoded as M31 (lower 31 bits of address) */\n token: bigint\n /** The leaf index in the STARK Keccak Merkle tree (set after shielding) */\n leafIndex?: number\n /** The commitment digest (set after computation) */\n commitment?: M31Digest\n /** Optional memo */\n memo?: string\n /** Timestamp when note was created */\n timestamp?: number\n}\n\n/**\n * STARK stealth meta-address (M31/Keccak-based)\n * Published once, used by senders to encrypt notes to the recipient\n */\nexport interface StarkStealthMetaAddress {\n /** Owner hash = keccak_m31(starkSecret) — 4 M31 elements */\n ownerHash: M31Digest\n /** Viewing hash = keccak_m31(starkViewingSecret) — 4 M31 elements */\n viewingHash: M31Digest\n}\n\n/**\n * STARK proof for ZK operations (serialized Circle STARK proof)\n */\nexport interface StarkProof {\n /** Raw serialized Stwo Circle STARK proof bytes */\n proofBytes: Hex\n /** Public inputs seed (keccak256 of public parameters) */\n publicInputsSeed: Hex\n}\n","/**\n * Note management utilities\n *\n * Create, encrypt, and decrypt private notes.\n */\n\nimport type { Address, Hex } from 'viem'\nimport type { Note, EncryptedNote } from './types.js'\nimport { NOTE_VERSION } from './types.js'\n\n/**\n * Parameters for creating a new note\n */\nexport interface CreateNoteParams {\n /** Token amount */\n amount: bigint\n /** ERC20 token address */\n token: Address\n /** Origin address (who is responsible) */\n origin: Address\n /** Sender address */\n sender: Address\n /** Optional memo */\n memo?: string\n /** Optional blinding factor (generated if not provided) */\n blinding?: bigint\n}\n\n/**\n * Create a new private note\n *\n * @example\n * ```ts\n * const note = createNote({\n * amount: 1000n * 10n ** 18n,\n * token: '0x...',\n * origin: '0xMyAddress...',\n * sender: '0xMyAddress...',\n * memo: 'Payment for services',\n * })\n * ```\n */\nexport function createNote(params: CreateNoteParams): Note {\n const { amount, token, origin, sender, memo, blinding } = params\n\n // Generate random blinding factor if not provided\n const noteBlinding = blinding ?? generateRandomBlinding()\n\n return {\n version: NOTE_VERSION,\n amount,\n blinding: noteBlinding,\n origin,\n sender,\n token,\n memo,\n timestamp: Math.floor(Date.now() / 1000),\n }\n}\n\n/**\n * Encrypt a note for a recipient\n *\n * @param note - The note to encrypt\n * @param sharedSecret - ECDH shared secret with recipient\n * @returns Encrypted note data\n */\nexport function encryptNote(_note: Note, _sharedSecret: Uint8Array): EncryptedNote {\n // TODO: Implement AES-GCM encryption\n throw new Error('Not implemented')\n}\n\n/**\n * Decrypt a received note\n *\n * @param encrypted - The encrypted note data\n * @param sharedSecret - ECDH shared secret\n * @returns Decrypted note or null if decryption fails\n */\nexport function decryptNote(_encrypted: EncryptedNote, _sharedSecret: Uint8Array): Note | null {\n // TODO: Implement AES-GCM decryption\n throw new Error('Not implemented')\n}\n\n/**\n * Compute the commitment hash for a note\n *\n * commitment = Poseidon(amount, blinding, origin, token)\n */\nexport function computeCommitment(_note: Note): Hex {\n // TODO: Implement Poseidon hash\n throw new Error('Not implemented')\n}\n\n/**\n * Compute the nullifier for spending a note\n *\n * nullifier = Poseidon(blinding, leafIndex)\n */\nexport function computeNullifier(_note: Note, _leafIndex: bigint): Hex {\n // TODO: Implement nullifier computation\n throw new Error('Not implemented')\n}\n\n/**\n * Generate a random blinding factor\n */\nfunction generateRandomBlinding(): bigint {\n // TODO: Use crypto.getRandomValues for secure randomness\n const bytes = new Uint8Array(31) // 31 bytes to stay in field\n crypto.getRandomValues(bytes)\n return BigInt('0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join(''))\n}\n","/**\n * Core UPP SDK functionality\n */\n\nexport { createUPPClient } from './client.js'\nexport type { UPPClient, UPPClientConfig } from './client.js'\n\nexport { createNote, encryptNote, decryptNote } from './note.js'\n\n// Stealth address utilities (post-quantum, hash-based)\nexport {\n STEALTH_ADDRESS_PREFIX,\n ADDRESS_VERSION,\n encodeStealthAddress,\n decodeStealthAddress,\n isValidStealthAddress,\n generateStealthAddress,\n createOneTimeKeys,\n verifyOwnership,\n computeNoteEncryptionKey,\n // STARK stealth addresses (0zs prefix)\n STARK_STEALTH_ADDRESS_PREFIX,\n STARK_ADDRESS_VERSION,\n encodeStarkStealthAddress,\n decodeStarkStealthAddress,\n isValidStarkStealthAddress,\n generateStarkStealthAddress,\n detectAddressType,\n} from './stealth.js'\n\n// Proof generation (UPP circuits)\nexport {\n generateUPPProof,\n formatProofForContract,\n getUPPCircuitArtifacts,\n STATE_TREE_DEPTH,\n ASP_TREE_DEPTH,\n} from './proof.js'\nexport type {\n UPPCircuitType,\n UPPTransferCircuitInputs,\n UPPWithdrawCircuitInputs,\n UPPCircuitInputs,\n CircuitArtifacts,\n ProofResult,\n} from './proof.js'\n\n// Legacy stealth proof exports (deprecated)\nexport {\n generateProof,\n verifyProof,\n generateStealthProof,\n getStealthCircuitArtifacts,\n} from './proof.js'\nexport type {\n CircuitType,\n StealthCircuitType,\n StealthCircuitInputs,\n Stealth1x2CircuitInputs,\n Stealth2x2CircuitInputs,\n} from './proof.js'\n\nexport * from './types.js'\n\n// Swap order book module\nexport {\n computeGiveAmount,\n computeTakeAmount,\n computeRate,\n formatRate,\n computeCancelKeyHash,\n generateCancelSecret,\n filterOrdersByASP,\n filterOrdersByTokenPair,\n isFillerASPAccepted,\n isOrderActive,\n computeTotalBuyAmount,\n computeFillPercentage,\n storeCancelSecret,\n getCancelSecret,\n removeCancelSecret,\n getOwnOrderIds,\n RATE_PRECISION,\n SWAP_EVENTS_ABI,\n SWAP_ORDER_PLACED_EVENT,\n SWAP_ORDER_FILLED_EVENT,\n SWAP_ORDER_CLAIMED_EVENT,\n SWAP_ORDER_CANCELLED_EVENT,\n} from './swap.js'\nexport type {\n SwapOrder,\n SwapOrderParams,\n SwapFillParams,\n SwapOrderEvent,\n SwapFillEvent,\n} from './swap.js'\n\n// Account adapter (pluggable key source + persistence)\nexport { DirectAccountAdapter, StorableAccountAdapter } from './account.js'\nexport type { IAccountAdapter } from './account.js'\n\n// ASP provider (pluggable compliance)\nexport type { IASPProvider, ASPMembershipProof } from './asp-provider.js'\n\n// Note store (single source of truth for note state)\nexport { NoteStore } from './note-store.js'\nexport type { INoteStore, ShieldedNote, NoteStatus, ProofSystem } from './note-store.js'\n\n// ASP (Association Set Provider) module\nexport {\n computeSingleOriginASPRoot,\n generateSingleOriginASPProof,\n verifyASPProof,\n DEMO_ASP_ID,\n DEMO_ASP_NAME,\n createDemoASPRoot,\n // Multi-origin ASP tree\n buildASPTree,\n computeMultiOriginASPRoot,\n generateMultiOriginASPProof,\n generateASPProof,\n} from './asp.js'\nexport type { ASPProof } from './asp.js'\n\n// Transfer module\nexport {\n syncMerkleTree,\n getMerkleProofsForNotes,\n computeNullifier,\n buildUPPTransferCircuitInputs,\n buildTransfer,\n formatOutputForContract,\n} from './transfer.js'\nexport type {\n TransferStage,\n SpendableNote,\n MerkleProofWithNote,\n TransferContext,\n TransferBuildResult,\n NoteWithAmount,\n} from './transfer.js'\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/proof.ts"],"names":["snarkjs"],"mappings":";AAUA,IAAI,OAAA,GAAe,IAAA;AAKnB,eAAe,WAAA,GAA4B;AACzC,EAAA,IAAI,SAAS,OAAO,OAAA;AACpB,EAAA,OAAA,GAAU,MAAM,OAAO,SAAS,CAAA;AAChC,EAAA,OAAO,OAAA;AACT;AAOO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,cAAA,GAAiB;AA+SvB,SAAS,sBAAA,CACd,OAAA,EACA,OAAA,GAAkB,YAAA,EACA;AAClB,EAAA,MAAM,OAAO,OAAA,CAAQ,QA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 PLONK)\n *\n * Uses snarkjs for PLONK proof generation over the BLS12-381 curve.\n * PLONK provides a universal trusted setup (no per-circuit ceremony).\n */\n\nimport type { Proof } from './types.js'\n\n// Lazy-loaded snarkjs reference\nlet snarkjs: any = null\n\n/**\n * Load snarkjs dynamically\n */\nasync function loadSnarkjs(): Promise<any> {\n if (snarkjs) return snarkjs\n snarkjs = await import('snarkjs')\n return snarkjs\n}\n\n// ============================================================================\n// UPP Circuit Constants\n// ============================================================================\n\n/** State tree depth (32 levels = ~4B notes) */\nexport const STATE_TREE_DEPTH = 32\n\n/** ASP tree depth (20 levels = ~1M addresses) */\nexport const ASP_TREE_DEPTH = 20\n\n// ============================================================================\n// UPP Circuit Types\n// ============================================================================\n\n/**\n * Circuit types available in UPP (full protocol)\n */\nexport type UPPCircuitType = 'transfer' | 'merge' | 'withdraw' | 'joinsplit' | 'merge_transfer_2x2' | 'merge_transfer_4x2'\n\n/**\n * @deprecated Use UPPCircuitType instead\n */\nexport type CircuitType = 'shield' | 'transfer' | 'merge' | 'withdraw'\n\n/**\n * @deprecated Stealth circuits are being replaced by UPP circuits\n */\nexport type StealthCircuitType = '1x2' | '2x2'\n\n/**\n * Input signals for UPP transfer circuit (1-in-2-out, BLS12-381 PLONK)\n *\n * Matches transfer.circom: Transfer(32, 20)\n * Public: stateRoot, aspRoot, nullifier, outputCommitment1, outputCommitment2, token\n *\n * Note: Uses hash-based ownership (ownerHash) instead of BabyJubJub pubkeys.\n */\nexport interface UPPTransferCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier: string\n outputCommitment1: string\n outputCommitment2: string\n token: string\n\n // Private inputs - Input Note\n inputAmount: string\n inputOneTimeSecret: string\n inputBlinding: string\n inputOrigin: string\n inputLeafIndex: string\n inputPathElements: string[] // 32 elements\n inputPathIndices: string[] // 32 elements\n\n // Private inputs - ASP Membership Proof\n aspPathElements: string[] // 20 elements\n aspPathIndices: string[] // 20 elements\n\n // Private inputs - Output Notes (hash-based ownership)\n outputAmount1: string\n outputOwnerHash1: string\n outputBlinding1: string\n\n outputAmount2: string\n outputOwnerHash2: string\n outputBlinding2: string\n}\n\n/**\n * Input signals for UPP withdraw circuit (BLS12-381 PLONK)\n *\n * Matches withdraw.circom with optional ASP check (ragequit support)\n */\nexport interface UPPWithdrawCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier: string\n amount: string\n recipient: string\n token: string\n isRagequit: string // '0' or '1'\n\n // Private inputs - Input Note\n inputAmount: string\n inputOneTimeSecret: string\n inputBlinding: string\n inputOrigin: string\n inputLeafIndex: string\n inputPathElements: string[] // 32 elements\n inputPathIndices: string[] // 32 elements\n\n // Private inputs - ASP Membership Proof (can be zeros if ragequit)\n aspPathElements: string[] // 20 elements\n aspPathIndices: string[] // 20 elements\n}\n\n/**\n * Input signals for UPP merge circuit (2-in-1-out, BLS12-381 PLONK)\n */\nexport interface UPPMergeCircuitInputs {\n // Public inputs\n stateRoot: string\n nullifier1: string\n nullifier2: string\n outputCommitment: string\n merger: string\n token: string\n\n // Private inputs - Input Note 1\n inputAmount1: string\n inputOneTimeSecret1: string\n inputBlinding1: string\n inputOrigin1: string\n inputLeafIndex1: string\n inputPathElements1: string[]\n inputPathIndices1: string[]\n\n // Private inputs - Input Note 2\n inputAmount2: string\n inputOneTimeSecret2: string\n inputBlinding2: string\n inputOrigin2: string\n inputLeafIndex2: string\n inputPathElements2: string[]\n inputPathIndices2: string[]\n\n // Private inputs - Output Note\n outputAmount: string\n outputOwnerHash: string\n outputBlinding: string\n}\n\n/**\n * Input signals for UPP joinsplit circuit (4-in-2-out, BLS12-381 PLONK)\n */\nexport interface UPPJoinSplitCircuitInputs {\n // Public inputs\n stateRoot: string\n aspRoot: string\n nullifier1: string\n nullifier2: string\n nullifier3: string\n nullifier4: string\n outputCommitment1: string\n outputCommitment2: string\n token: string\n\n // Private inputs - 4 Input Notes\n inputAmount1: string; inputOneTimeSecret1: string; inputBlinding1: string\n inputOrigin1: string; inputLeafIndex1: string\n inputPathElements1: string[]; inputPathIndices1: string[]\n\n inputAmount2: string; inputOneTimeSecret2: string; inputBlinding2: string\n inputOrigin2: string; inputLeafIndex2: string\n inputPathElements2: string[]; inputPathIndices2: string[]\n\n inputAmount3: string; inputOneTimeSecret3: string; inputBlinding3: string\n inputOrigin3: string; inputLeafIndex3: string\n inputPathElements3: string[]; inputPathIndices3: string[]\n\n inputAmount4: string; inputOneTimeSecret4: string; inputBlinding4: string\n inputOrigin4: string; inputLeafIndex4: string\n inputPathElements4: string[]; inputPathIndices4: string[]\n\n // Private inputs - ASP Membership Proof\n aspPathElements: string[]\n aspPathIndices: string[]\n\n // Private inputs - Output Notes\n outputAmount1: string; outputOwnerHash1: string; outputBlinding1: string\n outputAmount2: string; outputOwnerHash2: string; outputBlinding2: string\n}\n\n/**\n * @deprecated Use UPPTransferCircuitInputs instead\n */\nexport interface TransferCircuitInputs {\n stateRoot: bigint\n aspRoot: bigint\n nullifier: bigint\n outputCommitment1: bigint\n outputCommitment2: bigint\n token: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n statePathElements: bigint[]\n statePathIndices: bigint\n aspPathElements: bigint[]\n outAmount1: bigint\n outBlinding1: bigint\n outOrigin1: bigint\n outAmount2: bigint\n outBlinding2: bigint\n outOrigin2: bigint\n}\n\n/**\n * Input signals for shield circuit\n */\nexport interface ShieldCircuitInputs {\n commitment: bigint\n token: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n}\n\n/**\n * Input signals for merge circuit\n */\nexport interface MergeCircuitInputs {\n stateRoot: bigint\n nullifier1: bigint\n nullifier2: bigint\n outputCommitment: bigint\n newOrigin: bigint\n token: bigint\n amount1: bigint\n blinding1: bigint\n origin1: bigint\n token1: bigint\n pathElements1: bigint[]\n pathIndices1: bigint\n amount2: bigint\n blinding2: bigint\n origin2: bigint\n token2: bigint\n pathElements2: bigint[]\n pathIndices2: bigint\n outputAmount: bigint\n outputBlinding: bigint\n}\n\n/**\n * Input signals for withdraw circuit\n */\nexport interface WithdrawCircuitInputs {\n stateRoot: bigint\n aspRoot: bigint\n nullifier: bigint\n withdrawAmount: bigint\n recipient: bigint\n token: bigint\n isRagequit: bigint\n amount: bigint\n blinding: bigint\n origin: bigint\n statePathElements: bigint[]\n statePathIndices: bigint\n aspPathElements: bigint[]\n}\n\n/**\n * Circuit inputs union type\n */\nexport type CircuitInputs =\n | ShieldCircuitInputs\n | TransferCircuitInputs\n | MergeCircuitInputs\n | WithdrawCircuitInputs\n\n// ============================================================================\n// Stealth Circuit Types (deprecated)\n// ============================================================================\n\n/**\n * @deprecated\n */\nexport interface Stealth1x2CircuitInputs {\n root: string; nullifierHash: string; publicAmount: string\n recipient: string; extDataHash: string\n inputAmount: string; inputOneTimeSecret: string; inputBlinding: string\n inputLeafIndex: string; inputPathElements: string[]; inputPathIndices: string[]\n outputAmount1: string; outputPubkeyX1: string; outputPubkeyY1: string; outputBlinding1: string\n outputAmount2: string; outputPubkeyX2: string; outputPubkeyY2: string; outputBlinding2: string\n}\n\n/**\n * @deprecated\n */\nexport interface Stealth2x2CircuitInputs {\n root: string; nullifierHash1: string; nullifierHash2: string\n publicAmount: string; recipient: string; extDataHash: string\n inputAmount1: string; inputOneTimeSecret1: string; inputBlinding1: string\n inputLeafIndex1: string; inputPathElements1: string[]; inputPathIndices1: string[]\n inputAmount2: string; inputOneTimeSecret2: string; inputBlinding2: string\n inputLeafIndex2: string; inputPathElements2: string[]; inputPathIndices2: string[]\n outputAmount1: string; outputPubkeyX1: string; outputPubkeyY1: string; outputBlinding1: string\n outputAmount2: string; outputPubkeyX2: string; outputPubkeyY2: string; outputBlinding2: string\n}\n\n/** @deprecated */\nexport type StealthCircuitInputs = Stealth1x2CircuitInputs | Stealth2x2CircuitInputs\n\n/**\n * Circuit artifact paths\n */\nexport interface CircuitArtifacts {\n wasm: string\n zkey: string\n}\n\n/**\n * Get circuit artifacts for a UPP circuit\n *\n * @param circuit - UPP circuit type\n * @param baseUrl - Base URL for circuit files (default: '/circuits/')\n */\nexport function getUPPCircuitArtifacts(\n circuit: UPPCircuitType,\n baseUrl: string = '/circuits/'\n): CircuitArtifacts {\n const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n\n const circuitMap: Record<UPPCircuitType, CircuitArtifacts> = {\n transfer: {\n wasm: `${base}transfer.wasm`,\n zkey: `${base}transfer.zkey`,\n },\n merge: {\n wasm: `${base}merge.wasm`,\n zkey: `${base}merge.zkey`,\n },\n withdraw: {\n wasm: `${base}withdraw.wasm`,\n zkey: `${base}withdraw.zkey`,\n },\n joinsplit: {\n wasm: `${base}joinsplit.wasm`,\n zkey: `${base}joinsplit.zkey`,\n },\n merge_transfer_2x2: {\n wasm: `${base}merge_transfer_2x2.wasm`,\n zkey: `${base}merge_transfer_2x2.zkey`,\n },\n merge_transfer_4x2: {\n wasm: `${base}merge_transfer_4x2.wasm`,\n zkey: `${base}merge_transfer_4x2.zkey`,\n },\n }\n\n return circuitMap[circuit]\n}\n\n/**\n * @deprecated Use getUPPCircuitArtifacts instead\n */\nexport function getStealthCircuitArtifacts(\n circuit: StealthCircuitType,\n baseUrl: string = '/circuits/'\n): CircuitArtifacts {\n const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`\n\n const circuitMap: Record<StealthCircuitType, CircuitArtifacts> = {\n '1x2': {\n wasm: `${base}shielded_stealth.wasm`,\n zkey: `${base}shielded_stealth_final.zkey`,\n },\n '2x2': {\n wasm: `${base}stealth_2x2.wasm`,\n zkey: `${base}stealth_2x2_final.zkey`,\n },\n }\n\n return circuitMap[circuit]\n}\n\n/**\n * UPP circuit inputs union type\n */\nexport type UPPCircuitInputs =\n | UPPTransferCircuitInputs\n | UPPWithdrawCircuitInputs\n | UPPMergeCircuitInputs\n | UPPJoinSplitCircuitInputs\n\n/**\n * Generate a ZK proof for a UPP circuit (BLS12-381 PLONK)\n *\n * @param circuitType - Which UPP circuit to use\n * @param inputs - Circuit input signals\n * @param baseUrl - Base URL for circuit artifacts (default: '/circuits/')\n * @returns Generated proof and public signals\n *\n * @example\n * ```ts\n * const { proof, publicSignals } = await generateUPPProof('transfer', {\n * stateRoot: String(currentRoot),\n * aspRoot: String(aspRoot),\n * // ... other inputs\n * })\n * ```\n */\nexport async function generateUPPProof(\n circuitType: UPPCircuitType,\n inputs: UPPCircuitInputs,\n baseUrl: string = '/circuits/'\n): Promise<ProofResult> {\n const snarkjs = await loadSnarkjs()\n const artifacts = getUPPCircuitArtifacts(circuitType, baseUrl)\n\n // Debug: log key circuit inputs\n if (circuitType === 'transfer') {\n const i = inputs as UPPTransferCircuitInputs\n console.log('[generateUPPProof] === PLONK CIRCUIT INPUTS ===')\n console.log(` circuitType: ${circuitType}`)\n console.log(` stateRoot: ${i.stateRoot}`)\n console.log(` aspRoot: ${i.aspRoot}`)\n console.log(` inputOrigin: ${i.inputOrigin}`)\n console.log(` aspPathElements[0..2]: ${i.aspPathElements?.slice(0, 3).join(', ')}`)\n console.log(` artifacts.wasm: ${artifacts.wasm}`)\n console.log(` artifacts.zkey: ${artifacts.zkey}`)\n }\n\n // Use PLONK prover (not Groth16)\n const result = await snarkjs.plonk.fullProve(inputs, artifacts.wasm, artifacts.zkey)\n\n return {\n proof: {\n proof: result.proof,\n publicSignals: result.publicSignals,\n },\n publicSignals: result.publicSignals,\n }\n}\n\n/**\n * @deprecated Use generateUPPProof instead\n */\nexport async function generateProof(\n _circuitType: CircuitType,\n _inputs: CircuitInputs\n): Promise<Proof> {\n throw new Error('Deprecated: Use generateUPPProof instead')\n}\n\n/**\n * Result from proof generation\n */\nexport interface ProofResult {\n proof: Proof\n publicSignals: string[]\n}\n\n/**\n * @deprecated Stealth circuits use old Groth16 format\n */\nexport async function generateStealthProof(\n circuit: StealthCircuitType,\n inputs: StealthCircuitInputs,\n baseUrl: string = '/circuits/'\n): Promise<ProofResult> {\n const snarkjs = await loadSnarkjs()\n const artifacts = getStealthCircuitArtifacts(circuit, baseUrl)\n\n const result = await snarkjs.groth16.fullProve(inputs, artifacts.wasm, artifacts.zkey)\n\n return {\n proof: {\n proof: result.proof,\n publicSignals: result.publicSignals,\n },\n publicSignals: result.publicSignals,\n }\n}\n\n/**\n * Verify a ZK proof\n */\nexport async function verifyProof(\n _circuitType: CircuitType,\n _proof: Proof\n): Promise<boolean> {\n throw new Error('Not implemented')\n}\n\n/**\n * Format PLONK proof for on-chain verification\n *\n * PLONK proofs use a different format than Groth16:\n * - Groth16: uint256[8] (pi_a, pi_b, pi_c)\n * - PLONK: bytes (encoded proof with commitments and evaluations)\n *\n * Use snarkjs.plonk.exportSolidityCallData() for the exact encoding.\n */\nexport async function formatPlonkProofForContract(proof: Proof): Promise<{\n proofBytes: `0x${string}`\n publicSignals: bigint[]\n}> {\n const snarkjs = await loadSnarkjs()\n const calldata = await snarkjs.plonk.exportSolidityCallData(\n proof.proof,\n proof.publicSignals\n )\n\n // snarkjs returns a comma-separated string: \"0xproof,[sig1,sig2,...]\"\n const [proofHex, signalsStr] = calldata.split(',[\"')\n const signals = signalsStr\n ? signalsStr.replace('\"]', '').split('\",\"').map((s: string) => BigInt(s))\n : proof.publicSignals.map((s: string) => BigInt(s))\n\n return {\n proofBytes: proofHex as `0x${string}`,\n publicSignals: signals,\n }\n}\n\n/**\n * @deprecated Use formatPlonkProofForContract for PLONK proofs.\n *\n * Format Groth16 proof for on-chain verification (old format).\n */\nexport function formatProofForContract(proof: Proof): {\n a: [bigint, bigint]\n b: [[bigint, bigint], [bigint, bigint]]\n c: [bigint, bigint]\n} {\n const { pi_a, pi_b, pi_c } = proof.proof\n\n return {\n a: [BigInt(pi_a[0]), BigInt(pi_a[1])],\n b: [\n [BigInt(pi_b[0][1]), BigInt(pi_b[0][0])],\n [BigInt(pi_b[1][1]), BigInt(pi_b[1][0])],\n ],\n c: [BigInt(pi_c[0]), BigInt(pi_c[1])],\n }\n}\n"]}
|