@sig-net/midnight 0.0.8 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +254 -112
  2. package/dist/index.d.ts +4 -11
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -11
  5. package/dist/index.js.map +1 -1
  6. package/dist/managed/compiler/contract-info.json +88 -0
  7. package/dist/managed/compiler/contract-manifest.json +8 -8
  8. package/dist/managed/contract/index.d.ts +12 -0
  9. package/dist/managed/contract/index.js +328 -54
  10. package/dist/managed/contract/index.js.map +1 -1
  11. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  12. package/dist/signature-requests-state-reader.js +2 -1
  13. package/dist/signature-requests-state-reader.js.map +1 -1
  14. package/dist/signature-response-verification.d.ts +1 -1
  15. package/dist/signature-response-verification.d.ts.map +1 -1
  16. package/dist/signature-response-verification.js +1 -1
  17. package/dist/signature-response-verification.js.map +1 -1
  18. package/dist/signet-evtype2tx-requests.d.ts +247 -0
  19. package/dist/signet-evtype2tx-requests.d.ts.map +1 -0
  20. package/dist/signet-evtype2tx-requests.js +371 -0
  21. package/dist/signet-evtype2tx-requests.js.map +1 -0
  22. package/dist/signet-request-response-reader.d.ts +1 -1
  23. package/dist/signet-request-response-reader.d.ts.map +1 -1
  24. package/dist/signet-request-response-reader.js +1 -1
  25. package/dist/signet-request-response-reader.js.map +1 -1
  26. package/dist/signet-requests.d.ts +36 -202
  27. package/dist/signet-requests.d.ts.map +1 -1
  28. package/dist/signet-requests.js +31 -300
  29. package/dist/signet-requests.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/Signet.compact +74 -4
  32. package/src/circuits.compact +13 -27
