@sig-net/midnight 0.0.8 → 0.0.9

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 (31) hide show
  1. package/dist/index.d.ts +5 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +5 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/managed/compiler/contract-info.json +54 -0
  6. package/dist/managed/compiler/contract-manifest.json +8 -8
  7. package/dist/managed/contract/index.d.ts +8 -0
  8. package/dist/managed/contract/index.js +250 -35
  9. package/dist/managed/contract/index.js.map +1 -1
  10. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  11. package/dist/signature-requests-state-reader.js +2 -1
  12. package/dist/signature-requests-state-reader.js.map +1 -1
  13. package/dist/signature-response-verification.d.ts +1 -1
  14. package/dist/signature-response-verification.d.ts.map +1 -1
  15. package/dist/signature-response-verification.js +1 -1
  16. package/dist/signature-response-verification.js.map +1 -1
  17. package/dist/signet-evtype2tx-requests.d.ts +228 -0
  18. package/dist/signet-evtype2tx-requests.d.ts.map +1 -0
  19. package/dist/signet-evtype2tx-requests.js +340 -0
  20. package/dist/signet-evtype2tx-requests.js.map +1 -0
  21. package/dist/signet-request-response-reader.d.ts +1 -1
  22. package/dist/signet-request-response-reader.d.ts.map +1 -1
  23. package/dist/signet-request-response-reader.js +1 -1
  24. package/dist/signet-request-response-reader.js.map +1 -1
  25. package/dist/signet-requests.d.ts +36 -202
  26. package/dist/signet-requests.d.ts.map +1 -1
  27. package/dist/signet-requests.js +29 -298
  28. package/dist/signet-requests.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/Signet.compact +57 -3
  31. package/src/circuits.compact +4 -1
@@ -1,5 +1,10 @@
1
- // TypeScript twins of the request-side structs in the Compact library
2
- // `Signet.compact` (same directory). The shapes MUST stay in lockstep with the Compact structs: the
1
+ // TypeScript twins of the CHAIN-AGNOSTIC request-side structs in the Compact
2
+ // library `Signet.compact` (same directory): the request record, its enums,
3
+ // request ids, and the runtime-descriptor toolkit shared by every tx-params
4
+ // decomposition. Everything specific to the EVM Type-2 decomposition (the
5
+ // only decomposition so far) lives in `signet-evtype2tx-requests.ts`.
6
+ //
7
+ // The shapes MUST stay in lockstep with the Compact structs: the
3
8
  // compiler inlines struct types anonymously into each contract's generated
4
9
  // managed/contract/index.d.ts, and these named types match them structurally,
5
10
  // so ledger reads assign to them without casts.
@@ -13,9 +18,7 @@
13
18
  //
14
19
  // Read more: https://docs.sig.network/ (signet protocol) and the module
15
20
  // header in Signet.compact (key derivation, event flow).
