@permissionless-technologies/upp-sdk 0.5.4 → 0.5.6

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 (90) hide show
  1. package/dist/{chunk-Q6BLTPWV.js → chunk-2NKFTLPD.js} +3 -3
  2. package/dist/{chunk-Q6BLTPWV.js.map → chunk-2NKFTLPD.js.map} +1 -1
  3. package/dist/{chunk-EHGH6TAW.js → chunk-37RFFZU2.js} +3 -3
  4. package/dist/{chunk-EHGH6TAW.js.map → chunk-37RFFZU2.js.map} +1 -1
  5. package/dist/{chunk-UQIM2KT3.js → chunk-4E23V3AT.js} +29 -4
  6. package/dist/chunk-4E23V3AT.js.map +1 -0
  7. package/dist/{chunk-53JACDGZ.js → chunk-A6IYQ7UF.js} +3 -3
  8. package/dist/chunk-A6IYQ7UF.js.map +1 -0
  9. package/dist/{chunk-7T4CUE6E.js → chunk-AVSR443A.js} +3 -3
  10. package/dist/{chunk-7T4CUE6E.js.map → chunk-AVSR443A.js.map} +1 -1
  11. package/dist/{chunk-UFEDJJSH.cjs → chunk-BCSMUH4L.cjs} +30 -3
  12. package/dist/chunk-BCSMUH4L.cjs.map +1 -0
  13. package/dist/{chunk-IYRCJAME.cjs → chunk-C3HXJ5A6.cjs} +9 -9
  14. package/dist/{chunk-IYRCJAME.cjs.map → chunk-C3HXJ5A6.cjs.map} +1 -1
  15. package/dist/{chunk-DD4NT4D7.js → chunk-CRUJLZV7.js} +4 -3
  16. package/dist/chunk-CRUJLZV7.js.map +1 -0
  17. package/dist/{chunk-DTEAFJG7.js → chunk-FTEXUSHR.js} +4 -4
  18. package/dist/{chunk-DTEAFJG7.js.map → chunk-FTEXUSHR.js.map} +1 -1
  19. package/dist/chunk-FW2U6TKQ.js +498 -0
  20. package/dist/chunk-FW2U6TKQ.js.map +1 -0
  21. package/dist/{chunk-6TFDBBAQ.js → chunk-H4NDMIPF.js} +3 -3
  22. package/dist/{chunk-6TFDBBAQ.js.map → chunk-H4NDMIPF.js.map} +1 -1
  23. package/dist/{chunk-4T5DWZBN.cjs → chunk-HVSP62AH.cjs} +22 -36
  24. package/dist/chunk-HVSP62AH.cjs.map +1 -0
  25. package/dist/{chunk-7BNJV2ZS.cjs → chunk-LKXC3OQT.cjs} +14 -14
  26. package/dist/{chunk-7BNJV2ZS.cjs.map → chunk-LKXC3OQT.cjs.map} +1 -1
  27. package/dist/{chunk-HB43C26P.cjs → chunk-NGXEIUQ6.cjs} +4 -4
  28. package/dist/chunk-NGXEIUQ6.cjs.map +1 -0
  29. package/dist/{chunk-O2SKZZAP.cjs → chunk-P6E3LE7T.cjs} +4 -3
  30. package/dist/chunk-P6E3LE7T.cjs.map +1 -0
  31. package/dist/chunk-PGIV2GDM.cjs +511 -0
  32. package/dist/chunk-PGIV2GDM.cjs.map +1 -0
  33. package/dist/{chunk-4W7BBQ4H.js → chunk-UHMHZQZV.js} +6 -20
  34. package/dist/chunk-UHMHZQZV.js.map +1 -0
  35. package/dist/{chunk-I5EKGD4P.cjs → chunk-XNSMPNY6.cjs} +4 -4
  36. package/dist/{chunk-I5EKGD4P.cjs.map → chunk-XNSMPNY6.cjs.map} +1 -1
  37. package/dist/{chunk-U3YFYMWF.cjs → chunk-XSJ5VVH4.cjs} +5 -5
  38. package/dist/{chunk-U3YFYMWF.cjs.map → chunk-XSJ5VVH4.cjs.map} +1 -1
  39. package/dist/{chunk-SWTNJPK5.cjs → chunk-Y6WCXYOC.cjs} +11 -11
  40. package/dist/{chunk-SWTNJPK5.cjs.map → chunk-Y6WCXYOC.cjs.map} +1 -1
  41. package/dist/core/index.cjs +62 -66
  42. package/dist/core/index.d.cts +2 -5
  43. package/dist/core/index.d.ts +2 -5
  44. package/dist/core/index.js +6 -6
  45. package/dist/crypto-FWREDAVI.js +8 -0
  46. package/dist/crypto-FWREDAVI.js.map +1 -0
  47. package/dist/crypto-IZKHHFDU.cjs +42 -0
  48. package/dist/crypto-IZKHHFDU.cjs.map +1 -0
  49. package/dist/{index-BRgBwiBM.d.ts → index-DLvLv3mg.d.ts} +11 -23
  50. package/dist/{index-D6YhhbRP.d.cts → index-DOiHUft6.d.cts} +3 -4
  51. package/dist/{index-DHW5lKcd.d.ts → index-DY0XAmFw.d.ts} +3 -4
  52. package/dist/{index-brLSTa0y.d.cts → index-KTJgQUxb.d.cts} +11 -23
  53. package/dist/index.cjs +126 -126
  54. package/dist/index.d.cts +4 -7
  55. package/dist/index.d.ts +4 -7
  56. package/dist/index.js +9 -9
  57. package/dist/indexer/index.cjs +62 -11
  58. package/dist/indexer/index.d.cts +196 -12
  59. package/dist/indexer/index.d.ts +196 -12
  60. package/dist/indexer/index.js +4 -1
  61. package/dist/keys/index.cjs +17 -17
  62. package/dist/keys/index.js +3 -3
  63. package/dist/react/index.cjs +214 -690
  64. package/dist/react/index.cjs.map +1 -1
  65. package/dist/react/index.d.cts +138 -6
  66. package/dist/react/index.d.ts +138 -6
  67. package/dist/react/index.js +193 -669
  68. package/dist/react/index.js.map +1 -1
  69. package/dist/{transfer-CKA4PU2C.js → transfer-2UYFZMIK.js} +3 -3
  70. package/dist/{transfer-CKA4PU2C.js.map → transfer-2UYFZMIK.js.map} +1 -1
  71. package/dist/{transfer-QFTVCREE.cjs → transfer-6OW3XKVC.cjs} +9 -9
  72. package/dist/{transfer-QFTVCREE.cjs.map → transfer-6OW3XKVC.cjs.map} +1 -1
  73. package/dist/{transfer-p-NXHdGY.d.cts → transfer-C1XU_z-6.d.cts} +46 -156
  74. package/dist/{transfer-BxiDgCvx.d.ts → transfer-DgjxZlR7.d.ts} +46 -156
  75. package/dist/utils/index.cjs +44 -44
  76. package/dist/utils/index.d.cts +186 -5
  77. package/dist/utils/index.d.ts +186 -5
  78. package/dist/utils/index.js +4 -4
  79. package/package.json +1 -1
  80. package/src/deployments/31337.json +2 -1
  81. package/dist/chunk-4T5DWZBN.cjs.map +0 -1
  82. package/dist/chunk-4W7BBQ4H.js.map +0 -1
  83. package/dist/chunk-53JACDGZ.js.map +0 -1
  84. package/dist/chunk-DD4NT4D7.js.map +0 -1
  85. package/dist/chunk-HB43C26P.cjs.map +0 -1
  86. package/dist/chunk-O2SKZZAP.cjs.map +0 -1
  87. package/dist/chunk-UFEDJJSH.cjs.map +0 -1
  88. package/dist/chunk-UQIM2KT3.js.map +0 -1
  89. package/dist/stark-BcTD1OaJ.d.cts +0 -185
  90. package/dist/stark-BcTD1OaJ.d.ts +0 -185
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkI5EKGD4P_cjs = require('../chunk-I5EKGD4P.cjs');
4
- var chunkSWTNJPK5_cjs = require('../chunk-SWTNJPK5.cjs');
3
+ var chunkXNSMPNY6_cjs = require('../chunk-XNSMPNY6.cjs');
4
+ var chunkY6WCXYOC_cjs = require('../chunk-Y6WCXYOC.cjs');
5
5
  var chunkIIUKM5VE_cjs = require('../chunk-IIUKM5VE.cjs');
