@sig-net/midnight 0.0.6 → 0.0.7

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 (57) hide show
  1. package/README.md +23 -20
  2. package/dist/constants.d.ts +4 -16
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +4 -16
  5. package/dist/constants.js.map +1 -1
  6. package/dist/ecdsa-attestation.d.ts +79 -0
  7. package/dist/ecdsa-attestation.d.ts.map +1 -0
  8. package/dist/ecdsa-attestation.js +140 -0
  9. package/dist/ecdsa-attestation.js.map +1 -0
  10. package/dist/epsilon-derivation.d.ts +60 -0
  11. package/dist/epsilon-derivation.d.ts.map +1 -1
  12. package/dist/epsilon-derivation.js +106 -5
  13. package/dist/epsilon-derivation.js.map +1 -1
  14. package/dist/index.d.ts +9 -7
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +9 -7
  17. package/dist/index.js.map +1 -1
  18. package/dist/managed/compiler/contract-info.json +74 -52
  19. package/dist/managed/compiler/contract-manifest.json +8 -8
  20. package/dist/managed/contract/index.d.ts +38 -31
  21. package/dist/managed/contract/index.js +232 -382
  22. package/dist/managed/contract/index.js.map +1 -1
  23. package/dist/signature-requests-state-reader.d.ts +14 -13
  24. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  25. package/dist/signature-requests-state-reader.js +31 -20
  26. package/dist/signature-requests-state-reader.js.map +1 -1
  27. package/dist/signature-response-verification.d.ts +5 -5
  28. package/dist/signature-response-verification.d.ts.map +1 -1
  29. package/dist/signature-response-verification.js +4 -4
  30. package/dist/signature-response-verification.js.map +1 -1
  31. package/dist/signet-contract-state-reader.d.ts +101 -112
  32. package/dist/signet-contract-state-reader.d.ts.map +1 -1
  33. package/dist/signet-contract-state-reader.js +123 -115
  34. package/dist/signet-contract-state-reader.js.map +1 -1
  35. package/dist/signet-request-feed.d.ts +4 -3
  36. package/dist/signet-request-feed.d.ts.map +1 -1
  37. package/dist/signet-request-feed.js +9 -8
  38. package/dist/signet-request-feed.js.map +1 -1
  39. package/dist/signet-request-resolver.d.ts +6 -4
  40. package/dist/signet-request-resolver.d.ts.map +1 -1
  41. package/dist/signet-request-resolver.js +8 -6
  42. package/dist/signet-request-resolver.js.map +1 -1
  43. package/dist/signet-request-response-reader.d.ts +21 -20
  44. package/dist/signet-request-response-reader.d.ts.map +1 -1
  45. package/dist/signet-request-response-reader.js +35 -23
  46. package/dist/signet-request-response-reader.js.map +1 -1
  47. package/dist/signet-requests.d.ts +93 -59
  48. package/dist/signet-requests.d.ts.map +1 -1
  49. package/dist/signet-requests.js +84 -67
  50. package/dist/signet-requests.js.map +1 -1
  51. package/package.json +2 -2
  52. package/src/Signet.compact +277 -425
  53. package/src/circuits.compact +22 -21
  54. package/dist/ecdsa.d.ts +0 -114
  55. package/dist/ecdsa.d.ts.map +0 -1
  56. package/dist/ecdsa.js +0 -145
  57. package/dist/ecdsa.js.map +0 -1
@@ -4,5 +4,5 @@
4
4
  "sourceRoot": "../../../",
5
5
  "sources": ["src/circuits.compact", "src/./Signet.compact", "compiler/zkir-v3-library.compact"],
6
6
  "names": [],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;MCmIE,MAAA,wCASC;;OAAA;MA6FD,MAAA,kBAqBC;;OAAA;MAsHD,MAAA,wBAcC;;OAAA;MAuBD,MAAA,WAOC;;OAAA;MAQD,MAAA,oBAMC;;OAAA;;;;GDzYF;EArCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCC;EErCD,AAAA,kBAAA;qEAAA;;;EAAA,AAAA,kBAAA;oEAAA;;;EAAA,AAAA,kBAAA;oEAAA;;;EDmIE,AAAA,2CASC,CARC,eAA8B;8CAC9B,WAAoB;8CACpB,oBAA2B;;;;8CAIP,eAAa;8CAAW,WAAS;gCAAE,oBAAkB;;GAE1E;EA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iBC,CAhBC,WAAoB;qCACpB,2BAAoD;qCACpD,gBAA8B;;wEAI1B,WAAS;wEACT,2BAAyB;wEACzB,2BAAyB;;;;iFAGtB,2BAAyB;;;;;;iFACzB,2BAAyB;;;wCAE9B,gBAAc;GAEjB;EAKD,AAAA,gBAEC,CAFiC,IAAkB,kCACZ,IAAE,IACzC;;;;;;;;;;;;;;;;;;;;;;;EA/GD,AAAA,6CAWC;;;;UARC,eAA8B;UAC9B,oBAA2B;;;;;;;;;;;;;;;2EAD3B,eAA8B;2EAC9B,oBAA2B;GAO5B;EA0DD,AAAA,uBAUC;;;;UATC,WAAoB;UACpB,kBAA4B;UAC5B,WAAkB;;;;;;;;;;;;;;;;;;;;;;qDAFlB,WAAoB;qDACpB,kBAA4B;qDAC5B,WAAkB;GAOnB;EAQD,AAAA,+BAiBC;;;;UAhBC,WAAoB;UACpB,2BAAoD;UACpD,gBAA8B;;;;;;;;;;;;;;;6DAF9B,WAAoB;6DACpB,2BAAoD;6DACpD,gBAA8B;GAc/B;EAKD,AAAA,aAEC;;;;UAFiC,IAAkB;2CAAlB,IAAkB;GAEnD;;;;;;"
