@esseyonsui/sui-sdk-v3 0.3.2 → 0.4.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 (134) hide show
  1. package/dist/config.d.ts +3 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -0
  4. package/dist/errors.d.ts +3 -1
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/errors.js +5 -0
  7. package/dist/essey.d.ts +157 -131
  8. package/dist/essey.d.ts.map +1 -1
  9. package/dist/essey.js +641 -823
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/network.d.ts +2 -0
  14. package/dist/network.d.ts.map +1 -1
  15. package/dist/network.js +17 -3
  16. package/dist/v3/collateral/bodies.d.ts +23 -14
  17. package/dist/v3/collateral/bodies.d.ts.map +1 -1
  18. package/dist/v3/collateral/bodies.js +42 -35
  19. package/dist/v3/collateral/ext.d.ts +18 -13
  20. package/dist/v3/collateral/ext.d.ts.map +1 -1
  21. package/dist/v3/collateral/ext.js +5 -6
  22. package/dist/v3/collateral/health.d.ts +16 -10
  23. package/dist/v3/collateral/health.d.ts.map +1 -1
  24. package/dist/v3/collateral/health.js +55 -30
  25. package/dist/v3/collateral/math.d.ts +0 -2
  26. package/dist/v3/collateral/math.d.ts.map +1 -1
  27. package/dist/v3/collateral/math.js +0 -5
  28. package/dist/v3/collateral/openings.d.ts +5 -1
  29. package/dist/v3/collateral/openings.d.ts.map +1 -1
  30. package/dist/v3/collateral/openings.js +7 -12
  31. package/dist/v3/credential/membership.d.ts +16 -2
  32. package/dist/v3/credential/membership.d.ts.map +1 -1
  33. package/dist/v3/credential/membership.js +36 -3
  34. package/dist/v3/domains.d.ts +9 -0
  35. package/dist/v3/domains.d.ts.map +1 -1
  36. package/dist/v3/domains.js +5 -0
  37. package/dist/v3/fees.d.ts +13 -1
  38. package/dist/v3/fees.d.ts.map +1 -1
  39. package/dist/v3/fees.js +32 -2
  40. package/dist/v3/funds.d.ts +34 -0
  41. package/dist/v3/funds.d.ts.map +1 -0
  42. package/dist/v3/funds.js +60 -0
  43. package/dist/v3/keeper-payload.d.ts +29 -7
  44. package/dist/v3/keeper-payload.d.ts.map +1 -1
  45. package/dist/v3/keeper-payload.js +33 -22
  46. package/dist/v3/kinds.d.ts +6 -6
  47. package/dist/v3/kinds.d.ts.map +1 -1
  48. package/dist/v3/kinds.js +5 -13
  49. package/dist/v3/loans/bodies.d.ts +40 -68
  50. package/dist/v3/loans/bodies.d.ts.map +1 -1
  51. package/dist/v3/loans/bodies.js +50 -73
  52. package/dist/v3/loans/offer-payload.d.ts +109 -0
  53. package/dist/v3/loans/offer-payload.d.ts.map +1 -0
  54. package/dist/v3/loans/offer-payload.js +207 -0
  55. package/dist/v3/loans/offer-plan.d.ts +8 -60
  56. package/dist/v3/loans/offer-plan.d.ts.map +1 -1
  57. package/dist/v3/loans/offer-plan.js +19 -95
  58. package/dist/v3/loans/open-plan.d.ts +15 -5
  59. package/dist/v3/loans/open-plan.d.ts.map +1 -1
  60. package/dist/v3/loans/open-plan.js +18 -7
  61. package/dist/v3/loans/reclaim-plan.d.ts +31 -15
  62. package/dist/v3/loans/reclaim-plan.d.ts.map +1 -1
  63. package/dist/v3/loans/reclaim-plan.js +63 -32
  64. package/dist/v3/loans/refi-plan.d.ts +8 -34
  65. package/dist/v3/loans/refi-plan.d.ts.map +1 -1
  66. package/dist/v3/loans/refi-plan.js +30 -111
  67. package/dist/v3/loans/repay-plan.d.ts.map +1 -1
  68. package/dist/v3/loans/repay-plan.js +2 -2
  69. package/dist/v3/loans/settle-plan.d.ts +88 -53
  70. package/dist/v3/loans/settle-plan.d.ts.map +1 -1
  71. package/dist/v3/loans/settle-plan.js +141 -150
  72. package/dist/v3/locks.d.ts +21 -0
  73. package/dist/v3/locks.d.ts.map +1 -0
  74. package/dist/v3/locks.js +15 -0
  75. package/dist/v3/memo.d.ts +14 -4
  76. package/dist/v3/memo.d.ts.map +1 -1
  77. package/dist/v3/memo.js +14 -7
  78. package/dist/v3/notes/derive.d.ts +5 -0
  79. package/dist/v3/notes/derive.d.ts.map +1 -1
  80. package/dist/v3/notes/derive.js +5 -0
  81. package/dist/v3/pace.d.ts +0 -1
  82. package/dist/v3/pace.d.ts.map +1 -1
  83. package/dist/v3/pace.js +0 -1
  84. package/dist/v3/pads.d.ts +15 -0
  85. package/dist/v3/pads.d.ts.map +1 -0
  86. package/dist/v3/pads.js +25 -0
  87. package/dist/v3/prover.d.ts +1 -1
  88. package/dist/v3/prover.d.ts.map +1 -1
  89. package/dist/v3/prover.js +1 -0
  90. package/dist/v3/relay/client.d.ts.map +1 -1
  91. package/dist/v3/relay/client.js +2 -2
  92. package/dist/v3/sales/auctioneer.d.ts +32 -27
  93. package/dist/v3/sales/auctioneer.d.ts.map +1 -1
  94. package/dist/v3/sales/auctioneer.js +67 -108
  95. package/dist/v3/sales/bid.d.ts +20 -49
  96. package/dist/v3/sales/bid.d.ts.map +1 -1
  97. package/dist/v3/sales/bid.js +28 -83
  98. package/dist/v3/sales/bodies.d.ts +4 -54
  99. package/dist/v3/sales/bodies.d.ts.map +1 -1
  100. package/dist/v3/sales/bodies.js +10 -52
  101. package/dist/v3/sales/claim.d.ts +0 -2
  102. package/dist/v3/sales/claim.d.ts.map +1 -1
  103. package/dist/v3/sales/claim.js +6 -8
  104. package/dist/v3/sales/index.d.ts +0 -1
  105. package/dist/v3/sales/index.d.ts.map +1 -1
  106. package/dist/v3/sales/index.js +0 -1
  107. package/dist/v3/sales/listing.d.ts +8 -6
  108. package/dist/v3/sales/listing.d.ts.map +1 -1
  109. package/dist/v3/sales/listing.js +27 -9
  110. package/dist/v3/sales/open-kind.d.ts +1 -3
  111. package/dist/v3/sales/open-kind.d.ts.map +1 -1
  112. package/dist/v3/sales/open-kind.js +2 -3
  113. package/dist/v3/sales/outcome.d.ts +5 -8
  114. package/dist/v3/sales/outcome.d.ts.map +1 -1
  115. package/dist/v3/sales/outcome.js +5 -9
  116. package/dist/v3/sales/package-gate.d.ts +3 -4
  117. package/dist/v3/sales/package-gate.d.ts.map +1 -1
  118. package/dist/v3/sales/package-gate.js +9 -7
  119. package/dist/v3/sales/rows.d.ts +9 -49
  120. package/dist/v3/sales/rows.d.ts.map +1 -1
  121. package/dist/v3/sales/rows.js +17 -91
  122. package/dist/v3/sales/seller.d.ts +2 -6
  123. package/dist/v3/sales/seller.d.ts.map +1 -1
  124. package/dist/v3/sales/seller.js +4 -11
  125. package/dist/v3/stage1.d.ts +8 -21
  126. package/dist/v3/stage1.d.ts.map +1 -1
  127. package/dist/v3/stage1.js +8 -76
  128. package/package.json +1 -1
  129. package/dist/v3/loans/lock-round.d.ts +0 -22
  130. package/dist/v3/loans/lock-round.d.ts.map +0 -1
  131. package/dist/v3/loans/lock-round.js +0 -20
  132. package/dist/v3/sales/reclaim.d.ts +0 -46
  133. package/dist/v3/sales/reclaim.d.ts.map +0 -1
  134. package/dist/v3/sales/reclaim.js +0 -57