6
- var chunkU3YFYMWF_cjs = require('../chunk-U3YFYMWF.cjs');
7
- var chunkUFEDJJSH_cjs = require('../chunk-UFEDJJSH.cjs');
6
+ var chunkXSJ5VVH4_cjs = require('../chunk-XSJ5VVH4.cjs');
7
+ var chunkBCSMUH4L_cjs = require('../chunk-BCSMUH4L.cjs');
8
8
  var chunkHEHXSV47_cjs = require('../chunk-HEHXSV47.cjs');
9
9
  require('../chunk-G7VZBCD6.cjs');
10
10
 
@@ -12,103 +12,103 @@ require('../chunk-G7VZBCD6.cjs');
12
12
 
13
13
  Object.defineProperty(exports, "addPoints", {
14
14
  enumerable: true,
15
- get: function () { return chunkI5EKGD4P_cjs.addPoints; }
15
+ get: function () { return chunkXNSMPNY6_cjs.addPoints; }
16
16
  });
17
17
  Object.defineProperty(exports, "computeSharedSecret", {
18
18
  enumerable: true,
19
- get: function () { return chunkI5EKGD4P_cjs.computeSharedSecret; }
19
+ get: function () { return chunkXNSMPNY6_cjs.computeSharedSecret; }
20
20
  });
21
21
  Object.defineProperty(exports, "deriveDecryptionViewingKey", {
22
22
  enumerable: true,
23
- get: function () { return chunkI5EKGD4P_cjs.deriveDecryptionViewingKey; }
23
+ get: function () { return chunkXNSMPNY6_cjs.deriveDecryptionViewingKey; }
24
24
  });
25
25
  Object.defineProperty(exports, "deriveEncryptionViewingKey", {
26
26
  enumerable: true,
27
- get: function () { return chunkI5EKGD4P_cjs.deriveEncryptionViewingKey; }
27
+ get: function () { return chunkXNSMPNY6_cjs.deriveEncryptionViewingKey; }
28
28
  });
29
29
  Object.defineProperty(exports, "getBasePoint", {
30
30
  enumerable: true,
31
- get: function () { return chunkI5EKGD4P_cjs.getBasePoint; }
31
+ get: function () { return chunkXNSMPNY6_cjs.getBasePoint; }
32
32
  });
33
33
  Object.defineProperty(exports, "getSubOrder", {
34
34
  enumerable: true,
35
- get: function () { return chunkI5EKGD4P_cjs.getSubOrder; }
35
+ get: function () { return chunkXNSMPNY6_cjs.getSubOrder; }
36
36
  });
37
37
  Object.defineProperty(exports, "isOnCurve", {
38
38
  enumerable: true,
39
- get: function () { return chunkI5EKGD4P_cjs.isOnCurve; }
39
+ get: function () { return chunkXNSMPNY6_cjs.isOnCurve; }
40
40
  });
41
41
  Object.defineProperty(exports, "mulPointScalar", {
42
42
  enumerable: true,
43
- get: function () { return chunkI5EKGD4P_cjs.mulPointScalar; }
43
+ get: function () { return chunkXNSMPNY6_cjs.mulPointScalar; }
44
44
  });
45
45
  Object.defineProperty(exports, "packPoint", {
46
46
  enumerable: true,
47
- get: function () { return chunkI5EKGD4P_cjs.packPoint; }
47
+ get: function () { return chunkXNSMPNY6_cjs.packPoint; }
48
48
  });
