@esseyonsui/sui-sdk-v3 0.0.0-stage → 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 (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 +3592 -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,57 @@
1
+ import { address } from "../../network.js";
2
+ import { ENC_BYTES } from "../kinds.js";
3
+ import { reclaimLock } from "../loans/reclaim-plan.js";
4
+ import { notePk } from "../notes/keys.js";
5
+ import { SLOTS, lock4, residualLock } from "./rows.js";
6
+ /**
7
+ * Witness for `circuits/v3/reclaim/reclaim.circom` over a sale room. Public signals, in order: hLock, residual, hCtx, N,
8
+ * hOut. The lock is rebuilt under this room's `sale_key`; a room that does not hold it is refused.
9
+ */
10
+ export async function reclaim(p) {
11
+ const { room, bid } = p;
12
+ if (p.relayerFee > 0n && BigInt(p.relayer) === 0n)
13
+ throw new Error("a relayer fee needs a relayer");
14
+ if (room.locks.length > SLOTS)
15
+ throw new Error("a room holds at most 16 bids");
16
+ if (p.encs.some((e) => e.length !== ENC_BYTES))
17
+ throw new Error("a note ciphertext is 128 bytes");
18
+ const ownerPk = notePk(bid.ownerSk);
19
+ const change = p.what === "residual";
20
+ const amount = change ? bid.amount - bid.v : bid.amount;
21
+ const own = change
22
+ ? residualLock(room.saleKey, ownerPk, bid.ns, amount)
23
+ : { nsEff: bid.ns, b: bid.b, ...lock4(room.saleKey, ownerPk, bid.ns, amount, bid.b) };
24
+ const residualSlot = own.lock === room.residual ? SLOTS : -1;
25
+ const slot = change ? residualSlot : room.locks.indexOf(own.lock);
26
+ if (slot < 0)
27
+ throw new Error("this room does not hold the lock");
28
+ if (amount < p.relayerFee)
29
+ throw new Error("the lock does not cover the relayer fee");
30
+ const w = await reclaimLock({
31
+ locks: room.locks,
32
+ slot,
33
+ field: room.saleKey,
34
+ amount,
35
+ ownerSk: bid.ownerSk,
36
+ ns: own.nsEff,
37
+ b: own.b,
38
+ out: p.out,
39
+ relayer: p.relayer,
40
+ relayerFee: p.relayerFee,
41
+ encs: p.encs,
42
+ fee: p.fee,
43
+ eph: p.eph,
44
+ residual: room.residual,
45
+ });
46
+ const statement = {
47
+ nullifier: w.n,
48
+ out_note: w.outNote,
49
+ fee_note: w.feeNote,
50
+ eph_x: w.ephX,
51
+ eph_y: w.ephY,
52
+ fee_ct: w.feeCt,
53
+ fee_commit: w.feeCommit,
54
+ relayer: address(p.relayer, "relayer"),
55
+ };
56
+ return { input: w.input, publics: w.publics, statement, outAmt: w.outAmt };
57
+ }
@@ -0,0 +1,55 @@
1
+ /** `sale_room.move` MAX_BIDS, the width of SaleSettle(16) and of Reclaim's lock rows. */
2
+ export declare const SLOTS = 16;
3
+ /** `sale_room.move` BID_BLOB_LEN. */
4
+ export declare const BID_PLAIN_BYTES = 144;
5
+ /** What a bidder keeps: it reopens the lock, the residual and the item claim. Never sent. */
6
+ export type BidSecrets = {
7
+ v: bigint;
8
+ s: bigint;
9
+ ns: bigint;
10
+ amount: bigint;
11
+ b: bigint;
12
+ ownerSk: bigint;
13
+ };
14
+ export type BidOpening = Omit<BidSecrets, "ownerSk"> & {
15
+ ownerPk: bigint;
16
+ };
17
+ export declare function padSlots(xs: bigint[]): bigint[];
18
+ /** `rows::enc_hash`, refusing a ciphertext that is not 128 bytes. */
19
+ export declare function encHash(encs: Uint8Array[]): bigint;
20
+ /** E-2, `lib/lock.circom` Lock4, with the lock's nullifier N. */
21
+ export declare function lock4(field: bigint, ownerPk: bigint, ns: bigint, amount: bigint, b: bigint): {
22
+ lock: bigint;
23
+ nullifier: bigint;
24
+ };
25
+ /** C §4.4: the winner's change, a lock whose `ns` and blinding both derive from the bid's `ns`. */
26
+ export declare function residualLock(field: bigint, ownerPk: bigint, ns: bigint, amount: bigint): {
27
+ lock: bigint;
28
+ nullifier: bigint;
29
+ nsEff: bigint;
30
+ b: bigint;
31
+ };
32
+ export declare const bidCommit: (v: bigint, s: bigint) => bigint;
33
+ export type BidExt = {
34
+ room: string;
35
+ seq: number;
36
+ relayer: string;
37
+ relayerFee: bigint;
38
+ commit: bigint;
39
+ sealed: Uint8Array;
40
+ /** `[enc_change, enc_fee]`, the order `room_lock_spend` takes them. */
41
+ encs: Uint8Array[];
42
+ };
43
+ /** `sale_room::ext_hash`: keccak256(bcs(ExtLockBid)) mod R, the digest read big-endian. */
44
+ export declare function bidExt(x: BidExt): bigint;
45
+ /** `sale_room::bid_key_id`: blake2b256("ess3/bid" ‖ bcs(sale_key) ‖ bcs(seq)), the Seal id `pin_bid` requires. */
46
+ export declare const bidKeyId: (saleKey: bigint, seq: bigint) => Uint8Array;
47
+ /** `pin_bid`'s aad: bcs(n0), the note the bid spends. */
48
+ export declare const bidAad: (n0: bigint) => Uint8Array;
49
+ /** `membership::seal_bid(room, seq, viewer).bind`, the pass `seal_approve_bid` checks. */
50
+ export declare const sealBidBind: (room: string, seq: bigint, viewer: string) => Uint8Array;
51
+ /** C §7.1 plaintext, in the order `sale_room::opens` peels it: v ‖ s ‖ ns ‖ amount ‖ b ‖ ownerPk. */
52
+ export declare function bidPlaintext(x: BidSecrets): Uint8Array;
53
+ /** `sale_room::opens`: the opening when the plaintext gives both the commit and the lock. */
54
+ export declare function openBid(plain: Uint8Array | undefined, field: bigint, commit: bigint, lock: bigint): BidOpening | undefined;
55
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/rows.ts"],"names":[],"mappings":"AAYA,yFAAyF;AACzF,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,qCAAqC;AACrC,eAAO,MAAM,eAAe,MAAM,CAAC;AAMnC,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,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ACzD,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,KAAG,UAA+C,CAAC;AAEpF,0FAA0F;AAC1F,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,UAMpE,CAAC;AAEL,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAStD;AAED,6FAA6F;AAC7F,wBAAgB,OAAO,CACrB,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAiBxB"}
@@ -0,0 +1,98 @@
1
+ import { poseidonHash } from "@mysten/sui/zklogin";
2
+ import { blake2b } from "@noble/hashes/blake2.js";
3
+ import { keccak_256 } from "@noble/hashes/sha3.js";
4
+ import { DOM_BID, DOM_LNULL, DOM_RBLIND, DOM_RESID, R } from "../domains.js";
5
+ import { ENC_BYTES } from "../kinds.js";
6
+ import { lock4 as lockOf } from "../loans/offer-plan.js";
7
+ import { encHash as loanEncHash } from "../loans/reclaim-plan.js";
8
+ import { notePk } from "../notes/keys.js";
9
+ import { addressBytes, bcsBytes, le } from "./bcs.js";
10
+ /** `sale_room.move` MAX_BIDS, the width of SaleSettle(16) and of Reclaim's lock rows. */
11
+ export const SLOTS = 16;
12
+ /** `sale_room.move` BID_BLOB_LEN. */
13
+ export const BID_PLAIN_BYTES = 144;
14
+ const SBID_TAG = Buffer.from("ess3/sbid/", "ascii");
15
+ /** `sale_room.move` FIRST_BID_PAIRS: the first bid also reserves settlement's pair and the residual's. */
16
+ const FIRST_BID_PAIRS = 3;
17
+ const keccakModR = (bytes) => BigInt(`0x${Buffer.from(keccak_256(Uint8Array.from(bytes))).toString("hex")}`) % R;
18
+ export function padSlots(xs) {
19
+ if (xs.length > SLOTS)
20
+ throw new Error("a room holds at most 16 bids");
21
+ return Array.from({ length: SLOTS }, (_, i) => xs[i] ?? 0n);
22
+ }
23
+ /** `rows::enc_hash`, refusing a ciphertext that is not 128 bytes. */
24
+ export function encHash(encs) {
25
+ if (encs.some((e) => e.length !== ENC_BYTES))
26
+ throw new Error("a note ciphertext is 128 bytes");
27
+ return loanEncHash(encs);
28
+ }
29
+ /** E-2, `lib/lock.circom` Lock4, with the lock's nullifier N. */
30
+ export function lock4(field, ownerPk, ns, amount, b) {
31
+ const lock = lockOf(field, ownerPk, ns, amount, b);
32
+ return { lock, nullifier: poseidonHash([DOM_LNULL, ns, lock]) };
33
+ }
34
+ /** C §4.4: the winner's change, a lock whose `ns` and blinding both derive from the bid's `ns`. */
35
+ export function residualLock(field, ownerPk, ns, amount) {
36
+ const nsEff = poseidonHash([DOM_RESID, ns]);
37
+ const b = poseidonHash([DOM_RBLIND, ns]);
38
+ return { nsEff, b, ...lock4(field, ownerPk, nsEff, amount, b) };
39
+ }
40
+ export const bidCommit = (v, s) => poseidonHash([DOM_BID, v, s]);
41
+ /** `sale_room::ext_hash`: keccak256(bcs(ExtLockBid)) mod R, the digest read big-endian. */
42
+ export function bidExt(x) {
43
+ return keccakModR([
44
+ ...bcsBytes(SBID_TAG),
45
+ ...addressBytes(x.room, "room"),
46
+ ...le(BigInt(x.seq), 8, "seq"),
47
+ ...addressBytes(x.relayer, "relayer"),
48
+ ...le(x.relayerFee, 8, "relayerFee"),
49
+ x.seq === 0 ? FIRST_BID_PAIRS : 1,
50
+ ...le(x.commit, 32, "commit"),
51
+ ...bcsBytes(blake2b(x.sealed, { dkLen: 32 })),
52
+ ...le(encHash(x.encs), 32, "encHash"),
53
+ ]);
54
+ }
55
+ const blake = (bytes) => blake2b(Uint8Array.from(bytes), { dkLen: 32 });
56
+ /** `sale_room::bid_key_id`: blake2b256("ess3/bid" ‖ bcs(sale_key) ‖ bcs(seq)), the Seal id `pin_bid` requires. */
57
+ export const bidKeyId = (saleKey, seq) => blake([...Buffer.from("ess3/bid", "ascii"), ...le(saleKey, 32, "saleKey"), ...le(seq, 8, "seq")]);
58
+ /** `pin_bid`'s aad: bcs(n0), the note the bid spends. */
59
+ export const bidAad = (n0) => Uint8Array.from(le(n0, 32, "n0"));
60
+ /** `membership::seal_bid(room, seq, viewer).bind`, the pass `seal_approve_bid` checks. */
61
+ export const sealBidBind = (room, seq, viewer) => blake([
62
+ ...Buffer.from("essey-v3/seal/bid", "ascii"),
63
+ ...addressBytes(room, "room"),
64
+ ...le(seq, 8, "seq"),
65
+ ...addressBytes(viewer, "viewer"),
66
+ ]);
67
+ /** C §7.1 plaintext, in the order `sale_room::opens` peels it: v ‖ s ‖ ns ‖ amount ‖ b ‖ ownerPk. */
68
+ export function bidPlaintext(x) {
69
+ return Uint8Array.from([
70
+ ...le(x.v, 8, "v"),
71
+ ...le(x.s, 32, "s"),
72
+ ...le(x.ns, 32, "ns"),
73
+ ...le(x.amount, 8, "amount"),
74
+ ...le(x.b, 32, "b"),
75
+ ...le(notePk(x.ownerSk), 32, "ownerPk"),
76
+ ]);
77
+ }
78
+ /** `sale_room::opens`: the opening when the plaintext gives both the commit and the lock. */
79
+ export function openBid(plain, field, commit, lock) {
80
+ if (plain?.length !== BID_PLAIN_BYTES)
81
+ return undefined;
82
+ const at = (from, size) => {
83
+ const be = Buffer.from(plain.subarray(from, from + size)).reverse();
84
+ return BigInt(`0x${be.toString("hex")}`);
85
+ };
86
+ const o = {
87
+ v: at(0, 8),
88
+ s: at(8, 32),
89
+ ns: at(40, 32),
90
+ amount: at(72, 8),
91
+ b: at(80, 32),
92
+ ownerPk: at(112, 32),
93
+ };
94
+ if ([o.s, o.ns, o.b, o.ownerPk].some((x) => x >= R))
95
+ return undefined;
96
+ const opens = bidCommit(o.v, o.s) === commit && lock4(field, o.ownerPk, o.ns, o.amount, o.b).lock === lock;
97
+ return opens ? o : undefined;
98
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `std::type_name::with_original_ids<T>()` of a non-generic struct tag: 64 hex digits, no `0x`. The tag must name
3
+ * the package's original id, which `keys::allow_item` keys on too.
4
+ */
5
+ export declare function typeNameOf(tag: string): string;
6
+ /** What `sale_room::open` stores and the item it takes. No listing: none is sealed until a listing encryptor exists. */
7
+ export type OpenArgs = {
8
+ saleKey: bigint;
9
+ /** The `Pool<C>` object. */
10
+ pool: string;
11
+ item: {
12
+ id: string;
13
+ typeName: string;
14
+ };
15
+ sellerCommit: bigint;
16
+ sellerItemFallback: bigint;
17
+ boundsCommit: bigint;
18
+ closeMs: bigint;
19
+ finishByMs: bigint;
20
+ maxBids: number;
21
+ };
22
+ /** `sale_room::open` aborts 44_005 or 44_032 outside this window (`sale_room.move:171-174`). */
23
+ export declare function assertFinishWindow(closeMs: bigint, finishByMs: bigint): void;
24
+ /** `sale_room::open_args` (`sale_room.move:545-566`) with a `none` listing, which hashes as `b""`. */
25
+ export declare function openArgs(p: OpenArgs): Uint8Array;
26
+ /** The three commits `sale_room::open` stores (C §4: sellerCommit, sellerItemFallback, boundsCommit). */
27
+ export declare function openCommits(s: {
28
+ sellerSk: bigint;
29
+ sellerSecret: bigint;
30
+ boundsSalt: bigint;
31
+ }, bounds: {
32
+ lo: bigint;
33
+ hi: bigint;
34
+ }): {
35
+ sellerCommit: bigint;
36
+ sellerItemFallback: bigint;
37
+ boundsCommit: bigint;
38
+ };
39
+ //# sourceMappingURL=seller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seller.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/seller.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED,wHAAwH;AACxH,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAK5E;AAED,sGAAsG;AACtG,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,UAAU,CAwBhD;AAED,yGAAyG;AACzG,wBAAgB,WAAW,CACzB,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACjE,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;;;;EAQnC"}
@@ -0,0 +1,67 @@
1
+ import { poseidonHash } from "@mysten/sui/zklogin";
2
+ import { blake2b } from "@noble/hashes/blake2.js";
3
+ import { DOM_BOUNDS, DOM_SELLER, R } from "../domains.js";
4
+ import { notePk } from "../notes/keys.js";
5
+ import { addressBytes, bcsBytes, le } from "./bcs.js";
6
+ import { fallbackSalt, itemClaimCommit } from "./claim.js";
7
+ import { SLOTS } from "./rows.js";
8
+ /** `sale_room.move` MIN_FINISH_WINDOW_MS and MAX_FINISH_WINDOW_MS. */
9
+ const MIN_FINISH_WINDOW_MS = 1800000n;
10
+ const MAX_FINISH_WINDOW_MS = 30n * 86400000n;
11
+ const STRUCT_TAG = /^0x([0-9a-fA-F]{1,64})(::[A-Za-z_][A-Za-z0-9_]*){2}$/;
12
+ const ascii = (text) => [...Buffer.from(text, "ascii")];
13
+ const EMPTY_BLAKE = blake2b(new Uint8Array(), { dkLen: 32 });
14
+ /**
15
+ * `std::type_name::with_original_ids<T>()` of a non-generic struct tag: 64 hex digits, no `0x`. The tag must name
16
+ * the package's original id, which `keys::allow_item` keys on too.
17
+ */
18
+ export function typeNameOf(tag) {
19
+ const m = STRUCT_TAG.exec(tag);
20
+ if (!m)
21
+ throw new Error("item type is not a non-generic struct tag");
22
+ return `${m[1].toLowerCase().padStart(64, "0")}${tag.slice(2 + m[1].length)}`;
23
+ }
24
+ /** `sale_room::open` aborts 44_005 or 44_032 outside this window (`sale_room.move:171-174`). */
25
+ export function assertFinishWindow(closeMs, finishByMs) {
26
+ if (finishByMs < closeMs + MIN_FINISH_WINDOW_MS)
27
+ throw new Error("finishByMs is less than 30 minutes after closeMs");
28
+ if (finishByMs - closeMs > MAX_FINISH_WINDOW_MS)
29
+ throw new Error("finishByMs is more than 30 days after closeMs");
30
+ }
31
+ /** `sale_room::open_args` (`sale_room.move:545-566`) with a `none` listing, which hashes as `b""`. */
32
+ export function openArgs(p) {
33
+ if (p.saleKey <= 0n || p.saleKey >= R)
34
+ throw new Error("saleKey is not a sale key");
35
+ for (const [what, x] of Object.entries({
36
+ sellerCommit: p.sellerCommit,
37
+ sellerItemFallback: p.sellerItemFallback,
38
+ boundsCommit: p.boundsCommit,
39
+ }))
40
+ if (x < 0n || x >= R)
41
+ throw new Error(`${what} is not a field element`);
42
+ if (!Number.isInteger(p.maxBids) || p.maxBids < 1 || p.maxBids > SLOTS)
43
+ throw new Error("maxBids is not 1 to 16");
44
+ assertFinishWindow(p.closeMs, p.finishByMs);
45
+ return Uint8Array.from([
46
+ ...le(p.saleKey, 32, "saleKey"),
47
+ ...addressBytes(p.pool, "pool"),
48
+ ...le(p.sellerCommit, 32, "sellerCommit"),
49
+ ...le(p.sellerItemFallback, 32, "sellerItemFallback"),
50
+ ...le(p.boundsCommit, 32, "boundsCommit"),
51
+ ...EMPTY_BLAKE,
52
+ ...le(p.closeMs, 8, "closeMs"),
53
+ ...le(p.finishByMs, 8, "finishByMs"),
54
+ ...le(BigInt(p.maxBids), 8, "maxBids"),
55
+ ...addressBytes(p.item.id, "item"),
56
+ ...bcsBytes(Uint8Array.from(ascii(p.item.typeName))),
57
+ ]);
58
+ }
59
+ /** The three commits `sale_room::open` stores (C §4: sellerCommit, sellerItemFallback, boundsCommit). */
60
+ export function openCommits(s, bounds) {
61
+ const sellerPk = notePk(s.sellerSk);
62
+ return {
63
+ sellerCommit: poseidonHash([DOM_SELLER, sellerPk, poseidonHash([s.sellerSecret])]),
64
+ sellerItemFallback: itemClaimCommit(sellerPk, fallbackSalt(s.sellerSecret)),
65
+ boundsCommit: poseidonHash([DOM_BOUNDS, bounds.lo, bounds.hi, s.boundsSalt]),
66
+ };
67
+ }
@@ -0,0 +1,204 @@
1
+ import { type CoinKey, type V3Config } from "../config.ts";
2
+ import { afterPage, MAX_LIST_PAGES } from "./collateral/scan.ts";
3
+ export { afterPage, MAX_LIST_PAGES };
4
+ import { type CollOpening, type ReqOpening } from "./collateral/openings.ts";
5
+ import type { KeeperTerms } from "./keeper-payload.ts";
6
+ import type { Reading } from "./collateral/math.ts";
7
+ import { type PoolEvents } from "./notes/scan.ts";
8
+ /**
9
+ * D-SPEC §6.2 public reads and the arguments of its open calls
10
+ * (`v3/docs/specs/D-SPEC.md:563-611`). Stage 1 is the three flows that section
11
+ * names before keeper and the later loan verbs: shielded-pool notes (`:578-586`),
12
+ * sealed sale rooms and the credential that gates them (`:572-574`, `:598-604`),
13
+ * and loans (`:587-589`).
14
+ *
15
+ * Pool open/list/view sit on the notes SDK (V3-124): `openOpening` plus the
16
+ * commitment check in `ownNotes`. Loan open submits the body `v3.loans.open`
17
+ * already builds (V3-050). Sale open is the sponsored edge, not a relay kind,
18
+ * so it checks these arguments and does not invent an envelope.
19
+ */
20
+ /** D-SPEC §6.2:582. A note this seed can spend. No spend key, blinding, or ciphertext. */
21
+ export type PoolPosition = {
22
+ coin: CoinKey;
23
+ index: number;
24
+ value: bigint;
25
+ };
26
+ /** D-SPEC §6.2:582. The same position plus the on-chain commitment it was checked against. */
27
+ export type PoolView = PoolPosition & {
28
+ commitment: bigint;
29
+ };
30
+ /** D-SPEC §6.2:588. Public fields of a loan request. Amounts stay inside `view`. */
31
+ export type OpenRequest = {
32
+ id: string;
33
+ state: number;
34
+ round: bigint;
35
+ /** From the current `Round`. Null when that dynamic field was not supplied. */
36
+ closeMs: bigint | null;
37
+ offers: number | null;
38
+ loanCoin: CoinKey;
39
+ collateralCoin: CoinKey;
40
+ };
41
+ /**
42
+ * D-SPEC §6.2:589. `lifecycle` is the loan's state (`loan.move:26-34`).
43
+ * `opened` is `request` while that state still keeps the bid in `req_commit`
44
+ * (`loan.move:193`, `request.move:35-56`) and `terms` once `activate` has written `terms_commit` (`loan.move:458-470`).
45
+ */
46
+ export declare const LOAN_LIFECYCLE: readonly ["draft", "bidding", "active", "repaid", "liquidated", "defaulted", "closed", "cancelled", "refi"];
47
+ export type LoanLifecycle = (typeof LOAN_LIFECYCLE)[number];
48
+ export type MyLoanView = OpenRequest & {
49
+ lifecycle: LoanLifecycle;
50
+ opened: "request" | "terms" | "both" | "public";
51
+ covered: boolean;
52
+ ltvBps: bigint | null;
53
+ /** Null when this view did not open an amount. A missing opening is not a healthy loan. */
54
+ underwater: boolean | null;
55
+ liquidationPrice: bigint | null;
56
+ bestBucketK: number | null;
57
+ request: {
58
+ principal: bigint;
59
+ maxRateBps: bigint;
60
+ termMs: bigint;
61
+ } | null;
62
+ terms: {
63
+ principal: bigint;
64
+ rateBps: bigint;
65
+ owed: bigint;
66
+ maturityS: bigint;
67
+ } | null;
68
+ };
69
+ /** D-SPEC §6.2:588. */
70
+ export type LoanOpenParams = {
71
+ loanCoin: CoinKey;
72
+ principal: bigint;
73
+ collateralCoin: CoinKey;
74
+ collateral: bigint;
75
+ maxRateBps: number;
76
+ termMs: number;
77
+ offerWindowMs: number;
78
+ };
79
+ /**
80
+ * What `view` checks. A bidding loan carries `request` (`health.circom:238-244`).
81
+ * An active loan carries `terms` (`health.circom:229-237`). The salt is not returned.
82
+ */
83
+ export type LoanOpening = {
84
+ borrowerPk: bigint;
85
+ collateral: CollOpening;
86
+ request?: ReqOpening;
87
+ terms?: KeeperTerms;
88
+ };
89
+ /** D-SPEC §6.2:600. Public fields of a sealed sale room. */
90
+ export type OpenSale = {
91
+ id: string;
92
+ coin: CoinKey;
93
+ state: number;
94
+ closeMs: bigint;
95
+ bids: number;
96
+ };
97
+ /** D-SPEC §6.2:600. Prices are set only when the caller's bounds open `bounds_commit`. */
98
+ export type MySaleView = OpenSale & {
99
+ finishByMs: bigint;
100
+ maxBids: bigint;
101
+ minPrice: bigint | null;
102
+ maxPrice: bigint | null;
103
+ };
104
+ /** D-SPEC §6.2:599. */
105
+ export type SaleOpenParams = {
106
+ itemId: string;
107
+ itemType: string;
108
+ coin: CoinKey;
109
+ minPrice: bigint;
110
+ maxPrice: bigint;
111
+ closeMs: number;
112
+ finishWindowMs: number;
113
+ maxBids: number;
114
+ /** Absent: the relayer pays when one with an address is set up, else `submitSaleOpen` does. */
115
+ sponsored?: boolean;
116
+ };
117
+ /** The public numbers `essey_loan_view` already collects. MCP calls `publicLoanStatus` instead of recomputing them. */
118
+ export type PublicLoanView = {
119
+ id: string;
120
+ state: number;
121
+ collateral: bigint;
122
+ owed: bigint;
123
+ cDec: bigint;
124
+ lDec: bigint;
125
+ liqBps: bigint;
126
+ spot: bigint;
127
+ ema: bigint;
128
+ expo: bigint;
129
+ floorPrice: bigint;
130
+ floorExpo: number;
131
+ hbExpiryMs: bigint;
132
+ nonce: bigint;
133
+ nowMs: bigint;
134
+ };
135
+ export type PublicLoanStatus = {
136
+ id: string;
137
+ state: number;
138
+ covered: boolean;
139
+ ltvBps: string | null;
140
+ underwater: boolean;
141
+ liquidationPrice: string | null;
142
+ bestBucketK: number | null;
143
+ };
144
+ export declare function assertCoin(coin: unknown): asserts coin is CoinKey;
145
+ /** The deployment record's pool id for `coin`. Null until setup fills it (`deployments/essey-v3.testnet.json`). */
146
+ export declare function poolId(config: V3Config, coin: CoinKey): string;
147
+ export declare function coinByPool(config: V3Config, pool: string): CoinKey;
148
+ export declare function requireSale(config: V3Config): void;
149
+ /** C-SPEC (`v3/docs/specs/C-SPEC.md:179`): Poseidon4(DOM_BOUNDS, lo, hi, boundsSalt). */
150
+ export declare function boundsCommit(lo: bigint, hi: bigint, salt: bigint): bigint;
151
+ /** D-SPEC §6.2:582. Opens one ciphertext. A commitment that does not rebuild is tampered. */
152
+ export declare function openPosition(coin: CoinKey, index: number, events: PoolEvents, seed: Uint8Array): PoolPosition;
153
+ /** D-SPEC §6.2:582. The same open, plus the commitment the chain published. */
154
+ export declare function viewPosition(coin: CoinKey, index: number, events: PoolEvents, seed: Uint8Array): PoolView;
155
+ /** D-SPEC §6.2:582. Every unspent note `ownNotes` keeps. A leaf that does not open is not listed. */
156
+ export declare function listPositions(coin: CoinKey, events: PoolEvents, seed: Uint8Array): PoolPosition[];
157
+ /** D-SPEC §6.2:589. Public columns only. */
158
+ export declare function summarizeLoan(config: V3Config, row: {
159
+ id: string;
160
+ json: unknown;
161
+ round?: unknown;
162
+ }): OpenRequest;
163
+ /** D-SPEC §6.2:589. Each opening field is copied once; the hash and the result are that copy. */
164
+ export declare function viewLoanObject(config: V3Config, row: {
165
+ id: string;
166
+ json: unknown;
167
+ round?: unknown;
168
+ }, o: {
169
+ reading: Reading;
170
+ nowMs: bigint;
171
+ opening: LoanOpening | null;
172
+ }): MyLoanView;
173
+ /** D-SPEC §6.2:600. */
174
+ export declare function summarizeRoom(config: V3Config, row: {
175
+ id: string;
176
+ json: unknown;
177
+ }): OpenSale;
178
+ /** D-SPEC §6.2:600. A bounds opening that misses `bounds_commit` is tampered (`C-SPEC.md:179`). */
179
+ export declare function viewRoomObject(config: V3Config, row: {
180
+ id: string;
181
+ json: unknown;
182
+ }, bounds: {
183
+ lo: bigint;
184
+ hi: bigint;
185
+ salt: bigint;
186
+ } | null): MySaleView;
187
+ /** D-SPEC §6.2:588. Refuses before any envelope is built. */
188
+ export declare function assertLoanOpen(p: LoanOpenParams): void;
189
+ /** D-SPEC §6.2:599. Copies each argument once. `maxBids` is `sale_room.move`'s 1..16. */
190
+ export declare function assertSaleOpen(p: SaleOpenParams): SaleOpenParams;
191
+ /**
192
+ * The room the sponsor named is this open: same coin pool, close, finish window and max bids
193
+ * (`sale_room.move:181-193`).
194
+ */
195
+ export declare function assertRoomMatches(config: V3Config, open: SaleOpenParams, row: {
196
+ id: string;
197
+ json: unknown;
198
+ }): void;
199
+ /**
200
+ * The health verdict `packages/mcp-v3` used to compute itself.
201
+ * D-SPEC §6.2:589 and §7.2 `essey_loan_view` (`D-SPEC.md:672`). Amounts stay decimal strings.
202
+ */
203
+ export declare function publicLoanStatus(loan: PublicLoanView): PublicLoanStatus;
204
+ //# sourceMappingURL=stage1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage1.d.ts","sourceRoot":"","sources":["../../src/v3/stage1.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAW,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;AAErC,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;;;;;;;GAWG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,8FAA8F;AAC9F,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CA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