@permissionless-technologies/upp-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +194 -0
  3. package/dist/asp-TXSAFFD3.cjs +53 -0
  4. package/dist/asp-TXSAFFD3.cjs.map +1 -0
  5. package/dist/asp-ZA3RGN7G.js +4 -0
  6. package/dist/asp-ZA3RGN7G.js.map +1 -0
  7. package/dist/babyjubjub-2MGQVCKB.js +5 -0
  8. package/dist/babyjubjub-2MGQVCKB.js.map +1 -0
  9. package/dist/babyjubjub-MWZLJOVZ.cjs +66 -0
  10. package/dist/babyjubjub-MWZLJOVZ.cjs.map +1 -0
  11. package/dist/chunk-2JQISXBD.js +150 -0
  12. package/dist/chunk-2JQISXBD.js.map +1 -0
  13. package/dist/chunk-3HQ7A6ZM.cjs +61 -0
  14. package/dist/chunk-3HQ7A6ZM.cjs.map +1 -0
  15. package/dist/chunk-5AKBSMEQ.cjs +1008 -0
  16. package/dist/chunk-5AKBSMEQ.cjs.map +1 -0
  17. package/dist/chunk-5V5HSN6Y.js +81 -0
  18. package/dist/chunk-5V5HSN6Y.js.map +1 -0
  19. package/dist/chunk-BH24DZ5S.cjs +91 -0
  20. package/dist/chunk-BH24DZ5S.cjs.map +1 -0
  21. package/dist/chunk-C7QQOJ7T.cjs +67 -0
  22. package/dist/chunk-C7QQOJ7T.cjs.map +1 -0
  23. package/dist/chunk-ERQE57IA.cjs +404 -0
  24. package/dist/chunk-ERQE57IA.cjs.map +1 -0
  25. package/dist/chunk-EUP7MBAH.cjs +165 -0
  26. package/dist/chunk-EUP7MBAH.cjs.map +1 -0
  27. package/dist/chunk-G7VZBCD6.cjs +35 -0
  28. package/dist/chunk-G7VZBCD6.cjs.map +1 -0
  29. package/dist/chunk-GQV47S3N.cjs +10 -0
  30. package/dist/chunk-GQV47S3N.cjs.map +1 -0
  31. package/dist/chunk-GXZ3MTCQ.cjs +527 -0
  32. package/dist/chunk-GXZ3MTCQ.cjs.map +1 -0
  33. package/dist/chunk-JWNXBALH.cjs +57 -0
  34. package/dist/chunk-JWNXBALH.cjs.map +1 -0
  35. package/dist/chunk-KIKBPJXJ.cjs +348 -0
  36. package/dist/chunk-KIKBPJXJ.cjs.map +1 -0
  37. package/dist/chunk-NCW4AE7L.js +8 -0
  38. package/dist/chunk-NCW4AE7L.js.map +1 -0
  39. package/dist/chunk-NDM5EJEV.cjs +70 -0
  40. package/dist/chunk-NDM5EJEV.cjs.map +1 -0
  41. package/dist/chunk-NUIQHTSA.js +489 -0
  42. package/dist/chunk-NUIQHTSA.js.map +1 -0
  43. package/dist/chunk-OQDSHMXU.js +1002 -0
  44. package/dist/chunk-OQDSHMXU.js.map +1 -0
  45. package/dist/chunk-P37MRZ73.js +58 -0
  46. package/dist/chunk-P37MRZ73.js.map +1 -0
  47. package/dist/chunk-PWHOUQOZ.js +335 -0
  48. package/dist/chunk-PWHOUQOZ.js.map +1 -0
  49. package/dist/chunk-S4B7GYLN.js +112 -0
  50. package/dist/chunk-S4B7GYLN.js.map +1 -0
  51. package/dist/chunk-SGZZL5AC.js +59 -0
  52. package/dist/chunk-SGZZL5AC.js.map +1 -0
  53. package/dist/chunk-SQKBT2SH.cjs +122 -0
  54. package/dist/chunk-SQKBT2SH.cjs.map +1 -0
  55. package/dist/chunk-TSF6HEVS.cjs +201 -0
  56. package/dist/chunk-TSF6HEVS.cjs.map +1 -0
  57. package/dist/chunk-V23OSL25.js +48 -0
  58. package/dist/chunk-V23OSL25.js.map +1 -0
  59. package/dist/chunk-W77GRBO4.js +53 -0
  60. package/dist/chunk-W77GRBO4.js.map +1 -0
  61. package/dist/chunk-XV72HNHN.js +399 -0
  62. package/dist/chunk-XV72HNHN.js.map +1 -0
  63. package/dist/chunk-YOWDERVC.js +186 -0
  64. package/dist/chunk-YOWDERVC.js.map +1 -0
  65. package/dist/chunk-Z6ZWNWWR.js +30 -0
  66. package/dist/chunk-Z6ZWNWWR.js.map +1 -0
  67. package/dist/chunk-ZKZV6OI3.cjs +165 -0
  68. package/dist/chunk-ZKZV6OI3.cjs.map +1 -0
  69. package/dist/chunk-ZU6J7KMY.js +159 -0
  70. package/dist/chunk-ZU6J7KMY.js.map +1 -0
  71. package/dist/core/index.cjs +300 -0
  72. package/dist/core/index.cjs.map +1 -0
  73. package/dist/core/index.d.cts +9 -0
  74. package/dist/core/index.d.ts +9 -0
  75. package/dist/core/index.js +11 -0
  76. package/dist/core/index.js.map +1 -0
  77. package/dist/index-BBzvvrhG.d.ts +757 -0
  78. package/dist/index-BGvapsJy.d.cts +2811 -0
  79. package/dist/index-C-jSNw6j.d.cts +757 -0
  80. package/dist/index-ChGaGPzP.d.ts +2811 -0
  81. package/dist/index.cjs +3652 -0
  82. package/dist/index.cjs.map +1 -0
  83. package/dist/index.d.cts +12 -0
  84. package/dist/index.d.ts +12 -0
  85. package/dist/index.js +3112 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/indexer/index.cjs +58 -0
  88. package/dist/indexer/index.cjs.map +1 -0
  89. package/dist/indexer/index.d.cts +206 -0
  90. package/dist/indexer/index.d.ts +206 -0
  91. package/dist/indexer/index.js +5 -0
  92. package/dist/indexer/index.js.map +1 -0
  93. package/dist/keccak-m31-B_AqBbRF.d.cts +70 -0
  94. package/dist/keccak-m31-B_AqBbRF.d.ts +70 -0
  95. package/dist/keys/index.cjs +68 -0
  96. package/dist/keys/index.cjs.map +1 -0
  97. package/dist/keys/index.d.cts +158 -0
  98. package/dist/keys/index.d.ts +158 -0
  99. package/dist/keys/index.js +7 -0
  100. package/dist/keys/index.js.map +1 -0
  101. package/dist/merkle-7KS2EHRF.js +5 -0
  102. package/dist/merkle-7KS2EHRF.js.map +1 -0
  103. package/dist/merkle-HGDC6OB4.cjs +30 -0
  104. package/dist/merkle-HGDC6OB4.cjs.map +1 -0
  105. package/dist/merkle-mteVOlDf.d.cts +188 -0
  106. package/dist/merkle-mteVOlDf.d.ts +188 -0
  107. package/dist/poseidon-UHTJLWQM.js +7 -0
  108. package/dist/poseidon-UHTJLWQM.js.map +1 -0
  109. package/dist/poseidon-WHJSZSNP.cjs +45 -0
  110. package/dist/poseidon-WHJSZSNP.cjs.map +1 -0
  111. package/dist/proof-5OECB3RQ.cjs +45 -0
  112. package/dist/proof-5OECB3RQ.cjs.map +1 -0
  113. package/dist/proof-C4YBP6RY.js +4 -0
  114. package/dist/proof-C4YBP6RY.js.map +1 -0
  115. package/dist/react/index.cjs +2641 -0
  116. package/dist/react/index.cjs.map +1 -0
  117. package/dist/react/index.d.cts +757 -0
  118. package/dist/react/index.d.ts +757 -0
  119. package/dist/react/index.js +2598 -0
  120. package/dist/react/index.js.map +1 -0
  121. package/dist/transfer-2UDHDS7Q.cjs +37 -0
  122. package/dist/transfer-2UDHDS7Q.cjs.map +1 -0
  123. package/dist/transfer-BlmbO-Rd.d.ts +1270 -0
  124. package/dist/transfer-DKZuJnRM.d.cts +1270 -0
  125. package/dist/transfer-KTCXKHS4.js +8 -0
  126. package/dist/transfer-KTCXKHS4.js.map +1 -0
  127. package/dist/types-CJSbxv4q.d.cts +143 -0
  128. package/dist/types-mLybMxNR.d.ts +143 -0
  129. package/dist/utils/index.cjs +178 -0
  130. package/dist/utils/index.cjs.map +1 -0
  131. package/dist/utils/index.d.cts +88 -0
  132. package/dist/utils/index.d.ts +88 -0
  133. package/dist/utils/index.js +9 -0
  134. package/dist/utils/index.js.map +1 -0
  135. package/package.json +119 -0
  136. package/src/contracts/interfaces/IASPRegistry.sol +36 -0
  137. package/src/contracts/interfaces/IUniversalPrivatePool.sol +260 -0
  138. package/src/contracts/interfaces/IVerifiers.sol +68 -0
  139. package/src/deployments/11155111.json +19 -0
  140. package/src/deployments/31337.json +19 -0
