@sig-net/midnight 0.24.0-rc.2 → 0.24.0-rc.3

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 (42) hide show
  1. package/README.md +13 -21
  2. package/dist/compact-descriptors.d.ts +17 -4
  3. package/dist/compact-descriptors.d.ts.map +1 -1
  4. package/dist/compact-descriptors.js +29 -29
  5. package/dist/compact-descriptors.js.map +1 -1
  6. package/dist/constants.d.ts +1 -1
  7. package/dist/constants.js +1 -1
  8. package/dist/ecdsa-attestation.d.ts +3 -3
  9. package/dist/ecdsa-attestation.js +4 -4
  10. package/dist/ecdsa-attestation.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/managed/compiler/contract-info.json +952 -2
  16. package/dist/managed/compiler/contract-manifest.json +8 -8
  17. package/dist/managed/contract/index.d.ts +221 -0
  18. package/dist/managed/contract/index.js +915 -201
  19. package/dist/managed/contract/index.js.map +1 -1
  20. package/dist/mpc-output-cache.js +2 -2
  21. package/dist/mpc-output-cache.js.map +1 -1
  22. package/dist/signature-requests-state-reader.js +3 -3
  23. package/dist/signature-requests-state-reader.js.map +1 -1
  24. package/dist/signet-contract-events.d.ts +4 -4
  25. package/dist/signet-evtype2tx-record-decoding.d.ts.map +1 -1
  26. package/dist/signet-evtype2tx-record-decoding.js +5 -4
  27. package/dist/signet-evtype2tx-record-decoding.js.map +1 -1
  28. package/dist/signet-evtype2tx-requests.d.ts +17 -12
  29. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  30. package/dist/signet-evtype2tx-requests.js +85 -16
  31. package/dist/signet-evtype2tx-requests.js.map +1 -1
  32. package/dist/signet-request-id.d.ts +5 -3
  33. package/dist/signet-request-id.d.ts.map +1 -1
  34. package/dist/signet-request-id.js +14 -12
  35. package/dist/signet-request-id.js.map +1 -1
  36. package/dist/signet-requests.d.ts +30 -34
  37. package/dist/signet-requests.d.ts.map +1 -1
  38. package/dist/signet-requests.js +15 -23
  39. package/dist/signet-requests.js.map +1 -1
  40. package/package.json +2 -2
  41. package/src/Signet.compact +181 -72
  42. package/src/circuits.compact +42 -9
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAMnE;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,SAAS,CAAY,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB,sFAAsF;aACtF,QAAQ,EAAE,CAAC;IACX;;;;OAIG;aACH,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAChC,4BAA4B;aAC5B,KAAK,EAAE,CAAC;IACR,0EAA0E;aAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,sCAAsC;aACtC,MAAM,EAAE,CAAC;IACT,0EAA0E;aAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB,CAAC,QAAQ,GAAG,gBAAgB;IAC5D,+EAA+E;IAC/E,MAAM,EAAE,eAAe,CAAC;IACxB,kDAAkD;IAClD,UAAU,EA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ACpC,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,YAAY,GAAG,SAAS,CAE1D;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,GACzD,2BAA2B,CAM7B"}
@@ -91,30 +91,22 @@ const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
91
91
  const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
92
92
  const MPC_DESTINATION = new CompactTypeEnum(1, 1);
93
93
  /**
94
- * Descriptor of {@link RequestIdPreimage} over ANY tx-params decomposition:
95
- * the TS analogue of Compact's generic `RequestIdPreimage`, what
96
- * `calculateRequestId` (signet-request-id.ts) hashes. Field order is the
97
- * Compact struct's, a subsequence of {@link signBidirectionalEventDescriptorWith}'s.
98
- *
99
- * @param txParams - Descriptor of the tx-params decomposition, already at
100
- * its capacity instantiation.
101
- * @returns The preimage descriptor.
94
+ * Descriptor of {@link RequestIdPreimage}: what {@link calculateRequestId}
95
+ * hashes, in Compact declaration order.
102
96
  */
