@sig-net/midnight 0.10.0 → 0.11.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.
- package/README.md +8 -8
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/ecdsa-attestation.d.ts +53 -1
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +96 -4
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/epsilon-derivation.d.ts +8 -8
- package/dist/epsilon-derivation.d.ts.map +1 -1
- package/dist/epsilon-derivation.js +15 -17
- package/dist/epsilon-derivation.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +42 -24
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +14 -10
- package/dist/managed/contract/index.js +142 -86
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +2 -2
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +32 -15
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +1 -1
- package/dist/signature-response-verification.js +5 -5
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-state-reader.d.ts +49 -30
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +55 -35
- package/dist/signet-contract-state-reader.js.map +1 -1
- package/dist/signet-evtype2tx-requests.d.ts +47 -44
- package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
- package/dist/signet-evtype2tx-requests.js +47 -79
- package/dist/signet-evtype2tx-requests.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +3 -3
- package/dist/signet-request-response-reader.js +9 -9
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +4 -4
- package/dist/signet-requests.js +1 -1
- package/package.json +1 -1
- package/src/Signet.compact +85 -51
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,uBAAuB;AACvB,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,6BAA6B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,iCAAiC,EACjC,iBAAiB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AAoExC;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACrB,MAAM,CAAoC;IAE3D,qEAAqE;IACpD,YAAY,GAAG,IAAI,GAAG,EAGpC,CAAC;IAEJ;;OAEG;IACH,YAAY,MAAyC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,aAAa,CACzB,eAAuB,EACvB,IAAY;QAEZ,MAAM,KAAK,GACT,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,2BAA2B,IAAI,cAAc,eAAe,qBAAqB,CAClF,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,mBAAmB,CACvB,SAAuB;QAEvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAClC,IAAI,CAAC,MAAM,CAAC,wBAAwB,EACpC,WAAW,CACZ,CAAC;QACF,MAAM,OAAO,GAAG,qBAAqB,CACnC,GAAG,EACH,IAAI,CAAC,MAAM,CAAC,2BAA2B,EACvC,SAAS,CACV,CAAC;QACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,WAAW,SAAS,6CAA6C;gBAC/D,2BAA2B,IAAI,CAAC,MAAM,CAAC,2BAA2B,uBAAuB,CAC5F,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,qBAAqB,CACzB,SAAuB;QAEvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAClC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EACjC,iBAAiB,CAClB,CAAC;QACF,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,uBAAuB;AACvB,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,6BAA6B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,iCAAiC,EACjC,iBAAiB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AAoExC;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IAC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AAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,6BAA6B,CACjC,SAAuB;QAEvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAClC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EACjC,iBAAiB,CAClB,CAAC;QACF,MAAM,EAAE,8BAA8B,EAAE,uBAAuB,EAAE,GAC/D,iCAAiC,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,UAAU,GAAG,8BAA8B,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACvE,MAAM,SAAS,GAAgC,EAAE,CAAC;QAClD,KAAK,IAAI,KAAK,GAAG,EAAE,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACjD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,GAAG,CAC1C,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CACpC,CAAC;YACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,0CAA0C,KAAK,gBAAgB,SAAS,GAAG;oBACzE,+BAA+B,UAAU,iCAAiC,CAC7E,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CompactType } from "@midnight-ntwrk/compact-runtime";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EvmType2TxParams } from "./signet-evtype2tx-requests.ts";
|
|
3
3
|
/**
|
|
4
4
|
* 32-byte signet request id (Compact: `new type RequestId = Bytes<32>`).
|
|
5
5
|
* Chain-agnostic: downstream consumers treat it as an opaque key. Ids are
|
|
@@ -23,7 +23,7 @@ export interface ContractAddress {
|
|
|
23
23
|
* `enum`) so the values stay structurally `number`.
|
|
24
24
|
*/
|
|
25
25
|
export declare const TxParamType: {
|
|
26
|
-
/** `
|
|
26
|
+
/** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
|
|
27
27
|
readonly evmType2: 0;
|
|
28
28
|
/**
|
|
29
29
|
* Never emitted — mirrors the Compact-side padding variant that keeps the
|
|
@@ -68,12 +68,12 @@ export interface Maybe<T> {
|
|
|
68
68
|
* contract's `SignBidirectionalEventMap` (at whichever ledger field the
|
|
69
69
|
* contract declares it — its notifications name the position). Generic over
|
|
70
70
|
* the tx-params decomposition, exactly like the Compact struct; the default
|
|
71
|
-
* instantiation is {@link
|
|
71
|
+
* instantiation is {@link EvmType2TxParams} — the only decomposition so far;
|
|
72
72
|
* new tx kinds supply their own type argument alongside their Compact struct.
|
|
73
73
|
* The schema fields carry their contract-declared byte widths in their array
|
|
74
74
|
* lengths.
|
|
75
75
|
*/
|
|
76
|
-
export interface SignBidirectionalEvent<TxParams =
|
|
76
|
+
export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
|
|
77
77
|
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
78
78
|
sender: ContractAddress;
|
|
79
79
|
/** Contract-local nonce captured when the request was created. */
|
package/dist/signet-requests.js
CHANGED
|
@@ -26,7 +26,7 @@ import { CompactTypeBoolean, CompactTypeBytes, CompactTypeEnum, CompactTypeUnsig
|
|
|
26
26
|
* `enum`) so the values stay structurally `number`.
|
|
27
27
|
*/
|
|
28
28
|
export const TxParamType = {
|
|
29
|
-
/** `
|
|
29
|
+
/** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
|
|
30
30
|
evmType2: 0,
|
|
31
31
|
/**
|
|
32
32
|
* Never emitted — mirrors the Compact-side padding variant that keeps the
|
package/package.json
CHANGED
package/src/Signet.compact
CHANGED
|
@@ -121,7 +121,7 @@ module Signet {
|
|
|
121
121
|
// TxParamType indicates which transaction-param decomposition a request
|
|
122
122
|
// contains so an off-chain consumer (e.g. the MPC) knows how to re-assemble it.
|
|
123
123
|
export enum TxParamType {
|
|
124
|
-
evmType2, //
|
|
124
|
+
evmType2, // EvmType2TxParams: an EIP-1559 EVM transaction (envelope + calldata)
|
|
125
125
|
reserved, // Reserved for future use. Exists to keep enum >= 2 (proof server bug).
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -166,14 +166,16 @@ module Signet {
|
|
|
166
166
|
// (see calculateRequestId).
|
|
167
167
|
export new type RequestId = Bytes<32>;
|
|
168
168
|
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
169
|
+
// keccak256 of the whole record, so the id commits to every field including sender
|
|
170
|
+
// (which scopes ids per contract). No domain-separation tag, deliberately.
|
|
171
|
+
//
|
|
172
|
+
// Hashes the field-aligned binary representation (each field re-padded to its declared
|
|
173
|
+
// width), NOT an ABI/EIP-712 field encoding, so off-chain consumers must reproduce that
|
|
174
|
+
// layout exactly. Type argument is the INPUT type; the return is always Bytes<32>.
|
|
173
175
|
export pure circuit calculateRequestId<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
|
|
174
176
|
request: SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>
|
|
175
177
|
): RequestId {
|
|
176
|
-
return
|
|
178
|
+
return keccak256<SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>>(request) as RequestId;
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
// ---- Client Contract: SignBidirectionalEvent Map ---------------------------------------------------
|
|
@@ -190,7 +192,7 @@ module Signet {
|
|
|
190
192
|
// Signet singleton to notify the MPC of a SignBidirectionalEvent.
|
|
191
193
|
export contract SignetSigner {
|
|
192
194
|
// Called by client contracts to notify the MPC of a SignBidirectionalEvent.
|
|
193
|
-
circuit
|
|
195
|
+
circuit signBidirectional(
|
|
194
196
|
// Canonical id of the SignBidirectionalEvent (calculate with calculateRequestId).
|
|
195
197
|
requestId: RequestId,
|
|
196
198
|
// Versioned notification of the SignBidirectionalEvent
|
|
@@ -221,13 +223,35 @@ module Signet {
|
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
225
|
|
|
226
|
+
// A curve point in affine coordinates, SEC1 big-endian. Field-for-field the
|
|
227
|
+
// AffinePoint of the sig-net EVM and Solana signer contracts.
|
|
228
|
+
export struct AffinePoint {
|
|
229
|
+
x: Bytes<32>;
|
|
230
|
+
y: Bytes<32>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// The MPC's canonical ECDSA signature: bigR the full nonce point (so consumers
|
|
234
|
+
// never decompress), s big-endian, recoveryId the parity of R.y (0 or 1).
|
|
235
|
+
// Deliberately identical to the Signature struct every other sig-net signer
|
|
236
|
+
// contract exposes (EVM ChainSignatures.sol, the Solana signet program) and to
|
|
237
|
+
// the MPC's own Signature { big_r, s, recovery_id } — one vocabulary across
|
|
238
|
+
// chains. No algorithm tag is stored: the scheme is fixed by the request's own
|
|
239
|
+
// MPCSignatureAlgorithm.
|
|
240
|
+
//
|
|
241
|
+
// Stored bytes are BIG-endian throughout, the canonical SEC1 order. The scalar
|
|
242
|
+
// casts read little-endian, so verifyRespondBidirectionalEvent reverses on the
|
|
243
|
+
// way in rather than making the stored record non-canonical.
|
|
244
|
+
export struct Signature {
|
|
245
|
+
bigR: AffinePoint;
|
|
246
|
+
s: Bytes<32>;
|
|
247
|
+
recoveryId: Uint<8>;
|
|
248
|
+
}
|
|
249
|
+
|
|
224
250
|
// Counterpart to SignBidirectionalEvent containing MPC generated signature requested by a SignBidirectionalEvent.
|
|
225
251
|
// Posted by MPC back to Signet singleton for clients to extract to build a signed transaction.
|
|
226
252
|
export struct SignatureRespondedEvent {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
s: Bytes<32>; // signature s
|
|
230
|
-
recoveryId: Uint<8>; // parity of R.y for public-key recovery
|
|
253
|
+
// The requested signature over the transaction the request describes.
|
|
254
|
+
signature: Signature;
|
|
231
255
|
}
|
|
232
256
|
|
|
233
257
|
// Structure containing the output of a transaction executed on a foreign blockchain,
|
|
@@ -251,16 +275,9 @@ module Signet {
|
|
|
251
275
|
// Meaningful byte count of serializedOutput.
|
|
252
276
|
outputLen: Uint<8>;
|
|
253
277
|
|
|
254
|
-
//
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
// r is the MPC signature's big_r.x reduced mod the curve order.
|
|
258
|
-
r: Bytes<32>;
|
|
259
|
-
s: Bytes<32>;
|
|
260
|
-
|
|
261
|
-
// Recovery id (parity of R.y), for off-chain public key recovery only.
|
|
262
|
-
// Unused in-circuit: verification takes the public key as an explicit input.
|
|
263
|
-
recoveryId: Uint<8>;
|
|
278
|
+
// Signs signetAttestationDigest(requestId, serializedOutput) — outputLen above is
|
|
279
|
+
// NOT covered. The verify circuit's r is this signature's bigR.x mod the curve order.
|
|
280
|
+
signature: Signature;
|
|
264
281
|
}
|
|
265
282
|
|
|
266
283
|
// SignetMapKey used to locate SignBidirectionalEventNotifications, SignatureRespondedEvent and
|
|
@@ -270,45 +287,59 @@ module Signet {
|
|
|
270
287
|
requestId: RequestId;
|
|
271
288
|
};
|
|
272
289
|
|
|
273
|
-
// The 32-byte digest the MPC ECDSA-signs to attest a remote execution:
|
|
274
|
-
//
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
//
|
|
290
|
+
// The 32-byte digest the MPC ECDSA-signs to attest a remote execution: keccak256 over
|
|
291
|
+
// requestId (32) ++ serializedOutput (128). The output is hashed as the full zero-padded
|
|
292
|
+
// Bytes<128>, not at its meaningful length, because Compact cannot hash a runtime-length
|
|
293
|
+
// prefix — an off-chain signer must pad to exactly 128 before hashing.
|
|
294
|
+
//
|
|
295
|
+
// outputLen is NOT covered. A consumer that treats it as attested must pin it itself.
|
|
296
|
+
//
|
|
297
|
+
// secp256k1EcdsaVerify reads the digest as a BIG-ENDIAN integer mod the curve order
|
|
298
|
+
// (RFC 6979). ONE implementation for everyone: off-chain signers call the compiled copy
|
|
299
|
+
// via circuits.compact, never a TS re-implementation.
|
|
280
300
|
export pure circuit signetAttestationDigest(
|
|
281
301
|
requestId: RequestId,
|
|
282
|
-
serializedOutput: Bytes<128
|
|
283
|
-
outputLen: Uint<8>
|
|
302
|
+
serializedOutput: Bytes<128>
|
|
284
303
|
): Bytes<32> {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
304
|
+
const requestIdBytes = requestId as Bytes<32>;
|
|
305
|
+
return keccak256<Bytes<160>>(Bytes[...requestIdBytes, ...serializedOutput]);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Same Bytes -> Vector<Uint<8>> idiom numericAbiWord uses. Pulls in a byte-decomposition
|
|
309
|
+
// lookup table, a fixed cost the calling circuit pays once and shares with any other
|
|
310
|
+
// byte-level work it does, so reverse at the boundary and never per element.
|
|
311
|
+
pure circuit reverseBytes32(b: Bytes<32>): Bytes<32> {
|
|
312
|
+
const v = b as Vector<32, Uint<8>>;
|
|
313
|
+
return Bytes[v[31], v[30], v[29], v[28], v[27], v[26], v[25], v[24],
|
|
314
|
+
v[23], v[22], v[21], v[20], v[19], v[18], v[17], v[16],
|
|
315
|
+
v[15], v[14], v[13], v[12], v[11], v[10], v[9], v[8],
|
|
316
|
+
v[7], v[6], v[5], v[4], v[3], v[2], v[1], v[0]];
|
|
290
317
|
}
|
|
291
318
|
|
|
292
|
-
// Verify a
|
|
319
|
+
// Verify a respond-bidirectional attestation against a secp256k1 public key: the
|
|
293
320
|
// ECDSA signature must sign the attestation digest of (requestId, output). This is
|
|
294
321
|
// the check client contracts run before accepting a response (the Signet singleton
|
|
295
322
|
// stores posts unverified); pass the contract's MPC RESPONSE key (derived off-chain
|
|
296
323
|
// from the contract's address + the fixed path "midnight response key", typically
|
|
297
324
|
// hash-pinned in the contract's ledger at deploy time).
|
|
325
|
+
//
|
|
326
|
+
// Takes the event as stored: the caller hands over the record it read, and the
|
|
327
|
+
// big-endian-to-little-endian re-encoding happens here instead of in every
|
|
328
|
+
// integrator.
|
|
329
|
+
//
|
|
330
|
+
// ECDSA's r is bigR.x reduced mod the curve order; bigR.x is taken as-is because it
|
|
331
|
+
// is already below the order for all but a ~2^-128 fraction of signatures, and one
|
|
332
|
+
// that is not simply fails to verify.
|
|
298
333
|
export pure circuit verifyRespondBidirectionalEvent(
|
|
299
334
|
requestId: RequestId,
|
|
300
335
|
respondBidirectionalEvent: RespondBidirectionalEvent,
|
|
301
336
|
mpcResponseKey: Secp256k1Point
|
|
302
337
|
): Boolean {
|
|
303
338
|
return secp256k1EcdsaVerify(
|
|
304
|
-
signetAttestationDigest(
|
|
305
|
-
requestId,
|
|
306
|
-
respondBidirectionalEvent.serializedOutput,
|
|
307
|
-
respondBidirectionalEvent.outputLen
|
|
308
|
-
),
|
|
339
|
+
signetAttestationDigest(requestId, respondBidirectionalEvent.serializedOutput),
|
|
309
340
|
Secp256k1EcdsaSignature {
|
|
310
|
-
r: respondBidirectionalEvent.
|
|
311
|
-
s: respondBidirectionalEvent.s as Secp256k1Scalar,
|
|
341
|
+
r: reverseBytes32(respondBidirectionalEvent.signature.bigR.x) as Secp256k1Scalar,
|
|
342
|
+
s: reverseBytes32(respondBidirectionalEvent.signature.s) as Secp256k1Scalar,
|
|
312
343
|
},
|
|
313
344
|
mpcResponseKey
|
|
314
345
|
);
|
|
@@ -337,23 +368,26 @@ module Signet {
|
|
|
337
368
|
// count that says how many leading slots are real. Off-chain consumers use
|
|
338
369
|
// the counts; unused capacity is hashed as part of the record (zero-fill by
|
|
339
370
|
// convention) but never reaches the assembled transaction.
|
|
340
|
-
|
|
341
|
-
|
|
371
|
+
// Canonical EIP-1559 payload order, which is the RLP order the MPC re-assembles into.
|
|
372
|
+
// Each count sits directly before the slot it bounds. This order is also the
|
|
373
|
+
// request-id hash order, so it is part of the wire contract.
|
|
374
|
+
export struct EvmType2TxParams<#maxCalldataWords, #maxAccessListEntries, #maxStorageKeysPerEntry> {
|
|
342
375
|
chainId: Uint<64>; // EVM chain id (also expressed in caip2Id)
|
|
343
376
|
nonce: Uint<64>; // account nonce of the derived sender
|
|
344
|
-
gasLimit: Uint<64>; // gas ceiling for the call
|
|
345
|
-
maxFeePerGas: Uint<128>; // wei
|
|
346
377
|
maxPriorityFeePerGas: Uint<128>; // wei
|
|
378
|
+
maxFeePerGas: Uint<128>; // wei
|
|
379
|
+
gasLimit: Uint<64>; // gas ceiling for the call
|
|
380
|
+
to: Bytes<20>; // call target (e.g. the ERC20 contract)
|
|
347
381
|
value: Uint<128>; // ETH sent with the call, in wei
|
|
382
|
+
calldata: Maybe<EvmCalldata<maxCalldataWords>>; // none = plain ETH transfer ("0x" data)
|
|
348
383
|
accessListEntryCount: Uint<8>; // how many leading accessList entries are real
|
|
349
|
-
accessList: Vector<maxAccessListEntries,
|
|
350
|
-
calldata: Maybe<EVMCalldata<maxCalldataWords>>; // none = plain ETH transfer ("0x" data)
|
|
384
|
+
accessList: Vector<maxAccessListEntries, EvmAccessListEntry<maxStorageKeysPerEntry>>;
|
|
351
385
|
}
|
|
352
386
|
|
|
353
387
|
// One EIP-2930 access-list entry (https://eips.ethereum.org/EIPS/eip-2930):
|
|
354
388
|
// an address plus the storage keys the transaction pre-declares. Keys are
|
|
355
389
|
// raw 32-byte values, copied verbatim into the RLP encoding.
|
|
356
|
-
export struct
|
|
390
|
+
export struct EvmAccessListEntry<#maxStorageKeys> {
|
|
357
391
|
address: Bytes<20>;
|
|
358
392
|
storageKeyCount: Uint<8>; // how many leading storageKeys are real
|
|
359
393
|
storageKeys: Vector<maxStorageKeys, Bytes<32>>;
|
|
@@ -365,7 +399,7 @@ module Signet {
|
|
|
365
399
|
// the MPC signs a transaction composed of exactly these words. See the
|
|
366
400
|
// ABI Calldata Word Construction Utilities below for help constructing
|
|
367
401
|
// canonical ABI words for common types.
|
|
368
|
-
export struct
|
|
402
|
+
export struct EvmCalldata<#maxWords> {
|
|
369
403
|
selector: Bytes<4>; // the literal first 4 calldata bytes
|
|
370
404
|
noWords: Uint<16>; // No. of used words in the words list
|
|
371
405
|
words: Vector<maxWords, Bytes<32>>; // canonical ABI words (big-endian)
|