@@ -0,0 +1,188 @@
1
+ /**
2
+ * BabyJubJub Elliptic Curve Utilities
3
+ *
4
+ * Wrapper around circomlibjs BabyJubJub implementation.
5
+ * Used for stealth addresses, key derivation, and ECDH.
6
+ *
7
+ * BabyJubJub is a twisted Edwards curve embedded in BN254's scalar field,
8
+ * making it efficient for use in zk-SNARKs.
9
+ */
10
+ /**
11
+ * A point on the BabyJubJub curve
12
+ */
13
+ interface Point {
14
+ x: bigint;
15
+ y: bigint;
16
+ }
17
+ /**
18
+ * Get the BabyJubJub subgroup order
19
+ */
20
+ declare function getSubOrder(): Promise<bigint>;
21
+ /**
22
+ * Get the generator point (Base8)
23
+ */
24
+ declare function getBasePoint(): Promise<Point>;
25
+ /**
26
+ * Check if a point is on the curve
27
+ */
28
+ declare function isOnCurve(point: Point): Promise<boolean>;
29
+ /**
30
+ * Scalar multiplication: point * scalar
31
+ *
32
+ * @param point - Point on the curve
33
+ * @param scalar - Scalar value (mod subOrder)
34
+ * @returns Resulting point
35
+ */
36
+ declare function mulPointScalar(point: Point, scalar: bigint): Promise<Point>;
37
+ /**
38
+ * Point addition: p1 + p2
39
+ */
40
+ declare function addPoints(p1: Point, p2: Point): Promise<Point>;
41
+ /**
42
+ * Generate public key from private key
43
+ * pubKey = privateKey * Base8
44
+ *
45
+ * @param privateKey - Private key scalar (must be < subOrder)
46
+ * @returns Public key point
47
+ */
48
+ declare function privateToPublic(privateKey: bigint): Promise<Point>;
49
+ /**
50
+ * Compute ECDH shared secret
51
+ * sharedSecret = myPrivateKey * theirPublicKey
52
+ *
53
+ * @param myPrivateKey - Your private key
54
+ * @param theirPublicKey - Their public key
55
+ * @returns Shared secret point
56
+ */
57
+ declare function computeSharedSecret(myPrivateKey: bigint, theirPublicKey: Point): Promise<Point>;
58
+ /**
59
+ * Pack a point into a single bigint (compressed form)
60
+ * Uses the x-coordinate and a sign bit for y
61
+ */
62
+ declare function packPoint(point: Point): bigint;
63
+ /**
64
+ * Convert a point to tuple format [x, y] for use with snarkjs
65
+ */
66
+ declare function pointToTuple(point: Point): [bigint, bigint];
67
+ /**
68
+ * Convert a tuple [x, y] to Point format
69
+ */
70
+ declare function tupleToPoint(tuple: [bigint, bigint]): Point;
71
+ /**
72
+ * Derive a per-transaction viewing public key (EVK)
73
+ *
74
+ * EVK = MVK_pub + Poseidon(MVK_pub.x, MVK_pub.y, nonce) * Base8
75
+ *
76
+ * This allows the sender to derive a unique encryption key for each transaction
77
+ * without knowing the recipient's private key.
78
+ *
79
+ * @param masterViewingPubKey - Recipient's master viewing public key
80
+ * @param nonce - Unique per-note nonce (R.x — ephemeral public key x-coordinate)
81
+ * @returns Per-transaction encryption viewing key
82
+ */
83
+ declare function deriveEncryptionViewingKey(masterViewingPubKey: Point, nonce: bigint): Promise<Point>;
84
+ /**
85
+ * Derive a per-transaction viewing private key (DVK)
86
+ *
87
+ * DVK = MVK_priv + Poseidon(MVK_pub.x, MVK_pub.y, nonce)
88
+ *
89
+ * Only the owner with MVK_priv can compute this.
90
+ * DVK can be shared with auditors to decrypt specific transactions.
91
+ *
92
+ * @param masterViewingPrivKey - Owner's master viewing private key
93
+ * @param masterViewingPubKey - Owner's master viewing public key
94
+ * @param nonce - Unique per-note nonce (R.x — ephemeral public key x-coordinate)
95
+ * @returns Per-transaction decryption viewing key
96
+ */
97
+ declare function deriveDecryptionViewingKey(masterViewingPrivKey: bigint, masterViewingPubKey: Point, nonce: bigint): Promise<bigint>;
98
+
99
+ /**
100
+ * Merkle Tree Utilities
101
+ *
102
+ * Client-side Merkle tree for computing proofs.
103
+ * Compatible with LeanIMT on-chain implementation.
104
+ */
105
+ /**
106
+ * Maximum tree depth (matches contract)
107
+ */
108
+ declare const MAX_TREE_DEPTH = 32;
109
+ /**
110
+ * Merkle proof for a leaf
111
+ */
112
+ interface MerkleProof {
113
+ /** Path elements (siblings) */
114
+ pathElements: bigint[];
115
+ /** Path indices (0 = left, 1 = right) */
116
+ pathIndices: number[];
117
+ /** Leaf index in the tree */
118
+ leafIndex: number;
119
+ /** Tree root */
120
+ root: bigint;
121
+ }
122
+ /**
123
+ * LeanIMT-compatible Merkle Tree
124
+ *
125
+ * Features:
126
+ * - Dynamic depth (grows as needed)
127
+ * - Single-child optimization
128
+ * - Async hash operations (Poseidon is async)
129
+ */
130
+ declare class MerkleTree {
131
+ private leaves;
132
+ private nodes;
133
+ private cachedRoot;
134
+ readonly maxDepth: number;
135
+ constructor(maxDepth?: number);
136
+ /**
137
+ * Insert a leaf into the tree
138
+ */
139
+ insert(leaf: bigint): number;
140
+ /**
141
+ * Get the number of leaves in the tree
142
+ */
143
+ get size(): number;
144
+ /**
145
+ * Get the current depth of the tree
146
+ * LeanIMT: depth grows when 2^depth < size
147
+ */
148
+ get depth(): number;
149
+ /**
150
+ * Check if a leaf exists in the tree
151
+ */
152
+ has(leaf: bigint): boolean;
153
+ /**
154
+ * Get the index of a leaf
155
+ */
156
+ indexOf(leaf: bigint): number;
157
+ /**
158
+ * Get the current root (async because of Poseidon)
159
+ */
160
+ getRoot(): Promise<bigint>;
161
+ /**
162
+ * Get a Merkle proof for a leaf at index
163
+ */
164
+ getProof(index: number): Promise<MerkleProof>;
165
+ /**
166
+ * Get the hash of a node at (level, index)
167
+ * level 0 = leaves, higher levels are internal nodes
168
+ */
169
+ private getNodeHash;
170
+ /**
171
+ * Compute the root hash
172
+ */
173
+ private computeRoot;
174
+ }
175
+ /**
176
+ * Build a Merkle tree from an array of leaves
177
+ */
178
+ declare function buildMerkleTree(leaves: bigint[]): MerkleTree;
179
+ /**
180
+ * Get a Merkle proof for a specific leaf (async)
181
+ */
182
+ declare function getMerkleProof(leaves: bigint[], index: number): Promise<MerkleProof>;
183
+ /**
184
+ * Verify a Merkle proof (async)
185
+ */
186
+ declare function verifyMerkleProof(leaf: bigint, proof: MerkleProof): Promise<boolean>;
187
+
188
+ export { MAX_TREE_DEPTH as M, type Point as P, type MerkleProof as a, MerkleTree as b, addPoints as c, buildMerkleTree as d, computeSharedSecret as e, deriveDecryptionViewingKey as f, deriveEncryptionViewingKey as g, getBasePoint as h, getMerkleProof as i, getSubOrder as j, isOnCurve as k, pointToTuple as l, mulPointScalar as m, privateToPublic as n, packPoint as p, tupleToPoint as t, verifyMerkleProof as v };
@@ -0,0 +1,7 @@
1
+ import { init_poseidon } from './chunk-V23OSL25.js';
2
+ export { BABYJUBJUB_SUBORDER, FIELD_PRIME, addressToField, fieldToAddress, isValidFieldElement, poseidon, poseidonHash, poseidonScalar, toFieldElement } from './chunk-V23OSL25.js';
3
+ import './chunk-Z6ZWNWWR.js';
4
+
5
+ init_poseidon();
6
+ //# sourceMappingURL=poseidon-UHTJLWQM.js.map
7
+ //# sourceMappingURL=poseidon-UHTJLWQM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"poseidon-UHTJLWQM.js"}
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var chunkJWNXBALH_cjs = require('./chunk-JWNXBALH.cjs');
4
+ require('./chunk-G7VZBCD6.cjs');
5
+
6
+ chunkJWNXBALH_cjs.init_poseidon();
7
+
8
+ Object.defineProperty(exports, "BABYJUBJUB_SUBORDER", {
9
+ enumerable: true,
10
+ get: function () { return chunkJWNXBALH_cjs.BABYJUBJUB_SUBORDER; }
11
+ });
12
+ Object.defineProperty(exports, "FIELD_PRIME", {
13
+ enumerable: true,
14
+ get: function () { return chunkJWNXBALH_cjs.FIELD_PRIME; }
15
+ });
16
+ Object.defineProperty(exports, "addressToField", {
17
+ enumerable: true,
18
+ get: function () { return chunkJWNXBALH_cjs.addressToField; }
19
+ });
20
+ Object.defineProperty(exports, "fieldToAddress", {
21
+ enumerable: true,
22
+ get: function () { return chunkJWNXBALH_cjs.fieldToAddress; }
23
+ });
24
+ Object.defineProperty(exports, "isValidFieldElement", {
25
+ enumerable: true,
26
+ get: function () { return chunkJWNXBALH_cjs.isValidFieldElement; }
27
+ });
28
+ Object.defineProperty(exports, "poseidon", {
29
+ enumerable: true,
30
+ get: function () { return chunkJWNXBALH_cjs.poseidon; }
31
+ });
32
+ Object.defineProperty(exports, "poseidonHash", {
33
+ enumerable: true,
34
+ get: function () { return chunkJWNXBALH_cjs.poseidonHash; }
35
+ });
36
+ Object.defineProperty(exports, "poseidonScalar", {
37
+ enumerable: true,
38
+ get: function () { return chunkJWNXBALH_cjs.poseidonScalar; }
39
+ });
40
+ Object.defineProperty(exports, "toFieldElement", {
41
+ enumerable: true,
42
+ get: function () { return chunkJWNXBALH_cjs.toFieldElement; }
43
+ });
44
+ //# sourceMappingURL=poseidon-WHJSZSNP.cjs.map
45
+ //# sourceMappingURL=poseidon-WHJSZSNP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"poseidon-WHJSZSNP.cjs"}
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var chunkSQKBT2SH_cjs = require('./chunk-SQKBT2SH.cjs');
4
+ require('./chunk-G7VZBCD6.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "ASP_TREE_DEPTH", {
9
+ enumerable: true,
10
+ get: function () { return chunkSQKBT2SH_cjs.ASP_TREE_DEPTH; }
11
+ });
12
+ Object.defineProperty(exports, "STATE_TREE_DEPTH", {
13
+ enumerable: true,
14
+ get: function () { return chunkSQKBT2SH_cjs.STATE_TREE_DEPTH; }
15
+ });
16
+ Object.defineProperty(exports, "formatProofForContract", {
17
+ enumerable: true,
18
+ get: function () { return chunkSQKBT2SH_cjs.formatProofForContract; }
19
+ });
20
+ Object.defineProperty(exports, "generateProof", {
21
+ enumerable: true,
22
+ get: function () { return chunkSQKBT2SH_cjs.generateProof; }
23
+ });
24
+ Object.defineProperty(exports, "generateStealthProof", {
25
+ enumerable: true,
26
+ get: function () { return chunkSQKBT2SH_cjs.generateStealthProof; }
27
+ });
28
+ Object.defineProperty(exports, "generateUPPProof", {
29
+ enumerable: true,
30
+ get: function () { return chunkSQKBT2SH_cjs.generateUPPProof; }
31
+ });
32
+ Object.defineProperty(exports, "getStealthCircuitArtifacts", {
33
+ enumerable: true,
34
+ get: function () { return chunkSQKBT2SH_cjs.getStealthCircuitArtifacts; }
35
+ });
36
+ Object.defineProperty(exports, "getUPPCircuitArtifacts", {
37
+ enumerable: true,
38
+ get: function () { return chunkSQKBT2SH_cjs.getUPPCircuitArtifacts; }
39
+ });
40
+ Object.defineProperty(exports, "verifyProof", {
41
+ enumerable: true,
42
+ get: function () { return chunkSQKBT2SH_cjs.verifyProof; }
43
+ });
44
+ //# sourceMappingURL=proof-5OECB3RQ.cjs.map
45
+ //# sourceMappingURL=proof-5OECB3RQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"proof-5OECB3RQ.cjs"}
@@ -0,0 +1,4 @@
1
+ export { ASP_TREE_DEPTH, STATE_TREE_DEPTH, formatProofForContract, generateProof, generateStealthProof, generateUPPProof, getStealthCircuitArtifacts, getUPPCircuitArtifacts, verifyProof } from './chunk-S4B7GYLN.js';
2
+ import './chunk-Z6ZWNWWR.js';
3
+ //# sourceMappingURL=proof-C4YBP6RY.js.map
4
+ //# sourceMappingURL=proof-C4YBP6RY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"proof-C4YBP6RY.js"}