103
- export function requestIdPreimageDescriptorWith(txParams) {
104
- return compactStructDescriptor({
105
- sender: CONTRACT_ADDRESS,
106
- keyVersion: UINT_8,
107
- path: BYTES_32,
108
- algo: MPC_SIGNATURE_ALGORITHM,
109
- txParamType: TX_PARAM_TYPE,
110
- txParams,
111
- executionDest: BYTES_32,
112
- });
113
- }
97
+ export const requestIdPreimageDescriptor = compactStructDescriptor({
98
+ keyVersion: UINT_8,
99
+ sender: CONTRACT_ADDRESS,
100
+ path: BYTES_32,
101
+ algo: MPC_SIGNATURE_ALGORITHM,
102
+ txParamType: TX_PARAM_TYPE,
103
+ txParamsDigest: BYTES_32,
104
+ executionDest: BYTES_32,
105
+ });
114
106
  /**
115
107
  * Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
116
108
  * decomposition: the TS analogue of Compact's generic
117
- * `SignBidirectionalEvent`. Each decomposition wraps this with its own
109
+ * `SignBidirectionalEventV1`. Each decomposition wraps this with its own
118
110
  * capacity-parameterised convenience (see `signBidirectionalEventDescriptor`
119
111
  * in signet-evtype2tx-requests.ts for the EVM Type-2 one).
120
112
  *
@@ -128,15 +120,15 @@ export function requestIdPreimageDescriptorWith(txParams) {
128
120
  */
129
121
  export function signBidirectionalEventDescriptorWith(txParams, lenOutputDeserialization, lenRespondSerialization) {
130
122
  return compactStructDescriptor({
131
- sender: CONTRACT_ADDRESS,
132
123
  keyVersion: UINT_8,
124
+ sender: CONTRACT_ADDRESS,
133
125
  path: BYTES_32,
134
126
  algo: MPC_SIGNATURE_ALGORITHM,
135
- signatureDest: MPC_DESTINATION,
136
- params: BYTES_64,
137
127
  txParamType: TX_PARAM_TYPE,
138
128
  txParams,
139
129
  executionDest: BYTES_32,
130
+ signatureDest: MPC_DESTINATION,
131
+ params: BYTES_64,
140
132
  outputDeserializationSchema: new CompactTypeBytes(lenOutputDeserialization),
141
133
  respondSerializationSchema: new CompactTypeBytes(lenRespondSerialization),
142
134
  });
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8CAA8C;AAC9C,yDAAyD;AAEzD,OAAO,EAEL,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AAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAgB;IAC7C,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAA0D;IAE1D,MAAM,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC/C,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sig-net/midnight",
3
- "version": "0.24.0-rc.2",
3
+ "version": "0.24.0-rc.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sig-net/midnight-integration",
@@ -49,7 +49,7 @@
49
49
  "@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
50
50
  "@midnight-ntwrk/midnight-js-types": "5.0.0-beta.6",
51
51
  "@noble/curves": "^2.2.0",
52
- "@sig-net/midnight-serde": "^0.24.0-rc.2",
52
+ "@sig-net/midnight-serde": "^0.24.0-rc.3",
53
53
  "ethers": "^6.17.0"
54
54
  },