8
8
  }
@@ -1,30 +1,31 @@
1
- import { type RequestIdHex, type SignBidirectionalRequest, type SignBidirectionalRequestIndex } from "./signet-requests.ts";
1
+ import { type RequestIdHex, type SignBidirectionalEvent, type SignBidirectionalEventIndex } from "./signet-requests.ts";
2
2
  import { type RawContractState } from "./signature-state-reading.ts";
3
3
  /**
4
- * Aligned-value entry count of a request record EXCLUDING the capacity-scaled
5
- * vectors: requestNonce (1) + txParamType (1, enums are one atom whatever
6
- * their byte width) + the EVMType2TxParams fixed fields (to..value = 7,
7
- * accessListEntryCount = 1) + the calldata Maybe's is_some (1), selector (1)
8
- * and noWords (1) + the routing fields caip2Id..respondSerializationSchema (8).
9
- * A stored request cell therefore holds
4
+ * Aligned-value entry count of an event record EXCLUDING the capacity-scaled
5
+ * vectors: sender (1) + requestNonce (1) + keyVersion (1) + path (1) +
6
+ * algo (1) + dest (1) + params (1) + txParamType (1, enums are one atom
7
+ * whatever their byte width) + the EVMType2TxParams fixed fields
8
+ * (to..value = 7, accessListEntryCount = 1) + the calldata Maybe's
9
+ * is_some (1), selector (1) and noWords (1) + caip2Id (1) + the two schema
10
+ * fields (1 each). A stored event cell therefore holds
10
11
  * `REQUEST_FIXED_VALUE_ATOMS + maxCalldataWords
11
12
  * + maxAccessListEntries·(2 + maxStorageKeysPerEntry)`
12
13
  * entries (each calldata word is one Bytes<32> atom; each access-list entry is
13
14
  * address + storageKeyCount + its keys).
14
15
  */
15
- export declare const REQUEST_FIXED_VALUE_ATOMS = 21;
16
+ export declare const REQUEST_FIXED_VALUE_ATOMS = 22;
16
17
  /**
17
18
  * The decoded signet ledger fields of a requesting contract: its request
18
- * index and its contract-local request counter (Compact `SignetNonce`, the
19
+ * index and its contract-local request counter (Compact `Counter`, the
19
20
  * source of each request's `requestNonce` — nothing off-chain depends on it,
20
21
  * it is decoded here only because both fields travel together in tests and
21
22
  * diagnostics).
22
23
  */
23
24
  export interface SignetRequestsLedger {
24
- /** The request counter (`SignetNonce`). */
25
+ /** The request counter (`Counter`). */
25
26
  nonce: bigint;
26
27
  /** The request index, keyed by hex request id. */
27
- requestsIndex: SignBidirectionalRequestIndex;
28
+ requestsIndex: SignBidirectionalEventIndex;
28
29
  }
29
30
  /**
30
31
  * MPC-style read: parse the signet ledger fields out of raw contract state
@@ -60,7 +61,7 @@ export declare function readSignetRequestsLedgerFromState(raw: RawContractState,
60
61
  * malformed or adversarial notification can never crash the reader.
61
62
  *
62
63
  * Only the matched record is decoded (not the whole index), and it is decoded
63
- * by the same {@link decodeSignBidirectionalRequest} the full reader uses, so
64
+ * by the same {@link decodeSignBidirectionalEvent} the full reader uses, so
64
65
  * the result is `toEqual` to `readSignetRequestsLedgerFromState(raw,
65
66
  * fieldIndex, …).requestsIndex.get(requestId)`.
66
67
  *
@@ -69,5 +70,5 @@ export declare function readSignetRequestsLedgerFromState(raw: RawContractState,
69
70
  * @param requestId - The request id to look up.
70
71
  * @returns The stored request record, or `undefined` when it is not a member.
71
72
  */
72
- export declare function lookupSignetRequestAt(raw: RawContractState, fieldIndex: number, requestId: RequestIdHex): SignBidirectionalRequest | undefined;
73
+ export declare function lookupSignetRequestAt(raw: RawContractState, fieldIndex: number, requestId: RequestIdHex): SignBidirectionalEvent | undefined;
73
74
  //# sourceMappingURL=signature-requests-state-reader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAgE5C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,EAAE,6BAA6B,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,EACrB,kBAAkB,EAAE,MAAM,EAC1B,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAwBtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,YAAY,GACtB,wBAAwB,GAAG,SAAS,CA2BtC"}
1
+ {"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AA4E5C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,EAAE,2BAA2B,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,EACrB,kBAAkB,EAAE,MAAM,EAC1B,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAwBtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,YAAY,GACtB,sBAAsB,GAAG,SAAS,CA2BpC"}
@@ -10,46 +10,57 @@
10
10
  // the record descriptors themselves are the parameterized twins in
11
11
  // signet-requests.ts. The generic tree walk and shared base descriptors live
12
12
  // in signature-state-reading.ts.
13
- import { requestIdHex, signBidirectionalRequestDescriptor, } from "./signet-requests.js";
13
+ import { requestIdHex, signBidirectionalEventDescriptor, } from "./signet-requests.js";
14
14
  import { requestIdType, signetFieldNode, u64, } from "./signature-state-reading.js";