@@ -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,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
+ {"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,GACnC,MAAM,gCAAgC,CAAC;AAIxC;;;;;;;;;;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"}
@@ -0,0 +1,247 @@
1
+ import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
+ import { Signature, Transaction } from "ethers";
3
+ import type { SignatureRespondedEvent } from "./signet-contract-state-reader.ts";
4
+ import { type Maybe, type RequestId, type SignBidirectionalEvent } from "./signet-requests.ts";
5
+ /**
6
+ * ABI calldata as a 4-byte selector + 32-byte word slots (Compact:
7
+ * `EVMCalldata<#maxWords>`). Every stored byte is ABI-READY: the calldata the
8
+ * MPC signs is `selector || words[0..noWords]` VERBATIM (see
9
+ * {@link assembleCalldata}), so words are big-endian broadcast-form ABI words,
10
+ * built in-circuit by Signet.compact's `evmAddressAbiWord` / `numericAbiWord`.
11
+ */
12
+ export interface EVMCalldata {
13
+ /** The literal first 4 calldata bytes (as broadcast). */
14
+ selector: Uint8Array;
15
+ /** How many leading {@link words} are real (Compact `noWords: Uint<16>`). */
16
+ noWords: bigint;
17
+ /**
18
+ * ABI-ready big-endian 32-byte word slots, stored exactly as broadcast;
19
+ * capacity is the contract's `#maxWords` (vault: 2).
20
+ */
21
+ words: Uint8Array[];
22
+ }
23
+ /**
24
+ * One EIP-2930 access-list entry (Compact:
25
+ * `EVMAccessListEntry<#maxStorageKeys>`).
26
+ */
27
+ export interface EVMAccessListEntry {
28
+ /** The pre-declared contract address, 20 display-order bytes. */
29
+ address: Uint8Array;
30
+ /** How many leading {@link storageKeys} are real. */
31
+ storageKeyCount: bigint;
32
+ /** Raw 32-byte storage keys, copied verbatim into the transaction. */
33
+ storageKeys: Uint8Array[];
34
+ }
35
+ /**
36
+ * The EVM transaction to be signed, decomposed into typed fields (Compact:
37
+ * `EVMType2TxParams<#maxCalldataWords, #maxAccessListEntries,
38
+ * #maxStorageKeysPerEntry>`; EIP-1559 — https://eips.ethereum.org/EIPS/eip-1559).
39
+ * Compact `Bytes<N>` fields arrive as N-byte `Uint8Array`s, `Uint<N>` as
40
+ * `bigint`. Vector capacities are each contract's compile-time throttle;
41
+ * the runtime counts say how many leading slots are real.
42
+ */
43
+ export interface EVMType2TxParams {
44
+ /** Call target (e.g. the ERC20 contract), 20 bytes. */
45
+ to: Uint8Array;
46
+ /** EVM chain id (also expressed in the record's `caip2Id`). */
47
+ chainId: bigint;
48
+ /** Account nonce of the MPC-derived sender address. */
49
+ nonce: bigint;
50
+ /** Gas ceiling for the call. */
51
+ gasLimit: bigint;
52
+ /** Max total fee per gas, wei. */
53
+ maxFeePerGas: bigint;
54
+ /** Max priority fee per gas, wei. */
55
+ maxPriorityFeePerGas: bigint;
56
+ /** ETH sent with the call, wei. */
57
+ value: bigint;
58
+ /** How many leading {@link accessList} entries are real. */
59
+ accessListEntryCount: bigint;
60
+ /** EIP-2930 access list slots (capacity = contract's throttle). */
61
+ accessList: EVMAccessListEntry[];
62
+ /** Call data; `is_some: false` means a plain ETH transfer (`0x` data). */
63
+ calldata: Maybe<EVMCalldata>;
64
+ }
65
+ /**
66
+ * Descriptor of {@link EVMCalldata} at one word capacity — the TS analogue
67
+ * of instantiating Compact's `EVMCalldata<#maxWords>`.
68
+ *
69
+ * @param maxWords - The contract's calldata word capacity (the vault uses 2).
70
+ * @returns The calldata descriptor.
71
+ */
72
+ export declare function evmCalldataDescriptor(maxWords: number): CompactType<EVMCalldata>;
73
+ /**
74
+ * Descriptor of {@link EVMAccessListEntry} at one storage-key capacity
75
+ * (Compact: `EVMAccessListEntry<#maxStorageKeys>`).
76
+ *
77
+ * @param maxStorageKeys - Storage-key capacity per entry.
78
+ * @returns The entry descriptor.
79
+ */
80
+ export declare function evmAccessListEntryDescriptor(maxStorageKeys: number): CompactType<EVMAccessListEntry>;
81
+ /**
82
+ * Descriptor of {@link EVMType2TxParams} at one capacity instantiation —
83
+ * the TS analogue of Compact's `EVMType2TxParams<#maxCalldataWords,
84
+ * #maxAccessListEntries, #maxStorageKeysPerEntry>`.
85
+ *
86
+ * @param maxCalldataWords - Calldata word capacity.
87
+ * @param maxAccessListEntries - Access-list entry capacity.
88
+ * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
89
+ * @returns The tx-params descriptor.
90
+ */
91
+ export declare function evmType2TxParamsDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number): CompactType<EVMType2TxParams>;
92
+ /**
93
+ * Descriptor of {@link SignBidirectionalEvent} at one EVM Type-2 capacity
94
+ * instantiation — the generic record descriptor
95
+ * (`signBidirectionalEventDescriptorWith`) over
96
+ * {@link evmType2TxParamsDescriptor}.
97
+ *
98
+ * @param maxCalldataWords - Calldata word capacity.
99
+ * @param maxAccessListEntries - Access-list entry capacity.
100
+ * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
101
+ * @param lenOutputDeserialization - Declared byte width of
102
+ * `outputDeserializationSchema` (Compact `#LenOutputDeserialization`).
103
+ * @param lenRespondSerialization - Declared byte width of
104
+ * `respondSerializationSchema` (Compact `#LenRespondSerialization`).
105
+ * @returns The event record descriptor.
106
+ */
107
+ export declare function signBidirectionalEventDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent>;
108
+ /**
109
+ * Canonical id of a signet request: the persistent hash of the entire event
110
+ * record (which commits to every field, the sender address included — there
111
+ * is deliberately no extra domain tag). TS twin of Signet.compact's
112
+ * `calculateRequestId` circuit (see the deviation note in
113
+ * signet-requests.ts), generic over the capacity instantiation via the
114
+ * record's own array lengths — pass the record exactly as the ledger stores
115
+ * it, unused slots included and schemas at their declared widths.
116
+ *
117
+ * @param request - The full event record (contract-shaped, all slots).
118
+ * @returns The 32-byte request id — the record's ledger map key.
119
+ */
120
+ export declare function calculateRequestId(request: SignBidirectionalEvent): RequestId;
121
+ /**
122
+ * The ABI word for a numeric value (e.g. an ERC20 amount): the value as a
123
+ * 32-byte BIG-ENDIAN integer, exactly as broadcast. TS mirror of
124
+ * Signet.compact's `numericAbiWord` circuit (lockstep-tested against the
125
+ * compiled circuit). Use when building words off-chain (UIs, expected-record
126
+ * builders, tests).
127
+ *
128
+ * @param value - The word's numeric value (e.g. an amount).
129
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
130
+ */
131
+ export declare function numericAbiWord(value: bigint): Uint8Array;
132
+ /**
133
+ * The ABI word for an EVM address: 12 zero bytes, then the 20 display-order
134
+ * address bytes, exactly as broadcast. TS mirror of Signet.compact's
135
+ * `evmAddressAbiWord` circuit (lockstep-tested against the compiled circuit).
136
+ *
137
+ * @param address - The 20-byte address in display order.
138
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
139
+ * @throws Error if the address is not exactly 20 bytes.
140
+ */
141
+ export declare function evmAddressAbiWord(address: Uint8Array): Uint8Array;
142
+ /**
143
+ * The ABI word for a Boolean: 31 zero bytes, then 0x01 (true) or 0x00
144
+ * (false). TS mirror of Signet.compact's `boolAbiWord` circuit
145
+ * (lockstep-tested against the compiled circuit).
146
+ *
147
+ * @param value - The word's Boolean value.
148
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
149
+ */
150
+ export declare function boolAbiWord(value: boolean): Uint8Array;
151
+ /**
152
+ * Read a numeric ABI word back into a bigint: the big-endian reading of bytes
153
+ * 16..31. TS mirror of Signet.compact's `abiWordToUint128` circuit, including
154
+ * its canonicality check: the leading 16 bytes must be zero, so a word wider
155
+ * than Uint<128> is rejected rather than silently truncated.
156
+ *
157
+ * @param word - The ABI-ready 32-byte word.
158
+ * @returns The word's numeric value.
159
+ * @throws Error if the word is not 32 bytes or its leading half is nonzero.
160
+ */
161
+ export declare function abiWordToUint128(word: Uint8Array): bigint;
162
+ /**
163
+ * Read a Boolean ABI word back into a boolean. TS mirror of Signet.compact's
164
+ * `abiWordToBool` circuit, including its canonicality check: the first 31
165
+ * bytes must be zero and the last byte 0 or 1.
166
+ *
167
+ * @param word - The ABI-ready 32-byte word.
168
+ * @returns The word's Boolean value.
169
+ * @throws Error if the word is not 32 bytes or is not a canonical Boolean.
170
+ */
171
+ export declare function abiWordToBool(word: Uint8Array): boolean;
172
+ /**
173
+ * Assemble the raw calldata a request's words describe:
174
+ * `data = selector || words[0..noWords]`, VERBATIM. Words are stored
175
+ * ABI-ready (see {@link EVMCalldata}), so no byte of the stored record is
176
+ * reordered or reinterpreted on the way into the transaction; slots past
177
+ * `noWords` are unused capacity and are dropped. This is THE implementation
178
+ * of the signer-side assembly documented on `EVMCalldata` in Signet.compact.
179
+ *
180
+ * @param calldata - The request's calldata field.
181
+ * @returns Hex calldata for the transaction (`"0x"` when absent).
182
+ */
183
+ export declare function assembleCalldata(calldata: Maybe<EVMCalldata>): string;
184
+ /**
185
+ * Rebuild the unsigned EIP-1559 transaction a request record describes,
186
+ * byte-identical to the one the MPC assembles and signs: calldata from the
187
+ * tagged words (see {@link assembleCalldata}), the count-trimmed access
188
+ * list, and the stored envelope fields. This is the canonical
189
+ * request→transaction transform; response-side verification
190
+ * (`signature-response-verification.ts`) and the signed-transaction builder
191
+ * below both go through it, so the transaction a client broadcasts is
192
+ * provably the one the MPC put its signature over.
193
+ *
194
+ * @param request - The on-ledger request record.
195
+ * @returns The unsigned ethers transaction (`unsignedHash` is the digest the
196
+ * MPC signs).
197
+ * @throws Error if a calldata word carries an unknown kind.
198
+ */
199
+ export declare function signBidirectionalEventToUnsignedEVMTransaction(request: SignBidirectionalEvent): Transaction;
200
+ /**
201
+ * Decode a response signature record (as posted to the signet contract's
202
+ * signature response log — the canonical MPC `Signature { big_r, s,
203
+ * recovery_id }` shape) into an ethers {@link Signature}: `r` is `bigR`'s x
204
+ * coordinate, `v` the legacy parity derived from the recovery id.
205
+ *
206
+ * @param response - The posted signature record.
207
+ * @returns The ethers signature.
208
+ * @throws Error if the recovery id is not 0 or 1.
209
+ */
210
+ export declare function signatureRespondedEventToSignature(response: SignatureRespondedEvent): Signature;
211
+ /**
212
+ * Encode an ECDSA signature as the response record posted to the signet
213
+ * contract — the inverse of {@link signatureRespondedEventToSignature},
214
+ * for MPC-side posters (the fakenet signer, tests). The canonical record
215
+ * carries `bigR` as a full affine point but an `r || s || v` signature only
216
+ * has R.x and the parity of R.y, so R.y is recovered by decompressing the
217
+ * point on the curve (y² = x³ + 7 over the secp256k1 base field).
218
+ *
219
+ * The parameter is structural (the r/s/yParity subset of an ethers
220
+ * {@link Signature}) so signatures from ANY ethers instance qualify — posters
221
+ * living in other repos resolve their own ethers install, and nominal class
222
+ * typing would reject it.
223
+ *
224
+ * @param signature - The signature to encode (`r`/`s` as 0x hex, `yParity` 0 or 1).
225
+ * @returns The response record, ready to post.
226
+ * @throws Error if `r` is not the x coordinate of a curve point.
227
+ */
228
+ export declare function signatureToSignatureRespondedEvent(signature: Pick<Signature, "r" | "s" | "yParity">): SignatureRespondedEvent;
229
+ /**
230
+ * Assemble the broadcast-ready signed EIP-1559 transaction for a request from
231
+ * its MPC signature response: rebuild the exact unsigned transaction the MPC
232
+ * signed (see {@link signBidirectionalEventToUnsignedEVMTransaction}) and
233
+ * attach the signature. Does NOT check that the signature recovers to the
234
+ * requester's derived address — the response log is unauthenticated, so
235
+ * verify first with `verifySignatureRespondedEvent`.
236
+ *
237
+ * @param request - The on-ledger request record.
238
+ * @param response - The posted signature record answering it.
239
+ * @returns The signed ethers transaction; `serialized` is the raw payload for
240
+ * `eth_sendRawTransaction`, `hash` its on-chain hash, `from` the recovered
241
+ * sender.
242
+ * @throws Error if the request record is malformed (see
243
+ * {@link signBidirectionalEventToUnsignedEVMTransaction}) or the response
244
+ * is not a decodable signature.
245
+ */
246
+ export declare function signBidirectionalEventToSignedEVMTransaction(request: SignBidirectionalEvent, response: SignatureRespondedEvent): Transaction;
247
+ //# sourceMappingURL=signet-evtype2tx-requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signet-evtype2tx-requests.d.ts","sourceRoot":"","sources":["../src/signet-evtype2tx-requests.ts"],"names":[],"mappings":"AAYA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAwB,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAKL,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,QAAQ,EAAE,UAAU,CAAC;IACrB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,OAAO,EAAE,UAAU,CAAC;IACpB,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,EAAE,EAAE,UAAU,CAAC;IACf,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mEAAmE;IACnE,UAAU,EAAE,kBA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C,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,MAAM,CAUrE;AAsBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8CAA8C,CAC5D,OAAO,EAAE,sBAAsB,GAC9B,WAAW,CAcb;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,uBAAuB,GAChC,SAAS,CAUX;AA6BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC,GAChD,uBAAuB,CAiBzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,GAChC,WAAW,CAIb"}
@@ -0,0 +1,371 @@
1
+ // The EVM Type-2 (EIP-1559) instantiation of the signet request protocol:
2
+ // TypeScript twins of the `EVMType2TxParams` decomposition structs in
3
+ // `Signet.compact`, their runtime descriptors, the ABI-word helpers, and the
4
+ // request -> transaction assembly the signer runs. Everything chain-agnostic
5
+ // (the request record itself, ids, the descriptor toolkit) lives in
6
+ // `signet-requests.ts`; a future non-EVM decomposition gets a sibling of THIS
7
+ // file.
8
+ //
9
+ // The no-translation invariant lives here: words are stored ABI-ready and
10
+ // {@link assembleCalldata} concatenates `selector || words` VERBATIM, so the
11
+ // transaction the MPC signs carries the contract-stored bytes untouched.
12
+ import { CompactTypeBytes, CompactTypeUnsignedInteger, CompactTypeVector, persistentHash, } from "@midnight-ntwrk/compact-runtime";
13
+ import { getAddress, getBytes, Signature, Transaction } from "ethers";
14
+ import { bytesToHex, compactMaybeDescriptor, compactStructDescriptor, signBidirectionalEventDescriptorWith, } from "./signet-requests.js";
15
+ // ---- Runtime descriptors (see the deviation note in signet-requests.ts) ----
16
+ // Base-type literals match what the compiler emits for the EVM structs'
17
+ // fields (Uint<8/16/64/128>, Bytes<4/20/32>).
18
+ const BYTES_4 = new CompactTypeBytes(4);
19
+ const BYTES_20 = new CompactTypeBytes(20);
20
+ const BYTES_32 = new CompactTypeBytes(32);
21
+ const UINT_8 = new CompactTypeUnsignedInteger(2n ** 8n - 1n, 1);
22
+ const UINT_16 = new CompactTypeUnsignedInteger(2n ** 16n - 1n, 2);
23
+ const UINT_64 = new CompactTypeUnsignedInteger(2n ** 64n - 1n, 8);
24
+ const UINT_128 = new CompactTypeUnsignedInteger(2n ** 128n - 1n, 16);
25
+ /**
26
+ * Descriptor of {@link EVMCalldata} at one word capacity — the TS analogue
27
+ * of instantiating Compact's `EVMCalldata<#maxWords>`.
28
+ *
29
+ * @param maxWords - The contract's calldata word capacity (the vault uses 2).
30
+ * @returns The calldata descriptor.
31
+ */
32
+ export function evmCalldataDescriptor(maxWords) {
33
+ return compactStructDescriptor({
34
+ selector: BYTES_4,
35
+ noWords: UINT_16,
36
+ words: new CompactTypeVector(maxWords, BYTES_32),
37
+ });
38
+ }
39
+ /**
40
+ * Descriptor of {@link EVMAccessListEntry} at one storage-key capacity
41
+ * (Compact: `EVMAccessListEntry<#maxStorageKeys>`).
42
+ *
43
+ * @param maxStorageKeys - Storage-key capacity per entry.
44
+ * @returns The entry descriptor.
45
+ */
46
+ export function evmAccessListEntryDescriptor(maxStorageKeys) {
47
+ return compactStructDescriptor({
48
+ address: BYTES_20,
49
+ storageKeyCount: UINT_8,
50
+ storageKeys: new CompactTypeVector(maxStorageKeys, BYTES_32),
51
+ });
52
+ }
53
+ /**
54
+ * Descriptor of {@link EVMType2TxParams} at one capacity instantiation —
55
+ * the TS analogue of Compact's `EVMType2TxParams<#maxCalldataWords,
56
+ * #maxAccessListEntries, #maxStorageKeysPerEntry>`.
57
+ *
58
+ * @param maxCalldataWords - Calldata word capacity.
59
+ * @param maxAccessListEntries - Access-list entry capacity.
60
+ * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
61
+ * @returns The tx-params descriptor.
62
+ */
63
+ export function evmType2TxParamsDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry) {
64
+ return compactStructDescriptor({
65
+ to: BYTES_20,
66
+ chainId: UINT_64,
67
+ nonce: UINT_64,
68
+ gasLimit: UINT_64,
69
+ maxFeePerGas: UINT_128,
70
+ maxPriorityFeePerGas: UINT_128,
71
+ value: UINT_128,
72
+ accessListEntryCount: UINT_8,
73
+ accessList: new CompactTypeVector(maxAccessListEntries, evmAccessListEntryDescriptor(maxStorageKeysPerEntry)),
74
+ calldata: compactMaybeDescriptor(evmCalldataDescriptor(maxCalldataWords)),
75
+ });
76
+ }
77
+ /**
78
+ * Descriptor of {@link SignBidirectionalEvent} at one EVM Type-2 capacity
79
+ * instantiation — the generic record descriptor
80
+ * (`signBidirectionalEventDescriptorWith`) over
81
+ * {@link evmType2TxParamsDescriptor}.
82
+ *
83
+ * @param maxCalldataWords - Calldata word capacity.
84
+ * @param maxAccessListEntries - Access-list entry capacity.
85
+ * @param maxStorageKeysPerEntry - Storage-key capacity per entry.
86
+ * @param lenOutputDeserialization - Declared byte width of
87
+ * `outputDeserializationSchema` (Compact `#LenOutputDeserialization`).
88
+ * @param lenRespondSerialization - Declared byte width of
89
+ * `respondSerializationSchema` (Compact `#LenRespondSerialization`).
90
+ * @returns The event record descriptor.
91
+ */
92
+ export function signBidirectionalEventDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry, lenOutputDeserialization, lenRespondSerialization) {
93
+ return signBidirectionalEventDescriptorWith(evmType2TxParamsDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry), lenOutputDeserialization, lenRespondSerialization);
94
+ }
95
+ /**
96
+ * Canonical id of a signet request: the persistent hash of the entire event
97
+ * record (which commits to every field, the sender address included — there
98
+ * is deliberately no extra domain tag). TS twin of Signet.compact's
99
+ * `calculateRequestId` circuit (see the deviation note in
100
+ * signet-requests.ts), generic over the capacity instantiation via the
101
+ * record's own array lengths — pass the record exactly as the ledger stores
102
+ * it, unused slots included and schemas at their declared widths.
103
+ *
104
+ * @param request - The full event record (contract-shaped, all slots).
105
+ * @returns The 32-byte request id — the record's ledger map key.
106
+ */
107
+ export function calculateRequestId(request) {
108
+ const { txParams } = request;
109
+ const maxCalldataWords = txParams.calldata.value.words.length;
110
+ const maxAccessListEntries = txParams.accessList.length;
111
+ const maxStorageKeysPerEntry = maxAccessListEntries === 0 ? 0 : txParams.accessList[0].storageKeys.length;
112
+ return persistentHash(signBidirectionalEventDescriptor(maxCalldataWords, maxAccessListEntries, maxStorageKeysPerEntry, request.outputDeserializationSchema.length, request.respondSerializationSchema.length), request);
113
+ }
114
+ // ---- ABI words / calldata / transaction assembly ---------------------------
115
+ /**
116
+ * The ABI word for a numeric value (e.g. an ERC20 amount): the value as a
117
+ * 32-byte BIG-ENDIAN integer, exactly as broadcast. TS mirror of
118
+ * Signet.compact's `numericAbiWord` circuit (lockstep-tested against the
119
+ * compiled circuit). Use when building words off-chain (UIs, expected-record
120
+ * builders, tests).
121
+ *
122
+ * @param value - The word's numeric value (e.g. an amount).
123
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
124
+ */
125
+ export function numericAbiWord(value) {
126
+ return bigintToBytes32BE(value);
127
+ }
128
+ /**
129
+ * The ABI word for an EVM address: 12 zero bytes, then the 20 display-order
130
+ * address bytes, exactly as broadcast. TS mirror of Signet.compact's
131
+ * `evmAddressAbiWord` circuit (lockstep-tested against the compiled circuit).
132
+ *
133
+ * @param address - The 20-byte address in display order.
134
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
135
+ * @throws Error if the address is not exactly 20 bytes.
136
+ */
137
+ export function evmAddressAbiWord(address) {
138
+ if (address.length !== 20) {
139
+ throw new Error(`EVM address must be 20 bytes, got ${address.length}`);
140
+ }
141
+ const word = new Uint8Array(32);
142
+ word.set(address, 12);
143
+ return word;
144
+ }
145
+ /**
146
+ * The ABI word for a Boolean: 31 zero bytes, then 0x01 (true) or 0x00
147
+ * (false). TS mirror of Signet.compact's `boolAbiWord` circuit
148
+ * (lockstep-tested against the compiled circuit).
149
+ *
150
+ * @param value - The word's Boolean value.
151
+ * @returns The ABI-ready 32-byte word to store in an {@link EVMCalldata} word.
152
+ */
153
+ export function boolAbiWord(value) {
154
+ const word = new Uint8Array(32);
155
+ word[31] = value ? 1 : 0;
156
+ return word;
157
+ }
158
+ /**
159
+ * Read a numeric ABI word back into a bigint: the big-endian reading of bytes
160
+ * 16..31. TS mirror of Signet.compact's `abiWordToUint128` circuit, including
161
+ * its canonicality check: the leading 16 bytes must be zero, so a word wider
162
+ * than Uint<128> is rejected rather than silently truncated.
163
+ *
164
+ * @param word - The ABI-ready 32-byte word.
165
+ * @returns The word's numeric value.
166
+ * @throws Error if the word is not 32 bytes or its leading half is nonzero.
167
+ */
168
+ export function abiWordToUint128(word) {
169
+ if (word.length !== 32) {
170
+ throw new Error(`ABI word must be 32 bytes, got ${word.length}`);
171
+ }
172
+ if (word.slice(0, 16).some((byte) => byte !== 0)) {
173
+ throw new Error("ABI word exceeds Uint<128>");
174
+ }
175
+ let value = 0n;
176
+ for (let i = 16; i < 32; i++) {
177
+ value = value * 256n + BigInt(word[i]);
178
+ }
179
+ return value;
180
+ }
181
+ /**
182
+ * Read a Boolean ABI word back into a boolean. TS mirror of Signet.compact's
183
+ * `abiWordToBool` circuit, including its canonicality check: the first 31
184
+ * bytes must be zero and the last byte 0 or 1.
185
+ *
186
+ * @param word - The ABI-ready 32-byte word.
187
+ * @returns The word's Boolean value.
188
+ * @throws Error if the word is not 32 bytes or is not a canonical Boolean.
189
+ */
190
+ export function abiWordToBool(word) {
191
+ if (word.length !== 32) {
192
+ throw new Error(`ABI word must be 32 bytes, got ${word.length}`);
193
+ }
194
+ if (word.slice(0, 31).some((byte) => byte !== 0) || word[31] > 1) {
195
+ throw new Error("ABI word is not a canonical Boolean");
196
+ }
197
+ return word[31] === 1;
198
+ }
199
+ /**
200
+ * Assemble the raw calldata a request's words describe:
201
+ * `data = selector || words[0..noWords]`, VERBATIM. Words are stored
202
+ * ABI-ready (see {@link EVMCalldata}), so no byte of the stored record is
203
+ * reordered or reinterpreted on the way into the transaction; slots past
204
+ * `noWords` are unused capacity and are dropped. This is THE implementation
205
+ * of the signer-side assembly documented on `EVMCalldata` in Signet.compact.
206
+ *
207
+ * @param calldata - The request's calldata field.
208
+ * @returns Hex calldata for the transaction (`"0x"` when absent).
209
+ */
210
+ export function assembleCalldata(calldata) {
211
+ if (!calldata.is_some) {
212
+ return "0x";
213
+ }
214
+ const { selector, noWords, words } = calldata.value;
215
+ let data = `0x${bytesToHex(selector)}`;
216
+ for (let i = 0; i < Number(noWords); i++) {
217
+ data += bytesToHex(words[i]);
218
+ }
219
+ return data;
220
+ }
221
+ /**
222
+ * Decode the real (count-trimmed) access list of a request into the shape
223
+ * ethers' `Transaction.from` accepts.
224
+ *
225
+ * @param txParams - The request's transaction decomposition.
226
+ * @returns The access list, possibly empty.
227
+ */
228
+ function decodeAccessList(txParams) {
229
+ return txParams.accessList
230
+ .slice(0, Number(txParams.accessListEntryCount))
231
+ .map((entry) => ({
232
+ address: getAddress(`0x${bytesToHex(entry.address)}`),
233
+ storageKeys: entry.storageKeys
234
+ .slice(0, Number(entry.storageKeyCount))
235
+ .map((key) => `0x${bytesToHex(key)}`),
236
+ }));
237
+ }
238
+ /**
239
+ * Rebuild the unsigned EIP-1559 transaction a request record describes,
240
+ * byte-identical to the one the MPC assembles and signs: calldata from the
241
+ * tagged words (see {@link assembleCalldata}), the count-trimmed access
242
+ * list, and the stored envelope fields. This is the canonical
243
+ * request→transaction transform; response-side verification
244
+ * (`signature-response-verification.ts`) and the signed-transaction builder
245
+ * below both go through it, so the transaction a client broadcasts is
246
+ * provably the one the MPC put its signature over.
247
+ *
248
+ * @param request - The on-ledger request record.
249
+ * @returns The unsigned ethers transaction (`unsignedHash` is the digest the
250
+ * MPC signs).
251
+ * @throws Error if a calldata word carries an unknown kind.
252
+ */
253
+ export function signBidirectionalEventToUnsignedEVMTransaction(request) {
254
+ const { txParams } = request;
255
+ return Transaction.from({
256
+ type: 2,
257
+ chainId: txParams.chainId,
258
+ nonce: Number(txParams.nonce),
259
+ gasLimit: txParams.gasLimit,
260
+ maxFeePerGas: txParams.maxFeePerGas,
261
+ maxPriorityFeePerGas: txParams.maxPriorityFeePerGas,
262
+ to: getAddress(`0x${bytesToHex(txParams.to)}`),
263
+ value: txParams.value,
264
+ accessList: decodeAccessList(txParams),
265
+ data: assembleCalldata(txParams.calldata),
266
+ });
267
+ }
268
+ /**
269
+ * Decode a response signature record (as posted to the signet contract's
270
+ * signature response log — the canonical MPC `Signature { big_r, s,
271
+ * recovery_id }` shape) into an ethers {@link Signature}: `r` is `bigR`'s x
272
+ * coordinate, `v` the legacy parity derived from the recovery id.
273
+ *
274
+ * @param response - The posted signature record.
275
+ * @returns The ethers signature.
276
+ * @throws Error if the recovery id is not 0 or 1.
277
+ */
278
+ export function signatureRespondedEventToSignature(response) {
279
+ const recoveryId = Number(response.recoveryId);
280
+ if (recoveryId !== 0 && recoveryId !== 1) {
281
+ throw new Error(`expected a recovery id of 0 or 1, got ${recoveryId}`);
282
+ }
283
+ return Signature.from({
284
+ r: `0x${bytesToHex(response.bigRx)}`,
285
+ s: `0x${bytesToHex(response.s)}`,
286
+ v: recoveryId + 27,
287
+ });
288
+ }
289
+ /** secp256k1 base field prime (2^256 - 2^32 - 977). */
290
+ const SECP256K1_P = 2n ** 256n - 2n ** 32n - 977n;
291
+ /** Modular exponentiation by squaring. */
292
+ function modPow(base, exponent, modulus) {
293
+ let result = 1n;
294
+ let b = base % modulus;
295
+ let e = exponent;
296
+ while (e > 0n) {
297
+ if (e & 1n)
298
+ result = (result * b) % modulus;
299
+ b = (b * b) % modulus;
300
+ e >>= 1n;
301
+ }
302
+ return result;
303
+ }
304
+ /** Encode a bigint as exactly 32 BIG-endian bytes (secp256k1 scalar form). */
305
+ function bigintToBytes32BE(value) {
306
+ const out = new Uint8Array(32);
307
+ let v = value;
308
+ for (let i = 31; i >= 0; i--) {
309
+ out[i] = Number(v & 0xffn);
310
+ v >>= 8n;
311
+ }
312
+ return out;
313
+ }
314
+ /**
315
+ * Encode an ECDSA signature as the response record posted to the signet
316
+ * contract — the inverse of {@link signatureRespondedEventToSignature},
317
+ * for MPC-side posters (the fakenet signer, tests). The canonical record
318
+ * carries `bigR` as a full affine point but an `r || s || v` signature only
319
+ * has R.x and the parity of R.y, so R.y is recovered by decompressing the
320
+ * point on the curve (y² = x³ + 7 over the secp256k1 base field).
321
+ *
322
+ * The parameter is structural (the r/s/yParity subset of an ethers
323
+ * {@link Signature}) so signatures from ANY ethers instance qualify — posters
324
+ * living in other repos resolve their own ethers install, and nominal class
325
+ * typing would reject it.
326
+ *
327
+ * @param signature - The signature to encode (`r`/`s` as 0x hex, `yParity` 0 or 1).
328
+ * @returns The response record, ready to post.
329
+ * @throws Error if `r` is not the x coordinate of a curve point.
330
+ */
331
+ export function signatureToSignatureRespondedEvent(signature) {
332
+ const x = BigInt(signature.r);
333
+ const ySquared = (modPow(x, 3n, SECP256K1_P) + 7n) % SECP256K1_P;
334
+ // P ≡ 3 (mod 4), so a square root (when one exists) is c^((P+1)/4).
335
+ let y = modPow(ySquared, (SECP256K1_P + 1n) / 4n, SECP256K1_P);
336
+ if ((y * y) % SECP256K1_P !== ySquared) {
337
+ throw new Error("signature r is not the x coordinate of a secp256k1 point");
338
+ }
339
+ if ((y & 1n) !== BigInt(signature.yParity)) {
340
+ y = SECP256K1_P - y;
341
+ }
342
+ return {
343
+ bigRx: getBytes(signature.r),
344
+ bigRy: bigintToBytes32BE(y),
345
+ s: getBytes(signature.s),
346
+ recoveryId: BigInt(signature.yParity),
347
+ };
348
+ }
349
+ /**
350
+ * Assemble the broadcast-ready signed EIP-1559 transaction for a request from
351
+ * its MPC signature response: rebuild the exact unsigned transaction the MPC
352
+ * signed (see {@link signBidirectionalEventToUnsignedEVMTransaction}) and
353
+ * attach the signature. Does NOT check that the signature recovers to the
354
+ * requester's derived address — the response log is unauthenticated, so
355
+ * verify first with `verifySignatureRespondedEvent`.
356
+ *
357
+ * @param request - The on-ledger request record.
358
+ * @param response - The posted signature record answering it.
359
+ * @returns The signed ethers transaction; `serialized` is the raw payload for
360
+ * `eth_sendRawTransaction`, `hash` its on-chain hash, `from` the recovered
361
+ * sender.
362
+ * @throws Error if the request record is malformed (see
363
+ * {@link signBidirectionalEventToUnsignedEVMTransaction}) or the response
364
+ * is not a decodable signature.
365
+ */
366
+ export function signBidirectionalEventToSignedEVMTransaction(request, response) {
367
+ const transaction = signBidirectionalEventToUnsignedEVMTransaction(request);
368
+ transaction.signature = signatureRespondedEventToSignature(response);
369
+ return transaction;
370
+ }
371
+ //# sourceMappingURL=signet-evtype2tx-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signet-evtype2tx-requests.js","sourceRoot":"","sources":["../src/signet-evtype2tx-requests.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,6EAA6E;AAC7E,oEAAoE;AACpE,8EAA8E;AAC9E,QAAQ;AACR,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,yEAAyE;AAEzE,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,cAAc,GAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGtE,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oCAAoC,GAIrC,MAAM,sBAAsB,CAAC;AAiE9B,+EAA+E;AAC/E,wEAAwE;AACxE,8CAA8C;AAC9C,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC1C,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAA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AAM,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,WAAW,CAAC;IACjE,oEAAoE;IACpE,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;IAC/D,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QAC5B,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC3B,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;KACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,4CAA4C,CAC1D,OAA+B,EAC/B,QAAiC;IAEjC,MAAM,WAAW,GAAG,8CAA8C,CAAC,OAAO,CAAC,CAAC;IAC5E,WAAW,CAAC,SAAS,GAAG,kCAAkC,CAAC,QAAQ,CAAC,CAAC;IACrE,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -2,7 +2,7 @@ import type { PublicDataProvider } from "@midnight-ntwrk/midnight-js-types";
2
2
  import type { Transaction } from "ethers";
3
3
  import { type SignatureRespondedEvent, type RespondBidirectionalEvent } from "./signet-contract-state-reader.ts";
4
4
  import type { RawContractState } from "./signature-state-reading.ts";
5
- import { type SignBidirectionalEvent, type RequestIdHex } from "./signet-requests.ts";
5
+ import type { SignBidirectionalEvent, RequestIdHex } from "./signet-requests.ts";
6
6
  /**
7
7
  * The least of midnight-js's `PublicDataProvider` the reader needs: raw
8
8
  * contract state by address. Declared structurally (rather than a `Pick`) so