@esseyonsui/sui-sdk-v3 0.0.0-stage → 0.1.1

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 (197) hide show
  1. package/README.md +45 -2
  2. package/dist/config.d.ts +82 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +180 -0
  5. package/dist/errors.d.ts +38 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +32 -0
  8. package/dist/essey.d.ts +866 -0
  9. package/dist/essey.d.ts.map +1 -0
  10. package/dist/essey.js +3593 -0
  11. package/dist/index.d.ts +9 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +4 -0
  14. package/dist/keeper.d.ts +54 -0
  15. package/dist/keeper.d.ts.map +1 -0
  16. package/dist/keeper.js +44 -0
  17. package/dist/network.d.ts +17 -0
  18. package/dist/network.d.ts.map +1 -0
  19. package/dist/network.js +62 -0
  20. package/dist/v3/addr-field.d.ts +3 -0
  21. package/dist/v3/addr-field.d.ts.map +1 -0
  22. package/dist/v3/addr-field.js +10 -0
  23. package/dist/v3/bodies.d.ts +54 -0
  24. package/dist/v3/bodies.d.ts.map +1 -0
  25. package/dist/v3/bodies.js +68 -0
  26. package/dist/v3/body-args.d.ts +29 -0
  27. package/dist/v3/body-args.d.ts.map +1 -0
  28. package/dist/v3/body-args.js +78 -0
  29. package/dist/v3/collateral/bodies.d.ts +78 -0
  30. package/dist/v3/collateral/bodies.d.ts.map +1 -0
  31. package/dist/v3/collateral/bodies.js +136 -0
  32. package/dist/v3/collateral/ext.d.ts +21 -0
  33. package/dist/v3/collateral/ext.d.ts.map +1 -0
  34. package/dist/v3/collateral/ext.js +19 -0
  35. package/dist/v3/collateral/health.d.ts +115 -0
  36. package/dist/v3/collateral/health.d.ts.map +1 -0
  37. package/dist/v3/collateral/health.js +255 -0
  38. package/dist/v3/collateral/index.d.ts +9 -0
  39. package/dist/v3/collateral/index.d.ts.map +1 -0
  40. package/dist/v3/collateral/index.js +8 -0
  41. package/dist/v3/collateral/local-health.d.ts +23 -0
  42. package/dist/v3/collateral/local-health.d.ts.map +1 -0
  43. package/dist/v3/collateral/local-health.js +27 -0
  44. package/dist/v3/collateral/math.d.ts +33 -0
  45. package/dist/v3/collateral/math.d.ts.map +1 -0
  46. package/dist/v3/collateral/math.js +38 -0
  47. package/dist/v3/collateral/openings.d.ts +27 -0
  48. package/dist/v3/collateral/openings.d.ts.map +1 -0
  49. package/dist/v3/collateral/openings.js +28 -0
  50. package/dist/v3/collateral/scan.d.ts +41 -0
  51. package/dist/v3/collateral/scan.d.ts.map +1 -0
  52. package/dist/v3/collateral/scan.js +76 -0
  53. package/dist/v3/collateral/seal.d.ts +31 -0
  54. package/dist/v3/collateral/seal.d.ts.map +1 -0
  55. package/dist/v3/collateral/seal.js +59 -0
  56. package/dist/v3/credential/issue.d.ts +27 -0
  57. package/dist/v3/credential/issue.d.ts.map +1 -0
  58. package/dist/v3/credential/issue.js +109 -0
  59. package/dist/v3/credential/membership.d.ts +37 -0
  60. package/dist/v3/credential/membership.d.ts.map +1 -0
  61. package/dist/v3/credential/membership.js +34 -0
  62. package/dist/v3/credential/pow.d.ts +10 -0
  63. package/dist/v3/credential/pow.d.ts.map +1 -0
  64. package/dist/v3/credential/pow.js +22 -0
  65. package/dist/v3/domains.d.ts +141 -0
  66. package/dist/v3/domains.d.ts.map +1 -0
  67. package/dist/v3/domains.js +158 -0
  68. package/dist/v3/ext.d.ts +29 -0
  69. package/dist/v3/ext.d.ts.map +1 -0
  70. package/dist/v3/ext.js +82 -0
  71. package/dist/v3/faucet.d.ts +66 -0
  72. package/dist/v3/faucet.d.ts.map +1 -0
  73. package/dist/v3/faucet.js +64 -0
  74. package/dist/v3/fee-witness.d.ts +5 -0
  75. package/dist/v3/fee-witness.d.ts.map +1 -0
  76. package/dist/v3/fee-witness.js +18 -0
  77. package/dist/v3/fees.d.ts +78 -0
  78. package/dist/v3/fees.d.ts.map +1 -0
  79. package/dist/v3/fees.js +190 -0
  80. package/dist/v3/index.d.ts +24 -0
  81. package/dist/v3/index.d.ts.map +1 -0
  82. package/dist/v3/index.js +23 -0
  83. package/dist/v3/inputs.d.ts +89 -0
  84. package/dist/v3/inputs.d.ts.map +1 -0
  85. package/dist/v3/inputs.js +152 -0
  86. package/dist/v3/keeper-badge.d.ts +48 -0
  87. package/dist/v3/keeper-badge.d.ts.map +1 -0
  88. package/dist/v3/keeper-badge.js +49 -0
  89. package/dist/v3/keeper-payload.d.ts +36 -0
  90. package/dist/v3/keeper-payload.d.ts.map +1 -0
  91. package/dist/v3/keeper-payload.js +116 -0
  92. package/dist/v3/kinds.d.ts +23 -0
  93. package/dist/v3/kinds.d.ts.map +1 -0
  94. package/dist/v3/kinds.js +50 -0
  95. package/dist/v3/loans/bodies.d.ts +215 -0
  96. package/dist/v3/loans/bodies.d.ts.map +1 -0
  97. package/dist/v3/loans/bodies.js +255 -0
  98. package/dist/v3/loans/offer-plan.d.ts +66 -0
  99. package/dist/v3/loans/offer-plan.d.ts.map +1 -0
  100. package/dist/v3/loans/offer-plan.js +141 -0
  101. package/dist/v3/loans/open-plan.d.ts +62 -0
  102. package/dist/v3/loans/open-plan.d.ts.map +1 -0
  103. package/dist/v3/loans/open-plan.js +92 -0
  104. package/dist/v3/loans/reclaim-plan.d.ts +65 -0
  105. package/dist/v3/loans/reclaim-plan.d.ts.map +1 -0
  106. package/dist/v3/loans/reclaim-plan.js +125 -0
  107. package/dist/v3/loans/refi-plan.d.ts +62 -0
  108. package/dist/v3/loans/refi-plan.d.ts.map +1 -0
  109. package/dist/v3/loans/refi-plan.js +157 -0
  110. package/dist/v3/loans/repay-plan.d.ts +40 -0
  111. package/dist/v3/loans/repay-plan.d.ts.map +1 -0
  112. package/dist/v3/loans/repay-plan.js +77 -0
  113. package/dist/v3/loans/settle-plan.d.ts +152 -0
  114. package/dist/v3/loans/settle-plan.d.ts.map +1 -0
  115. package/dist/v3/loans/settle-plan.js +210 -0
  116. package/dist/v3/market.d.ts +38 -0
  117. package/dist/v3/market.d.ts.map +1 -0
  118. package/dist/v3/market.js +30 -0
  119. package/dist/v3/notes/denominations.d.ts +13 -0
  120. package/dist/v3/notes/denominations.d.ts.map +1 -0
  121. package/dist/v3/notes/denominations.js +35 -0
  122. package/dist/v3/notes/deposit.d.ts +57 -0
  123. package/dist/v3/notes/deposit.d.ts.map +1 -0
  124. package/dist/v3/notes/deposit.js +103 -0
  125. package/dist/v3/notes/derive.d.ts +16 -0
  126. package/dist/v3/notes/derive.d.ts.map +1 -0
  127. package/dist/v3/notes/derive.js +34 -0
  128. package/dist/v3/notes/faucet.d.ts +3 -0
  129. package/dist/v3/notes/faucet.d.ts.map +1 -0
  130. package/dist/v3/notes/faucet.js +8 -0
  131. package/dist/v3/notes/index.d.ts +9 -0
  132. package/dist/v3/notes/index.d.ts.map +1 -0
  133. package/dist/v3/notes/index.js +8 -0
  134. package/dist/v3/notes/keys.d.ts +5 -0
  135. package/dist/v3/notes/keys.d.ts.map +1 -0
  136. package/dist/v3/notes/keys.js +11 -0
  137. package/dist/v3/notes/opening.d.ts +16 -0
  138. package/dist/v3/notes/opening.d.ts.map +1 -0
  139. package/dist/v3/notes/opening.js +62 -0
  140. package/dist/v3/notes/scan.d.ts +32 -0
  141. package/dist/v3/notes/scan.d.ts.map +1 -0
  142. package/dist/v3/notes/scan.js +71 -0
  143. package/dist/v3/notes/tree.d.ts +9 -0
  144. package/dist/v3/notes/tree.d.ts.map +1 -0
  145. package/dist/v3/notes/tree.js +31 -0
  146. package/dist/v3/notes/withdraw.d.ts +12 -0
  147. package/dist/v3/notes/withdraw.d.ts.map +1 -0
  148. package/dist/v3/notes/withdraw.js +27 -0
  149. package/dist/v3/proof-bytes.d.ts +4 -0
  150. package/dist/v3/proof-bytes.d.ts.map +1 -0
  151. package/dist/v3/proof-bytes.js +22 -0
  152. package/dist/v3/prover.d.ts +34 -0
  153. package/dist/v3/prover.d.ts.map +1 -0
  154. package/dist/v3/prover.js +76 -0
  155. package/dist/v3/relay/client.d.ts +57 -0
  156. package/dist/v3/relay/client.d.ts.map +1 -0
  157. package/dist/v3/relay/client.js +80 -0
  158. package/dist/v3/relay/possession.d.ts +21 -0
  159. package/dist/v3/relay/possession.d.ts.map +1 -0
  160. package/dist/v3/relay/possession.js +45 -0
  161. package/dist/v3/sales/auctioneer.d.ts +60 -0
  162. package/dist/v3/sales/auctioneer.d.ts.map +1 -0
  163. package/dist/v3/sales/auctioneer.js +130 -0
  164. package/dist/v3/sales/bcs.d.ts +4 -0
  165. package/dist/v3/sales/bcs.d.ts.map +1 -0
  166. package/dist/v3/sales/bcs.js +16 -0
  167. package/dist/v3/sales/bid.d.ts +51 -0
  168. package/dist/v3/sales/bid.d.ts.map +1 -0
  169. package/dist/v3/sales/bid.js +85 -0
  170. package/dist/v3/sales/bodies.d.ts +83 -0
  171. package/dist/v3/sales/bodies.d.ts.map +1 -0
  172. package/dist/v3/sales/bodies.js +78 -0
  173. package/dist/v3/sales/claim.d.ts +40 -0
  174. package/dist/v3/sales/claim.d.ts.map +1 -0
  175. package/dist/v3/sales/claim.js +44 -0
  176. package/dist/v3/sales/index.d.ts +10 -0
  177. package/dist/v3/sales/index.d.ts.map +1 -0
  178. package/dist/v3/sales/index.js +9 -0
  179. package/dist/v3/sales/open-kind.d.ts +42 -0
  180. package/dist/v3/sales/open-kind.d.ts.map +1 -0
  181. package/dist/v3/sales/open-kind.js +43 -0
  182. package/dist/v3/sales/outcome.d.ts +20 -0
  183. package/dist/v3/sales/outcome.d.ts.map +1 -0
  184. package/dist/v3/sales/outcome.js +21 -0
  185. package/dist/v3/sales/reclaim.d.ts +46 -0
  186. package/dist/v3/sales/reclaim.d.ts.map +1 -0
  187. package/dist/v3/sales/reclaim.js +57 -0
  188. package/dist/v3/sales/rows.d.ts +55 -0
  189. package/dist/v3/sales/rows.d.ts.map +1 -0
  190. package/dist/v3/sales/rows.js +98 -0
  191. package/dist/v3/sales/seller.d.ts +39 -0
  192. package/dist/v3/sales/seller.d.ts.map +1 -0
  193. package/dist/v3/sales/seller.js +67 -0
  194. package/dist/v3/stage1.d.ts +204 -0
  195. package/dist/v3/stage1.d.ts.map +1 -0
  196. package/dist/v3/stage1.js +575 -0
  197. package/package.json +33 -4