55
55
  "devDependencies": {
@@ -18,17 +18,23 @@
18
18
  // import "@sig-net/midnight/src/Signet";
19
19
  //
20
20
  // Key types at a glance (each declaration below carries the full contract):
21
- // - SignBidirectionalEvent: a client contract's structured request for a signature on a transaction.
22
- // - RequestId: 32-byte id of a request, the transientHash of its RequestIdPreimage (the record
23
- // minus the serialisation schemas).
24
- // - SignBidirectionalEventMap: the RequestId -> SignBidirectionalEvent map a client contract
21
+ // - SignBidirectionalEventV1: a client contract's structured request for a signature on a transaction.
22
+ // - RequestId: 32-byte id of a request, the transientHash of its RequestIdPreimageV1 (the fields
23
+ // that name one execution: key, sender, path, a digest of the transaction and its destination).
24
+ // - SignBidirectionalEventMapV1: the RequestId -> SignBidirectionalEventV1 map a client contract
25
25
  // declares in its own ledger for the MPC to read requests from.
26
26
  // - SignetSigner: the contract interface client contracts call to notify the Signet singleton.
27
- // - SignBidirectionalEventNotification: the versioned notification delivered through that call.
28
- // - SignatureRespondedEvent: the MPC's posted signature answering a request.
29
- // - RespondBidirectionalEvent: the MPC's posted attestation that the foreign chain executed the
27
+ // - SignBidirectionalEventNotification: the notification delivered through that call, versioned by
28
+ // the version byte it carries.
29
+ // - SignatureRespondedEventV1: the MPC's posted signature answering a request.
30
+ // - RespondBidirectionalEventV1: the MPC's posted attestation that the foreign chain executed the
30
31
  // signed transaction.
31
32
  //
33
+ // The V1 suffix marks the wire and hash-domain artefacts of protocol version 1 (the structs the
34
+ // ledger stores and the singleton emits, and the circuits that hash or verify them). Vocabulary
35
+ // shared across versions (RequestId, OutputKind, Signature, the enums, the transaction parameter
36
+ // structs, which TxParamType tags) and the version-tagged notification carry no suffix.
37
+ //
32
38
  // These key types are best understood within the sign bidirectional flow that they enable:
33
39
  // 1. Client contract stores a SignBidirectionalEvent in a SignBidirectionalEventMap in its own ledger
34
40
  // (against the calculated RequestId) and requests a signature from the MPC via a cross contract call
@@ -67,10 +73,8 @@ module Signet {
67
73
  //
68
74
  // KEY: texual order of the fields in this structure must remain fixed as is as their order
69
75
  // is relied upon for consistent hashing and decoding from ledger state.
70
- export struct SignBidirectionalEvent<TxParams, #LenOutputDeserialization, #LenRespondSerialization> {
71
- // Address of the client contract that stores and notifies of this SignBidirectionalEvent.
72
- // Set with kernel.self().
73
- sender: ContractAddress;
76
+ export struct SignBidirectionalEventV1<TxParams, #LenOutputDeserialization, #LenRespondSerialization> {
77
+ // ---- RequestIdPreimageV1 fields: hashed into the request id, in this order ----
74
78
 
75
79
  // MPC Key Derivation Parameters.
76
80
  // Every key the MPC signs with is scoped by the requesting contract:
@@ -83,13 +87,13 @@ module Signet {
83
87
  // CRITICAL: the MPC renders the path as hex::encode(path) for key derivation (lowercase hex
84
88
  // of the full 32 bytes, no trimming, no 0x prefix). The sender is always part
85
89
  // of the derivation, so no contract can reach another contract's derived keys.
86
- keyVersion: Uint<8>; // MPC root-key version to derive from. Currently 1.
87
- path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
90
+ keyVersion: Uint<8>; // MPC root-key version to derive from. Currently 1.
91
+ sender: ContractAddress; // Address of the client contract that stores and notifies of this
92
+ // request. Set with kernel.self().
93
+ path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
88
94
 
89
95
  // MPC Parameters.
90
96
  algo: MPCSignatureAlgorithm; // Signature algorithm scheme, e.g. ecdsa
91
- signatureDest: MPCDestination; // Destination field reserved for future use. Set to unused.
92
- params: Bytes<64>; // Extra MPC parameters reserved for future use. Zero-fill.
93
97
 
94
98
  // Specific destination chain Transaction parameters.
95
99
  txParamType: TxParamType; // Off-chain tag indicating what type txParams is set to.
@@ -99,6 +103,11 @@ module Signet {
99
103
  // (mainnet, Sepolia or a local anvil) uses ethereumCaip2Id():
100
104
  // the network itself is txParams' chainId.
101
105
 
106
+ // ---- Protocol-only fields: outside the request id ----
107
+
108
+ signatureDest: MPCDestination; // Destination field reserved for future use. Set to unused.
109
+ params: Bytes<64>; // Extra MPC parameters reserved for future use. Zero-fill.
110
+
102
111
  // Serialisation Schemas.
103
112
  // outputDeserializationSchema tells the MPC how to deserialise the destination chain's
104
113
  // execution output (destination chain -> MPC). respondSerializationSchema tells the MPC
@@ -131,36 +140,37 @@ module Signet {
131
140
  reserved, // Reserved for future use. Exists to keep enum >= 2 (proof server bug).
132
141
  }
133
142
 
134
- // Construction helper for the canonical Signet SignBidirectionalEvent.
135
- export pure circuit constructSignBidirectionalEvent<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
136
- sender: ContractAddress,
143
+ // Construction helper for the canonical Signet SignBidirectionalEventV1.
144
+ export pure circuit constructSignBidirectionalEventV1<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
137
145
  keyVersion: Uint<8>,
146
+ sender: ContractAddress,
138
147
  path: Bytes<32>,
139
148
  algo: MPCSignatureAlgorithm,
140
- signatureDest: MPCDestination,
141
- params: Bytes<64>,
142
149
  txParamType: TxParamType,
143
150
  txParams: TxParams,
144
151
  executionDest: Bytes<32>,
152
+ signatureDest: MPCDestination,
153
+ params: Bytes<64>,
145
154
  outputDeserializationSchema: Bytes<LenOutputDeserialization>,
146
155
  respondSerializationSchema: Bytes<LenRespondSerialization>,
147
- ): SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
156
+ ): SignBidirectionalEventV1<TxParams, LenOutputDeserialization, LenRespondSerialization> {
148
157
  assert(keyVersion >= 1, "keyVersion must be >= 1");
149
158
  // The protocol reserves the "midnight response key" path for the MPC's
150
- // attestation key of this contract (see RespondBidirectionalEvent), and the
159
+ // attestation key of this contract (see RespondBidirectionalEventV1), and the
151
160
  // MPC refuses a request that names it.
152
161
  assert(path != pad(32, "midnight response key"), "path is reserved for the MPC response key");
153
162
 
154
- return SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
155
- sender,
163
+ // Shorthand struct fields bind positionally: this list follows the declaration order.
164
+ return SignBidirectionalEventV1<TxParams, LenOutputDeserialization, LenRespondSerialization> {
156
165
  keyVersion,
166
+ sender,
157
167
  path,
158
168
  algo,
159
- signatureDest,
160
- params,
161
169
  txParamType,
162
170
  txParams,
163
171
  executionDest,
172
+ signatureDest,
173
+ params,
164
174
  outputDeserializationSchema,
165
175
  respondSerializationSchema,
166
176
  };
@@ -169,25 +179,27 @@ module Signet {
169
179
  // ---- SignBidirectionalEvent RequestId --------------------------------------------------------------
170
180
 
171
181
  // 32 byte chain agnostic nominal id of a SignBidirectionalEvent, calculated as the
172
- // transientHash of its RequestIdPreimage (see calculateRequestId).
182
+ // transientHash of its RequestIdPreimageV1 (see calculateRequestIdV1).
173
183
  export new type RequestId = Bytes<32>;
174
184
 
175
- // The fields of a SignBidirectionalEvent that name one execution: the requesting contract,
176
- // the signing key (version, path, algorithm), the transaction and its execution destination.
177
- // The serialisation schemas and the reserved MPC parameters (signatureDest, params) stay
178
- // out, so two requests for one transaction cannot both be outstanding whatever schemas
179
- // they declare, and the id does not depend on the schemas' declared widths either.
185
+ // The fields of a SignBidirectionalEventV1 that name one execution: the signing key
186
+ // (keyVersion, path, algo), the requesting contract, the transaction and its execution
187
+ // destination. Fields the execution does not depend on (the serialisation schemas and
188
+ // the reserved MPC parameters signatureDest and params) stay out. The transaction
189
+ // enters as a digest computed per TxParamType over its USED entries only
190
+ // (calculateEvmType2TxParamsDigestV1 for evmType2), so one execution has one id
191
+ // whatever capacities the requester compiled with and whatever sits in unused slots.
180
192
  //
181
- // KEY: the field order follows SignBidirectionalEvent's and is relied upon for consistent
182
- // hashing. The TS twin (requestIdPreimageDescriptorWith in signet-requests.ts)
183
- // mirrors it field by field.
184
- export struct RequestIdPreimage<TxParams> {
185
- sender: ContractAddress;
193
+ // KEY: the field order follows SignBidirectionalEventV1's and is relied upon for consistent
194
+ // hashing. The TS twin (requestIdPreimageDescriptor in signet-requests.ts) mirrors it
195
+ // field by field.
196
+ export struct RequestIdPreimageV1 {
186
197
  keyVersion: Uint<8>;
198
+ sender: ContractAddress;
187
199
  path: Bytes<32>;
188
200
  algo: MPCSignatureAlgorithm;
189
201
  txParamType: TxParamType;
190
- txParams: TxParams;
202
+ txParamsDigest: Bytes<32>;
191
203
  executionDest: Bytes<32>;
192
204
  }
193
205
 
@@ -201,21 +213,10 @@ module Signet {
201
213
  // - byte 31 is always zero. upgradeFromTransient writes the field element's 31
202
214
  // little-endian bytes into bytes 0..30, so an id carries ~248 bits of entropy.
203
215
  // - a Bytes<N> field packs into ceil(N/31) field elements, so trailing zero bytes
204
- // within a chunk do not change the hash. Widths here are fixed at compile time
205
- // and every id commits to its sender, so requests cannot collide in practice.
206
- export pure circuit calculateRequestId<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
207
- request: SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>
208
- ): RequestId {
209
- const preimage = RequestIdPreimage<TxParams> {
210
- sender: request.sender,
211
- keyVersion: request.keyVersion,
212
- path: request.path,
213
- algo: request.algo,
214
- txParamType: request.txParamType,
215
- txParams: request.txParams,
216
- executionDest: request.executionDest,
217
- };
218
- return upgradeFromTransient(transientHash<RequestIdPreimage<TxParams>>(preimage)) as RequestId;
216
+ // within a chunk do not change the hash. Every id commits to its sender, so
217
+ // requests cannot collide in practice.
218
+ export pure circuit calculateRequestIdV1(preimage: RequestIdPreimageV1): RequestId {
219
+ return upgradeFromTransient(transientHash<RequestIdPreimageV1>(preimage)) as RequestId;
219
220
  }
220
221
 
221
222
  // ---- Client Contract: SignBidirectionalEvent Map ---------------------------------------------------
@@ -224,7 +225,7 @@ module Signet {
224
225
  // in their ledger. Client contract tells MPC field location of this map when making a cross
225
226
  // contract call, via SignetSigner, to the Signet singleton. The MPC looks here to find
226
227
  // SignBidirectionalEvents.
227
- export new type SignBidirectionalEventMap<TxParams, #LenOutputDeserialization, #LenRespondSerialization> = Map<RequestId, SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>>;
228
+ export new type SignBidirectionalEventMapV1<TxParams, #LenOutputDeserialization, #LenRespondSerialization> = Map<RequestId, SignBidirectionalEventV1<TxParams, LenOutputDeserialization, LenRespondSerialization>>;
228
229
 
229
230
  // ---- Cross Contract SignBidirectionalEventNotification ---------------------------------------------
230
231
 
@@ -233,7 +234,7 @@ module Signet {
233
234
  export contract SignetSigner {
234
235
  // Called by client contracts to notify the MPC of a SignBidirectionalEvent.
235
236
  circuit signBidirectional(
236
- // Canonical id of the SignBidirectionalEvent (calculate with calculateRequestId).
237
+ // Canonical id of the SignBidirectionalEvent (calculateEvmType2RequestIdV1 for evmType2).
237
238
  // Disclosed in the emitted notification event: the MPC looks this id up in the
238
239
  // caller's own request map.
239
240
  requestId: RequestId,
@@ -256,7 +257,7 @@ module Signet {
256
257
  // Construction helper for the V1 SignBidirectionalEventNotification.
257
258
  //
258
259
  // The payload is a pointer for the MPC: the contract that holds the
259
- // SignBidirectionalEventMap (callerAddress) and the position of that map in
260
+ // SignBidirectionalEventMapV1 (callerAddress) and the position of that map in
260
261
  // the contract's raw ledger state tree (requestsPathDepth + requestsPath).
261
262
  //
262
263
  // Read the path from your contract's compiled artifacts, never derive it by
@@ -272,7 +273,7 @@ module Signet {
272
273
  // Number of meaningful entries in requestsPath: 1 for a flat (15 or fewer
273
274
  // field) contract, one more per chunk level after that (max 4).
274
275
  requestsPathDepth: Uint<8>,
275
- // Resolved ledger-tree path of the caller's SignBidirectionalEventMap, from
276
+ // Resolved ledger-tree path of the caller's SignBidirectionalEventMapV1, from
276
277
  // its contract-info.json "index". Entries at and beyond requestsPathDepth
277
278
  // are zero.
278
279
  requestsPath: Vector<4, Uint<8>>
@@ -309,7 +310,7 @@ module Signet {
309
310
  // Counterpart to SignBidirectionalEvent: the MPC generated signature a request asked for.
310
311
  // Posted by the MPC through the Signet singleton for clients to extract and build a
311
312
  // signed transaction from.
312
- export struct SignatureRespondedEvent {
313
+ export struct SignatureRespondedEventV1 {
313
314
  // The request this signature answers. Routing data: the singleton emits it
314
315
  // unverified, and a reader proves the signature against the request's own key.
315
316
  requestId: RequestId;
@@ -329,10 +330,10 @@ module Signet {
329
330
  // mpcResponseKey = f(mpcRootKey[keyVersion], caip2ChainId, sender, "midnight response key")
330
331
  //
331
332
  // The output travels off chain and the digest is recomputed at verification
332
- // time (verifyRespondBidirectionalEvent). The signature is the ONLY thing that
333
+ // time (verifyRespondBidirectionalEventV1). The signature is the ONLY thing that
333
334
  // distinguishes a genuine post from garbage: the singleton emits every post
334
335
  // unverified.
335
- export struct RespondBidirectionalEvent {
336
+ export struct RespondBidirectionalEventV1 {
336
337
  // The request this attestation answers. Signed into the digest: a verified
337
338
  // post settles exactly the request it names, so a client consumes this id
338
339
  // and never one taken from elsewhere.
@@ -347,7 +348,7 @@ module Signet {
347
348
  // or unviable execution), so a client holding no output yet knows which
348
349
  // width to settle at.
349
350
  serializedOutputLength: Uint<64>;
350
- // The attestation digest the signature is over (calculateSignetAttestationDigest),
351
+ // The attestation digest the signature is over (calculateSignetAttestationDigestV1),
351
352
  // so a reader holding no output can check the signature. The verifying
352
353
  // circuit recomputes it from the output and never reads this copy.
353
354
  digest: Bytes<32>;
@@ -370,8 +371,8 @@ module Signet {
370
371
  // transaction the attestation describes, in the destination chain's own
371
372
  // numbering (a slot on Solana).
372
373
  // Off-chain code uses the TypeScript twin:
373
- // import { calculateSignetAttestationDigest } from "@sig-net/midnight";
374
- export pure circuit calculateSignetAttestationDigest<#serializedOutputLength>(
374
+ // import { calculateSignetAttestationDigest } from "@sig-net/midnight/testing";
375
+ export pure circuit calculateSignetAttestationDigestV1<#serializedOutputLength>(
375
376
  requestId: RequestId,
376
377
  blockHeight: Uint<64>,
377
378
  outputKind: OutputKind,
@@ -397,12 +398,12 @@ module Signet {
397
398
  // that reduces to 0 mod the curve order aborts the
398
399
  // circuit rather than returning false, so sift candidate posts off chain
399
400
  // first (verifyRespondBidirectionalSignature).
400
- export pure circuit verifyRespondBidirectionalEvent<#serializedOutputLength>(
401
+ export pure circuit verifyRespondBidirectionalEventV1<#serializedOutputLength>(
401
402
  serializedOutput: Bytes<serializedOutputLength>,
402
- respondBidirectionalEvent: RespondBidirectionalEvent,
403
+ respondBidirectionalEvent: RespondBidirectionalEventV1,
403
404
  mpcResponseKey: Secp256k1Point
404
405
  ): Boolean {
405
- const digest = calculateSignetAttestationDigest<serializedOutputLength>(
406
+ const digest = calculateSignetAttestationDigestV1<serializedOutputLength>(
406
407
  respondBidirectionalEvent.requestId,
407
408
  respondBidirectionalEvent.blockHeight,
408
409
  respondBidirectionalEvent.outputKind,
@@ -439,10 +440,11 @@ module Signet {
439
440
  //
440
441
  // Every variable-length part is a compile-time CAPACITY (a generic size
441
442
  // parameter the requesting contract fixes) plus a runtime count of how many
442
- // leading slots are real. Unused capacity is hashed as part of the record
443
- // (zero-fill) but never reaches the assembled transaction. Field order is
444
- // the canonical EIP-1559 RLP order and the request-id hash order: part of
445
- // the wire contract, each count directly before the slot it bounds.
443
+ // leading slots are real. Unused capacity sits in the ledger record but
444
+ // reaches neither the request id (calculateEvmType2TxParamsDigestV1 walks
445
+ // the used slots only) nor the assembled transaction. Field order is the
446
+ // canonical EIP-1559 RLP order and the digest order: part of the wire
447
+ // contract, each count directly before the slot it bounds.
446
448
  //
447
449
  // KEY: texual order of the fields in this structure must remain fixed as is as their order
448
450
  // is relied upon for consistent hashing and decoding from ledger state.
@@ -464,7 +466,7 @@ module Signet {
464
466
  // raw 32-byte values, copied verbatim into the RLP encoding.
465
467
  //
466
468
  // KEY: texual order of the fields in this structure must remain fixed as is as their order
467
- // is relied upon for consistent hashing and decoding from ledger state.
469
+ // is relied upon for consistent hashing and decoding from ledger state.
468
470
  export struct EvmAccessListEntry<#maxStorageKeys> {
469
471
  address: Bytes<20>;
470
472
  storageKeyCount: Uint<8>; // how many leading storageKeys are real
@@ -479,13 +481,120 @@ module Signet {
479
481
  // canonical ABI words for common types.
480
482
  //
481
483
  // KEY: texual order of the fields in this structure must remain fixed as is as their order
482
- // is relied upon for consistent hashing and decoding from ledger state.
484
+ // is relied upon for consistent hashing and decoding from ledger state.
483
485
  export struct EvmCalldata<#maxWords> {
484
486
  selector: Bytes<4>; // the literal first 4 calldata bytes
485
487
  noWords: Uint<16>; // No. of used words in the words list
486
488
  words: Vector<maxWords, Bytes<32>>; // canonical ABI words (big-endian)
487
489
  }
488
490
 
491
+ // Digest of an EvmType2TxParams over the bytes that reach the signed transaction:
492
+ // the scalar fields, then the calldata words, access-list entries and storage keys
493
+ // up to their declared counts, each count hashed beside its entries so the encoding
494
+ // commits to its length. Slots past a count are skipped, and an absent calldata
495
+ // contributes only its absence, so one transaction has one digest whatever
496
+ // capacities the requester compiled its struct with and whatever bytes sit in
497
+ // unused slots. The counts must fit their capacities. Off-chain code uses the
498
+ // TypeScript twin calculateEvmType2TxParamsDigest in @sig-net/midnight.
499
+ //
500
+ // The slot walks are folds carrying the slot index and a running hash: a `for`
501
+ // over `0..n` has no index type at n = 0, and a zero capacity is the common case.
502
+ export pure circuit calculateEvmType2TxParamsDigestV1<#maxCalldataWords, #maxAccessListEntries, #maxStorageKeysPerEntry>(
503
+ txParams: EvmType2TxParams<maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry>
504
+ ): Bytes<32> {
505
+ // An absent calldata contributes is_some = false, a zero selector and a zero word count.
506
+ const calldata = txParams.calldata;
507
+ const noWords = calldata.is_some ? calldata.value.noWords : 0 as Uint<16>;
508
+ const selector = calldata.is_some ? calldata.value.selector : default<Bytes<4>>;
509
+
510
+ assert(noWords <= maxCalldataWords, "calldata noWords exceeds capacity");
511
+ assert(txParams.accessListEntryCount <= maxAccessListEntries, "accessListEntryCount exceeds capacity");
512
+
513
+ // For every used access-list entry, confirm its storageKeyCount fits
514
+ // maxStorageKeysPerEntry. A Compact loop needs a compile-time bound, so the walk
515
+ // is a fold over every slot carrying [slot index, all fit so far], and the index
516
+ // picks out the used entries.
517
+ const keyCountsFit = fold(
518
+ (acc: [Uint<8>, Boolean], entry: EvmAccessListEntry<maxStorageKeysPerEntry>): [Uint<8>, Boolean] =>
519
+ [(acc[0] + 1) as Uint<8>, acc[1] && (acc[0] >= txParams.accessListEntryCount || entry.storageKeyCount <= maxStorageKeysPerEntry)],
520
+ [0 as Uint<8>, true],
521
+ txParams.accessList
522
+ );
523
+ assert(keyCountsFit[1], "a used entry's storageKeyCount exceeds capacity");
524
+
525
+ // The scalar fields and the counts, hashed as one field-aligned tuple.
526
+ const head = transientHash<[Uint<64>, Uint<64>, Uint<128>, Uint<128>, Uint<64>, Bytes<20>, Uint<128>, Boolean, Bytes<4>, Uint<16>, Uint<8>]>([
527
+ txParams.chainId,
528
+ txParams.nonce,
529
+ txParams.maxPriorityFeePerGas,
530
+ txParams.maxFeePerGas,
531
+ txParams.gasLimit,
532
+ txParams.to,
533
+ txParams.value,
534
+ calldata.is_some,
535
+ selector,
536
+ noWords,
537
+ txParams.accessListEntryCount
538
+ ]);
539
+
540
+ // The calldata words below noWords, chained onto the head one word at a time.
541
+ // calldata.value is read whether or not the calldata is present: with noWords
542
+ // at zero every step passes the head through.
543
+ const wordsScan = fold(
544
+ (acc: [Uint<16>, Field], word: Bytes<32>): [Uint<16>, Field] =>
545
+ [(acc[0] + 1) as Uint<16>, acc[0] < noWords ? transientHash<[Field, Bytes<32>]>([acc[1], word]) : acc[1]],
546
+ [0 as Uint<16>, head],
547
+ calldata.value.words
548
+ );
549
+
550
+ // The access-list entries below accessListEntryCount, each chained on as its
551
+ // address, its key count and a digest of its storage keys below that count
552
+ // (the inner fold, started from a zero Field).
553
+ const listScan = fold(
554
+ (acc: [Uint<8>, Field], entry: EvmAccessListEntry<maxStorageKeysPerEntry>): [Uint<8>, Field] =>
555
+ [
556
+ (acc[0] + 1) as Uint<8>,
557
+ acc[0] < txParams.accessListEntryCount
558
+ ? transientHash<[Field, Bytes<20>, Uint<8>, Field]>([
559
+ acc[1],
560
+ entry.address,
561
+ entry.storageKeyCount,
562
+ fold(
563
+ (keyAcc: [Uint<8>, Field], key: Bytes<32>): [Uint<8>, Field] =>
564
+ [(keyAcc[0] + 1) as Uint<8>, keyAcc[0] < entry.storageKeyCount ? transientHash<[Field, Bytes<32>]>([keyAcc[1], key]) : keyAcc[1]],
565
+ [0 as Uint<8>, 0 as Field],
566
+ entry.storageKeys
567
+ )[1]
568
+ ])
569
+ : acc[1]
570
+ ],
571
+ [0 as Uint<8>, wordsScan[1]],
572
+ txParams.accessList
573
+ );
574
+
575
+ // The running hash is a Field. upgradeFromTransient writes it out as Bytes<32>.
576
+ return upgradeFromTransient(listScan[1]);
577
+ }
578
+
579
+ // The request id of an EVM type-2 request: its preimage with the transaction digested
580
+ // by calculateEvmType2TxParamsDigestV1. Off-chain code uses the TypeScript twin:
581
+ // import { calculateRequestId } from "@sig-net/midnight";
582
+ export pure circuit calculateEvmType2RequestIdV1<#maxCalldataWords, #maxAccessListEntries, #maxStorageKeysPerEntry, #LenOutputDeserialization, #LenRespondSerialization>(
583
+ request: SignBidirectionalEventV1<EvmType2TxParams<maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry>, LenOutputDeserialization, LenRespondSerialization>
584
+ ): RequestId {
585
+ assert(request.txParamType == TxParamType.evmType2, "txParamType must tag txParams as evmType2");
586
+ const preimage = RequestIdPreimageV1 {
587
+ keyVersion: request.keyVersion,
588
+ sender: request.sender,
589
+ path: request.path,
590
+ algo: request.algo,
591
+ txParamType: request.txParamType,
592
+ txParamsDigest: calculateEvmType2TxParamsDigestV1<maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry>(request.txParams),
593
+ executionDest: request.executionDest,
594
+ };
595
+ return calculateRequestIdV1(preimage);
596
+ }
597
+
489
598
  // ---- ABI Calldata Word Construction Utilities ------------------------------------------------------
490
599
  // Canonical ABI word builders and readers. Words MUST be stored in canonical
491
600
  // ABI form (big-endian, per the ABI spec). These utilities help construct