16
- import { CompactTypeBoolean, CompactTypeBytes, CompactTypeEnum, CompactTypeUnsignedInteger, CompactTypeVector, persistentHash, } from "@midnight-ntwrk/compact-runtime";
17
- import { getAddress, getBytes, Signature, Transaction } from "ethers";
18
- import { bigintToBytes32, bytesToBigint } from "./ecdsa-attestation.js";
21
+ import { CompactTypeBoolean, CompactTypeBytes, CompactTypeEnum, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
19
22
  /**
20
23
  * Which transaction-param decomposition a request carries (Compact:
21
24
  * `enum TxParamType`), as the generated code represents enums: a `number`
@@ -23,7 +26,7 @@ import { bigintToBytes32, bytesToBigint } from "./ecdsa-attestation.js";
23
26
  * `enum`) so the values stay structurally `number`.
24
27
  */
25
28
  export const TxParamType = {
26
- /** {@link EVMType2TxParams}: an EIP-1559 EVM transaction. */
29
+ /** `EVMType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
27
30
  evmType2: 0,
28
31
  /**
29
32
  * Never emitted — mirrors the Compact-side padding variant that keeps the
@@ -52,17 +55,18 @@ export const MPCDestination = {
52
55
  /** Never emitted — the >= 2 variants padding (see {@link TxParamType}). */
53
56
  reserved: 1,
54
57
  };
55
- // ---- Request id (TS twin of the Compact circuit) ---------------------------
58
+ // ---- Runtime descriptor toolkit (TS twin of the compiled struct codecs) ----
56
59
  //
57
60
  // DEVIATION from the "pure circuits are compiled, never re-written in TS"
58
- // rule (see circuits.compact): `calculateRequestId` is generic over the
61
+ // rule (see circuits.compact): the request-id circuit is generic over the
59
62
  // tx-params type and schema lengths, the Compact compiler cannot export
60
63
  // type-parameterized circuits from the top level, and a compiled copy would
61
64
  // have to be monomorphized at ONE capacity instantiation — a client
62
65
  // contract's choice that never belongs in this client-agnostic package. So
63
- // the request-id circuit alone gets a TS twin here.
66
+ // the record descriptor (and the per-decomposition `calculateRequestId`
67
+ // built on it, see signet-evtype2tx-requests.ts) alone gets a TS twin here.
64
68
  //
65
- // It is NOT a hand-port of the hash algorithm: it calls the very
69
+ // It is NOT a hand-port of the hash algorithm: ids come from the very
66
70
  // `persistentHash` runtime builtin that compiled circuits call, over runtime
67
71
  // type descriptors mirroring the ones the compiler generates (compare
68
72
  // `_calculateRequestId_0` in any consuming contract's
@@ -71,21 +75,17 @@ export const MPCDestination = {
71
75
  // field by field, in declaration order. Enforced by caller-contract's
72
76
  // "submitSignatureRequest round-trip" test, which asserts the id computed
73
77
  // here equals the ledger map key minted by the REAL compiled contract.
74
- // Runtime descriptors of the Compact base types the request record uses.
75
- // CompactTypeUnsignedInteger takes (maxValue, byte length) — same literals
76
- // the compiler emits for Uint<8/64/128>. CompactTypeEnum takes
78
+ // Runtime descriptors of the Compact base types the generic record fields
79
+ // use. CompactTypeUnsignedInteger takes (maxValue, byte length) — same
80
+ // literals the compiler emits for Uint<8/64>. CompactTypeEnum takes
77
81
  // (variantCount - 1, byte length); NOTE a 1-variant enum would compile to
78
82
  // `CompactTypeEnum(0, 0)` — zero bytes, which the proof server cannot parse
79
83
  // inside persistentHash preimages. Every enum therefore carries a padding
80
84
  // `reserved` variant so it stays at (1, 1).
81
- const BYTES_4 = new CompactTypeBytes(4);
82
- const BYTES_20 = new CompactTypeBytes(20);
83
85
  const BYTES_32 = new CompactTypeBytes(32);
84
86
  const BYTES_64 = new CompactTypeBytes(64);
85
87
  const UINT_8 = new CompactTypeUnsignedInteger(2n ** 8n - 1n, 1);
86
- const UINT_16 = new CompactTypeUnsignedInteger(2n ** 16n - 1n, 2);
87
88
  const UINT_64 = new CompactTypeUnsignedInteger(2n ** 64n - 1n, 8);
88
- const UINT_128 = new CompactTypeUnsignedInteger(2n ** 128n - 1n, 16);
89
89
  const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
90
90
  const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
91
91
  const MPC_DESTINATION = new CompactTypeEnum(1, 1);
@@ -110,7 +110,7 @@ const CONTRACT_ADDRESS = {
110
110
  * @param fields - One runtime descriptor per struct field, in declaration order.
111
111
  * @returns The composed struct descriptor.
112
112
  */
113
- function compactStructDescriptor(fields) {
113
+ export function compactStructDescriptor(fields) {
114
114
  const entries = Object.entries(fields);
115
115
  return {
116
116
  alignment: () => entries.flatMap(([, type]) => type.alignment()),
@@ -131,77 +131,29 @@ function compactStructDescriptor(fields) {
131
131
  * @param inner - Descriptor of the wrapped type.
132
132
  * @returns The Maybe struct descriptor.
133
133
  */
134
- function compactMaybeDescriptor(inner) {
134
+ export function compactMaybeDescriptor(inner) {
135
135
  return compactStructDescriptor({
136
136
  is_some: CompactTypeBoolean,
137
137
  value: inner,
138
138
  });
139
139
  }
140
140
  /**
141
- * Descriptor of {@link EVMCalldata} at one word capacity — the TS analogue
142
- * of instantiating Compact's `EVMCalldata<#maxWords>`.
143
- *
144
- * @param maxWords - The contract's calldata word capacity (the vault uses 2).
145
- * @returns The calldata descriptor.
146
- */
147
- export function evmCalldataDescriptor(maxWords) {
148
- return compactStructDescriptor({
149
- selector: BYTES_4,
150
- noWords: UINT_16,
151
- words: new CompactTypeVector(maxWords, BYTES_32),
152
- });
153
- }
154
- /**
155
- * Descriptor of {@link EVMAccessListEntry} at one storage-key capacity
156
- * (Compact: `EVMAccessListEntry<#maxStorageKeys>`).
157
- *
158
- * @param maxStorageKeys - Storage-key capacity per entry.
159
- * @returns The entry descriptor.
160
- */
161
- export function evmAccessListEntryDescriptor(maxStorageKeys) {
162
- return compactStructDescriptor({
163
- address: BYTES_20,
164
- storageKeyCount: UINT_8,
165
- storageKeys: new CompactTypeVector(maxStorageKeys, BYTES_32),
166
- });
167
- }
168
- /**
169
- * Descriptor of {@link EVMType2TxParams} at one capacity instantiation —
170
- * the TS analogue of Compact's `EVMType2TxParams<#maxCalldataWords,
171
- * #maxAccessListEntries, #maxStorageKeysPerEntry>`.
172
- *
173
- * @param maxCalldataWords - Calldata word capacity.
174
- * @param maxAccessListEntries - Access-list entry capacity.
175
- * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
176
- * @returns The tx-params descriptor.
177
- */
178
- export function evmType2TxParamsDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry) {
179
- return compactStructDescriptor({
180
- to: BYTES_20,
181
- chainId: UINT_64,
182
- nonce: UINT_64,
183
- gasLimit: UINT_64,
184
- maxFeePerGas: UINT_128,
185
- maxPriorityFeePerGas: UINT_128,
186
- value: UINT_128,
187
- accessListEntryCount: UINT_8,
188
- accessList: new CompactTypeVector(maxAccessListEntries, evmAccessListEntryDescriptor(maxStorageKeysPerEntry)),
189
- calldata: compactMaybeDescriptor(evmCalldataDescriptor(maxCalldataWords)),
190
- });
191
- }
192
- /**
193
- * Descriptor of {@link SignBidirectionalEvent} at one capacity instantiation.
141
+ * Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
142
+ * decomposition — the TS analogue of Compact's generic
143
+ * `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
144
+ * #LenRespondSerialization>`. Each decomposition wraps this with its own
145
+ * capacity-parameterized convenience (see `signBidirectionalEventDescriptor`
146
+ * in signet-evtype2tx-requests.ts for the EVM Type-2 one).
194
147
  *
195
- * @param maxCalldataWords - Calldata word capacity.
196
- * @param maxAccessListEntries - Access-list entry capacity.
197
- * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
148
+ * @param txParams - Descriptor of the tx-params decomposition, already at
149
+ * its capacity instantiation.
198
150
  * @param lenOutputDeserialization - Declared byte width of
199
151
  * `outputDeserializationSchema` (Compact `#LenOutputDeserialization`).
200
152
  * @param lenRespondSerialization - Declared byte width of
201
153
  * `respondSerializationSchema` (Compact `#LenRespondSerialization`).
202
154
  * @returns The event record descriptor.
203
155
  */
204
- export function signBidirectionalEventDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry, lenOutputDeserialization, lenRespondSerialization) {
156
+ export function signBidirectionalEventDescriptorWith(txParams, lenOutputDeserialization, lenRespondSerialization) {
205
157
  return compactStructDescriptor({
206
158
  sender: CONTRACT_ADDRESS,
207
159
  requestNonce: UINT_64,
@@ -211,233 +163,12 @@ export function signBidirectionalEventDescriptor(maxCalldataWords, maxAccessList
211
163
  dest: MPC_DESTINATION,
212
164
  params: BYTES_64,
213
165
  txParamType: TX_PARAM_TYPE,
214
- txParams: evmType2TxParamsDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry),
166
+ txParams,
215
167
  caip2Id: BYTES_32,
216
168
  outputDeserializationSchema: new CompactTypeBytes(lenOutputDeserialization),
217
169
  respondSerializationSchema: new CompactTypeBytes(lenRespondSerialization),
218
170
  });
219
171
  }
220
- /**
221
- * Canonical id of a signet request: the persistent hash of the entire event
222
- * record (which commits to every field, the sender address included — there
223
- * is deliberately no extra domain tag). TS twin of Signet.compact's
224
- * `calculateRequestId` circuit (see the deviation note atop this section),
225
- * generic over the capacity instantiation via the record's own array
226
- * lengths — pass the record exactly as the ledger stores it, unused slots
227
- * included and schemas at their declared widths.
228
- *
229
- * @param request - The full event record (contract-shaped, all slots).
230
- * @returns The 32-byte request id — the record's ledger map key.
231
- */
232
- export function calculateRequestId(request) {
233
- const { txParams } = request;
234
- const maxCalldataWords = txParams.calldata.value.words.length;
235
- const maxAccessListEntries = txParams.accessList.length;
236
- const maxStorageKeysPerEntry = maxAccessListEntries === 0 ? 0 : txParams.accessList[0].storageKeys.length;
237
- return persistentHash(signBidirectionalEventDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry, request.outputDeserializationSchema.length, request.respondSerializationSchema.length), request);
238
- }
239
- // ---- Calldata / transaction assembly ----------------------------------------
240
- /**
241
- * The 32-byte value of a numeric ABI word: the little-endian field embed of
242
- * the number, exactly what Compact's `x as Field as Bytes<32>` cast produces
243
- * in-circuit. Use when building words off-chain (UIs, expected-record
244
- * builders, tests).
245
- *
246
- * @param value - The word's numeric value (e.g. an amount).
247
- * @returns The 32-byte LE embed to store in an {@link EVMCalldata} word.
248
- */
249
- export function numericAbiWordValue(value) {
250
- return bigintToBytes32(value);
251
- }
252
- /**
253
- * The 32-byte staticArg word value for an EVM address: the BIG-ENDIAN
254
- * numeric reading of its 20 display-order bytes, LE-embedded. TS mirror of
255
- * Signet.compact's `evmAddressAbiValue` circuit (+ `as Bytes<32>`); see the
256
- * warning there — embedding the display-order bytes directly would come out
257
- * byte-reversed in the assembled calldata.
258
- *
259
- * @param address - The 20-byte address in display order.
260
- * @returns The 32-byte word value to store in an {@link EVMCalldata} word.
261
- */
262
- export function evmAddressAbiWord(address) {
263
- let value = 0n;
264
- for (const byte of address) {
265
- value = value * 256n + BigInt(byte);
266
- }
267
- return bigintToBytes32(value);
268
- }
269
- /**
270
- * Re-assemble the raw calldata a request's words describe:
271
- * `data = selector || BE(words[0..noWords])`. Each word is a little-endian
272
- * field embed (the contract's `x as Field as Bytes<32>` cast); the leading
273
- * `noWords` are re-encoded big-endian into 32-byte ABI words and any remaining
274
- * capacity slots are dropped. This is THE implementation of the MPC re-assembly
275
- * documented on `EVMCalldata` in Signet.compact.
276
- *
277
- * @param calldata - The request's calldata field.
278
- * @returns Hex calldata for the transaction (`"0x"` when absent).
279
- */
280
- export function assembleCalldata(calldata) {
281
- if (!calldata.is_some) {
282
- return "0x";
283
- }
284
- const { selector, noWords, words } = calldata.value;
285
- let data = `0x${bytesToHex(selector)}`;
286
- for (let i = 0; i < Number(noWords); i++) {
287
- data += bytesToHex(bigintToBytes32BE(bytesToBigint(words[i])));
288
- }
289
- return data;
290
- }
291
- /**
292
- * Decode the real (count-trimmed) access list of a request into the shape
293
- * ethers' `Transaction.from` accepts.
294
- *
295
- * @param txParams - The request's transaction decomposition.
296
- * @returns The access list, possibly empty.
297
- */
298
- function decodeAccessList(txParams) {
299
- return txParams.accessList
300
- .slice(0, Number(txParams.accessListEntryCount))
301
- .map((entry) => ({
302
- address: getAddress(`0x${bytesToHex(entry.address)}`),
303
- storageKeys: entry.storageKeys
304
- .slice(0, Number(entry.storageKeyCount))
305
- .map((key) => `0x${bytesToHex(key)}`),
306
- }));
307
- }
308
- /**
309
- * Rebuild the unsigned EIP-1559 transaction a request record describes,
310
- * byte-identical to the one the MPC assembles and signs: calldata from the
311
- * tagged words (see {@link assembleCalldata}), the count-trimmed access
312
- * list, and the stored envelope fields. This is the canonical
313
- * request→transaction transform; response-side verification
314
- * (`signature-response-verification.ts`) and the signed-transaction builder
315
- * below both go through it, so the transaction a client broadcasts is
316
- * provably the one the MPC put its signature over.
317
- *
318
- * @param request - The on-ledger request record.
319
- * @returns The unsigned ethers transaction (`unsignedHash` is the digest the
320
- * MPC signs).
321
- * @throws Error if a calldata word carries an unknown kind.
322
- */
323
- export function signBidirectionalEventToUnsignedEVMTransaction(request) {
324
- const { txParams } = request;
325
- return Transaction.from({
326
- type: 2,
327
- chainId: txParams.chainId,
328
- nonce: Number(txParams.nonce),
329
- gasLimit: txParams.gasLimit,
330
- maxFeePerGas: txParams.maxFeePerGas,
331
- maxPriorityFeePerGas: txParams.maxPriorityFeePerGas,
332
- to: getAddress(`0x${bytesToHex(txParams.to)}`),
333
- value: txParams.value,
334
- accessList: decodeAccessList(txParams),
335
- data: assembleCalldata(txParams.calldata),
336
- });
337
- }
338
- /**
339
- * Decode a response signature record (as posted to the signet contract's
340
- * signature response log — the canonical MPC `Signature { big_r, s,
341
- * recovery_id }` shape) into an ethers {@link Signature}: `r` is `bigR`'s x
342
- * coordinate, `v` the legacy parity derived from the recovery id.
343
- *
344
- * @param response - The posted signature record.
345
- * @returns The ethers signature.
346
- * @throws Error if the recovery id is not 0 or 1.
347
- */
348
- export function signatureRespondedEventToSignature(response) {
349
- const recoveryId = Number(response.recoveryId);
350
- if (recoveryId !== 0 && recoveryId !== 1) {
351
- throw new Error(`expected a recovery id of 0 or 1, got ${recoveryId}`);
352
- }
353
- return Signature.from({
354
- r: `0x${bytesToHex(response.bigRx)}`,
355
- s: `0x${bytesToHex(response.s)}`,
356
- v: recoveryId + 27,
357
- });
358
- }
359
- /** secp256k1 base field prime (2^256 - 2^32 - 977). */
360
- const SECP256K1_P = 2n ** 256n - 2n ** 32n - 977n;
361
- /** Modular exponentiation by squaring. */
362
- function modPow(base, exponent, modulus) {
363
- let result = 1n;
364
- let b = base % modulus;
365
- let e = exponent;
366
- while (e > 0n) {
367
- if (e & 1n)
368
- result = (result * b) % modulus;
369
- b = (b * b) % modulus;
370
- e >>= 1n;
371
- }
372
- return result;
373
- }
374
- /** Encode a bigint as exactly 32 BIG-endian bytes (secp256k1 scalar form). */
375
- function bigintToBytes32BE(value) {
376
- const out = new Uint8Array(32);
377
- let v = value;
378
- for (let i = 31; i >= 0; i--) {
379
- out[i] = Number(v & 0xffn);
380
- v >>= 8n;
381
- }
382
- return out;
383
- }
384
- /**
385
- * Encode an ECDSA signature as the response record posted to the signet
386
- * contract — the inverse of {@link signatureRespondedEventToSignature},
387
- * for MPC-side posters (the fakenet signer, tests). The canonical record
388
- * carries `bigR` as a full affine point but an `r || s || v` signature only
389
- * has R.x and the parity of R.y, so R.y is recovered by decompressing the
390
- * point on the curve (y² = x³ + 7 over the secp256k1 base field).
391
- *
392
- * The parameter is structural (the r/s/yParity subset of an ethers
393
- * {@link Signature}) so signatures from ANY ethers instance qualify — posters
394
- * living in other repos resolve their own ethers install, and nominal class
395
- * typing would reject it.
396
- *
397
- * @param signature - The signature to encode (`r`/`s` as 0x hex, `yParity` 0 or 1).
398
- * @returns The response record, ready to post.
399
- * @throws Error if `r` is not the x coordinate of a curve point.
400
- */
401
- export function signatureToSignatureRespondedEvent(signature) {
402
- const x = BigInt(signature.r);
403
- const ySquared = (modPow(x, 3n, SECP256K1_P) + 7n) % SECP256K1_P;
404
- // P ≡ 3 (mod 4), so a square root (when one exists) is c^((P+1)/4).
405
- let y = modPow(ySquared, (SECP256K1_P + 1n) / 4n, SECP256K1_P);
406
- if ((y * y) % SECP256K1_P !== ySquared) {
407
- throw new Error("signature r is not the x coordinate of a secp256k1 point");
408
- }
409
- if ((y & 1n) !== BigInt(signature.yParity)) {
410
- y = SECP256K1_P - y;
411
- }
412
- return {
413
- bigRx: getBytes(signature.r),
414
- bigRy: bigintToBytes32BE(y),
415
- s: getBytes(signature.s),
416
- recoveryId: BigInt(signature.yParity),
417
- };
418
- }
419
- /**
420
- * Assemble the broadcast-ready signed EIP-1559 transaction for a request from
421
- * its MPC signature response: rebuild the exact unsigned transaction the MPC
422
- * signed (see {@link signBidirectionalEventToUnsignedEVMTransaction}) and
423
- * attach the signature. Does NOT check that the signature recovers to the
424
- * requester's derived address — the response log is unauthenticated, so
425
- * verify first with `verifySignatureRespondedEvent`.
426
- *
427
- * @param request - The on-ledger request record.
428
- * @param response - The posted signature record answering it.
429
- * @returns The signed ethers transaction; `serialized` is the raw payload for
430
- * `eth_sendRawTransaction`, `hash` its on-chain hash, `from` the recovered
431
- * sender.
432
- * @throws Error if the request record is malformed (see
433
- * {@link signBidirectionalEventToUnsignedEVMTransaction}) or the response
434
- * is not a decodable signature.
435
- */
436
- export function signBidirectionalEventToSignedEVMTransaction(request, response) {
437
- const transaction = signBidirectionalEventToUnsignedEVMTransaction(request);
438
- transaction.signature = signatureRespondedEventToSignature(response);
439
- return transaction;
440
- }
441
172
  /**
442
173
  * Render bytes as a lowercase hex string, no `0x` prefix.
443
174
  *
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,oGAAoG;AACpG,2EAA2E;AAC3E,8EAA8E;AAC9E,gDAAgD;AA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ight",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sig-net/midnight-integration",
@@ -358,10 +358,64 @@ module Signet {
358
358
  }
359
359
 
360
360
  // ABI calldata for the EVM call: 4-byte selector + 32-byte slots
361
- // (https://docs.soliditylang.org/en/latest/abi-spec.html).
361
+ // (https://docs.soliditylang.org/en/latest/abi-spec.html). Every stored
362
+ // byte is ABI-READY: the signer broadcasts selector || words[0..noWords]
363
+ // VERBATIM, so what the contract stores is exactly what the MPC signs.
362
364
  export struct EVMCalldata<#maxWords> {
363
- selector: Bytes<4>; // the literal first 4 calldata bytes (big-endian, as broadcast)
365
+ selector: Bytes<4>; // the literal first 4 calldata bytes (as broadcast)
364
366
  noWords: Uint<16>; // No. of used words in the words list
365
- words: Vector<maxWords, Bytes<32>>;
367
+ words: Vector<maxWords, Bytes<32>>; // ABI-ready big-endian words (as broadcast)
368
+ }
369
+
370
+ // ---- ABI calldata word construction -----------------------------------------------------
371
+ // The protocol's canonical word builders and reader. Words are stored in
372
+ // broadcast form (big-endian, per the ABI spec above): no off-chain step
373
+ // may reorder or reinterpret them, so the byte order must be produced HERE,
374
+ // in-circuit. Compact's integer<->bytes casts are little-endian, hence the
375
+ // explicit reversal in numericAbiWord and the explicit fold in
376
+ // abiWordToUint128. TS mirrors of the same names live in signet-requests.ts
377
+ // and are kept honest by lockstep tests against these compiled circuits.
378
+
379
+ // The ABI word for an EVM address: 12 zero bytes, then the 20 display-order
380
+ // address bytes, exactly as they appear in the broadcast calldata.
381
+ export pure circuit evmAddressAbiWord(addr: Bytes<20>): Bytes<32> {
382
+ return Bytes[...default<Bytes<12>>, ...addr];
383
+ }
384
+
385
+ // The ABI word for a numeric value (e.g. an ERC20 amount): the value as a
386
+ // 32-byte big-endian integer. Compact's Uint->Bytes cast is little-endian,
387
+ // so cast to 16 LE bytes and emit them reversed into the low half.
388
+ export pure circuit numericAbiWord(value: Uint<128>): Bytes<32> {
389
+ const le = (value as Bytes<16>) as Vector<16, Uint<8>>;
390
+ return Bytes[
391
+ ...default<Bytes<16>>,
392
+ le[15], le[14], le[13], le[12], le[11], le[10], le[9], le[8],
393
+ le[7], le[6], le[5], le[4], le[3], le[2], le[1], le[0]
394
+ ];
395
+ }
396
+
397
+ // Read a numeric ABI word back into a Uint<128>: the big-endian fold of
398
+ // bytes 16..31. The leading half must be zero (a canonical Uint<128> word);
399
+ // rejecting junk there keeps settle circuits from silently truncating a
400
+ // wider value. Max fold result is 2^128 - 1, well inside the field.
401
+ export pure circuit abiWordToUint128(word: Bytes<32>): Uint<128> {
402
+ assert(slice<16>(word, 0) as Field == 0 as Field, "ABI word exceeds Uint<128>");
403
+ const b0 = slice<1>(word, 16) as Field;
404
+ const b1 = b0 * 256 + (slice<1>(word, 17) as Field);
405
+ const b2 = b1 * 256 + (slice<1>(word, 18) as Field);
406
+ const b3 = b2 * 256 + (slice<1>(word, 19) as Field);
407
+ const b4 = b3 * 256 + (slice<1>(word, 20) as Field);
408
+ const b5 = b4 * 256 + (slice<1>(word, 21) as Field);
409
+ const b6 = b5 * 256 + (slice<1>(word, 22) as Field);
410
+ const b7 = b6 * 256 + (slice<1>(word, 23) as Field);
411
+ const b8 = b7 * 256 + (slice<1>(word, 24) as Field);
412
+ const b9 = b8 * 256 + (slice<1>(word, 25) as Field);
413
+ const b10 = b9 * 256 + (slice<1>(word, 26) as Field);
414
+ const b11 = b10 * 256 + (slice<1>(word, 27) as Field);
415
+ const b12 = b11 * 256 + (slice<1>(word, 28) as Field);
416
+ const b13 = b12 * 256 + (slice<1>(word, 29) as Field);
417
+ const b14 = b13 * 256 + (slice<1>(word, 30) as Field);
418
+ const b15 = b14 * 256 + (slice<1>(word, 31) as Field);
419
+ return b15 as Uint<128>;
366
420
  }
367
421
  }
@@ -34,5 +34,8 @@ export {
34
34
  signetAttestationDigest,
35
35
  verifyRespondBidirectionalEvent,
36
36
  signetKeyHash,
37
- constructSignBidirectionalEventNotificationV1
37
+ constructSignBidirectionalEventNotificationV1,
38
+ evmAddressAbiWord,
39
+ numericAbiWord,
40
+ abiWordToUint128
38
41
  };