@@ -1 +1 @@
1
- {"version":3,"file":"prover.d.ts","sourceRoot":"","sources":["../../src/v3/prover.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,uEAAuE;AACvE,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAE/D,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrF,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,KAAK,C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MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACjD,MAAM,CAcR"}
package/dist/v3/prover.js CHANGED
@@ -35,6 +35,7 @@ export const SDK_CIRCUITS = [
35
35
  "lock_bid",
36
36
  "sale_settle",
37
37
  "item_claim",
38
+ "funds_read",
38
39
  ];
39
40
  function pinnedFile(value, what) {
40
41
  const row = value;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/v3/relay/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAiC,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACxD,MAAM,MAAM,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACvD,qHAAqH;AACrH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,KAAK,KAAK,GAAG,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAEjD,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC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AAC,QAAQ,CAAC,KAAK,CAAQ;gBAElB,CAAC,EAAE,kBAAkB;IAK3B,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAOlC,mFAAmF;IAC7E,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IASjD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAenD"}
@@ -1,5 +1,5 @@
1
1
  import { EsseyError } from "../../errors.js";
2
- import { getJson, postJson, serviceUrl } from "../../network.js";
2
+ import { getJson, postJson, serviceUrl, submitJson } from "../../network.js";
3
3
  const TICKET = /^t_[0-9a-f]{32}$/;
4
4
  const STATES = new Set(["queued", "landed", "failed", "expired"]);
5
5
  const abortOf = (abort) => abort && typeof abort === "object" ? abort : undefined;
@@ -37,7 +37,7 @@ export class RelayClient {
37
37
  }
38
38
  /** 200 is a landed transaction, 202 a queued one whose ticket `status` follows. */
39
39
  async submit(body) {
40
- const reply = await postJson(this.fetch, `${this.base}/v3/relay`, body);
40
+ const reply = await submitJson(this.fetch, `${this.base}/v3/relay`, body);
41
41
  const { ok, digest, ticket, etaMs } = reply.body;
42
42
  if (ok !== true || typeof ticket !== "string" || !TICKET.test(ticket))
43
43
  throw refusal(reply);
@@ -1,58 +1,63 @@
1
1
  import { type FeeCommitInput } from "../fees.ts";
2
2
  import type { CircuitInput } from "../inputs.ts";
3
3
  export type PlanParams = {
4
- /** `SaleRoom` as read from chain: its `sale_key`, both commits, and each `BidEntry` in seq order. */
4
+ /** `SaleRoom` as read from chain. */
5
5
  room: {
6
6
  saleKey: bigint;
7
- boundsCommit: bigint;
7
+ postedCommit: bigint;
8
8
  sellerCommit: bigint;
9
- bids: {
10
- commit: bigint;
11
- lock: bigint;
12
- active: boolean;
13
- }[];
14
- /**
15
- * `SaleRoom.pick`: `finish` opens that slot alone (`sale_room.move:712-716`). `null` with no active bid is the
16
- * no-winner finish. `"legacy"` is a room of a previous sale package, whose `finish` opens every active bid.
17
- */
18
- pick: number | null | "legacy";
19
9
  };
20
- /** The decrypted sealed bid of each seq; absent where decryption gave nothing. Only the pick's is read. */
21
- plains: (Uint8Array | undefined)[];
10
+ /** The posted price and its salt `s*`, which open `posted_commit`. */
11
+ price: bigint;
12
+ postSalt: bigint;
22
13
  seller: {
23
14
  sellerSk: bigint;
24
15
  sellerSecret: bigint;
25
16
  };
26
- bounds: {
27
- lo: bigint;
28
- hi: bigint;
29
- salt: bigint;
17
+ /** One bid lock the seller's scan opened (`offer-payload.ts` scanLocks with `bidOpen`). */
18
+ bid: {
19
+ ownerPk: bigint;
20
+ ns: bigint;
21
+ b: bigint;
22
+ amount: bigint;
23
+ unlockS: bigint;
30
24
  };
31
- /** `[seller note, fee note]`, the order `finish` hands `room_insert`. */
32
- encs: [Uint8Array, Uint8Array];
25
+ lock: {
26
+ root: bigint;
27
+ index: bigint;
28
+ path: bigint[];
29
+ };
30
+ pad: {
31
+ pk: bigint;
32
+ blinding: bigint;
33
+ };
34
+ dummySeed: bigint;
35
+ /** `[seller note, fee note, change, pad]`, the order `finish` hands `room_apply`. */
36
+ encs: Uint8Array[];
33
37
  fee: FeeCommitInput;
34
38
  eph: bigint;
35
39
  };
36
40
  /** The `u256` arguments of `sale_room::finish`, under Move's own names and in its order. */
37
41
  export type SettleStatement = {
42
+ root: bigint;
43
+ n_lock: bigint;
44
+ n_dummy: bigint;
38
45
  seller_out: bigint;
39
46
  fee_out: bigint;
40
- residual: bigint;
47
+ change: bigint;
41
48
  item_claim: bigint;
42
- win_null: bigint;
49
+ pad: bigint;
43
50
  eph_x: bigint;
44
51
  eph_y: bigint;
45
52
  fee_ct: bigint;
46
53
  fee_commit: bigint;
47
54
  };
48
55
  /**
49
- * Witness for `circuits/v3/sale_settle/sale_settle.circom`. Public signals, in order: hSet, hLock, hCtx, hOut.
50
- * `slash` lists the opened bids whose plaintext does not open their commit and lock: the pick, or in a legacy room
51
- * any active bid, which the witness then leaves out of the mask. Either way it proves only once each is slashed.
52
- * hCtx carries relayer `NO_ADDRESS` and fee 0, the only pair `sale_room::finish` rebuilds.
56
+ * Witness for `circuits/v3/sale_settle/sale_settle.circom` (Z1 freeze §3.5). Public signals, in order: root, nLock,
57
+ * nDummy, hCtx, hOut. hCtx carries relayer `NO_ADDRESS` and fee 0, the only pair `sale_room::finish` rebuilds. The
58
+ * buyer's change is a note under its bid key with a blind only its `ns` opens, so the seller cannot spend it.
53
59
  */
54
60
  export declare function plan(p: PlanParams): Promise<{
55
- slash: number[];
56
61
  input: CircuitInput;
57
62
  publics: bigint[];
58
63
  statement: SettleStatement;
@@ -1 +1 @@
1
- {"version":3,"file":"auctioneer.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/auctioneer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAUjD,MAAM,MAAM,UAAU,GAAG;IACvB,qGAAqG;IACrG,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;QAC1D;;;WAGG;QACH,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;KAChC,CAAC;IACF,2GAA2G;IAC3G,MAAM,EAAE,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC;IACnC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAA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C;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,+EAA+E;IAC/E,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD,CAAC,CA4ED"}
@@ -1,107 +1,70 @@
1
1
  import { poseidonHash } from "@mysten/sui/zklogin";
2
2
  import { addrField } from "../addr-field.js";
3
- import { DOM_BOUNDS, DOM_DUMMY, DOM_LNULL, DOM_SBLIND, DOM_SELLER } from "../domains.js";
3
+ import { DOM_RBLIND, DOM_SBLIND, DOM_SELLER } from "../domains.js";
4
4
  import { NO_ADDRESS } from "../ext.js";
5
5
  import { feeWitness } from "../fee-witness.js";
6
- import { feeLane } from "../fees.js";
6
+ import { flatFeeLane, minHiddenBase } from "../fees.js";
7
+ import { lock5 } from "../locks.js";
7
8
  import { noteCommitment, notePk } from "../notes/keys.js";
8
- import { itemClaimCommit, noWinnerSalt, winnerSalt } from "./claim.js";
9
- import { encHash, lock4, openBid, padSlots, residualLock } from "./rows.js";
10
- /** `sale_settle.circom` VERSION and RULE_HIGHEST, the constants `rows::fold_settle_ctx` folds. */
11
- const VERSION = 3n;
12
- const RULE_HIGHEST = 1n;
13
- /** AuctionCore rule 1: the highest value in [lo, hi] wins, the earliest seq on a tie. -1 is no winner. */
14
- function pickWinner(opened, lo, hi) {
15
- let winner = -1;
16
- opened.forEach((o, i) => {
17
- if (!o || o.v < lo || o.v > hi)
18
- return;
19
- if (winner < 0 || o.v > opened[winner].v)
20
- winner = i;
21
- });
22
- return winner;
23
- }
24
- function winnerBranch(roomField, won) {
25
- return {
26
- residual: residualLock(roomField, won.ownerPk, won.ns, won.amount - won.v).lock,
27
- item_claim: itemClaimCommit(won.ownerPk, winnerSalt(won.ns)),
28
- win_null: lock4(roomField, won.ownerPk, won.ns, won.amount, won.b).nullifier,
29
- };
30
- }
31
- /** C §4.4, §4.6: with no winner the residual is a zero lock and the item claim is the seller's. */
32
- function dummyBranch(roomField, sellerPk, sellerSecret) {
33
- const ns = poseidonHash([DOM_DUMMY, sellerSecret]);
34
- const b = poseidonHash([DOM_DUMMY, poseidonHash([sellerSecret, roomField])]);
35
- return {
36
- residual: lock4(roomField, sellerPk, ns, 0n, b).lock,
37
- item_claim: itemClaimCommit(sellerPk, noWinnerSalt(sellerSecret, roomField)),
38
- win_null: poseidonHash([DOM_LNULL, poseidonHash([DOM_DUMMY, sellerSecret, roomField])]),
39
- };
40
- }
41
- /** The slots `finish` opens; refuses what `sale_room::settle_mask` would abort on. */
42
- function readable(room) {
43
- const { bids, pick } = room;
44
- if (pick === "legacy")
45
- return (i) => bids[i].active;
46
- if (pick === null) {
47
- if (bids.some((b) => b.active))
48
- throw new Error("refused: draw the pick first (finish aborts 44_040)");
49
- return () => false;
50
- }
51
- if (!Number.isInteger(pick) || !bids[pick]?.active)
52
- throw new Error("the pick is not an active bid");
53
- return (i) => i === pick;
54
- }
9
+ import { dummyNull } from "../pads.js";
10
+ import { itemClaimCommit, winnerSalt } from "./claim.js";
11
+ import { postedCommit } from "./listing.js";
12
+ import { encHash } from "./rows.js";
13
+ /** `sale_settle.circom` VERSION (4 since Z1), the constant `rows::fold_settle_ctx` folds. */
14
+ const VERSION = 4n;
15
+ const LEVELS = 20;
16
+ const rootOf = (leaf, index, path) => path.reduce((node, sib, k) => ((index >> BigInt(k)) & 1n ? poseidonHash([sib, node]) : poseidonHash([node, sib])), leaf);
17
+ const refuse = (why) => {
18
+ throw new Error(`refused: ${why}`);
19
+ };
55
20
  /**
56
- * Witness for `circuits/v3/sale_settle/sale_settle.circom`. Public signals, in order: hSet, hLock, hCtx, hOut.
57
- * `slash` lists the opened bids whose plaintext does not open their commit and lock: the pick, or in a legacy room
58
- * any active bid, which the witness then leaves out of the mask. Either way it proves only once each is slashed.
59
- * hCtx carries relayer `NO_ADDRESS` and fee 0, the only pair `sale_room::finish` rebuilds.
21
+ * Witness for `circuits/v3/sale_settle/sale_settle.circom` (Z1 freeze §3.5). Public signals, in order: root, nLock,
22
+ * nDummy, hCtx, hOut. hCtx carries relayer `NO_ADDRESS` and fee 0, the only pair `sale_room::finish` rebuilds. The
23
+ * buyer's change is a note under its bid key with a blind only its `ns` opens, so the seller cannot spend it.
60
24
  */
61
25
  export async function plan(p) {
62
- const { room, bounds } = p;
63
- const { sellerSecret } = p.seller;
64
- const sellerPk = notePk(p.seller.sellerSk);
65
- if (poseidonHash([DOM_BOUNDS, bounds.lo, bounds.hi, bounds.salt]) !== room.boundsCommit)
66
- throw new Error("the bounds do not open this room");
67
- if (poseidonHash([DOM_SELLER, sellerPk, poseidonHash([sellerSecret])]) !== room.sellerCommit)
68
- throw new Error("the seller keys do not open this room");
69
- const commits = padSlots(room.bids.map((b) => b.commit));
70
- const locks = padSlots(room.bids.map((b) => b.lock));
71
- const read = readable(room);
72
- const opened = room.bids.map((b, i) => read(i) ? openBid(p.plains[i], room.saleKey, b.commit, b.lock) : undefined);
73
- const slash = room.bids.flatMap((_, i) => (read(i) && !opened[i] ? [i] : []));
74
- const activeMask = typeof room.pick === "number"
75
- ? 1n << BigInt(room.pick)
76
- : opened.reduce((m, o, i) => (o ? m | (1n << BigInt(i)) : m), 0n);
77
- const w = pickWinner(opened, bounds.lo, bounds.hi);
78
- const won = opened[w];
79
- const price = won?.v ?? 0n;
80
- const lane = await feeLane({ ...p.fee, base: price, eph: p.eph });
81
- const branch = won ? winnerBranch(room.saleKey, won) : dummyBranch(room.saleKey, sellerPk, sellerSecret);
82
- const sBlind = poseidonHash([DOM_SBLIND, sellerSecret, room.saleKey]);
26
+ const { room, bid, seller } = p;
27
+ const sellerPk = notePk(seller.sellerSk);
28
+ if (postedCommit({ price: p.price, salt: p.postSalt }) !== room.postedCommit)
29
+ refuse("the price does not open this room's posted commit");
30
+ if (poseidonHash([DOM_SELLER, sellerPk, poseidonHash([seller.sellerSecret])]) !== room.sellerCommit)
31
+ refuse("the seller keys do not open this room");
32
+ if (p.price < minHiddenBase(p.fee))
33
+ refuse("the price is under 10 x the flat fee (no witness)");
34
+ if (bid.amount < p.price)
35
+ refuse("the bid does not cover the price");
36
+ if (p.lock.path.length !== LEVELS)
37
+ refuse("a lock path is 20 levels");
38
+ if (p.encs.length !== 4)
39
+ refuse("finish carries 4 ciphertexts");
40
+ const w = lock5({ field: room.saleKey, ...bid });
41
+ if (rootOf(w.lock, p.lock.index, p.lock.path) !== p.lock.root)
42
+ refuse("the bid lock is not under root");
43
+ const lane = await flatFeeLane({ ...p.fee, base: p.price, eph: p.eph });
44
+ const sBlind = poseidonHash([DOM_SBLIND, seller.sellerSecret, room.saleKey]);
45
+ const relayerField = addrField(NO_ADDRESS);
46
+ const enc = encHash(p.encs);
83
47
  const statement = {
84
- seller_out: noteCommitment(price - lane.fee, sellerPk, sBlind),
48
+ root: p.lock.root,
49
+ n_lock: w.nullifier,
50
+ n_dummy: dummyNull(p.dummySeed),
51
+ seller_out: noteCommitment(p.price - lane.fee, sellerPk, sBlind),
85
52
  fee_out: lane.fee_note,
86
- ...branch,
53
+ change: noteCommitment(bid.amount - p.price, bid.ownerPk, poseidonHash([DOM_RBLIND, bid.ns])),
54
+ item_claim: itemClaimCommit(bid.ownerPk, winnerSalt(bid.ns)),
55
+ pad: noteCommitment(0n, p.pad.pk, p.pad.blinding),
87
56
  eph_x: lane.ephX,
88
57
  eph_y: lane.ephY,
89
58
  fee_ct: lane.fee_ct,
90
59
  fee_commit: lane.fee_commit,
91
60
  };
92
- const n = BigInt(room.bids.length);
93
- const relayerField = addrField(NO_ADDRESS);
94
- const enc = encHash(p.encs);
95
61
  const s = statement;
96
62
  const hCtx = poseidonHash([
97
- n,
98
- activeMask,
99
- room.boundsCommit,
63
+ VERSION,
64
+ room.postedCommit,
100
65
  room.sellerCommit,
101
66
  lane.fee_commit,
102
- RULE_HIGHEST,
103
67
  room.saleKey,
104
- VERSION,
105
68
  relayerField,
106
69
  0n,
107
70
  enc,
@@ -109,39 +72,35 @@ export async function plan(p) {
109
72
  const hOut = poseidonHash([
110
73
  s.seller_out,
111
74
  s.fee_out,
112
- s.residual,
75
+ s.change,
113
76
  s.item_claim,
114
- s.win_null,
77
+ s.pad,
115
78
  s.eph_x,
116
79
  s.eph_y,
117
80
  s.fee_ct,
118
81
  ]);
119
82
  const input = {
120
- commits: commits.map(String),
121
- locks: locks.map(String),
122
- values: padSlots(opened.map((o) => o?.v ?? 0n)).map(String),
123
- salts: padSlots(opened.map((o) => o?.s ?? 0n)).map(String),
124
- n: n.toString(),
125
- activeMask: activeMask.toString(),
126
- lo: bounds.lo.toString(),
127
- hi: bounds.hi.toString(),
128
- boundsSalt: bounds.salt.toString(),
129
- hasWinner: won ? "1" : "0",
130
- winner: won ? w.toString() : "0",
131
- price: price.toString(),
132
- amount_w: (won?.amount ?? 0n).toString(),
133
- ownerPk_w: (won?.ownerPk ?? 0n).toString(),
134
- ns_w: (won?.ns ?? 0n).toString(),
135
- b_w: (won?.b ?? 0n).toString(),
136
- sellerPk: sellerPk.toString(),
137
- sellerSecret: sellerSecret.toString(),
83
+ price: p.price.toString(),
84
+ postSalt: p.postSalt.toString(),
138
85
  roomField: room.saleKey.toString(),
139
- ...feeWitness(p.fee, price, p.eph, lane),
86
+ sellerPk: sellerPk.toString(),
87
+ sellerSecret: seller.sellerSecret.toString(),
88
+ amount_w: bid.amount.toString(),
89
+ ownerPk_w: bid.ownerPk.toString(),
90
+ ns_w: bid.ns.toString(),
91
+ b_w: bid.b.toString(),
92
+ unlock_w: bid.unlockS.toString(),
93
+ lockIndex: p.lock.index.toString(),
94
+ lockPath: p.lock.path.map(String),
95
+ root: p.lock.root.toString(),
96
+ padPk: p.pad.pk.toString(),
97
+ padBlind: p.pad.blinding.toString(),
98
+ dummySeed: p.dummySeed.toString(),
140
99
  relayerField: relayerField.toString(),
141
100
  relayer_fee: "0",
142
101
  encHash: enc.toString(),
102
+ ...feeWitness(p.fee, p.price, p.eph, lane),
143
103
  };
144
- const sellerNote = { value: price - lane.fee, blinding: sBlind };
145
- const publics = [poseidonHash(commits), poseidonHash(locks), hCtx, hOut];
146
- return { slash, input, publics, statement, sellerNote };
104
+ const publics = [p.lock.root, s.n_lock, s.n_dummy, hCtx, hOut];
105
+ return { input, publics, statement, sellerNote: { value: p.price - lane.fee, blinding: sBlind } };
147
106
  }
@@ -1,54 +1,25 @@
1
- import { type FeeCommitInput } from "../fees.ts";
2
- import { type CircuitInput, type SpendNote } from "../inputs.ts";
1
+ import { type Payload, type Recovery } from "../loans/offer-payload.ts";
3
2
  import { type BidSecrets } from "./rows.ts";
4
- export type LockBidParams = {
5
- root: bigint;
6
- ins: [SpendNote, SpendNote];
7
- /** `id` is the SaleRoom object, `saleKey` its `sale_key`, `seq` the number of bids it already holds. */
8
- room: {
9
- id: string;
10
- saleKey: bigint;
11
- seq: number;
12
- postedCommit: bigint;
13
- };
14
- bid: BidSecrets;
15
- /** The amount of the change note is what conserves value; it is computed, never passed. */
16
- change: {
17
- pk: bigint;
18
- blinding: bigint;
19
- };
20
- relayer: string;
21
- relayerFee: bigint;
22
- /** The Seal object `sale_room::bid` pins. The proof binds its blake2b256. */
23
- sealed: Uint8Array;
24
- /** The proof binds it with `sealed` (`sale_room::ext_hash`). */
25
- memo: Uint8Array;
26
- /** `[enc_change, enc_fee]`. */
27
- encs: [Uint8Array, Uint8Array];
28
- fee: FeeCommitInput;
29
- eph: bigint;
30
- };
31
- /** Everything `sale_room::bid` takes besides the pass, the proof, `sealed`, the relayer and the ciphertexts. */
32
- export type LockBidStatement = {
33
- root: bigint;
34
- n0: bigint;
35
- n1: bigint;
36
- lock: bigint;
37
- change: bigint;
38
- feeNote: bigint;
39
- commit: bigint;
40
- ephX: bigint;
41
- ephY: bigint;
42
- feeCt: bigint;
43
- feeCommit: bigint;
3
+ export type BidLock = {
4
+ pk: bigint;
5
+ blinding: bigint;
6
+ payload: Payload;
7
+ recovery: Recovery;
8
+ secrets: BidSecrets;
44
9
  };
45
10
  /**
46
- * Witness for `circuits/v3/lock_bid/lock_bid.circom`.
47
- * Public signals, in order: hOuts, hCtx, root, publicAmount, extHash, n0, n1.
11
+ * PRV-28 B+C: a bid is a plain transfer into a Lock5 leaf under the room's `sale_key`, with keys from the reserved
12
+ * note index (Erik's condition 2). aux carries `amount_w`; `unlock_s` is the first grid second after `finish_by_ms`,
13
+ * so an on-time reclaim cannot race a finish (condition 4).
48
14
  */
49
- export declare function lockBid(p: LockBidParams): Promise<{
50
- input: CircuitInput;
51
- publics: bigint[];
52
- statement: LockBidStatement;
53
- }>;
15
+ export declare function bidLock(p: {
16
+ saleKey: bigint;
17
+ own: {
18
+ sk: bigint;
19
+ blinding: bigint;
20
+ };
21
+ noteIndex: number;
22
+ amount: bigint;
23
+ finishByMs: bigint;
24
+ }): BidLock;
54
25
  //# sourceMappingURL=bid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bid.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/bid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC5B,wGAAwG;IACxG,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,GAAG,EAAE,UAAU,CAAC;IAChB,2FAA2F;IAC3F,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E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,CAAC,CAAC,EAAE;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAqBV"}
@@ -1,88 +1,33 @@
1
- import { poseidonHash } from "@mysten/sui/zklogin";
2
- import { R } from "../domains.js";
3
- import { feeWitness } from "../fee-witness.js";
4
- import { assertU64, feeLane } from "../fees.js";
5
- import { JS4_LEVELS } from "../inputs.js";
6
- import { noteCommitment, noteNullifier, notePk } from "../notes/keys.js";
7
- import { SLOTS, bidCommit, bidExt, lock4 } from "./rows.js";
1
+ import { assertU64 } from "../fees.js";
2
+ import { packAmount, unlockAfter } from "../loans/offer-payload.js";
3
+ import { lock5 } from "../locks.js";
4
+ import { notePk } from "../notes/keys.js";
5
+ import { bidSecrets } from "./rows.js";
8
6
  /**
9
- * Witness for `circuits/v3/lock_bid/lock_bid.circom`.
10
- * Public signals, in order: hOuts, hCtx, root, publicAmount, extHash, n0, n1.
7
+ * PRV-28 B+C: a bid is a plain transfer into a Lock5 leaf under the room's `sale_key`, with keys from the reserved
8
+ * note index (Erik's condition 2). aux carries `amount_w`; `unlock_s` is the first grid second after `finish_by_ms`,
9
+ * so an on-time reclaim cannot race a finish (condition 4).
11
10
  */
12
- export async function lockBid(p) {
13
- const { bid, room } = p;
14
- if (!Number.isInteger(room.seq) || room.seq < 0 || room.seq >= SLOTS)
15
- throw new Error("seq is not a bid slot");
16
- if (p.relayerFee > 0n && BigInt(p.relayer) === 0n)
17
- throw new Error("a relayer fee needs a relayer");
18
- assertU64("v", bid.v);
19
- assertU64("amount", bid.amount);
20
- if (bid.v > bid.amount)
21
- throw new Error("the deposit does not cover the bid");
22
- for (const note of p.ins)
23
- if (note.pathElements.length !== JS4_LEVELS)
24
- throw new Error("a spend needs 20 path elements");
25
- // Fee base 0 (E-21): the lane's fee is 0, so the balance line carries none.
26
- const lane = await feeLane({ ...p.fee, base: 0n, eph: p.eph });
27
- const chg = p.ins[0].amount + p.ins[1].amount - p.relayerFee - bid.amount;
28
- if (chg < 0n)
29
- throw new Error("inputs do not cover the deposit");
30
- const commitments = p.ins.map((n) => noteCommitment(n.amount, notePk(n.sk), n.blinding));
31
- const [n0, n1] = p.ins.map((n, i) => noteNullifier(commitments[i], n.sk, n.pathIndex));
32
- const ownerPk = notePk(bid.ownerSk);
33
- const commit = bidCommit(bid.v, bid.s);
34
- if (commit !== room.postedCommit)
35
- throw new Error("the bid is not the room's posted price (bid aborts 44_035)");
36
- const ext = bidExt({
37
- room: room.id,
38
- seq: room.seq,
39
- relayer: p.relayer,
40
- relayerFee: p.relayerFee,
41
- commit,
42
- sealed: p.sealed,
43
- memo: p.memo,
44
- encs: p.encs,
11
+ export function bidLock(p) {
12
+ assertU64("amount", p.amount);
13
+ if (p.amount === 0n)
14
+ throw new Error("the bid amount must be above 0");
15
+ const secrets = bidSecrets(p.own);
16
+ const ownerPk = notePk(secrets.ownerSk);
17
+ const unlockS = unlockAfter(p.finishByMs);
18
+ const { lockPk } = lock5({
19
+ field: p.saleKey,
20
+ ownerPk,
21
+ ns: secrets.ns,
22
+ amount: p.amount,
23
+ b: secrets.b,
24
+ unlockS,
45
25
  });
46
- const statement = {
47
- root: p.root,
48
- n0,
49
- n1,
50
- lock: lock4(room.saleKey, ownerPk, bid.ns, bid.amount, bid.b).lock,
51
- change: noteCommitment(chg, p.change.pk, p.change.blinding),
52
- feeNote: lane.fee_note,
53
- commit,
54
- ephX: lane.ephX,
55
- ephY: lane.ephY,
56
- feeCt: lane.fee_ct,
57
- feeCommit: lane.fee_commit,
26
+ return {
27
+ pk: lockPk,
28
+ blinding: secrets.b,
29
+ payload: { ownerPk, ns: secrets.ns, aux: packAmount(p.amount), unlockS },
30
+ recovery: { amount: p.amount, field: p.saleKey, unlockS, index: BigInt(p.noteIndex) },
31
+ secrets,
58
32
  };
59
- const s = statement;
60
- const hOuts = poseidonHash([s.lock, s.change, s.feeNote, commit, s.ephX, s.ephY, s.feeCt]);
61
- const hCtx = poseidonHash([room.saleKey, lane.fee_commit, p.relayerFee]);
62
- const publicAmount = p.relayerFee === 0n ? 0n : R - p.relayerFee;
63
- const input = {
64
- root: p.root.toString(),
65
- publicAmount: publicAmount.toString(),
66
- extHash: ext.toString(),
67
- n0: n0.toString(),
68
- n1: n1.toString(),
69
- inAmount: p.ins.map((n) => n.amount.toString()),
70
- inPrivateKey: p.ins.map((n) => n.sk.toString()),
71
- inBlinding: p.ins.map((n) => n.blinding.toString()),
72
- inPathIndices: p.ins.map((n) => n.pathIndex.toString()),
73
- inPathElements: p.ins.map((n) => n.pathElements.map(String)),
74
- amount: bid.amount.toString(),
75
- ownerPk: ownerPk.toString(),
76
- ns: bid.ns.toString(),
77
- b: bid.b.toString(),
78
- roomField: room.saleKey.toString(),
79
- v: bid.v.toString(),
80
- s: bid.s.toString(),
81
- chg: chg.toString(),
82
- pkC: p.change.pk.toString(),
83
- bC: p.change.blinding.toString(),
84
- relayer_fee: p.relayerFee.toString(),
85
- ...feeWitness(p.fee, 0n, p.eph, lane),
86
- };
87
- return { input, publics: [hOuts, hCtx, p.root, publicAmount, ext, n0, n1], statement };
88
33
  }