49
49
  Object.defineProperty(exports, "pointToTuple", {
50
50
  enumerable: true,
51
- get: function () { return chunkI5EKGD4P_cjs.pointToTuple; }
51
+ get: function () { return chunkXNSMPNY6_cjs.pointToTuple; }
52
52
  });
53
53
  Object.defineProperty(exports, "privateToPublic", {
54
54
  enumerable: true,
55
- get: function () { return chunkI5EKGD4P_cjs.privateToPublic; }
55
+ get: function () { return chunkXNSMPNY6_cjs.privateToPublic; }
56
56
  });
57
57
  Object.defineProperty(exports, "tupleToPoint", {
58
58
  enumerable: true,
59
- get: function () { return chunkI5EKGD4P_cjs.tupleToPoint; }
59
+ get: function () { return chunkXNSMPNY6_cjs.tupleToPoint; }
60
60
  });
61
61
  Object.defineProperty(exports, "STARK_AMOUNT_SCALE", {
62
62
  enumerable: true,
63
- get: function () { return chunkSWTNJPK5_cjs.STARK_AMOUNT_SCALE; }
63
+ get: function () { return chunkY6WCXYOC_cjs.STARK_AMOUNT_SCALE; }
64
64
  });
65
65
  Object.defineProperty(exports, "STARK_ASP_TREE_DEPTH", {
66
66
  enumerable: true,
67
- get: function () { return chunkSWTNJPK5_cjs.STARK_ASP_TREE_DEPTH; }
67
+ get: function () { return chunkY6WCXYOC_cjs.STARK_ASP_TREE_DEPTH; }
68
68
  });
69
69
  Object.defineProperty(exports, "STARK_STATE_TREE_DEPTH", {
70
70
  enumerable: true,
71
- get: function () { return chunkSWTNJPK5_cjs.STARK_STATE_TREE_DEPTH; }
71
+ get: function () { return chunkY6WCXYOC_cjs.STARK_STATE_TREE_DEPTH; }
72
72
  });
73
73
  Object.defineProperty(exports, "addressToM31", {
74
74
  enumerable: true,
75
- get: function () { return chunkSWTNJPK5_cjs.addressToM31; }
75
+ get: function () { return chunkY6WCXYOC_cjs.addressToM31; }
76
76
  });
77
77
  Object.defineProperty(exports, "buildStarkTransferWitness", {
78
78
  enumerable: true,
79
- get: function () { return chunkSWTNJPK5_cjs.buildStarkTransferWitness; }
79
+ get: function () { return chunkY6WCXYOC_cjs.buildStarkTransferWitness; }
80
80
  });
81
81
  Object.defineProperty(exports, "buildStarkWithdrawWitness", {
82
82
  enumerable: true,
83
- get: function () { return chunkSWTNJPK5_cjs.buildStarkWithdrawWitness; }
83
+ get: function () { return chunkY6WCXYOC_cjs.buildStarkWithdrawWitness; }
84
84
  });
85
85
  Object.defineProperty(exports, "computeTransferPublicInputsSeed", {
86
86
  enumerable: true,
87
- get: function () { return chunkSWTNJPK5_cjs.computeTransferPublicInputsSeed; }
87
+ get: function () { return chunkY6WCXYOC_cjs.computeTransferPublicInputsSeed; }
88
88
  });
89
89
  Object.defineProperty(exports, "computeWithdrawPublicInputsSeed", {
90
90
  enumerable: true,
91
- get: function () { return chunkSWTNJPK5_cjs.computeWithdrawPublicInputsSeed; }
91
+ get: function () { return chunkY6WCXYOC_cjs.computeWithdrawPublicInputsSeed; }
92
92
  });
93
93
  Object.defineProperty(exports, "isStarkAligned", {
94
94
  enumerable: true,
95
- get: function () { return chunkSWTNJPK5_cjs.isStarkAligned; }
95
+ get: function () { return chunkY6WCXYOC_cjs.isStarkAligned; }
96
96
  });
97
97
  Object.defineProperty(exports, "packM31Digest", {
98
98
  enumerable: true,
99
- get: function () { return chunkSWTNJPK5_cjs.packM31Digest; }
99
+ get: function () { return chunkY6WCXYOC_cjs.packM31Digest; }
100
100
  });
101
101
  Object.defineProperty(exports, "scaleAmountForStark", {
102
102
  enumerable: true,
103
- get: function () { return chunkSWTNJPK5_cjs.scaleAmountForStark; }
103
+ get: function () { return chunkY6WCXYOC_cjs.scaleAmountForStark; }
104
104
  });
105
105
  Object.defineProperty(exports, "splitSecretToM31Limbs", {
106
106
  enumerable: true,
107
- get: function () { return chunkSWTNJPK5_cjs.splitSecretToM31Limbs; }
107
+ get: function () { return chunkY6WCXYOC_cjs.splitSecretToM31Limbs; }
108
108
  });
109
109
  Object.defineProperty(exports, "truncateToM31", {
110
110
  enumerable: true,
111
- get: function () { return chunkSWTNJPK5_cjs.truncateToM31; }
111
+ get: function () { return chunkY6WCXYOC_cjs.truncateToM31; }
112
112
  });