15
15
  /**
16
- * Aligned-value entry count of a request record EXCLUDING the capacity-scaled
17
- * vectors: requestNonce (1) + txParamType (1, enums are one atom whatever
18
- * their byte width) + the EVMType2TxParams fixed fields (to..value = 7,
19
- * accessListEntryCount = 1) + the calldata Maybe's is_some (1), selector (1)
20
- * and noWords (1) + the routing fields caip2Id..respondSerializationSchema (8).
21
- * A stored request cell therefore holds
16
+ * Aligned-value entry count of an event record EXCLUDING the capacity-scaled
17
+ * vectors: sender (1) + requestNonce (1) + keyVersion (1) + path (1) +
18
+ * algo (1) + dest (1) + params (1) + txParamType (1, enums are one atom
19
+ * whatever their byte width) + the EVMType2TxParams fixed fields
20
+ * (to..value = 7, accessListEntryCount = 1) + the calldata Maybe's
21
+ * is_some (1), selector (1) and noWords (1) + caip2Id (1) + the two schema
22
+ * fields (1 each). A stored event cell therefore holds
22
23
  * `REQUEST_FIXED_VALUE_ATOMS + maxCalldataWords
23
24
  * + maxAccessListEntries·(2 + maxStorageKeysPerEntry)`
24
25
  * entries (each calldata word is one Bytes<32> atom; each access-list entry is
25
26
  * address + storageKeyCount + its keys).
26
27
  */
27
- export const REQUEST_FIXED_VALUE_ATOMS = 21;
28
+ export const REQUEST_FIXED_VALUE_ATOMS = 22;
28
29
  /**
29
30
  * Recover a record's capacity instantiation (maxCalldataWords,
30
31
  * maxAccessListEntries, maxStorageKeysPerEntry) from its aligned-value atom
31
- * count and decode it. Unlike the old single-vector layout, one atom count no
32
- * longer determines the capacities uniquely, so candidates are enumerated —
33
- * access-list-free first (today's producers — the caller contract <1, 0, 0>,
34
- * the erc20-vault example <2, 0, 0> — all are) —
35
- * and validated by the decode itself: the descriptors' Bytes length checks
36
- * and the enum range check reject wrong splits, and a decode that leaves
37
- * atoms unconsumed is rejected here.
32
+ * count and decode it. One atom count does not determine the capacities
33
+ * uniquely, so candidates are enumerated — access-list-free first (today's
34
+ * producers — the caller contract <1, 0, 0>, the erc20-vault example
35
+ * <2, 0, 0> — all are) — and validated by the decode itself: the descriptors'
36
+ * Bytes length checks and the enum range check reject wrong splits, and a
37
+ * decode that leaves atoms unconsumed is rejected here.
38
+ *
39
+ * The schema byte widths (`#LenOutputDeserialization`,
40
+ * `#LenRespondSerialization`) are read from the LAST TWO atoms' actual byte
41
+ * lengths. That works because the state layer stores atoms with trailing
42
+ * zeros trimmed and schemas are exact-length by protocol convention (JSON
43
+ * schema strings sized to fit, never NUL-padded, never ending in a zero
44
+ * byte) — so stored length == declared length. A contract that padded its
45
+ * schema capacity with trailing zeros would decode to the trimmed width and
46
+ * fail the request-id recompute, which is the authoritative check anyway.
38
47
  *
39
48
  * @param atoms - The record cell's aligned value (a fresh copy per attempt).
40
49
  * @returns The decoded record.
41
50
  * @throws Error if no capacity split decodes the value cleanly.
42
51
  */