@@ -0,0 +1,141 @@
1
+ export declare const R = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
2
+ export declare const MAX_FEE_BPS = 1000n;
3
+ /**
4
+ * keccak256("essey/v3/fee-params/v1") mod R, digest read big-endian. A `/v3/fee-params` pass is a membership
5
+ * proof whose room is 2^255 + this value as 32 big-endian bytes (D §5.4), so it is never a proof for an
6
+ * on-chain room.
7
+ */
8
+ export declare const FEE_PARAMS_DOMAIN = 19380924832110146460012410651437679277945213189123416477031835074489817075182n;
9
+ /**
10
+ * keccak256("essey/v3/faucet/v1") mod R, digest read big-endian (BORIS-RULING 0202 §2). A `/v3/faucet` pass
11
+ * room is 2^255 + Poseidon(FAUCET_DOMAIN, coinId, dayIndex) as 32 big-endian bytes (BORIS-RULING 0214 (d)):
12
+ * coinId is tusdsui 0, usdc 1, sui 2, and dayIndex is the UTC day since the Unix epoch.
13
+ */
14
+ export declare const FAUCET_DOMAIN = 21538274494898800326212708171769491349346517068411511462579316980228095862992n;
15
+ export declare function tagToField(tag: string): bigint;
16
+ export declare const TAGS: {
17
+ readonly DOM_LOCK: "ess3/lock";
18
+ readonly DOM_LNULL: "ess3/lnull";
19
+ readonly DOM_RESID: "ess3/resid";
20
+ readonly DOM_RBLIND: "ess3/rblind";
21
+ readonly DOM_BID: "ess3/bid";
22
+ readonly DOM_BOUNDS: "ess3/bounds";
23
+ readonly DOM_SELLER: "ess3/seller";
24
+ readonly DOM_SBLIND: "ess3/sblind";
25
+ readonly DOM_ITEM: "ess3/item";
26
+ readonly DOM_ISALT: "ess3/isalt";
27
+ readonly DOM_INULL: "ess3/inull";
28
+ readonly DOM_DUMMY: "ess3/dummy";
29
+ readonly DOM_FEE: "ess3/fee";
30
+ readonly DOM_FBLIND: "ess3/fblind";
31
+ readonly DOM_ACT: "ess3/act";
32
+ readonly DOM_ROUND: "ess3/round";
33
+ readonly DOM_OFFER: "ess3/offer";
34
+ readonly DOM_REQ: "ess3/req";
35
+ readonly DOM_TSALT: "ess3/tsalt";
36
+ readonly DOM_LBLIND: "ess3/lblind";
37
+ readonly DOM_LOCK_COLL: "ess3/lockcoll";
38
+ readonly DOM_A1: "ess3/a1";
39
+ readonly DOM_A2: "ess3/a2";
40
+ readonly DOM_A2O: "ess3/a2o";
41
+ readonly DOM_A2D: "ess3/a2d";
42
+ readonly DOM_A3: "ess3/a3";
43
+ readonly DOM_A6: "ess3/a6";
44
+ readonly DOM_A6O: "ess3/a6o";
45
+ readonly DOM_A6D: "ess3/a6d";
46
+ readonly DOM_A6P: "ess3/a6p";
47
+ readonly DOM_JS: "ess3/js";
48
+ readonly DOM_JSO: "ess3/jso";
49
+ readonly DOM_DEP: "ess3/dep";
50
+ readonly DOM_BLIND: "ess3/blind";
51
+ readonly DOM_HEALTH: "ess3/health";
52
+ readonly DOM_PRICE: "ess3/price";
53
+ readonly DOM_CL: "ess3/colllock";
54
+ readonly DOM_KPR: "ess3/kpr";
55
+ readonly DOM_SALEKEY: "ess3/salekey";
56
+ readonly DOM_CNULL: "ess3/cnull";
57
+ };
58
+ export declare const DOM_LOCK: bigint;
59
+ export declare const DOM_LNULL: bigint;
60
+ export declare const DOM_RESID: bigint;
61
+ export declare const DOM_RBLIND: bigint;
62
+ export declare const DOM_BID: bigint;
63
+ export declare const DOM_BOUNDS: bigint;
64
+ export declare const DOM_SELLER: bigint;
65
+ export declare const DOM_SBLIND: bigint;
66
+ export declare const DOM_ITEM: bigint;
67
+ export declare const DOM_ISALT: bigint;
68
+ export declare const DOM_INULL: bigint;
69
+ export declare const DOM_DUMMY: bigint;
70
+ export declare const DOM_FEE: bigint;
71
+ export declare const DOM_FBLIND: bigint;
72
+ export declare const DOM_ACT: bigint;
73
+ export declare const DOM_ROUND: bigint;
74
+ export declare const DOM_OFFER: bigint;
75
+ export declare const DOM_REQ: bigint;
76
+ export declare const DOM_TSALT: bigint;
77
+ export declare const DOM_LBLIND: bigint;
78
+ export declare const DOM_LOCK_COLL: bigint;
79
+ export declare const DOM_A1: bigint;
80
+ export declare const DOM_A2: bigint;
81
+ export declare const DOM_A2O: bigint;
82
+ export declare const DOM_A2D: bigint;
83
+ export declare const DOM_A3: bigint;
84
+ export declare const DOM_A6: bigint;
85
+ export declare const DOM_A6O: bigint;
86
+ export declare const DOM_A6D: bigint;
87
+ export declare const DOM_A6P: bigint;
88
+ export declare const DOM_JS: bigint;
89
+ export declare const DOM_JSO: bigint;
90
+ export declare const DOM_DEP: bigint;
91
+ export declare const DOM_BLIND: bigint;
92
+ export declare const DOM_HEALTH: bigint;
93
+ export declare const DOM_PRICE: bigint;
94
+ export declare const DOM_CL: bigint;
95
+ export declare const DOM_KPR: bigint;
96
+ export declare const DOM_SALEKEY: bigint;
97
+ export declare const DOM_CNULL: bigint;
98
+ export declare const DOMAINS: {
99
+ readonly DOM_LOCK: bigint;
100
+ readonly DOM_LNULL: bigint;
101
+ readonly DOM_RESID: bigint;
102
+ readonly DOM_RBLIND: bigint;
103
+ readonly DOM_BID: bigint;
104
+ readonly DOM_BOUNDS: bigint;
105
+ readonly DOM_SELLER: bigint;
106
+ readonly DOM_SBLIND: bigint;
107
+ readonly DOM_ITEM: bigint;
108
+ readonly DOM_ISALT: bigint;
109
+ readonly DOM_INULL: bigint;
110
+ readonly DOM_DUMMY: bigint;
111
+ readonly DOM_FEE: bigint;
112
+ readonly DOM_FBLIND: bigint;
113
+ readonly DOM_ACT: bigint;
114
+ readonly DOM_ROUND: bigint;
115
+ readonly DOM_OFFER: bigint;
116
+ readonly DOM_REQ: bigint;
117
+ readonly DOM_TSALT: bigint;
118
+ readonly DOM_LBLIND: bigint;
119
+ readonly DOM_LOCK_COLL: bigint;
120
+ readonly DOM_A1: bigint;
121
+ readonly DOM_A2: bigint;
122
+ readonly DOM_A2O: bigint;
123
+ readonly DOM_A2D: bigint;
124
+ readonly DOM_A3: bigint;
125
+ readonly DOM_A6: bigint;
126
+ readonly DOM_A6O: bigint;
127
+ readonly DOM_A6D: bigint;
128
+ readonly DOM_A6P: bigint;
129
+ readonly DOM_JS: bigint;
130
+ readonly DOM_JSO: bigint;
131
+ readonly DOM_DEP: bigint;
132
+ readonly DOM_BLIND: bigint;
133
+ readonly DOM_HEALTH: bigint;
134
+ readonly DOM_PRICE: bigint;
135
+ readonly DOM_CL: bigint;
136
+ readonly DOM_KPR: bigint;
137
+ readonly DOM_SALEKEY: bigint;
138
+ readonly DOM_CNULL: bigint;
139
+ };
140
+ export declare function fieldOfId(id: string): bigint;
141
+ //# sourceMappingURL=domains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../src/v3/domains.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,iFAAQ,CAAC;AAGvB,eAAO,MAAM,WAAW,QAAQ,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,iFACkD,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,aAAa,iFAAiF,CAAC;AAE5G,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCP,CAAC;AAEX,eAAO,MAAM,QAAQ,QAA4B,CAAC;AAClD,eAAO,MAAM,SAAS,QAA6B,CAAC;AACpD,eAAO,MAAM,SAAS,QAA6B,CAAC;AACpD,eAAO,MAAM,UAAU,QAA8B,CAAC;AACtD,eAAO,MAAM,OAAO,QAA2B,CAAC;AAChD,eAAO,MAAM,UAAU,QAA8B,CAAC;AACtD,eAAO,MAAM,UAAU,QAA8B,CAAC;AACtD,eAAO,MAAM,UAAU,QAA8B,CAAC;AACtD,eAAO,MAAM,QAAQ,QAA4B,CAAC;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;;;;;CAyCV,CAAC;AAEX,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAI5C"}
@@ -0,0 +1,158 @@
1
+ const FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
2
+ export const R = FIELD;
3
+ // Boris decision Nov 10. Fee rate cap enforced by the circuit. The basis-point divisor stays 10000.
4
+ export const MAX_FEE_BPS = 1000n;
5
+ /**
6
+ * keccak256("essey/v3/fee-params/v1") mod R, digest read big-endian. A `/v3/fee-params` pass is a membership
7
+ * proof whose room is 2^255 + this value as 32 big-endian bytes (D §5.4), so it is never a proof for an
8
+ * on-chain room.
9
+ */
10
+ export const FEE_PARAMS_DOMAIN = 19380924832110146460012410651437679277945213189123416477031835074489817075182n;
11
+ /**
12
+ * keccak256("essey/v3/faucet/v1") mod R, digest read big-endian (BORIS-RULING 0202 §2). A `/v3/faucet` pass
13
+ * room is 2^255 + Poseidon(FAUCET_DOMAIN, coinId, dayIndex) as 32 big-endian bytes (BORIS-RULING 0214 (d)):
14
+ * coinId is tusdsui 0, usdc 1, sui 2, and dayIndex is the UTC day since the Unix epoch.
15
+ */
16
+ export const FAUCET_DOMAIN = 21538274494898800326212708171769491349346517068411511462579316980228095862992n;
17
+ export function tagToField(tag) {
18
+ let acc = 0n;
19
+ for (const ch of tag) {
20
+ const byte = ch.codePointAt(0);
21
+ if (byte > 0x7f)
22
+ throw new Error("domain tag is not ASCII");
23
+ acc = (acc << 8n) + BigInt(byte);
24
+ }
25
+ if (acc <= 0n || acc >= R)
26
+ throw new Error("domain tag is outside the field");
27
+ return acc;
28
+ }
29
+ export const TAGS = {
30
+ DOM_LOCK: "ess3/lock",
31
+ DOM_LNULL: "ess3/lnull",
32
+ DOM_RESID: "ess3/resid",
33
+ DOM_RBLIND: "ess3/rblind",
34
+ DOM_BID: "ess3/bid",
35
+ DOM_BOUNDS: "ess3/bounds",
36
+ DOM_SELLER: "ess3/seller",
37
+ DOM_SBLIND: "ess3/sblind",
38
+ DOM_ITEM: "ess3/item",
39
+ DOM_ISALT: "ess3/isalt",
40
+ DOM_INULL: "ess3/inull",
41
+ DOM_DUMMY: "ess3/dummy",
42
+ DOM_FEE: "ess3/fee",
43
+ DOM_FBLIND: "ess3/fblind",
44
+ DOM_ACT: "ess3/act",
45
+ DOM_ROUND: "ess3/round",
46
+ DOM_OFFER: "ess3/offer",
47
+ DOM_REQ: "ess3/req",
48
+ DOM_TSALT: "ess3/tsalt",
49
+ DOM_LBLIND: "ess3/lblind",
50
+ DOM_LOCK_COLL: "ess3/lockcoll",
51
+ DOM_A1: "ess3/a1",
52
+ DOM_A2: "ess3/a2",
53
+ DOM_A2O: "ess3/a2o",
54
+ DOM_A2D: "ess3/a2d",
55
+ DOM_A3: "ess3/a3",
56
+ DOM_A6: "ess3/a6",
57
+ DOM_A6O: "ess3/a6o",
58
+ DOM_A6D: "ess3/a6d",
59
+ DOM_A6P: "ess3/a6p",
60
+ DOM_JS: "ess3/js",
61
+ DOM_JSO: "ess3/jso",
62
+ DOM_DEP: "ess3/dep",
63
+ DOM_BLIND: "ess3/blind",
64
+ DOM_HEALTH: "ess3/health",
65
+ DOM_PRICE: "ess3/price",
66
+ DOM_CL: "ess3/colllock",
67
+ DOM_KPR: "ess3/kpr",
68
+ DOM_SALEKEY: "ess3/salekey",
69
+ DOM_CNULL: "ess3/cnull",
70
+ };
71
+ export const DOM_LOCK = tagToField(TAGS.DOM_LOCK);
72
+ export const DOM_LNULL = tagToField(TAGS.DOM_LNULL);
73
+ export const DOM_RESID = tagToField(TAGS.DOM_RESID);
74
+ export const DOM_RBLIND = tagToField(TAGS.DOM_RBLIND);
75
+ export const DOM_BID = tagToField(TAGS.DOM_BID);
76
+ export const DOM_BOUNDS = tagToField(TAGS.DOM_BOUNDS);
77
+ export const DOM_SELLER = tagToField(TAGS.DOM_SELLER);
78
+ export const DOM_SBLIND = tagToField(TAGS.DOM_SBLIND);
79
+ export const DOM_ITEM = tagToField(TAGS.DOM_ITEM);
80
+ export const DOM_ISALT = tagToField(TAGS.DOM_ISALT);
81
+ export const DOM_INULL = tagToField(TAGS.DOM_INULL);
82
+ export const DOM_DUMMY = tagToField(TAGS.DOM_DUMMY);
83
+ export const DOM_FEE = tagToField(TAGS.DOM_FEE);
84
+ export const DOM_FBLIND = tagToField(TAGS.DOM_FBLIND);
85
+ export const DOM_ACT = tagToField(TAGS.DOM_ACT);
86
+ export const DOM_ROUND = tagToField(TAGS.DOM_ROUND);
87
+ export const DOM_OFFER = tagToField(TAGS.DOM_OFFER);
88
+ export const DOM_REQ = tagToField(TAGS.DOM_REQ);
89
+ export const DOM_TSALT = tagToField(TAGS.DOM_TSALT);
90
+ export const DOM_LBLIND = tagToField(TAGS.DOM_LBLIND);
91
+ export const DOM_LOCK_COLL = tagToField(TAGS.DOM_LOCK_COLL);
92
+ export const DOM_A1 = tagToField(TAGS.DOM_A1);
93
+ export const DOM_A2 = tagToField(TAGS.DOM_A2);
94
+ export const DOM_A2O = tagToField(TAGS.DOM_A2O);
95
+ export const DOM_A2D = tagToField(TAGS.DOM_A2D);
96
+ export const DOM_A3 = tagToField(TAGS.DOM_A3);
97
+ export const DOM_A6 = tagToField(TAGS.DOM_A6);
98
+ export const DOM_A6O = tagToField(TAGS.DOM_A6O);
99
+ export const DOM_A6D = tagToField(TAGS.DOM_A6D);
100
+ export const DOM_A6P = tagToField(TAGS.DOM_A6P);
101
+ export const DOM_JS = tagToField(TAGS.DOM_JS);
102
+ export const DOM_JSO = tagToField(TAGS.DOM_JSO);
103
+ export const DOM_DEP = tagToField(TAGS.DOM_DEP);
104
+ export const DOM_BLIND = tagToField(TAGS.DOM_BLIND);
105
+ export const DOM_HEALTH = tagToField(TAGS.DOM_HEALTH);
106
+ export const DOM_PRICE = tagToField(TAGS.DOM_PRICE);
107
+ export const DOM_CL = tagToField(TAGS.DOM_CL);
108
+ export const DOM_KPR = tagToField(TAGS.DOM_KPR);
109
+ export const DOM_SALEKEY = tagToField(TAGS.DOM_SALEKEY);
110
+ export const DOM_CNULL = tagToField(TAGS.DOM_CNULL);
111
+ export const DOMAINS = {
112
+ DOM_LOCK,
113
+ DOM_LNULL,
114
+ DOM_RESID,
115
+ DOM_RBLIND,
116
+ DOM_BID,
117
+ DOM_BOUNDS,
118
+ DOM_SELLER,
119
+ DOM_SBLIND,
120
+ DOM_ITEM,
121
+ DOM_ISALT,
122
+ DOM_INULL,
123
+ DOM_DUMMY,
124
+ DOM_FEE,
125
+ DOM_FBLIND,
126
+ DOM_ACT,
127
+ DOM_ROUND,
128
+ DOM_OFFER,
129
+ DOM_REQ,
130
+ DOM_TSALT,
131
+ DOM_LBLIND,
132
+ DOM_LOCK_COLL,
133
+ DOM_A1,
134
+ DOM_A2,
135
+ DOM_A2O,
136
+ DOM_A2D,
137
+ DOM_A3,
138
+ DOM_A6,
139
+ DOM_A6O,
140
+ DOM_A6D,
141
+ DOM_A6P,
142
+ DOM_JS,
143
+ DOM_JSO,
144
+ DOM_DEP,
145
+ DOM_BLIND,
146
+ DOM_HEALTH,
147
+ DOM_PRICE,
148
+ DOM_CL,
149
+ DOM_KPR,
150
+ DOM_SALEKEY,
151
+ DOM_CNULL,
152
+ };
153
+ export function fieldOfId(id) {
154
+ const hex = id.replace(/^0x/i, "").padStart(64, "0");
155
+ if (!/^[0-9a-fA-F]{64}$/.test(hex))
156
+ throw new Error("id must be 32 bytes");
157
+ return BigInt(`0x${hex}`) % R;
158
+ }
@@ -0,0 +1,29 @@
1
+ export declare const EXT_TRANSFER = 1;
2
+ export declare const EXT_WITHDRAW = 2;
3
+ export declare const NO_ADDRESS: string;
4
+ /** `essey_v3::liquidation` MODE_OPEN and MODE_TOPUP, the modes whose CollLock spend carries an ext. */
5
+ export declare const MODE_OPEN = 1;
6
+ export declare const MODE_TOPUP = 3;
7
+ /** `privacy_v3::pool::Ext`, same field order. `recipient` and `relayer` are `NO_ADDRESS` when nobody is paid. */
8
+ export type Ext = {
9
+ relayerFee: bigint;
10
+ recipient: string;
11
+ relayer: string;
12
+ nonceOrRound: bigint;
13
+ kind: number;
14
+ };
15
+ export declare function extBytes(ext: Ext): Uint8Array;
16
+ export declare function extHash(ext: Ext): bigint;
17
+ /**
18
+ * `liquidation::health_ext` (liquidation.move:579-587): keccak256("ess3/hext/" ‖ u8 mode ‖ loan ‖ pool_c ‖ market ‖
19
+ * bcs(ct) of each `cts`, in order) mod R, the digest read big-endian.
20
+ */
21
+ /** `liquidation::HEXT_TOPUP_BY_BORROWER`: the ext byte of `topup_by_borrower`, whose proof is otherwise TOPUP's. */
22
+ export declare const HEXT_TOPUP_BY_BORROWER = 131;
23
+ export declare function healthExt(mode: number, loan: string, poolC: string, market: string, cts: Uint8Array[]): bigint;
24
+ /**
25
+ * `liquidation::open_lock_ext` and `topup_lock_ext`: `healthExt` over the one byte string `relayer` in OPEN
26
+ * (`NO_ADDRESS` when self-submitted) and over none in TOPUP.
27
+ */
28
+ export declare function collLockExt(mode: number, loan: string, poolC: string, market: string, relayer?: string): bigint;
29
+ //# sourceMappingURL=ext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ext.d.ts","sourceRoot":"","sources":["../../src/v3/ext.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,uGAAuG;AACvG,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,UAAU,IAAI,CAAC;AAM5B,iHAAiH;AACjH,MAAM,MAAM,GAAG,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmBF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAS7C;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAExC;AAUD;;;GAGG;AACH,oHAAoH;AACpH,eAAO,MAAM,sBAAsB,MAAO,CAAC;AAE3C,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,EAAE,GAChB,MAAM,CAYR;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAMR"}
package/dist/v3/ext.js ADDED
@@ -0,0 +1,82 @@
1
+ import { keccak_256 } from "@noble/hashes/sha3.js";
2
+ import { R } from "./domains.js";
3
+ export const EXT_TRANSFER = 1;
4
+ export const EXT_WITHDRAW = 2;
5
+ export const NO_ADDRESS = `0x${"0".repeat(64)}`;
6
+ /** `essey_v3::liquidation` MODE_OPEN and MODE_TOPUP, the modes whose CollLock spend carries an ext. */
7
+ export const MODE_OPEN = 1;
8
+ export const MODE_TOPUP = 3;
9
+ const HEXT_TAG = Buffer.from("ess3/hext/", "ascii");
10
+ const U64_MAX = (1n << 64n) - 1n;
11
+ function u64Le(value, name) {
12
+ if (value < 0n || value > U64_MAX)
13
+ throw new Error(`${name} is not a u64`);
14
+ const out = new Uint8Array(8);
15
+ new DataView(out.buffer).setBigUint64(0, value, true);
16
+ return out;
17
+ }
18
+ function addressBytes(address, name) {
19
+ const hex = address.replace(/^0x/i, "").padStart(64, "0");
20
+ if (!/^[0-9a-fA-F]{64}$/.test(hex))
21
+ throw new Error(`${name} is not a 32-byte address`);
22
+ return Uint8Array.from(Buffer.from(hex, "hex"));
23
+ }
24
+ function toBigInt(bytes) {
25
+ return BigInt(`0x${Buffer.from(bytes).toString("hex")}`);
26
+ }
27
+ export function extBytes(ext) {
28
+ if (!Number.isInteger(ext.kind) || ext.kind < 0 || ext.kind > 0xff)
29
+ throw new Error("kind is not a u8");
30
+ return Uint8Array.from([
31
+ ...u64Le(ext.relayerFee, "relayerFee"),
32
+ ...addressBytes(ext.recipient, "recipient"),
33
+ ...addressBytes(ext.relayer, "relayer"),
34
+ ...u64Le(ext.nonceOrRound, "nonceOrRound"),
35
+ ext.kind,
36
+ ]);
37
+ }
38
+ export function extHash(ext) {
39
+ return toBigInt(keccak_256(extBytes(ext))) % R;
40
+ }
41
+ function uleb(length) {
42
+ const out = [];
43
+ let n = length;
44
+ for (; n >= 0x80; n >>>= 7)
45
+ out.push((n & 0x7f) | 0x80);
46
+ out.push(n);
47
+ return out;
48
+ }
49
+ /**
50
+ * `liquidation::health_ext` (liquidation.move:579-587): keccak256("ess3/hext/" ‖ u8 mode ‖ loan ‖ pool_c ‖ market ‖
51
+ * bcs(ct) of each `cts`, in order) mod R, the digest read big-endian.
52
+ */
53
+ /** `liquidation::HEXT_TOPUP_BY_BORROWER`: the ext byte of `topup_by_borrower`, whose proof is otherwise TOPUP's. */
54
+ export const HEXT_TOPUP_BY_BORROWER = 0x83;
55
+ export function healthExt(mode, loan, poolC, market, cts) {
56
+ const modeOk = (Number.isInteger(mode) && mode >= 1 && mode <= 7) || mode === HEXT_TOPUP_BY_BORROWER;
57
+ if (!modeOk)
58
+ throw new Error("mode is not a Health mode");
59
+ const bytes = Uint8Array.from([
60
+ ...HEXT_TAG,
61
+ mode,
62
+ ...addressBytes(loan, "loan"),
63
+ ...addressBytes(poolC, "poolC"),
64
+ ...addressBytes(market, "market"),
65
+ ...cts.flatMap((ct) => [...uleb(ct.length), ...ct]),
66
+ ]);
67
+ return toBigInt(keccak_256(bytes)) % R;
68
+ }
69
+ /**
70
+ * `liquidation::open_lock_ext` and `topup_lock_ext`: `healthExt` over the one byte string `relayer` in OPEN
71
+ * (`NO_ADDRESS` when self-submitted) and over none in TOPUP.
72
+ */
73
+ export function collLockExt(mode, loan, poolC, market, relayer) {
74
+ if (mode !== MODE_OPEN && mode !== MODE_TOPUP)
75
+ throw new Error("mode is not OPEN or TOPUP");
76
+ if (mode === MODE_OPEN && relayer === undefined)
77
+ throw new Error("OPEN binds a relayer");
78
+ if (mode === MODE_TOPUP && relayer !== undefined)
79
+ throw new Error("TOPUP binds no relayer");
80
+ const cts = relayer === undefined ? [] : [addressBytes(relayer, "relayer")];
81
+ return healthExt(mode, loan, poolC, market, cts);
82
+ }
@@ -0,0 +1,66 @@
1
+ import { type CoinKey } from "../config.ts";
2
+ import { type PassProof, type Proved, type WireProof } from "./bodies.ts";
3
+ import { type Credential, type MemberSecrets } from "./credential/membership.ts";
4
+ import type { FeeLaneResult } from "./fees.ts";
5
+ import { type CircuitInput } from "./inputs.ts";
6
+ import type { Prover } from "./prover.ts";
7
+ /**
8
+ * 2^255 + Poseidon(FAUCET_DOMAIN, coinId, dayIndex) as 32 big-endian bytes. `coinId` is the index in `COINS`,
9
+ * which only grows at its end; `dayIndex` is the UTC day since the Unix epoch (BORIS-RULING 0202 §1, 0214 (d)).
10
+ * The lift keeps every room at or above r, so `keys::register` refuses it as a sale or loan key
11
+ * (`move/v3/config/sources/keys.move:111`).
12
+ */
13
+ export declare function faucetRoom(coin: CoinKey, dayIndex: number): string;
14
+ export type FaucetPassParams = {
15
+ secrets: MemberSecrets;
16
+ credential: Credential;
17
+ coin: CoinKey;
18
+ /** v3api derives the day from its own clock, so a pass built on another UTC day does not verify. */
19
+ nowMs: number;
20
+ /** The relayer's address, the grant's sender, which is the pass `bind`. */
21
+ relayer: string;
22
+ };
23
+ /** Membership witness for a faucet pass: domain 1 (SENDER), circuit nonce 0 (BORIS-RULING 0200 Q1, 0202 §3). */
24
+ export declare function faucetPass(p: FaucetPassParams): {
25
+ input: CircuitInput;
26
+ publics: bigint[];
27
+ };
28
+ /** `inputs.deposit` of the grant amount with `faucet: true`, and its proof. */
29
+ export type FaucetDeposit = {
30
+ publics: bigint[];
31
+ lane: FeeLaneResult;
32
+ proved: Proved;
33
+ };
34
+ export type FaucetNote = {
35
+ deposit: FaucetDeposit;
36
+ encOut: string;
37
+ encFee: string;
38
+ };
39
+ /** `POST /v3/faucet`, the shape `parseFaucetRequest` takes (`services/v3api/src/faucet.ts`). */
40
+ export type FaucetBody = {
41
+ coin: CoinKey;
42
+ pass: {
43
+ tag: string;
44
+ expiryMs: string;
45
+ proof: PassProof;
46
+ };
47
+ outCommit: string;
48
+ encOut: string;
49
+ feeNote: string;
50
+ encFee: string;
51
+ ephX: string;
52
+ ephY: string;
53
+ feeCt: string;
54
+ feeCommit: string;
55
+ proof: WireProof;
56
+ };
57
+ export declare function faucetBody(p: FaucetNote & {
58
+ coin: CoinKey;
59
+ pass: {
60
+ publics: bigint[];
61
+ proved: Proved;
62
+ };
63
+ }): FaucetBody;
64
+ /** Proves the pass with the caller's prover. The deposit arrives proved: the SDK names no deposit circuit yet. */
65
+ export declare function proveFaucet(prover: Prover, p: FaucetPassParams & FaucetNote): Promise<FaucetBody>;
66
+ //# sourceMappingURL=faucet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faucet.d.ts","sourceRoot":"","sources":["../../src/v3/faucet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAInD,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5G,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQ1C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED,M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AO,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC7E,UAAU,CAiBZ;AAED,kHAAkH;AAClH,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAgB,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAIvG"}
@@ -0,0 +1,64 @@
1
+ import { poseidonHash } from "@mysten/sui/zklogin";
2
+ import { COINS } from "../config.js";
3
+ import { EsseyError } from "../errors.js";
4
+ import { address } from "../network.js";
5
+ import { ciphertext, passProof, wireProof } from "./bodies.js";
6
+ import { DAY_MS } from "./credential/issue.js";
7
+ import { DOMAIN_SENDER } from "./credential/membership.js";
8
+ import { FAUCET_DOMAIN } from "./domains.js";
9
+ import { membership } from "./inputs.js";
10
+ import { VK } from "./kinds.js";
11
+ const invalid = (what) => {
12
+ throw new EsseyError("INVALID_ARGUMENT", what);
13
+ };
14
+ const ROOM_LIFT = 1n << 255n;
15
+ /**
16
+ * 2^255 + Poseidon(FAUCET_DOMAIN, coinId, dayIndex) as 32 big-endian bytes. `coinId` is the index in `COINS`,
17
+ * which only grows at its end; `dayIndex` is the UTC day since the Unix epoch (BORIS-RULING 0202 §1, 0214 (d)).
18
+ * The lift keeps every room at or above r, so `keys::register` refuses it as a sale or loan key
19
+ * (`move/v3/config/sources/keys.move:111`).
20
+ */
21
+ export function faucetRoom(coin, dayIndex) {
22
+ const coinId = COINS.indexOf(coin);
23
+ if (coinId < 0)
24
+ invalid("coin is not tusdsui, usdc or sui");
25
+ if (!Number.isSafeInteger(dayIndex) || dayIndex < 0)
26
+ invalid("day is not a UTC day index");
27
+ const room = ROOM_LIFT + poseidonHash([FAUCET_DOMAIN, BigInt(coinId), BigInt(dayIndex)]);
28
+ return `0x${room.toString(16)}`;
29
+ }
30
+ /** Membership witness for a faucet pass: domain 1 (SENDER), circuit nonce 0 (BORIS-RULING 0200 Q1, 0202 §3). */
31
+ export function faucetPass(p) {
32
+ return membership({
33
+ secrets: p.secrets,
34
+ credential: p.credential,
35
+ domain: DOMAIN_SENDER,
36
+ room: faucetRoom(p.coin, Math.floor(p.nowMs / DAY_MS)),
37
+ bind: address(p.relayer, "relayer"),
38
+ });
39
+ }
40
+ export function faucetBody(p) {
41
+ if (!COINS.includes(p.coin))
42
+ invalid("coin is not tusdsui, usdc or sui");
43
+ const [tag, , expiryMs] = p.pass.publics;
44
+ const { publics, lane, proved } = p.deposit;
45
+ return {
46
+ coin: p.coin,
47
+ pass: { tag: tag.toString(), expiryMs: expiryMs.toString(), proof: passProof(p.pass.proved) },
48
+ outCommit: publics[0].toString(),
49
+ encOut: ciphertext(p.encOut),
50
+ feeNote: lane.fee_note.toString(),
51
+ encFee: ciphertext(p.encFee),
52
+ ephX: lane.ephX.toString(),
53
+ ephY: lane.ephY.toString(),
54
+ feeCt: lane.fee_ct.toString(),
55
+ feeCommit: lane.fee_commit.toString(),
56
+ proof: wireProof(VK.deposit, proved),
57
+ };
58
+ }
59
+ /** Proves the pass with the caller's prover. The deposit arrives proved: the SDK names no deposit circuit yet. */
60
+ export async function proveFaucet(prover, p) {
61
+ const { input, publics } = faucetPass(p);
62
+ const proved = await prover.prove("membership", input);
63
+ return faucetBody({ ...p, pass: { publics, proved } });
64
+ }
@@ -0,0 +1,5 @@
1
+ import type { FeeCommitInput, FeeLaneResult } from "./fees.ts";
2
+ import type { CircuitInput } from "./inputs.ts";
3
+ /** The input signals of `lib/fee_lane.circom` `FeeLane`. */
4
+ export declare function feeWitness(fee: FeeCommitInput, base: bigint, eph: bigint, lane: FeeLaneResult): CircuitInput;
5
+ //# sourceMappingURL=fee-witness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fee-witness.d.ts","sourceRoot":"","sources":["../../src/v3/fee-witness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,4DAA4D;AAC5D,wBAAgB,UAAU,CACxB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,aAAa,GAClB,YAAY,CAgBd"}
@@ -0,0 +1,18 @@
1
+ /** The input signals of `lib/fee_lane.circom` `FeeLane`. */
2
+ export function feeWitness(fee, base, eph, lane) {
3
+ return {
4
+ base: base.toString(),
5
+ fee_bps: fee.bps.toString(),
6
+ fee_min: fee.min.toString(),
7
+ fee_max: fee.max.toString(),
8
+ fee_pk: fee.pk.toString(),
9
+ tX: fee.tx.toString(),
10
+ tY: fee.ty.toString(),
11
+ fee_salt: fee.salt.toString(),
12
+ cfg_version: fee.version.toString(),
13
+ eph: eph.toString(),
14
+ q: lane.q.toString(),
15
+ r: lane.r.toString(),
16
+ fee_commit: lane.fee_commit.toString(),
17
+ };
18
+ }
@@ -0,0 +1,78 @@
1
+ import { MAX_FEE_BPS } from "./domains.ts";
2
+ export declare const BPS_DENOM = 10000n;
3
+ export { MAX_FEE_BPS };
4
+ export declare const SCALAR_BITS = 253n;
5
+ export type FeeRates = {
6
+ base: bigint;
7
+ bps: bigint;
8
+ min: bigint;
9
+ max: bigint;
10
+ };
11
+ export type FeeCommitInput = {
12
+ bps: bigint;
13
+ min: bigint;
14
+ max: bigint;
15
+ pk: bigint;
16
+ tx: bigint;
17
+ ty: bigint;
18
+ salt: bigint;
19
+ version: bigint;
20
+ };
21
+ export type FeeLaneInput = FeeCommitInput & {
22
+ base: bigint;
23
+ eph: bigint;
24
+ };
25
+ export type FeeOf = {
26
+ q: bigint;
27
+ r: bigint;
28
+ fee: bigint;
29
+ cap: bigint;
30
+ lo: bigint;
31
+ };
32
+ export type FeeLaneResult = FeeOf & {
33
+ fee_commit: bigint;
34
+ fee_note: bigint;
35
+ rFee: bigint;
36
+ ephX: bigint;
37
+ ephY: bigint;
38
+ sx: bigint;
39
+ sy: bigint;
40
+ fee_ct: bigint;
41
+ ctBlind: bigint;
42
+ };
43
+ export declare function assertU64(name: string, n: bigint): void;
44
+ export declare function feeOf({ base, bps, min, max }: FeeRates): FeeOf;
45
+ export declare function assertFeeConfig(bps: bigint, min: bigint, max: bigint): void;
46
+ export declare function feeCommit(input: FeeCommitInput): bigint;
47
+ export declare function fieldAdd(a: bigint, b: bigint): bigint;
48
+ export declare function feeLane(input: FeeLaneInput): Promise<FeeLaneResult>;
49
+ /**
50
+ * `circuits/v3/lib/ecdh_blind.circom` outside the fee lane: `E = e·Base8` and `S = e·Pub`, refused where that
51
+ * circuit has no witness. Health TOPUP delivers the new collateral amount to the lender through it.
52
+ */
53
+ export declare function ecdhBlind(pubX: bigint, pubY: bigint, e: bigint): Promise<{
54
+ ephX: bigint;
55
+ ephY: bigint;
56
+ sx: bigint;
57
+ }>;
58
+ export declare function treasuryPoint(scalar: bigint): Promise<{
59
+ tx: bigint;
60
+ ty: bigint;
61
+ }>;
62
+ /** The opening `POST /v3/fee-params` returns for one coin, as served: canonical decimal strings. */
63
+ export type FeeOpening = {
64
+ version: string;
65
+ feeBps: string;
66
+ feeMin: string;
67
+ feeMax: string;
68
+ feePk: string;
69
+ tX: string;
70
+ tY: string;
71
+ feeSalt: string;
72
+ };
73
+ /**
74
+ * Trusts an opening only when it hashes to the `fee_commit` read from the coin's on-chain FeeConfig,
75
+ * so the service cannot hand out parameters the chain would refuse (D §5.4).
76
+ */
77
+ export declare function verifyFeeOpening(opening: FeeOpening, onChainCommit: bigint): FeeCommitInput;
78
+ //# sourceMappingURL=fees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../src/v3/fees.ts"],"names":[],"mappings":"AAOA,OAAO,EAAuB,WAAW,EAAK,MAAM,cAAc,CAAC;AAKnE,eAAO,MAAM,SAAS,SAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,eAAO,MAAM,WAAW,OAAO,CAAC;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