113
113
  Object.defineProperty(exports, "MAX_TREE_DEPTH", {
114
114
  enumerable: true,
@@ -132,63 +132,63 @@ Object.defineProperty(exports, "verifyMerkleProof", {
132
132
  });
133
133
  Object.defineProperty(exports, "DIGEST_SIZE", {
134
134
  enumerable: true,
135
- get: function () { return chunkU3YFYMWF_cjs.DIGEST_SIZE; }
135
+ get: function () { return chunkXSJ5VVH4_cjs.DIGEST_SIZE; }
136
136
  });
137
137
  Object.defineProperty(exports, "M31_P", {
138
138
  enumerable: true,
139
- get: function () { return chunkU3YFYMWF_cjs.M31_P; }
139
+ get: function () { return chunkXSJ5VVH4_cjs.M31_P; }
140
140
  });
141
141
  Object.defineProperty(exports, "SECRET_LIMBS", {
142
142
  enumerable: true,
143
- get: function () { return chunkU3YFYMWF_cjs.SECRET_LIMBS; }
143
+ get: function () { return chunkXSJ5VVH4_cjs.SECRET_LIMBS; }
144
144
  });
145
145
  Object.defineProperty(exports, "computeStarkCommitment", {
146
146
  enumerable: true,
147
- get: function () { return chunkU3YFYMWF_cjs.computeStarkCommitment; }
147
+ get: function () { return chunkXSJ5VVH4_cjs.computeStarkCommitment; }
148
148
  });
149
149
  Object.defineProperty(exports, "computeStarkNullifier", {
150
150
  enumerable: true,
151
- get: function () { return chunkU3YFYMWF_cjs.computeStarkNullifier; }
151
+ get: function () { return chunkXSJ5VVH4_cjs.computeStarkNullifier; }
152
152
  });
153
153
  Object.defineProperty(exports, "computeStarkOwnerHash", {
154
154
  enumerable: true,
155
- get: function () { return chunkU3YFYMWF_cjs.computeStarkOwnerHash; }
155
+ get: function () { return chunkXSJ5VVH4_cjs.computeStarkOwnerHash; }
156
156
  });
157
157
  Object.defineProperty(exports, "keccakHashTwo", {
158
158
  enumerable: true,
159
- get: function () { return chunkU3YFYMWF_cjs.keccakHashTwo; }
159
+ get: function () { return chunkXSJ5VVH4_cjs.keccakHashTwo; }
160
160
  });
161
161
  Object.defineProperty(exports, "keccakM31", {
162
162
  enumerable: true,
163
- get: function () { return chunkU3YFYMWF_cjs.keccakM31; }
163
+ get: function () { return chunkXSJ5VVH4_cjs.keccakM31; }
164
164
  });
165
165
  Object.defineProperty(exports, "splitToM31Limbs", {
166
166
  enumerable: true,
167
- get: function () { return chunkU3YFYMWF_cjs.splitToM31Limbs; }
167
+ get: function () { return chunkXSJ5VVH4_cjs.splitToM31Limbs; }
168
168
  });
169
169
  Object.defineProperty(exports, "bigintToBytes", {
170
170
  enumerable: true,
171
- get: function () { return chunkUFEDJJSH_cjs.bigintToBytes; }
171
+ get: function () { return chunkBCSMUH4L_cjs.bigintToBytes; }
172
172
  });
173
173
  Object.defineProperty(exports, "bytesToBigint", {
174
174
  enumerable: true,
175
- get: function () { return chunkUFEDJJSH_cjs.bytesToBigint; }
175
+ get: function () { return chunkBCSMUH4L_cjs.bytesToBigint; }
176
176
  });
177
177
  Object.defineProperty(exports, "bytesToHex", {
178
178
  enumerable: true,
179
- get: function () { return chunkUFEDJJSH_cjs.bytesToHex; }
179
+ get: function () { return chunkBCSMUH4L_cjs.bytesToHex; }
180
180
  });
181
181
  Object.defineProperty(exports, "hexToBytes", {
182
182
  enumerable: true,
183
- get: function () { return chunkUFEDJJSH_cjs.hexToBytes; }
183
+ get: function () { return chunkBCSMUH4L_cjs.hexToBytes; }
184
184
  });
185
185
  Object.defineProperty(exports, "randomBytes", {
186
186
  enumerable: true,
187
- get: function () { return chunkUFEDJJSH_cjs.randomBytes; }
187
+ get: function () { return chunkBCSMUH4L_cjs.randomBytes; }
188
188
  });
189
189
  Object.defineProperty(exports, "randomFieldElement", {
190
190
  enumerable: true,
191
- get: function () { return chunkUFEDJJSH_cjs.randomFieldElement; }
191
+ get: function () { return chunkBCSMUH4L_cjs.randomFieldElement; }
192
192
  });
193
193
  Object.defineProperty(exports, "BABYJUBJUB_SUBORDER", {
194
194
  enumerable: true,
@@ -1,7 +1,188 @@
1
1
  export { M as MAX_TREE_DEPTH, a as MerkleProof, b as MerkleTree, P as Point, c as addPoints, d as buildMerkleTree, e as computeSharedSecret, f as deriveDecryptionViewingKey, g as deriveEncryptionViewingKey, h as getBasePoint, i as getMerkleProof, j as getSubOrder, k as isOnCurve, m as mulPointScalar, p as packPoint, l as pointToTuple, n as privateToPublic, t as tupleToPoint, v as verifyMerkleProof } from '../merkle-mteVOlDf.cjs';
2
- export { S as STARK_AMOUNT_SCALE, a as STARK_ASP_TREE_DEPTH, b as STARK_STATE_TREE_DEPTH, c as StarkTransferWitness, d as StarkWithdrawWitness, e as addressToM31, f as buildStarkTransferWitness, g as buildStarkWithdrawWitness, h as computeTransferPublicInputsSeed, i as computeWithdrawPublicInputsSeed, j as isStarkAligned, p as packM31Digest, s as scaleAmountForStark, k as splitSecretToM31Limbs, t as truncateToM31 } from '../stark-BcTD1OaJ.cjs';
2
+ import { Address, Hex } from 'viem';
3
3
  export { D as DIGEST_SIZE, a as M31Digest, M as M31Secret, b as M31_P, S as SECRET_LIMBS, c as computeStarkCommitment, d as computeStarkNullifier, e as computeStarkOwnerHash, k as keccakHashTwo, f as keccakM31, s as splitToM31Limbs } from '../keccak-m31-B_AqBbRF.cjs';
4
- import 'viem';
4
+
5
+ /**
6
+ * STARK Utilities — Amount scaling, witness building, Fiat-Shamir
7
+ *
8
+ * These functions must produce identical outputs to the Rust Stwo prover
9
+ * (stwo-prover/src/) and the Solidity verifier.
10
+ *
11
+ * M31 field: p = 2^31 - 1 = 2,147,483,647
12
+ * Amount precision: 0.001 tokens (1e15 wei scale factor)
13
+ */
14
+
15
+ /** Matches Solidity STARK_AMOUNT_SCALE = 1e15 */
16
+ declare const STARK_AMOUNT_SCALE: bigint;
17
+ /** State tree depth (Merkle tree for commitments) */
18
+ declare const STARK_STATE_TREE_DEPTH = 32;
19
+ /** ASP tree depth */
20
+ declare const STARK_ASP_TREE_DEPTH = 20;
21
+ /** Check if a wei amount is STARK-scale aligned and fits in M31. */
22
+ declare function isStarkAligned(amount: bigint): boolean;
23
+ /**
24
+ * Scale a wei amount down for the STARK circuit.
25
+ * Precision: 0.001 tokens (1e15 wei). Max: ~2.1M tokens.
26
+ *
27
+ * @returns The scaled amount as a number (fits in M31)
28
+ * @throws If not aligned to STARK_AMOUNT_SCALE or exceeds M31
29
+ */
30
+ declare function scaleAmountForStark(weiAmount: bigint): number;
31
+ /** Truncate a bigint to fit in M31 (modular reduction). */
32
+ declare function truncateToM31(value: bigint): number;
33
+ /** Convert an Ethereum address to an M31 field element (truncated). */
34
+ declare function addressToM31(addr: Address): number;
35
+ /**
36
+ * Split a 254-bit spending secret into 8 M31 limbs (248 bits of entropy).
37
+ *
38
+ * Each limb holds 31 bits (reduced mod M31_P). The secret is split
39
+ * little-endian: limb[0] = lowest 31 bits, limb[7] = highest bits.
40
+ *
41
+ * This matches the Rust prover's expectation of `[M31; 8]` for owner_secret.
42
+ */
43
+ declare function splitSecretToM31Limbs(secret: bigint): number[];
44
+ /**
45
+ * Pack an M31 digest (4 M31 elements) into a uint128 for Solidity.
46
+ * Each element occupies 32 bits (little-endian packing).
47
+ */
48
+ declare function packM31Digest(digest: [number, number, number, number]): bigint;
49
+ /**
50
+ * Compute the Fiat-Shamir public inputs seed for a STARK withdrawal.
51
+ * Must produce the same hash as Solidity and Rust.
52
+ */
53
+ declare function computeWithdrawPublicInputsSeed(params: {
54
+ nullifier: Hex;
55
+ stateRoot: bigint;
56
+ aspRoot: bigint;
57
+ aspId: bigint;
58
+ token: Address;
59
+ amount: bigint;
60
+ recipient: Address;
61
+ isRagequit: boolean;
62
+ }): Hex;
63
+ /**
64
+ * Compute the Fiat-Shamir public inputs seed for a STARK transfer.
65
+ * Must produce the same hash as Solidity and Rust.
66
+ */
67
+ declare function computeTransferPublicInputsSeed(params: {
68
+ nullifier: Hex;
69
+ stateRoot: bigint;
70
+ aspRoot: bigint;
71
+ token: Address;
72
+ outputCommitment1: Hex;
73
+ outputCommitment2: Hex;
74
+ }): Hex;
75
+ /**
76
+ * Witness inputs for the STARK withdrawal prover.
77
+ * All numeric values are u32 (must fit in M31 field, i.e. < 2^31 - 1).
78
+ * Hex string fields are for Fiat-Shamir seed binding.
79
+ */
80
+ interface StarkWithdrawWitness {
81
+ owner_secret: number[];
82
+ input_amount: number;
83
+ input_blinding: number;
84
+ input_origin: number;
85
+ token: number;
86
+ leaf_index: number;
87
+ state_path_elements: number[];
88
+ state_path_indices: number[];
89
+ asp_path_elements: number[];
90
+ asp_path_indices: number[];
91
+ withdraw_amount: number;
92
+ change_amount: number;
93
+ change_blinding: number;
94
+ recipient: number;
95
+ is_ragequit: number;
96
+ nullifier_hex: string;
97
+ state_root_hex: string;
98
+ asp_root_hex: string;
99
+ asp_id_hex: string;
100
+ token_address_hex: string;
101
+ amount_hex: string;
102
+ recipient_address_hex: string;
103
+ is_ragequit_bool: boolean;
104
+ }
105
+ /**
106
+ * Witness inputs for the STARK transfer prover (1-in-2-out).
107
+ * All numeric values are u32 (must fit in M31 field).
108
+ */
109
+ interface StarkTransferWitness {
110
+ owner_secret: number[];
111
+ input_amount: number;
112
+ input_blinding: number;
113
+ input_origin: number;
114
+ token: number;
115
+ leaf_index: number;
116
+ state_path_elements: number[];
117
+ state_path_indices: number[];
118
+ asp_path_elements: number[];
119
+ asp_path_indices: number[];
120
+ output1_amount: number;
121
+ output1_owner_hash: [number, number, number, number];
122
+ output1_blinding: number;
123
+ output1_origin: number;
124
+ output2_amount: number;
125
+ output2_owner_hash: [number, number, number, number];
126
+ output2_blinding: number;
127
+ output2_origin: number;
128
+ is_ragequit: number;
129
+ nullifier_hex: string;
130
+ state_root_hex: string;
131
+ asp_root_hex: string;
132
+ token_address_hex: string;
133
+ output_commitment_1_hex: string;
134
+ output_commitment_2_hex: string;
135
+ }
136
+ /**
137
+ * Build a complete STARK withdrawal witness from note data.
138
+ */
139
+ declare function buildStarkWithdrawWitness(params: {
140
+ ownerSecret: number[];
141
+ inputAmount: number;
142
+ inputBlinding: number;
143
+ inputOrigin: number;
144
+ token: number;
145
+ leafIndex: number;
146
+ withdrawAmount: number;
147
+ changeAmount: number;
148
+ changeBlinding: number;
149
+ recipient: number;
150
+ isRagequit: number;
151
+ nullifierHex: Hex;
152
+ stateRootBigInt: bigint;
153
+ aspRootBigInt: bigint;
154
+ aspIdBigInt: bigint;
155
+ tokenAddress: Address;
156
+ amountWei: bigint;
157
+ recipientAddress: Address;
158
+ isRagequitBool: boolean;
159
+ }): StarkWithdrawWitness;
160
+ /**
161
+ * Build a complete STARK transfer witness (1-in-2-out).
162
+ */
163
+ declare function buildStarkTransferWitness(params: {
164
+ ownerSecret: number[];
165
+ inputAmount: number;
166
+ inputBlinding: number;
167
+ inputOrigin: number;
168
+ token: number;
169
+ leafIndex: number;
170
+ output1Amount: number;
171
+ output1OwnerHash: [number, number, number, number];
172
+ output1Blinding: number;
173
+ output1Origin: number;
174
+ output2Amount: number;
175
+ output2OwnerHash: [number, number, number, number];
176
+ output2Blinding: number;
177
+ output2Origin: number;
178
+ isRagequit: number;
179
+ nullifierHex: Hex;
180
+ stateRootBigInt: bigint;
181
+ aspRootBigInt: bigint;
182
+ tokenAddress: Address;
183
+ outputCommitment1Hex: Hex;
184
+ outputCommitment2Hex: Hex;
185
+ }): StarkTransferWitness;
5
186
 
6
187
  /**
7
188
  * Poseidon Hash Utilities (BLS12-381)
@@ -98,9 +279,9 @@ declare function randomFieldElement(): bigint;
98
279
  */
99
280
  declare function bytesToHex(bytes: Uint8Array): `0x${string}`;
100
281
  /**
101
- * Convert hex string to bytes
282
+ * Convert hex string to bytes (handles with or without 0x prefix)
102
283
  */
103
- declare function hexToBytes(hex: `0x${string}`): Uint8Array;
284
+ declare function hexToBytes(hex: string): Uint8Array;
104
285
  /**
105
286
  * Convert bigint to bytes (big-endian)
106
287
  */
@@ -110,4 +291,4 @@ declare function bigintToBytes(value: bigint, length: number): Uint8Array;
110
291
  */
111
292
  declare function bytesToBigint(bytes: Uint8Array): bigint;
112
293
 
113
- export { BABYJUBJUB_SUBORDER, FIELD_PRIME, addressToField, bigintToBytes, bytesToBigint, bytesToHex, fieldToAddress, hexToBytes, isValidFieldElement, poseidon, poseidonHash, poseidonScalar, randomBytes, randomFieldElement, toFieldElement };
294
+ export { BABYJUBJUB_SUBORDER, FIELD_PRIME, STARK_AMOUNT_SCALE, STARK_ASP_TREE_DEPTH, STARK_STATE_TREE_DEPTH, type StarkTransferWitness, type StarkWithdrawWitness, addressToField, addressToM31, bigintToBytes, buildStarkTransferWitness, buildStarkWithdrawWitness, bytesToBigint, bytesToHex, computeTransferPublicInputsSeed, computeWithdrawPublicInputsSeed, fieldToAddress, hexToBytes, isStarkAligned, isValidFieldElement, packM31Digest, poseidon, poseidonHash, poseidonScalar, randomBytes, randomFieldElement, scaleAmountForStark, splitSecretToM31Limbs, toFieldElement, truncateToM31 };
@@ -1,7 +1,188 @@
1
1
  export { M as MAX_TREE_DEPTH, a as MerkleProof, b as MerkleTree, P as Point, c as addPoints, d as buildMerkleTree, e as computeSharedSecret, f as deriveDecryptionViewingKey, g as deriveEncryptionViewingKey, h as getBasePoint, i as getMerkleProof, j as getSubOrder, k as isOnCurve, m as mulPointScalar, p as packPoint, l as pointToTuple, n as privateToPublic, t as tupleToPoint, v as verifyMerkleProof } from '../merkle-mteVOlDf.js';
2
- export { S as STARK_AMOUNT_SCALE, a as STARK_ASP_TREE_DEPTH, b as STARK_STATE_TREE_DEPTH, c as StarkTransferWitness, d as StarkWithdrawWitness, e as addressToM31, f as buildStarkTransferWitness, g as buildStarkWithdrawWitness, h as computeTransferPublicInputsSeed, i as computeWithdrawPublicInputsSeed, j as isStarkAligned, p as packM31Digest, s as scaleAmountForStark, k as splitSecretToM31Limbs, t as truncateToM31 } from '../stark-BcTD1OaJ.js';
2
+ import { Address, Hex } from 'viem';
3
3
  export { D as DIGEST_SIZE, a as M31Digest, M as M31Secret, b as M31_P, S as SECRET_LIMBS, c as computeStarkCommitment, d as computeStarkNullifier, e as computeStarkOwnerHash, k as keccakHashTwo, f as keccakM31, s as splitToM31Limbs } from '../keccak-m31-B_AqBbRF.js';
4
- import 'viem';
4
+
5
+ /**
6
+ * STARK Utilities — Amount scaling, witness building, Fiat-Shamir
7
+ *
8
+ * These functions must produce identical outputs to the Rust Stwo prover
9
+ * (stwo-prover/src/) and the Solidity verifier.
10
+ *
11
+ * M31 field: p = 2^31 - 1 = 2,147,483,647
12
+ * Amount precision: 0.001 tokens (1e15 wei scale factor)
13
+ */
14
+
15
+ /** Matches Solidity STARK_AMOUNT_SCALE = 1e15 */
16
+ declare const STARK_AMOUNT_SCALE: bigint;
17
+ /** State tree depth (Merkle tree for commitments) */
18
+ declare const STARK_STATE_TREE_DEPTH = 32;
19
+ /** ASP tree depth */
20
+ declare const STARK_ASP_TREE_DEPTH = 20;
21
+ /** Check if a wei amount is STARK-scale aligned and fits in M31. */
22
+ declare function isStarkAligned(amount: bigint): boolean;
23
+ /**
24
+ * Scale a wei amount down for the STARK circuit.
25
+ * Precision: 0.001 tokens (1e15 wei). Max: ~2.1M tokens.
26
+ *
27
+ * @returns The scaled amount as a number (fits in M31)
28
+ * @throws If not aligned to STARK_AMOUNT_SCALE or exceeds M31
29
+ */
30
+ declare function scaleAmountForStark(weiAmount: bigint): number;
31
+ /** Truncate a bigint to fit in M31 (modular reduction). */
32
+ declare function truncateToM31(value: bigint): number;
33
+ /** Convert an Ethereum address to an M31 field element (truncated). */
34
+ declare function addressToM31(addr: Address): number;
35
+ /**
36
+ * Split a 254-bit spending secret into 8 M31 limbs (248 bits of entropy).
37
+ *
38
+ * Each limb holds 31 bits (reduced mod M31_P). The secret is split
39
+ * little-endian: limb[0] = lowest 31 bits, limb[7] = highest bits.
40
+ *
41
+ * This matches the Rust prover's expectation of `[M31; 8]` for owner_secret.
42
+ */
43
+ declare function splitSecretToM31Limbs(secret: bigint): number[];
44
+ /**
45
+ * Pack an M31 digest (4 M31 elements) into a uint128 for Solidity.
46
+ * Each element occupies 32 bits (little-endian packing).
47
+ */
48
+ declare function packM31Digest(digest: [number, number, number, number]): bigint;
49
+ /**
50
+ * Compute the Fiat-Shamir public inputs seed for a STARK withdrawal.
51
+ * Must produce the same hash as Solidity and Rust.
52
+ */
53
+ declare function computeWithdrawPublicInputsSeed(params: {
54
+ nullifier: Hex;
55
+ stateRoot: bigint;
56
+ aspRoot: bigint;
57
+ aspId: bigint;
58
+ token: Address;
59
+ amount: bigint;
60
+ recipient: Address;
61
+ isRagequit: boolean;
62
+ }): Hex;
63
+ /**
64
+ * Compute the Fiat-Shamir public inputs seed for a STARK transfer.
65
+ * Must produce the same hash as Solidity and Rust.
66
+ */
67
+ declare function computeTransferPublicInputsSeed(params: {
68
+ nullifier: Hex;
69
+ stateRoot: bigint;
70
+ aspRoot: bigint;
71
+ token: Address;
72
+ outputCommitment1: Hex;
73
+ outputCommitment2: Hex;
74
+ }): Hex;
75
+ /**
76
+ * Witness inputs for the STARK withdrawal prover.
77
+ * All numeric values are u32 (must fit in M31 field, i.e. < 2^31 - 1).
78
+ * Hex string fields are for Fiat-Shamir seed binding.
79
+ */
80
+ interface StarkWithdrawWitness {
81
+ owner_secret: number[];
82
+ input_amount: number;
83
+ input_blinding: number;
84
+ input_origin: number;
85
+ token: number;
86
+ leaf_index: number;
87
+ state_path_elements: number[];
88
+ state_path_indices: number[];
89
+ asp_path_elements: number[];
90
+ asp_path_indices: number[];
91
+ withdraw_amount: number;
92
+ change_amount: number;
93
+ change_blinding: number;
94
+ recipient: number;
95
+ is_ragequit: number;
96
+ nullifier_hex: string;
97
+ state_root_hex: string;
98
+ asp_root_hex: string;
99
+ asp_id_hex: string;
100
+ token_address_hex: string;
101
+ amount_hex: string;
102
+ recipient_address_hex: string;
103
+ is_ragequit_bool: boolean;
104
+ }
105
+ /**
106
+ * Witness inputs for the STARK transfer prover (1-in-2-out).
107
+ * All numeric values are u32 (must fit in M31 field).
108
+ */
109
+ interface StarkTransferWitness {
110
+ owner_secret: number[];
111
+ input_amount: number;
112
+ input_blinding: number;
113
+ input_origin: number;
114
+ token: number;
115
+ leaf_index: number;
116
+ state_path_elements: number[];
117
+ state_path_indices: number[];
118
+ asp_path_elements: number[];
119
+ asp_path_indices: number[];
120
+ output1_amount: number;
121
+ output1_owner_hash: [number, number, number, number];
122
+ output1_blinding: number;
123
+ output1_origin: number;
124
+ output2_amount: number;
125
+ output2_owner_hash: [number, number, number, number];
126
+ output2_blinding: number;
127
+ output2_origin: number;
128
+ is_ragequit: number;
129
+ nullifier_hex: string;
130
+ state_root_hex: string;
131
+ asp_root_hex: string;
132
+ token_address_hex: string;
133
+ output_commitment_1_hex: string;
134
+ output_commitment_2_hex: string;
135
+ }
136
+ /**
137
+ * Build a complete STARK withdrawal witness from note data.
138
+ */
139
+ declare function buildStarkWithdrawWitness(params: {
140
+ ownerSecret: number[];
141
+ inputAmount: number;
142
+ inputBlinding: number;
143
+ inputOrigin: number;
144
+ token: number;
145
+ leafIndex: number;
146
+ withdrawAmount: number;
147
+ changeAmount: number;
148
+ changeBlinding: number;
149
+ recipient: number;
150
+ isRagequit: number;
151
+ nullifierHex: Hex;
152
+ stateRootBigInt: bigint;
153
+ aspRootBigInt: bigint;
154
+ aspIdBigInt: bigint;
155
+ tokenAddress: Address;
156
+ amountWei: bigint;
157
+ recipientAddress: Address;
158
+ isRagequitBool: boolean;
159
+ }): StarkWithdrawWitness;
160
+ /**
161
+ * Build a complete STARK transfer witness (1-in-2-out).
162
+ */
163
+ declare function buildStarkTransferWitness(params: {
164
+ ownerSecret: number[];
165
+ inputAmount: number;
166
+ inputBlinding: number;
167
+ inputOrigin: number;
168
+ token: number;
169
+ leafIndex: number;
170
+ output1Amount: number;
171
+ output1OwnerHash: [number, number, number, number];
172
+ output1Blinding: number;
173
+ output1Origin: number;
174
+ output2Amount: number;
175
+ output2OwnerHash: [number, number, number, number];
176
+ output2Blinding: number;
177
+ output2Origin: number;
178
+ isRagequit: number;
179
+ nullifierHex: Hex;
180
+ stateRootBigInt: bigint;
181
+ aspRootBigInt: bigint;
182
+ tokenAddress: Address;
183
+ outputCommitment1Hex: Hex;
184
+ outputCommitment2Hex: Hex;
185
+ }): StarkTransferWitness;
5
186
 
6
187
  /**
7
188
  * Poseidon Hash Utilities (BLS12-381)
@@ -98,9 +279,9 @@ declare function randomFieldElement(): bigint;
98
279
  */
99
280
  declare function bytesToHex(bytes: Uint8Array): `0x${string}`;
100
281
  /**
101
- * Convert hex string to bytes
282
+ * Convert hex string to bytes (handles with or without 0x prefix)
102
283
  */
103
- declare function hexToBytes(hex: `0x${string}`): Uint8Array;
284
+ declare function hexToBytes(hex: string): Uint8Array;
104
285
  /**
105
286
  * Convert bigint to bytes (big-endian)
106
287
  */
@@ -110,4 +291,4 @@ declare function bigintToBytes(value: bigint, length: number): Uint8Array;
110
291
  */
111
292
  declare function bytesToBigint(bytes: Uint8Array): bigint;
112
293
 
113
- export { BABYJUBJUB_SUBORDER, FIELD_PRIME, addressToField, bigintToBytes, bytesToBigint, bytesToHex, fieldToAddress, hexToBytes, isValidFieldElement, poseidon, poseidonHash, poseidonScalar, randomBytes, randomFieldElement, toFieldElement };
294
+ export { BABYJUBJUB_SUBORDER, FIELD_PRIME, STARK_AMOUNT_SCALE, STARK_ASP_TREE_DEPTH, STARK_STATE_TREE_DEPTH, type StarkTransferWitness, type StarkWithdrawWitness, addressToField, addressToM31, bigintToBytes, buildStarkTransferWitness, buildStarkWithdrawWitness, bytesToBigint, bytesToHex, computeTransferPublicInputsSeed, computeWithdrawPublicInputsSeed, fieldToAddress, hexToBytes, isStarkAligned, isValidFieldElement, packM31Digest, poseidon, poseidonHash, poseidonScalar, randomBytes, randomFieldElement, scaleAmountForStark, splitSecretToM31Limbs, toFieldElement, truncateToM31 };
@@ -1,8 +1,8 @@
1
- export { addPoints, computeSharedSecret, deriveDecryptionViewingKey, deriveEncryptionViewingKey, getBasePoint, getSubOrder, isOnCurve, mulPointScalar, packPoint, pointToTuple, privateToPublic, tupleToPoint } from '../chunk-EHGH6TAW.js';
2
- export { STARK_AMOUNT_SCALE, STARK_ASP_TREE_DEPTH, STARK_STATE_TREE_DEPTH, addressToM31, buildStarkTransferWitness, buildStarkWithdrawWitness, computeTransferPublicInputsSeed, computeWithdrawPublicInputsSeed, isStarkAligned, packM31Digest, scaleAmountForStark, splitSecretToM31Limbs, truncateToM31 } from '../chunk-7T4CUE6E.js';
1
+ export { addPoints, computeSharedSecret, deriveDecryptionViewingKey, deriveEncryptionViewingKey, getBasePoint, getSubOrder, isOnCurve, mulPointScalar, packPoint, pointToTuple, privateToPublic, tupleToPoint } from '../chunk-37RFFZU2.js';
2
+ export { STARK_AMOUNT_SCALE, STARK_ASP_TREE_DEPTH, STARK_STATE_TREE_DEPTH, addressToM31, buildStarkTransferWitness, buildStarkWithdrawWitness, computeTransferPublicInputsSeed, computeWithdrawPublicInputsSeed, isStarkAligned, packM31Digest, scaleAmountForStark, splitSecretToM31Limbs, truncateToM31 } from '../chunk-AVSR443A.js';
3
3
  export { MAX_TREE_DEPTH, MerkleTree, buildMerkleTree, getMerkleProof, verifyMerkleProof } from '../chunk-GPF72JFR.js';
4
- export { DIGEST_SIZE, M31_P, SECRET_LIMBS, computeStarkCommitment, computeStarkNullifier, computeStarkOwnerHash, keccakHashTwo, keccakM31, splitToM31Limbs } from '../chunk-6TFDBBAQ.js';
5
- export { bigintToBytes, bytesToBigint, bytesToHex, hexToBytes, randomBytes, randomFieldElement } from '../chunk-UQIM2KT3.js';
4
+ export { DIGEST_SIZE, M31_P, SECRET_LIMBS, computeStarkCommitment, computeStarkNullifier, computeStarkOwnerHash, keccakHashTwo, keccakM31, splitToM31Limbs } from '../chunk-H4NDMIPF.js';
5
+ export { bigintToBytes, bytesToBigint, bytesToHex, hexToBytes, randomBytes, randomFieldElement } from '../chunk-4E23V3AT.js';
6
6
  export { BABYJUBJUB_SUBORDER, FIELD_PRIME, addressToField, fieldToAddress, isValidFieldElement, poseidon, poseidonHash, poseidonScalar, toFieldElement } from '../chunk-5QSSX3KR.js';
7
7
  import '../chunk-Z6ZWNWWR.js';
8
8
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@permissionless-technologies/upp-sdk",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Universal Private Pool SDK - Privacy-preserving token operations for any ERC20",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -27,7 +27,8 @@
27
27
  },
28
28
  "metadata": {
29
29
  "chainId": 31337,
30
- "deployTimestamp": 1774959216,
30
+ "deployBlock": 10562475,
31
+ "deployTimestamp": 1774983913,
31
32
  "deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
32
33
  }
33
34
  }