43
- function decodeSignBidirectionalRequest(atoms) {
52
+ function decodeSignBidirectionalEvent(atoms) {
44
53
  const variable = atoms.length - REQUEST_FIXED_VALUE_ATOMS;
45
54
  if (variable < 0) {
46
55
  throw new Error(`request record has ${atoms.length} value entries — fewer than the ` +
47
56
  `${REQUEST_FIXED_VALUE_ATOMS} its fixed fields need`);
48
57
  }
58
+ const lenOutputDeserialization = atoms[atoms.length - 2].length;
59
+ const lenRespondSerialization = atoms[atoms.length - 1].length;
49
60
  const attempt = (maxWords, maxEntries, maxKeys) => {
50
61
  const cursor = [...atoms];
51
62
  try {
52
- const record = signBidirectionalRequestDescriptor(maxWords, maxEntries, maxKeys).fromValue(cursor);
63
+ const record = signBidirectionalEventDescriptor(maxWords, maxEntries, maxKeys, lenOutputDeserialization, lenRespondSerialization).fromValue(cursor);
53
64
  // A clean decode consumes the record exactly.
54
65
  return cursor.length === 0 ? record : undefined;
55
66
  }
@@ -104,7 +115,7 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexField, nonce
104
115
  const cell = map.get(key)?.asCell();
105
116
  if (cell === undefined)
106
117
  continue;
107
- requestsIndex.set(requestIdHex(requestId), decodeSignBidirectionalRequest(cell.value));
118
+ requestsIndex.set(requestIdHex(requestId), decodeSignBidirectionalEvent(cell.value));
108
119
  }
109
120
  const nonceCell = signetFieldNode(raw, nonceField).asCell();
110
121
  if (nonceCell === undefined) {
@@ -129,7 +140,7 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexField, nonce
129
140
  * malformed or adversarial notification can never crash the reader.
130
141
  *
131
142
  * Only the matched record is decoded (not the whole index), and it is decoded
132
- * by the same {@link decodeSignBidirectionalRequest} the full reader uses, so
143
+ * by the same {@link decodeSignBidirectionalEvent} the full reader uses, so
133
144
  * the result is `toEqual` to `readSignetRequestsLedgerFromState(raw,
134
145
  * fieldIndex, …).requestsIndex.get(requestId)`.
135
146
  *
@@ -160,7 +171,7 @@ export function lookupSignetRequestAt(raw, fieldIndex, requestId) {
160
171
  return undefined;
161
172
  }
162
173
  try {
163
- return decodeSignBidirectionalRequest(cell.value);
174
+ return decodeSignBidirectionalEvent(cell.value);
164
175
  }
165
176
  catch {
166
177
  return undefined; // a cell that is not a decodable request record
@@ -1 +1 @@
1
- {"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,yDAAyD;AACzD,4EAA4E;AAC5E,yEAAyE;AACzE,kEAAkE;AAClE,qCAAqC;AACrC,gFAAgF;AAChF,mEAAmE;AACnE,6EAA6E;AAC7E,iCAAiC;AAIjC,OAAO,EACL,YAAY,EACZ,kCAAkC,GAInC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,aAAa,EACb,eAAe,EACf,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,SAAS,8BAA8B,CACrC,KAAmB;IAEnB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,yBAAyB,CAAC;IAC1D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,sBAAsB,KAAK,CAAC,MAAM,kCAAkC;YAClE,GAAG,yBAAyB,wBAAwB,CACvD,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,CACd,QAAgB,EAChB,UAAkB,EAClB,OAAe,EACuB,EAAE;QACxC,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAiB,CAAC;QAC1C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,kCAAkC,CAC/C,QAAQ,EACR,UAAU,EACV,OAAO,CACR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KAAK,EAAE,CAAC;IACzB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC,CAAC,yCAAyC;IAC7D,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,gEAAgE;QAChE,IAAI,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACxE,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC,CAAC,gDAAgD;QACpE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,2BAA2B;AAC/C,CAAC"}
1
+ {"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,yDAAyD;AACzD,4EAA4E;AAC5E,yEAAyE;AACzE,kEAAkE;AAClE,qCAAqC;AACrC,gFAAgF;AAChF,mEAAmE;AACnE,6EAA6E;AAC7E,iCAAiC;AAIjC,OAAO,EACL,YAAY,EACZ,gCAAgC,GAIjC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,aAAa,EACb,eAAe,EACf,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,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,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC,CAAC,gDAAgD;QACpE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,2BAA2B;AAC/C,CAAC"}
@@ -1,5 +1,5 @@
1
- import { type SignBidirectionalRequest } from "./signet-requests.ts";
2
- import type { SignatureResponse } from "./signet-contract-state-reader.ts";
1
+ import { type SignBidirectionalEvent } from "./signet-requests.ts";
2
+ import type { SignatureRespondedEvent } from "./signet-contract-state-reader.ts";
3
3
  /**
4
4
  * Recover the EVM address that produced a response signature, over the
5
5
  * signing hash of the transaction the request describes.
@@ -9,9 +9,9 @@ import type { SignatureResponse } from "./signet-contract-state-reader.ts";
9
9
  * @returns The checksummed recovered signer address.
10
10
  * @throws Error if the response is not a decodable signature or the request
11
11
  * record is malformed (see
12
- * {@link signBidirectionalRequestToUnsignedEVMTransaction}).
12
+ * {@link signBidirectionalEventToUnsignedEVMTransaction}).
13
13
  */
14
- export declare function recoverSignatureResponseSigner(request: SignBidirectionalRequest, response: SignatureResponse): string;
14
+ export declare function recoverSignatureResponseSigner(request: SignBidirectionalEvent, response: SignatureRespondedEvent): string;
15
15
  /**
16
16
  * Verify a posted response against its request: does the signature recover
17
17
  * to `expectedSigner`? Never throws — a response that is malformed or signed
@@ -23,5 +23,5 @@ export declare function recoverSignatureResponseSigner(request: SignBidirectiona
23
23
  * @param expectedSigner - The EVM address (any case, 0x hex) that must have signed.
24
24
  * @returns `true` iff the response is a valid signature by `expectedSigner`.
25
25
  */
26
- export declare function verifySignatureResponse(request: SignBidirectionalRequest, response: SignatureResponse, expectedSigner: string): boolean;
26
+ export declare function verifySignatureRespondedEvent(request: SignBidirectionalEvent, response: SignatureRespondedEvent, expectedSigner: string): boolean;
27
27
  //# sourceMappingURL=signature-response-verification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature-response-verification.d.ts","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,iBAAiB,GAC1B,MAAM,CAKR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,EACjC,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,MAAM,GACrB,OAAO,CAST"}
1
+ {"version":3,"file":"signature-response-verification.d.ts","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,GAChC,MAAM,CAKR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,EACjC,cAAc,EAAE,MAAM,GACrB,OAAO,CAST"}
@@ -7,7 +7,7 @@
7
7
  // check that the posted `{ bigR, s, recoveryId }` signature recovers to the
8
8
  // requester's derived EVM address over that transaction's signing hash.
9
9
  import { getAddress, recoverAddress } from "ethers";
10
- import { signBidirectionalRequestToUnsignedEVMTransaction, signatureResponseToSignature, } from "./signet-requests.js";
10
+ import { signBidirectionalEventToUnsignedEVMTransaction, signatureRespondedEventToSignature, } from "./signet-requests.js";
11
11
  /**
12
12
  * Recover the EVM address that produced a response signature, over the
13
13
  * signing hash of the transaction the request describes.
@@ -17,10 +17,10 @@ import { signBidirectionalRequestToUnsignedEVMTransaction, signatureResponseToSi
17
17
  * @returns The checksummed recovered signer address.
18
18
  * @throws Error if the response is not a decodable signature or the request
19
19
  * record is malformed (see
20
- * {@link signBidirectionalRequestToUnsignedEVMTransaction}).
20
+ * {@link signBidirectionalEventToUnsignedEVMTransaction}).
21
21
  */
22
22
  export function recoverSignatureResponseSigner(request, response) {
23
- return recoverAddress(signBidirectionalRequestToUnsignedEVMTransaction(request).unsignedHash, signatureResponseToSignature(response));
23
+ return recoverAddress(signBidirectionalEventToUnsignedEVMTransaction(request).unsignedHash, signatureRespondedEventToSignature(response));
24
24
  }
25
25
  /**
26
26
  * Verify a posted response against its request: does the signature recover
@@ -33,7 +33,7 @@ export function recoverSignatureResponseSigner(request, response) {
33
33
  * @param expectedSigner - The EVM address (any case, 0x hex) that must have signed.
34
34
  * @returns `true` iff the response is a valid signature by `expectedSigner`.
35
35
  */
36
- export function verifySignatureResponse(request, response, expectedSigner) {
36
+ export function verifySignatureRespondedEvent(request, response, expectedSigner) {
37
37
  try {
38
38
  return (recoverSignatureResponseSigner(request, response) ===
39
39
  getAddress(expectedSigner));
@@ -1 +1 @@
1
- {"version":3,"file":"signature-response-verification.js","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AAExE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EACL,gDAAgD,EAChD,4BAA4B,GAE7B,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAiC,EACjC,QAA2B;IAE3B,OAAO,cAAc,CACnB,gDAAgD,CAAC,OAAO,CAAC,CAAC,YAAY,EACtE,4BAA4B,CAAC,QAAQ,CAAC,CACvC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAiC,EACjC,QAA2B,EAC3B,cAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,CACL,8BAA8B,CAAC,OAAO,EAAE,QAAQ,CAAC;YACjD,UAAU,CAAC,cAAc,CAAC,CAC3B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"signature-response-verification.js","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AAExE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EACL,8CAA8C,EAC9C,kCAAkC,GAEnC,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA+B,EAC/B,QAAiC;IAEjC,OAAO,cAAc,CACnB,8CAA8C,CAAC,OAAO,CAAC,CAAC,YAAY,EACpE,kCAAkC,CAAC,QAAQ,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA+B,EAC/B,QAAiC,EACjC,cAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,CACL,8BAA8B,CAAC,OAAO,EAAE,QAAQ,CAAC;YACjD,UAAU,CAAC,cAAc,CAAC,CAC3B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,24 +1,25 @@
1
1
  import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
2
  import { type RequestId, type RequestIdHex } from "./signet-requests.ts";
3
3
  import { type RawContractState } from "./signature-state-reading.ts";
4
- /** Signet contract layout: the signature response counter index is ledger field 0. */
5
- export declare const SIGNATURE_RESPONSE_COUNTER_INDEX_FIELD = 0;
6
- /** Signet contract layout: the signature response log is ledger field 1. */
7
- export declare const SIGNATURE_RESPONSE_INDEX_FIELD = 1;
8
- /** Signet contract layout: the respond-bidirectional index is ledger field 2. */
9
- export declare const RESPOND_BIDIRECTIONAL_INDEX_FIELD = 2;
10
- /** Signet contract layout: the sealed MPC attestation key hash is ledger field 3. */
11
- export declare const MPC_PUB_KEY_HASH_FIELD = 3;
12
- /** Signet contract layout: the request notification registry is ledger field 4. */
13
- export declare const SIGN_BIDIRECTIONAL_NOTIFICATION_INDEX_FIELD = 4;
4
+ /** Signet contract layout: the notification counter map is ledger field 0. */
5
+ export declare const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD = 0;
6
+ /** Signet contract layout: the notification map is ledger field 1. */
7
+ export declare const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD = 1;
8
+ /** Signet contract layout: the signature response counter map is ledger field 2. */
9
+ export declare const SIGNATURE_RESPONSE_COUNTER_MAP_FIELD = 2;
10
+ /** Signet contract layout: the signature response map is ledger field 3. */
11
+ export declare const SIGNATURE_RESPONSE_MAP_FIELD = 3;
12
+ /** Signet contract layout: the respond-bidirectional counter map is ledger field 4. */
13
+ export declare const RESPOND_BIDIRECTIONAL_COUNTER_MAP_FIELD = 4;
14
+ /** Signet contract layout: the respond-bidirectional map is ledger field 5. */
15
+ export declare const RESPOND_BIDIRECTIONAL_MAP_FIELD = 5;
14
16
  /**
15
17
  * The MPC's secp256k1 signature over the requested EVM transaction (Compact
16
- * `SignatureResponse` — the canonical MPC `Signature { big_r, s,
18
+ * `SignatureRespondedEvent` — the canonical MPC `Signature { big_r, s,
17
19
  * recovery_id }` with `big_r` decomposed into affine coordinates, big-endian
18
- * scalar bytes). The request id it answers lives in the response index key,
19
- * not here.
20
+ * scalar bytes). The request id it answers lives in the map key, not here.
20
21
  */
21
- export interface SignatureResponse {
22
+ export interface SignatureRespondedEvent {
22
23
  /** Signature R.x, 32 big-endian bytes. */
23
24
  bigRx: Uint8Array;
24
25
  /** Signature R.y, 32 big-endian bytes. */
@@ -29,62 +30,59 @@ export interface SignatureResponse {
29
30
  recoveryId: bigint;
30
31
  }
31
32
  /**
32
- * Hand-composed descriptor for {@link SignatureResponse}. Field
33
+ * Hand-composed descriptor for {@link SignatureRespondedEvent}. Field
33
34
  * order (bigRx, bigRy, s, recoveryId) must match the Compact struct.
34
35
  */
35
- export declare const signatureResponseType: CompactType<SignatureResponse>;
36
+ export declare const signatureRespondedEventType: CompactType<SignatureRespondedEvent>;
36
37
  /**
37
- * The MPC's respond-bidirectional attestation of a request's remote EVM
38
- * execution (Compact `RespondBidirectional`): the serialized execution output
39
- * plus the secp256k1 ECDSA signature over the attestation digest
40
- * `signetAttestationMessage(requestId, serializedOutput, outputLen)`. Stored
41
- * records were verified IN-CIRCUIT by the signet contract at post time, so
42
- * readers can trust them without re-verifying. The signing public key is not
43
- * stored here — it is pinned by hash against the sealed MPC key.
38
+ * The MPC's respond-bidirectional response for a request's remote EVM
39
+ * execution (Compact `RespondBidirectionalEvent`): the serialized execution
40
+ * output plus the ECDSA signature over the attestation digest of
41
+ * `(requestId, serializedOutput, outputLen)`. Stored UNVERIFIED by the signet
42
+ * contract — clients verify it themselves (in-circuit via
43
+ * `verifyRespondBidirectionalEvent`, or off-chain via the compiled
44
+ * `pureCircuits.verifyRespondBidirectionalEvent`).
44
45
  */
45
- export interface RespondBidirectional {
46
+ export interface RespondBidirectionalEvent {
46
47
  /** ABI-encoded return data (canonical serialized_output), zero-padded to 128 bytes. */
47
48
  serializedOutput: Uint8Array;
48
49
  /** Meaningful byte count of {@link serializedOutput}. */
49
50
  outputLen: bigint;
50
- /**
51
- * ECDSA signature scalar r as 32 LITTLE-ENDIAN bytes (the byte order the
52
- * `Secp256k1Scalar as Bytes<32>` cast produces; recover the scalar with
53
- * `bytesToBigint`).
54
- */
55
- sigR: Uint8Array;
56
- /** ECDSA signature scalar s as 32 little-endian bytes (see {@link sigR}). */
57
- sigS: Uint8Array;
51
+ /** Signature scalar r (= R.x mod n), 32 LITTLE-endian bytes (the `Secp256k1Scalar as Bytes<32>` cast). */
52
+ r: Uint8Array;
53
+ /** Signature scalar s, 32 LITTLE-endian bytes. */
54
+ s: Uint8Array;
55
+ /** Recovery id (parity of R.y), for off-chain public-key recovery. */
56
+ recoveryId: bigint;
58
57
  }
59
58
  /**
60
- * Composite key of one posted signature response (Compact
61
- * `SignetResponseKey`): the request id it answers plus this post's 0-based
59
+ * Composite key of one posted entry in the signet contract's maps (Compact
60
+ * `SignetMapKey`): the request id it belongs to plus the post's 0-based
62
61
  * count. Field order — count first, then request id — mirrors the Compact
63
62
  * struct.
64
63
  */
65
- export interface SignetResponseKey {
66
- /** 0-based position of this post among the responses for {@link requestId}. */
64
+ export interface SignetMapKey {
65
+ /** 0-based position of this post among the entries for {@link requestId}. */
67
66
  count: bigint;
68
- /** 32-byte id of the request this response answers. */
67
+ /** 32-byte id of the request this entry belongs to. */
69
68
  requestId: RequestId;
70
69
  }
71
70
  /**
72
- * Hand-composed descriptor for {@link SignetResponseKey} — the map key of
73
- * the signature response log. Field order (count, then requestId) must match
74
- * the Compact struct.
71
+ * Hand-composed descriptor for {@link SignetMapKey} — the map key of every
72
+ * posted-entry map in the signet contract. Field order (count, then
73
+ * requestId) must match the Compact struct.
75
74
  */
76
- export declare const signetResponseKeyType: CompactType<SignetResponseKey>;
75
+ export declare const signetMapKeyType: CompactType<SignetMapKey>;
77
76
  /**
78
- * Hand-composed descriptor for {@link RespondBidirectional}. Field
79
- * order (serializedOutput, outputLen, sigR, sigS) must match the Compact
80
- * struct — the signature scalars are stored as `Bytes<32>`, not
81
- * `Secp256k1Scalar`.
77
+ * Hand-composed descriptor for {@link RespondBidirectionalEvent}. Field
78
+ * order (serializedOutput, outputLen, r, s, recoveryId) must match the
79
+ * Compact struct.
82
80
  */
83
- export declare const respondBidirectionalType: CompactType<RespondBidirectional>;
81
+ export declare const respondBidirectionalEventType: CompactType<RespondBidirectionalEvent>;
84
82
  /**
85
- * Raw twin of the Compact `SignBidirectionalNotification` struct as stored
86
- * on-ledger: the version tag plus the still-packed 65-byte payload. Decode
87
- * the payload with {@link decodeSignBidirectionalNotification}.
83
+ * Raw twin of the Compact `SignBidirectionalEventNotification` struct as
84
+ * stored on-ledger: the version tag plus the still-packed 128-byte payload.
85
+ * Decode the payload with {@link decodeSignBidirectionalNotification}.
88
86
  */
89
87
  export interface SignBidirectionalNotificationRecord {
90
88
  /** Payload layout tag (Compact `Uint<8>`); 1 = the V1 layout. */
@@ -100,35 +98,35 @@ export declare const signBidirectionalNotificationType: CompactType<SignBidirect
100
98
  /**
101
99
  * A decoded V1 notification from the signet contract's registry: the flat
102
100
  * pointer a client registered to tell the MPC a request was stored — and
103
- * WHERE to read the authenticated copy. Never trusted on its own: the
104
- * resolver authenticates by reading the request back from
101
+ * WHERE to read the authenticated copy. The request id is NOT in the payload:
102
+ * it lives in the registry map key the record was stored under. Never trusted
103
+ * on its own: the resolver authenticates by reading the request back from
105
104
  * {@link callerAddress}'s own ledger (see signet-request-resolver.ts).
106
105
  */
107
106
  export interface SignBidirectionalNotification {
108
107
  /** Payload layout tag; this decoder only produces version 1. */
109
108
  version: number;
110
109
  /**
111
- * Address of the contract whose request index holds the request, rendered
110
+ * Address of the contract whose request map holds the request, rendered
112
111
  * as lowercase hex, no `0x` prefix — directly usable as a
113
112
  * `queryContractState` argument. The MPC reads the request from THIS
114
113
  * contract's authenticated state; the field itself confers no authority.
115
114
  */
116
115
  callerAddress: string;
117
- /** Which request in {@link callerAddress}'s index this notification is about. */
118
- requestId: RequestIdHex;
119
116
  /**
120
- * Ledger field position of the `Map<RequestId, SignBidirectionalRequest>`
121
- * request index in {@link callerAddress} (the signet layout convention puts
122
- * it at field 0, but the notification carries it so the reader never assumes).
117
+ * Ledger field position of the `SignBidirectionalEventMap` in
118
+ * {@link callerAddress} (the caller contract in this repo declares it at
119
+ * field 4, but the notification carries it so the reader never assumes).
123
120
  */
124
121
  requestsIndexField: number;
125
122
  }
126
123
  /**
127
124
  * Unpack a stored {@link SignBidirectionalNotificationRecord}'s payload by
128
125
  * the fixed V1 offsets — the decode twin of the compiled
129
- * `constructSignBidirectionalNotificationV1` circuit (byte plumbing only; the
130
- * pack↔decode lockstep is pinned by the state-reader unit test that round-trips
131
- * through the real circuit).
126
+ * `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
127
+ * only; the pack↔decode lockstep is pinned by the state-reader unit test that
128
+ * round-trips through the real circuit). V1 layout:
129
+ * callerAddress (32) ++ requestsIndexField (1) ++ zero padding (95).
132
130
  *
133
131
  * Fails closed on an unrecognised `version`: a future payload layout adds a
134
132
  * branch here rather than silently misinterpreting bytes under the V1 offsets.
@@ -140,92 +138,83 @@ export interface SignBidirectionalNotification {
140
138
  export declare function decodeSignBidirectionalNotification(record: SignBidirectionalNotificationRecord): SignBidirectionalNotification;
141
139
  /**
142
140
  * Plain-JS notification registry parsed out of the ledger: hex request id
143
- * (the map KEY under which the notification was registered) to the raw
144
- * stored record. Decode each record with
141
+ * (from the `SignetMapKey` the notification was stored under) to the raw
142
+ * stored record. Re-notifies append under higher counts; this index keeps
143
+ * the FIRST post (count 0) per request id — the record the original submit
144
+ * registered. Decode each record with
145
145
  * {@link decodeSignBidirectionalNotification}.
146
146
  */
147
147
  export type SignBidirectionalNotificationIndex = Map<RequestIdHex, SignBidirectionalNotificationRecord>;
148
148
  /**
149
- * Plain-JS signature response counter index parsed out of the ledger: hex
150
- * request id (see {@link requestIdHex}) to the number of responses posted for
151
- * that request. Entries in the response log exist for counts `0 .. value - 1`.
149
+ * Plain-JS counter map parsed out of the ledger: hex request id (see
150
+ * {@link requestIdHex}) to the number of entries posted for that request.
151
+ * Entries in the corresponding map exist for counts `0 .. value - 1`.
152
152
  */
153
- export type SignatureResponseCounterIndex = Map<RequestIdHex, bigint>;
153
+ export type SignetCounterIndex = Map<RequestIdHex, bigint>;
154
154
  /**
155
155
  * Plain-JS signature response log parsed out of the ledger, keyed by
156
- * {@link signetResponseIndexKey} (`"<hexRequestId>:<count>"`) so the
157
- * composite Compact key survives as a usable JS `Map` key.
156
+ * {@link signetMapEntryKey} (`"<hexRequestId>:<count>"`) so the composite
157
+ * Compact key survives as a usable JS `Map` key.
158
158
  */
159
- export type SignatureResponseIndex = Map<string, SignatureResponse>;
159
+ export type SignatureResponseIndex = Map<string, SignatureRespondedEvent>;
160
160
  /**
161
- * Plain-JS respond-bidirectional index parsed out of the ledger: hex
162
- * request id to the contract-verified attestation. One slot per request.
161
+ * Plain-JS respond-bidirectional log parsed out of the ledger, keyed by
162
+ * {@link signetMapEntryKey} (`"<hexRequestId>:<count>"`).
163
163
  */
164
- export type RespondBidirectionalIndex = Map<RequestIdHex, RespondBidirectional>;
164
+ export type RespondBidirectionalIndex = Map<string, RespondBidirectionalEvent>;
165
165
  /**
166
- * Build the {@link SignatureResponseIndex} key for a `(requestId, count)`
167
- * pair — the composite Compact key flattened to a string so it works as a JS
166
+ * Build the flattened JS map key for a `(requestId, count)` pair — the
167
+ * composite Compact {@link SignetMapKey} as a string so it works as a JS
168
168
  * `Map` key.
169
169
  *
170
- * @param id - The request id the response answers, in canonical hex form.
170
+ * @param id - The request id the entry belongs to, in canonical hex form.
171
171
  * @param count - 0-based post count within that request.
172
172
  * @returns `"<hexRequestId>:<count>"`.
173
173
  */
174
- export declare function signetResponseIndexKey(id: RequestIdHex, count: bigint): string;
174
+ export declare function signetMapEntryKey(id: RequestIdHex, count: bigint): string;
175
175
  /**
176
176
  * Read ONLY the notification registry (ledger field
177
- * {@link SIGN_BIDIRECTIONAL_NOTIFICATION_INDEX_FIELD}) out of raw signet
177
+ * {@link SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD}) out of raw signet
178
178
  * contract state — the poll-loop primitive of {@link SignetRequestFeed},
179
- * which cycles frequently and has no use for the response fields.
179
+ * which cycles frequently and has no use for the response fields. One record
180
+ * per request id (the count-0 post; see
181
+ * {@link SignBidirectionalNotificationIndex}).
180
182
  *
181
183
  * @param raw - Raw contract state, e.g. `queryContractState(address).data`
182
184
  * from the indexer or `ctx.currentQueryContext.state` from the simulator.
183
- * @returns The registry, keyed by the hex request id each record was
184
- * registered under.
185
+ * @returns The registry, keyed by the hex request id of each entry's map key.
185
186
  * @throws Error if the field is missing or is not a Map.
186
187
  */
187
188
  export declare function readSignBidirectionalNotificationIndexFromState(raw: RawContractState): SignBidirectionalNotificationIndex;
188
189
  /**
189
- * The decoded ledger fields of the signet contract: the signature response
190
- * counter (field 0) and log (field 1), the respond-bidirectional index
191
- * (field 2), the sealed MPC attestation key hash (field 3), and the request
192
- * notification registry (field 4). Together they give a poller everything
193
- * the contract ever records about a request.
190
+ * The decoded ledger fields of the signet contract: the three
191
+ * (counter map, entry map) pairs — notifications (fields 0/1), signature
192
+ * responses (fields 2/3), respond-bidirectional responses (fields 4/5).
193
+ * Together they give a poller everything the contract ever records about a
194
+ * request. All entries are UNAUTHENTICATED: verify before trusting.
194
195
  */
195
196
  export interface SignetContractLedger {
197
+ /** Notification post counts per request id (ledger field 0). */
198
+ signBidirectionalEventNotificationCounterMap: SignetCounterIndex;
196
199
  /**
197
- * The signature response counter index (ledger field
198
- * {@link SIGNATURE_RESPONSE_COUNTER_INDEX_FIELD}), keyed by hex request id.
199
- */
200
- signatureResponseCounterIndex: SignatureResponseCounterIndex;
201
- /**
202
- * The signature response log (ledger field
203
- * {@link SIGNATURE_RESPONSE_INDEX_FIELD}), keyed by
204
- * {@link signetResponseIndexKey}.
205
- */
206
- signatureResponseIndex: SignatureResponseIndex;
207
- /**
208
- * The respond-bidirectional index (ledger field
209
- * {@link RESPOND_BIDIRECTIONAL_INDEX_FIELD}), keyed by hex request id.
210
- */
211
- respondBidirectionalIndex: RespondBidirectionalIndex;
212
- /**
213
- * The sealed MPC attestation key hash (ledger field
214
- * {@link MPC_PUB_KEY_HASH_FIELD}) posts are verified against.
215
- */
216
- mpcPubKeyHash: Uint8Array;
217
- /**
218
- * The request notification registry (ledger field
219
- * {@link SIGN_BIDIRECTIONAL_NOTIFICATION_INDEX_FIELD}), keyed by hex
220
- * request id.
200
+ * The notification registry (ledger field 1), one record per request id
201
+ * (count-0 post).
221
202
  */
222
- signBidirectionalNotificationIndex: SignBidirectionalNotificationIndex;
203
+ signBidirectionalEventNotificationMap: SignBidirectionalNotificationIndex;
204
+ /** Signature response post counts per request id (ledger field 2). */
205
+ signatureResponseCounterMap: SignetCounterIndex;
206
+ /** The signature response log (ledger field 3), keyed by {@link signetMapEntryKey}. */
207
+ signatureResponseMap: SignatureResponseIndex;
208
+ /** Respond-bidirectional post counts per request id (ledger field 4). */
209
+ respondBidirectionalCounterMap: SignetCounterIndex;
210
+ /** The respond-bidirectional log (ledger field 5), keyed by {@link signetMapEntryKey}. */
211
+ respondBidirectionalMap: RespondBidirectionalIndex;
223
212
  }
224
213
  /**
225
214
  * MPC-/client-style read: parse the signet contract's ledger fields out of
226
215
  * raw contract state by field position alone — no compiled contract, no
227
- * generated `ledger()`, only the signet contract layout convention and the
228
- * canonical descriptors above.
216
+ * generated `ledger()`, only the declaration-order layout and the canonical
217
+ * descriptors above.
229
218
  *
230
219
  * @param raw - Raw contract state, e.g. `queryContractState(address).data`
231
220
  * from the indexer or `ctx.currentQueryContext.state` from the simulator.