@sig-net/midnight 0.10.0 → 0.12.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 +17 -17
- package/dist/abi-serde.d.ts +89 -0
- package/dist/abi-serde.d.ts.map +1 -0
- package/dist/abi-serde.js +393 -0
- package/dist/abi-serde.js.map +1 -0
- package/dist/constants.d.ts +23 -14
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +28 -20
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +81 -9
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +137 -18
- 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 +16 -18
- package/dist/epsilon-derivation.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +180 -104
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +38 -24
- package/dist/managed/contract/index.js +363 -154
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +15 -15
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +51 -34
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +2 -2
- package/dist/signature-response-verification.js +8 -8
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-state-reader.d.ts +74 -58
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +76 -58
- package/dist/signet-contract-state-reader.js.map +1 -1
- package/dist/signet-evtype2tx-requests.d.ts +62 -59
- package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
- package/dist/signet-evtype2tx-requests.js +58 -90
- package/dist/signet-evtype2tx-requests.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +26 -26
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +37 -37
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +30 -30
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +29 -30
- package/dist/signet-requests.js.map +1 -1
- package/package.json +3 -2
- package/src/Signet.compact +137 -88
- package/src/circuits.compact +45 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-state-reader.d.ts","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,eAAO,MAAM,uDAAuD,IAAI,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,+CAA+C,IAAI,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"signet-contract-state-reader.d.ts","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,eAAO,MAAM,uDAAuD,IAAI,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,+CAA+C,IAAI,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,IAA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CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,GACpB,oBAAoB,CA2BtB"}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
// declaration-order layout:
|
|
7
7
|
// field 0: signBidirectionalEventNotificationCounterMap (Map<RequestId, Counter>)
|
|
8
8
|
// field 1: signBidirectionalEventNotificationMap (Map<SignetMapKey, Notification>)
|
|
9
|
-
// field 2:
|
|
10
|
-
// field 3:
|
|
9
|
+
// field 2: respondCounterMap (Map<RequestId, Counter>)
|
|
10
|
+
// field 3: respondMap (Map<SignetMapKey, SignatureRespondedEvent>)
|
|
11
11
|
// field 4: respondBidirectionalCounterMap (Map<RequestId, Counter>)
|
|
12
12
|
// field 5: respondBidirectionalMap (Map<SignetMapKey, RespondBidirectionalEvent>)
|
|
13
13
|
// Every store is an unauthenticated append-only log keyed by
|
|
14
|
-
// (requestId, count)
|
|
14
|
+
// (requestId, count): verification is the reader's job. The generic
|
|
15
15
|
// state-tree walk (RawContractState, signetFieldNode) and the shared base
|
|
16
16
|
// descriptors live in signature-state-reading.ts.
|
|
17
17
|
import { CompactTypeBytes, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
|
|
@@ -21,10 +21,10 @@ import { requestIdType, signetFieldNode, u64, } from "./signature-state-reading.
|
|
|
21
21
|
export const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD = 0;
|
|
22
22
|
/** Signet contract layout: the notification map is ledger field 1. */
|
|
23
23
|
export const SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD = 1;
|
|
24
|
-
/** Signet contract layout: the
|
|
25
|
-
export const
|
|
26
|
-
/** Signet contract layout: the
|
|
27
|
-
export const
|
|
24
|
+
/** Signet contract layout: the `respond` counter map is ledger field 2. */
|
|
25
|
+
export const RESPOND_COUNTER_MAP_FIELD = 2;
|
|
26
|
+
/** Signet contract layout: the `respond` post log is ledger field 3. */
|
|
27
|
+
export const RESPOND_MAP_FIELD = 3;
|
|
28
28
|
/** Signet contract layout: the respond-bidirectional counter map is ledger field 4. */
|
|
29
29
|
export const RESPOND_BIDIRECTIONAL_COUNTER_MAP_FIELD = 4;
|
|
30
30
|
/** Signet contract layout: the respond-bidirectional map is ledger field 5. */
|
|
@@ -32,19 +32,17 @@ export const RESPOND_BIDIRECTIONAL_MAP_FIELD = 5;
|
|
|
32
32
|
// ---- Type descriptors (must mirror Signet.compact field-for-field) ----
|
|
33
33
|
// As in the requests reader, fromValue consumes the aligned value
|
|
34
34
|
// sequentially, so field order and width here must match the Compact structs
|
|
35
|
-
// exactly
|
|
36
|
-
/** Descriptor for a 32-byte scalar / hash (`Bytes<32>`). */
|
|
35
|
+
// exactly: a mismatch is silent data corruption, not an error.
|
|
36
|
+
/** Descriptor for a 32-byte scalar / coordinate / hash (`Bytes<32>`). */
|
|
37
37
|
const bytes32 = new CompactTypeBytes(32);
|
|
38
|
-
/** Descriptor for the response's serialized output (`Bytes<128>`). */
|
|
39
|
-
const bytes128 = new CompactTypeBytes(128);
|
|
40
38
|
/** Descriptor for a Compact `Uint<8>` (1-byte unsigned integer). */
|
|
41
39
|
const u8 = new CompactTypeUnsignedInteger(255n, 1);
|
|
42
40
|
/**
|
|
43
|
-
* Hand-composed descriptor for {@link
|
|
44
|
-
*
|
|
41
|
+
* Hand-composed descriptor for {@link MpcSignature}. Leaf order
|
|
42
|
+
* (bigR.x, bigR.y, s, recoveryId) must match the nested Compact structs.
|
|
45
43
|
*/
|
|
46
|
-
|
|
47
|
-
/** @returns Compound alignment of the struct's
|
|
44
|
+
const mpcSignatureType = {
|
|
45
|
+
/** @returns Compound alignment of the struct's leaves in declaration order. */
|
|
48
46
|
alignment() {
|
|
49
47
|
return bytes32
|
|
50
48
|
.alignment()
|
|
@@ -53,36 +51,62 @@ export const signatureRespondedEventType = {
|
|
|
53
51
|
.concat(u8.alignment());
|
|
54
52
|
},
|
|
55
53
|
/**
|
|
56
|
-
* Decode one signature
|
|
57
|
-
* by field.
|
|
54
|
+
* Decode one signature from an aligned value, consuming it leaf by leaf.
|
|
58
55
|
*
|
|
59
|
-
* @param value - Mutable aligned value cursor
|
|
60
|
-
* @returns The decoded
|
|
56
|
+
* @param value - Mutable aligned value cursor: pass a copy.
|
|
57
|
+
* @returns The decoded signature.
|
|
61
58
|
*/
|
|
62
59
|
fromValue(value) {
|
|
63
60
|
return {
|
|
64
|
-
|
|
65
|
-
bigRy: bytes32.fromValue(value),
|
|
61
|
+
bigR: { x: bytes32.fromValue(value), y: bytes32.fromValue(value) },
|
|
66
62
|
s: bytes32.fromValue(value),
|
|
67
63
|
recoveryId: u8.fromValue(value),
|
|
68
64
|
};
|
|
69
65
|
},
|
|
70
66
|
/**
|
|
71
|
-
* Encode a signature
|
|
67
|
+
* Encode a signature into its aligned on-ledger representation.
|
|
72
68
|
*
|
|
73
|
-
* @param record - The
|
|
74
|
-
* @returns The aligned value,
|
|
69
|
+
* @param record - The signature to encode.
|
|
70
|
+
* @returns The aligned value, leaves concatenated in declaration order.
|
|
75
71
|
*/
|
|
76
72
|
toValue(record) {
|
|
77
73
|
return bytes32
|
|
78
|
-
.toValue(record.
|
|
79
|
-
.concat(bytes32.toValue(record.
|
|
74
|
+
.toValue(record.bigR.x)
|
|
75
|
+
.concat(bytes32.toValue(record.bigR.y))
|
|
80
76
|
.concat(bytes32.toValue(record.s))
|
|
81
77
|
.concat(u8.toValue(record.recoveryId));
|
|
82
78
|
},
|
|
83
79
|
};
|
|
84
80
|
/**
|
|
85
|
-
* Hand-composed descriptor for {@link
|
|
81
|
+
* Hand-composed descriptor for {@link SignatureRespondedEvent}: the single
|
|
82
|
+
* {@link MpcSignature} field, matching the Compact struct.
|
|
83
|
+
*/
|
|
84
|
+
export const signatureRespondedEventType = {
|
|
85
|
+
/** @returns Alignment of the struct's single signature field. */
|
|
86
|
+
alignment() {
|
|
87
|
+
return mpcSignatureType.alignment();
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Decode one signature response from an aligned value.
|
|
91
|
+
*
|
|
92
|
+
* @param value - Mutable aligned value cursor: pass a copy.
|
|
93
|
+
* @returns The decoded record.
|
|
94
|
+
*/
|
|
95
|
+
fromValue(value) {
|
|
96
|
+
return { signature: mpcSignatureType.fromValue(value) };
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* Encode a signature response into its aligned on-ledger representation.
|
|
100
|
+
*
|
|
101
|
+
* @param record - The record to encode.
|
|
102
|
+
* @returns The aligned value.
|
|
103
|
+
*/
|
|
104
|
+
toValue(record) {
|
|
105
|
+
return mpcSignatureType.toValue(record.signature);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Hand-composed descriptor for {@link SignetMapKey}, the map key of every
|
|
86
110
|
* posted-entry map in the signet contract. Field order (count, then
|
|
87
111
|
* requestId) must match the Compact struct.
|
|
88
112
|
*/
|
|
@@ -94,7 +118,7 @@ export const signetMapKeyType = {
|
|
|
94
118
|
/**
|
|
95
119
|
* Decode one key from an aligned value, consuming it field by field.
|
|
96
120
|
*
|
|
97
|
-
* @param value - Mutable aligned value cursor
|
|
121
|
+
* @param value - Mutable aligned value cursor: pass a copy.
|
|
98
122
|
* @returns The decoded composite key.
|
|
99
123
|
*/
|
|
100
124
|
fromValue(value) {
|
|
@@ -115,33 +139,26 @@ export const signetMapKeyType = {
|
|
|
115
139
|
};
|
|
116
140
|
/**
|
|
117
141
|
* Hand-composed descriptor for {@link RespondBidirectionalEvent}. Field
|
|
118
|
-
* order (
|
|
119
|
-
* Compact struct.
|
|
142
|
+
* order (attestationDigest, signature) must match the Compact struct.
|
|
120
143
|
*/
|
|
121
144
|
export const respondBidirectionalEventType = {
|
|
122
145
|
/** @returns Compound alignment of the struct's fields in declaration order. */
|
|
123
146
|
alignment() {
|
|
124
|
-
return
|
|
147
|
+
return bytes32
|
|
125
148
|
.alignment()
|
|
126
|
-
.concat(
|
|
127
|
-
.concat(bytes32.alignment())
|
|
128
|
-
.concat(bytes32.alignment())
|
|
129
|
-
.concat(u8.alignment());
|
|
149
|
+
.concat(mpcSignatureType.alignment());
|
|
130
150
|
},
|
|
131
151
|
/**
|
|
132
152
|
* Decode one response record from an aligned value, consuming it field
|
|
133
153
|
* by field.
|
|
134
154
|
*
|
|
135
|
-
* @param value - Mutable aligned value cursor
|
|
155
|
+
* @param value - Mutable aligned value cursor: pass a copy.
|
|
136
156
|
* @returns The decoded record.
|
|
137
157
|
*/
|
|
138
158
|
fromValue(value) {
|
|
139
159
|
return {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
r: bytes32.fromValue(value),
|
|
143
|
-
s: bytes32.fromValue(value),
|
|
144
|
-
recoveryId: u8.fromValue(value),
|
|
160
|
+
attestationDigest: bytes32.fromValue(value),
|
|
161
|
+
signature: mpcSignatureType.fromValue(value),
|
|
145
162
|
};
|
|
146
163
|
},
|
|
147
164
|
/**
|
|
@@ -151,12 +168,9 @@ export const respondBidirectionalEventType = {
|
|
|
151
168
|
* @returns The aligned value, fields concatenated in declaration order.
|
|
152
169
|
*/
|
|
153
170
|
toValue(record) {
|
|
154
|
-
return
|
|
155
|
-
.toValue(record.
|
|
156
|
-
.concat(
|
|
157
|
-
.concat(bytes32.toValue(record.r))
|
|
158
|
-
.concat(bytes32.toValue(record.s))
|
|
159
|
-
.concat(u8.toValue(record.recoveryId));
|
|
171
|
+
return bytes32
|
|
172
|
+
.toValue(record.attestationDigest)
|
|
173
|
+
.concat(mpcSignatureType.toValue(record.signature));
|
|
160
174
|
},
|
|
161
175
|
};
|
|
162
176
|
/** Descriptor for the notification's packed V1 payload (`Bytes<128>`). */
|
|
@@ -174,7 +188,7 @@ export const signBidirectionalNotificationType = {
|
|
|
174
188
|
* Decode one notification record from an aligned value, consuming it
|
|
175
189
|
* field by field.
|
|
176
190
|
*
|
|
177
|
-
* @param value - Mutable aligned value cursor
|
|
191
|
+
* @param value - Mutable aligned value cursor: pass a copy.
|
|
178
192
|
* @returns The decoded record.
|
|
179
193
|
*/
|
|
180
194
|
fromValue(value) {
|
|
@@ -203,9 +217,9 @@ const NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET = 32;
|
|
|
203
217
|
const SUPPORTED_NOTIFICATION_VERSION = 1n;
|
|
204
218
|
/**
|
|
205
219
|
* Unpack a stored {@link SignBidirectionalNotificationRecord}'s payload by
|
|
206
|
-
* the fixed V1 offsets
|
|
220
|
+
* the fixed V1 offsets: the decode twin of the compiled
|
|
207
221
|
* `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
|
|
208
|
-
* only
|
|
222
|
+
* only: the pack↔decode lockstep is pinned by the state-reader unit test that
|
|
209
223
|
* round-trips through the real circuit). V1 layout:
|
|
210
224
|
* callerAddress (32) ++ requestsIndexField (1) ++ zero padding (95).
|
|
211
225
|
*
|
|
@@ -223,6 +237,10 @@ export function decodeSignBidirectionalNotification(record) {
|
|
|
223
237
|
}
|
|
224
238
|
const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET, NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET));
|
|
225
239
|
const requestsIndexField = record.payload[NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET];
|
|
240
|
+
if (requestsIndexField === undefined) {
|
|
241
|
+
throw new Error(`SignBidirectionalEventNotification payload is ${record.payload.length} bytes: ` +
|
|
242
|
+
`too short for the V1 requestsIndexField at offset ${NOTIFICATION_REQUESTS_INDEX_FIELD_OFFSET}`);
|
|
243
|
+
}
|
|
226
244
|
return {
|
|
227
245
|
version: Number(record.version),
|
|
228
246
|
callerAddress,
|
|
@@ -230,7 +248,7 @@ export function decodeSignBidirectionalNotification(record) {
|
|
|
230
248
|
};
|
|
231
249
|
}
|
|
232
250
|
/**
|
|
233
|
-
* Build the flattened JS map key for a `(requestId, count)` pair
|
|
251
|
+
* Build the flattened JS map key for a `(requestId, count)` pair: the
|
|
234
252
|
* composite Compact {@link SignetMapKey} as a string so it works as a JS
|
|
235
253
|
* `Map` key.
|
|
236
254
|
*
|
|
@@ -278,9 +296,9 @@ function readSignetKeyedMap(raw, field, valueType) {
|
|
|
278
296
|
/**
|
|
279
297
|
* Read ONLY the notification registry (ledger field
|
|
280
298
|
* {@link SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_MAP_FIELD}) out of raw signet
|
|
281
|
-
* contract state
|
|
299
|
+
* contract state: the poll-loop primitive of {@link SignetRequestFeed},
|
|
282
300
|
* which cycles frequently and has no use for the response fields. One record
|
|
283
|
-
* per request id (the count-0 post
|
|
301
|
+
* per request id (the count-0 post, see
|
|
284
302
|
* {@link SignBidirectionalNotificationIndex}).
|
|
285
303
|
*
|
|
286
304
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
@@ -313,9 +331,9 @@ export function readSignBidirectionalNotificationIndexFromState(raw) {
|
|
|
313
331
|
}
|
|
314
332
|
/**
|
|
315
333
|
* MPC-/client-style read: parse the signet contract's ledger fields out of
|
|
316
|
-
* raw contract state by field position alone
|
|
317
|
-
* generated `ledger()`, only the declaration-order layout and the
|
|
318
|
-
* descriptors above.
|
|
334
|
+
* raw contract state by field position alone, with no compiled contract and
|
|
335
|
+
* no generated `ledger()`, only the declaration-order layout and the
|
|
336
|
+
* canonical descriptors above.
|
|
319
337
|
*
|
|
320
338
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
321
339
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
@@ -326,8 +344,8 @@ export function readSignetContractLedgerFromState(raw) {
|
|
|
326
344
|
return {
|
|
327
345
|
signBidirectionalEventNotificationCounterMap: readCounterMap(raw, SIGN_BIDIRECTIONAL_EVENT_NOTIFICATION_COUNTER_MAP_FIELD),
|
|
328
346
|
signBidirectionalEventNotificationMap: readSignBidirectionalNotificationIndexFromState(raw),
|
|
329
|
-
|
|
330
|
-
|
|
347
|
+
respondCounterMap: readCounterMap(raw, RESPOND_COUNTER_MAP_FIELD),
|
|
348
|
+
respondMap: readSignetKeyedMap(raw, RESPOND_MAP_FIELD, signatureRespondedEventType),
|
|
331
349
|
respondBidirectionalCounterMap: readCounterMap(raw, RESPOND_BIDIRECTIONAL_COUNTER_MAP_FIELD),
|
|
332
350
|
respondBidirectionalMap: readSignetKeyedMap(raw, RESPOND_BIDIRECTIONAL_MAP_FIELD, respondBidirectionalEventType),
|
|
333
351
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-state-reader.js","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AACvE,6EAA6E;AAC7E,oEAAoE;AACpE,2EAA2E;AAC3E,4BAA4B;AAC5B,oFAAoF;AACpF,qFAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"signet-contract-state-reader.js","sourceRoot":"","sources":["../src/signet-contract-state-reader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AACvE,6EAA6E;AAC7E,oEAAoE;AACpE,2EAA2E;AAC3E,4BAA4B;AAC5B,oFAAoF;AACpF,qFAAqF;AACrF,yDAAyD;AACzD,qEAAqE;AACrE,sEAAsE;AACtE,oFAAoF;AACpF,6DAA6D;AAC7D,oEAAoE;AACpE,0EAA0E;AAC1E,kDAAkD;AAElD,OAAO,EACL,gBAAgB,EAChB,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,YAAY,GAGb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EACb,eAAe,EACf,GAAG,GAEJ,MAAM,8BAA8B,CAAC;AAEtC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uDAAuD,GAAG,CAAC,CAAC;AAEzE,sEAAsE;AACtE,MAAM,CAAC,MAAM,+CAA+C,GAAG,CAAC,CAAC;AAEjE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,wEA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;;;GAUG;AACH,MAAM,UAAU,iCAAiC,CAC/C,GAAqB;IAErB,OAAO;QACL,4CAA4C,EAAE,cAAc,CAC1D,GAAG,EACH,uDAAuD,CACxD;QACD,qCAAqC,EACnC,+CAA+C,CAAC,GAAG,CAAC;QACtD,iBAAiB,EAAE,cAAc,CAC/B,GAAG,EACH,yBAAyB,CAC1B;QACD,UAAU,EAAE,kBAAkB,CAC5B,GAAG,EACH,iBAAiB,EACjB,2BAA2B,CAC5B;QACD,8BAA8B,EAAE,cAAc,CAC5C,GAAG,EACH,uCAAuC,CACxC;QACD,uBAAuB,EAAE,kBAAkB,CACzC,GAAG,EACH,+BAA+B,EAC/B,6BAA6B,CAC9B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -4,27 +4,27 @@ import type { SignatureRespondedEvent } from "./signet-contract-state-reader.ts"
|
|
|
4
4
|
import { type Maybe, type RequestId, type SignBidirectionalEvent } from "./signet-requests.ts";
|
|
5
5
|
/**
|
|
6
6
|
* ABI calldata as a 4-byte selector + 32-byte word slots (Compact:
|
|
7
|
-
* `
|
|
7
|
+
* `EvmCalldata<#maxWords>`). Every stored byte is ABI-READY: the calldata the
|
|
8
8
|
* MPC signs is `selector || words[0..noWords]` VERBATIM (see
|
|
9
9
|
* {@link assembleCalldata}), so words are big-endian broadcast-form ABI words,
|
|
10
10
|
* built in-circuit by Signet.compact's `evmAddressAbiWord` / `numericAbiWord`.
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
12
|
+
export interface EvmCalldata {
|
|
13
13
|
/** The literal first 4 calldata bytes (as broadcast). */
|
|
14
14
|
selector: Uint8Array;
|
|
15
15
|
/** How many leading {@link words} are real (Compact `noWords: Uint<16>`). */
|
|
16
16
|
noWords: bigint;
|
|
17
17
|
/**
|
|
18
|
-
* ABI-ready big-endian 32-byte word slots, stored exactly as broadcast
|
|
19
|
-
*
|
|
18
|
+
* ABI-ready big-endian 32-byte word slots, stored exactly as broadcast.
|
|
19
|
+
* Capacity is the contract's `#maxWords` (vault: 2).
|
|
20
20
|
*/
|
|
21
21
|
words: Uint8Array[];
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* One EIP-2930 access-list entry (Compact:
|
|
25
|
-
* `
|
|
25
|
+
* `EvmAccessListEntry<#maxStorageKeys>`).
|
|
26
26
|
*/
|
|
27
|
-
export interface
|
|
27
|
+
export interface EvmAccessListEntry {
|
|
28
28
|
/** The pre-declared contract address, 20 display-order bytes. */
|
|
29
29
|
address: Uint8Array;
|
|
30
30
|
/** How many leading {@link storageKeys} are real. */
|
|
@@ -34,53 +34,53 @@ export interface EVMAccessListEntry {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* The EVM transaction to be signed, decomposed into typed fields (Compact:
|
|
37
|
-
* `
|
|
38
|
-
* #maxStorageKeysPerEntry
|
|
37
|
+
* `EvmType2TxParams<#maxCalldataWords, #maxAccessListEntries,
|
|
38
|
+
* #maxStorageKeysPerEntry>`, EIP-1559: https://eips.ethereum.org/EIPS/eip-1559).
|
|
39
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.
|
|
40
|
+
* `bigint`. Vector capacities are each contract's compile-time throttle,
|
|
41
|
+
* and the runtime counts say how many leading slots are real.
|
|
42
42
|
*/
|
|
43
|
-
export interface
|
|
44
|
-
/** Call target (e.g. the ERC20 contract), 20 bytes. */
|
|
45
|
-
to: Uint8Array;
|
|
43
|
+
export interface EvmType2TxParams {
|
|
46
44
|
/** EVM chain id (also expressed in the record's `caip2Id`). */
|
|
47
45
|
chainId: bigint;
|
|
48
46
|
/** Account nonce of the MPC-derived sender address. */
|
|
49
47
|
nonce: bigint;
|
|
50
|
-
/** Gas ceiling for the call. */
|
|
51
|
-
gasLimit: bigint;
|
|
52
|
-
/** Max total fee per gas, wei. */
|
|
53
|
-
maxFeePerGas: bigint;
|
|
54
48
|
/** Max priority fee per gas, wei. */
|
|
55
49
|
maxPriorityFeePerGas: bigint;
|
|
50
|
+
/** Max total fee per gas, wei. */
|
|
51
|
+
maxFeePerGas: bigint;
|
|
52
|
+
/** Gas ceiling for the call. */
|
|
53
|
+
gasLimit: bigint;
|
|
54
|
+
/** Call target (e.g. the ERC20 contract), 20 bytes. */
|
|
55
|
+
to: Uint8Array;
|
|
56
56
|
/** ETH sent with the call, wei. */
|
|
57
57
|
value: bigint;
|
|
58
|
+
/** Call data: `is_some: false` means a plain ETH transfer (`0x` data). */
|
|
59
|
+
calldata: Maybe<EvmCalldata>;
|
|
58
60
|
/** How many leading {@link accessList} entries are real. */
|
|
59
61
|
accessListEntryCount: bigint;
|
|
60
62
|
/** EIP-2930 access list slots (capacity = contract's throttle). */
|
|
61
|
-
accessList:
|
|
62
|
-
/** Call data; `is_some: false` means a plain ETH transfer (`0x` data). */
|
|
63
|
-
calldata: Maybe<EVMCalldata>;
|
|
63
|
+
accessList: EvmAccessListEntry[];
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Descriptor of {@link
|
|
67
|
-
* of instantiating Compact's `
|
|
66
|
+
* Descriptor of {@link EvmCalldata} at one word capacity: the TS analogue
|
|
67
|
+
* of instantiating Compact's `EvmCalldata<#maxWords>`.
|
|
68
68
|
*
|
|
69
69
|
* @param maxWords - The contract's calldata word capacity (the vault uses 2).
|
|
70
70
|
* @returns The calldata descriptor.
|
|
71
71
|
*/
|
|
72
|
-
export declare function evmCalldataDescriptor(maxWords: number): CompactType<
|
|
72
|
+
export declare function evmCalldataDescriptor(maxWords: number): CompactType<EvmCalldata>;
|
|
73
73
|
/**
|
|
74
|
-
* Descriptor of {@link
|
|
75
|
-
* (Compact: `
|
|
74
|
+
* Descriptor of {@link EvmAccessListEntry} at one storage-key capacity
|
|
75
|
+
* (Compact: `EvmAccessListEntry<#maxStorageKeys>`).
|
|
76
76
|
*
|
|
77
77
|
* @param maxStorageKeys - Storage-key capacity per entry.
|
|
78
78
|
* @returns The entry descriptor.
|
|
79
79
|
*/
|
|
80
|
-
export declare function evmAccessListEntryDescriptor(maxStorageKeys: number): CompactType<
|
|
80
|
+
export declare function evmAccessListEntryDescriptor(maxStorageKeys: number): CompactType<EvmAccessListEntry>;
|
|
81
81
|
/**
|
|
82
|
-
* Descriptor of {@link
|
|
83
|
-
* the TS analogue of Compact's `
|
|
82
|
+
* Descriptor of {@link EvmType2TxParams} at one capacity instantiation:
|
|
83
|
+
* the TS analogue of Compact's `EvmType2TxParams<#maxCalldataWords,
|
|
84
84
|
* #maxAccessListEntries, #maxStorageKeysPerEntry>`.
|
|
85
85
|
*
|
|
86
86
|
* @param maxCalldataWords - Calldata word capacity.
|
|
@@ -88,10 +88,10 @@ export declare function evmAccessListEntryDescriptor(maxStorageKeys: number): Co
|
|
|
88
88
|
* @param maxStorageKeysPerEntry - Storage-key capacity per entry.
|
|
89
89
|
* @returns The tx-params descriptor.
|
|
90
90
|
*/
|
|
91
|
-
export declare function evmType2TxParamsDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number): CompactType<
|
|
91
|
+
export declare function evmType2TxParamsDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number): CompactType<EvmType2TxParams>;
|
|
92
92
|
/**
|
|
93
93
|
* Descriptor of {@link SignBidirectionalEvent} at one EVM Type-2 capacity
|
|
94
|
-
* instantiation
|
|
94
|
+
* instantiation: the generic record descriptor
|
|
95
95
|
* (`signBidirectionalEventDescriptorWith`) over
|
|
96
96
|
* {@link evmType2TxParamsDescriptor}.
|
|
97
97
|
*
|
|
@@ -107,15 +107,15 @@ export declare function evmType2TxParamsDescriptor(maxCalldataWords: number, max
|
|
|
107
107
|
export declare function signBidirectionalEventDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent>;
|
|
108
108
|
/**
|
|
109
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
|
|
111
|
-
*
|
|
110
|
+
* record (which commits to every field, the sender address included, and
|
|
111
|
+
* deliberately carries no extra domain tag). TS twin of Signet.compact's
|
|
112
112
|
* `calculateRequestId` circuit (see the deviation note in
|
|
113
113
|
* signet-requests.ts), generic over the capacity instantiation via the
|
|
114
|
-
* record's own array lengths
|
|
114
|
+
* record's own array lengths: pass the record exactly as the ledger stores
|
|
115
115
|
* it, unused slots included and schemas at their declared widths.
|
|
116
116
|
*
|
|
117
117
|
* @param request - The full event record (contract-shaped, all slots).
|
|
118
|
-
* @returns The 32-byte request id
|
|
118
|
+
* @returns The 32-byte request id, the record's ledger map key.
|
|
119
119
|
*/
|
|
120
120
|
export declare function calculateRequestId(request: SignBidirectionalEvent): RequestId;
|
|
121
121
|
/**
|
|
@@ -126,7 +126,8 @@ export declare function calculateRequestId(request: SignBidirectionalEvent): Req
|
|
|
126
126
|
* builders, tests).
|
|
127
127
|
*
|
|
128
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
|
|
129
|
+
* @returns The ABI-ready 32-byte word to store in an {@link EvmCalldata} word.
|
|
130
|
+
* @throws Error if the value is negative or does not fit 32 bytes.
|
|
130
131
|
*/
|
|
131
132
|
export declare function numericAbiWord(value: bigint): Uint8Array;
|
|
132
133
|
/**
|
|
@@ -135,7 +136,7 @@ export declare function numericAbiWord(value: bigint): Uint8Array;
|
|
|
135
136
|
* `evmAddressAbiWord` circuit (lockstep-tested against the compiled circuit).
|
|
136
137
|
*
|
|
137
138
|
* @param address - The 20-byte address in display order.
|
|
138
|
-
* @returns The ABI-ready 32-byte word to store in an {@link
|
|
139
|
+
* @returns The ABI-ready 32-byte word to store in an {@link EvmCalldata} word.
|
|
139
140
|
* @throws Error if the address is not exactly 20 bytes.
|
|
140
141
|
*/
|
|
141
142
|
export declare function evmAddressAbiWord(address: Uint8Array): Uint8Array;
|
|
@@ -145,7 +146,7 @@ export declare function evmAddressAbiWord(address: Uint8Array): Uint8Array;
|
|
|
145
146
|
* (lockstep-tested against the compiled circuit).
|
|
146
147
|
*
|
|
147
148
|
* @param value - The word's Boolean value.
|
|
148
|
-
* @returns The ABI-ready 32-byte word to store in an {@link
|
|
149
|
+
* @returns The ABI-ready 32-byte word to store in an {@link EvmCalldata} word.
|
|
149
150
|
*/
|
|
150
151
|
export declare function boolAbiWord(value: boolean): Uint8Array;
|
|
151
152
|
/**
|
|
@@ -172,21 +173,21 @@ export declare function abiWordToBool(word: Uint8Array): boolean;
|
|
|
172
173
|
/**
|
|
173
174
|
* Assemble the raw calldata a request's words describe:
|
|
174
175
|
* `data = selector || words[0..noWords]`, VERBATIM. Words are stored
|
|
175
|
-
* ABI-ready (see {@link
|
|
176
|
-
* reordered or reinterpreted on the way into the transaction
|
|
176
|
+
* ABI-ready (see {@link EvmCalldata}), so no byte of the stored record is
|
|
177
|
+
* reordered or reinterpreted on the way into the transaction. Slots past
|
|
177
178
|
* `noWords` are unused capacity and are dropped. This is THE implementation
|
|
178
|
-
* of the signer-side assembly documented on `
|
|
179
|
+
* of the signer-side assembly documented on `EvmCalldata` in Signet.compact.
|
|
179
180
|
*
|
|
180
181
|
* @param calldata - The request's calldata field.
|
|
181
182
|
* @returns Hex calldata for the transaction (`"0x"` when absent).
|
|
182
183
|
*/
|
|
183
|
-
export declare function assembleCalldata(calldata: Maybe<
|
|
184
|
+
export declare function assembleCalldata(calldata: Maybe<EvmCalldata>): string;
|
|
184
185
|
/**
|
|
185
186
|
* Rebuild the unsigned EIP-1559 transaction a request record describes,
|
|
186
187
|
* byte-identical to the one the MPC assembles and signs: calldata from the
|
|
187
188
|
* tagged words (see {@link assembleCalldata}), the count-trimmed access
|
|
188
189
|
* list, and the stored envelope fields. This is the canonical
|
|
189
|
-
* request→transaction transform
|
|
190
|
+
* request→transaction transform. Response-side verification
|
|
190
191
|
* (`signature-response-verification.ts`) and the signed-transaction builder
|
|
191
192
|
* below both go through it, so the transaction a client broadcasts is
|
|
192
193
|
* provably the one the MPC put its signature over.
|
|
@@ -196,52 +197,54 @@ export declare function assembleCalldata(calldata: Maybe<EVMCalldata>): string;
|
|
|
196
197
|
* MPC signs).
|
|
197
198
|
* @throws Error if a calldata word carries an unknown kind.
|
|
198
199
|
*/
|
|
199
|
-
export declare function
|
|
200
|
+
export declare function signBidirectionalEventToUnsignedEvmTransaction(request: SignBidirectionalEvent): Transaction;
|
|
200
201
|
/**
|
|
201
202
|
* Decode a response signature record (as posted to the signet contract's
|
|
202
|
-
* signature response log
|
|
203
|
-
*
|
|
204
|
-
*
|
|
203
|
+
* signature response log) into an ethers {@link Signature}. Goes through
|
|
204
|
+
* {@link mpcSignatureToEcdsaSignature}, so this and in-circuit claims decode
|
|
205
|
+
* a post identically:
|
|
206
|
+
* ethers' `r` is the ECDSA scalar (`bigR.x` reduced mod the curve order),
|
|
207
|
+
* not the raw coordinate, and a malformed record is rejected the same way
|
|
208
|
+
* in both paths.
|
|
205
209
|
*
|
|
206
210
|
* @param response - The posted signature record.
|
|
207
211
|
* @returns The ethers signature.
|
|
208
|
-
* @throws Error if the
|
|
212
|
+
* @throws Error if the record is malformed (see {@link mpcSignatureToEcdsaSignature}).
|
|
209
213
|
*/
|
|
210
214
|
export declare function signatureRespondedEventToSignature(response: SignatureRespondedEvent): Signature;
|
|
211
215
|
/**
|
|
212
216
|
* Encode an ECDSA signature as the response record posted to the signet
|
|
213
|
-
* contract
|
|
214
|
-
*
|
|
215
|
-
* carries
|
|
216
|
-
*
|
|
217
|
-
* point on the curve (y² = x³ + 7 over the secp256k1 base field).
|
|
217
|
+
* contract: the inverse of {@link signatureRespondedEventToSignature}, for
|
|
218
|
+
* MPC-side posters (the fakenet signer, tests). An `r || s || v` signature
|
|
219
|
+
* carries only R.x and the parity of R.y, so the full R point the record
|
|
220
|
+
* stores is recovered on-curve (see {@link ecdsaSignatureToMpcSignature}).
|
|
218
221
|
*
|
|
219
222
|
* The parameter is structural (the r/s/yParity subset of an ethers
|
|
220
|
-
* {@link Signature}) so signatures from ANY ethers instance qualify
|
|
223
|
+
* {@link Signature}) so signatures from ANY ethers instance qualify: posters
|
|
221
224
|
* living in other repos resolve their own ethers install, and nominal class
|
|
222
225
|
* typing would reject it.
|
|
223
226
|
*
|
|
224
227
|
* @param signature - The signature to encode (`r`/`s` as 0x hex, `yParity` 0 or 1).
|
|
225
228
|
* @returns The response record, ready to post.
|
|
226
|
-
* @throws Error if `r` is not the x coordinate of a
|
|
229
|
+
* @throws Error if `r` is not the x coordinate of a secp256k1 point.
|
|
227
230
|
*/
|
|
228
231
|
export declare function signatureToSignatureRespondedEvent(signature: Pick<Signature, "r" | "s" | "yParity">): SignatureRespondedEvent;
|
|
229
232
|
/**
|
|
230
233
|
* Assemble the broadcast-ready signed EIP-1559 transaction for a request from
|
|
231
234
|
* its MPC signature response: rebuild the exact unsigned transaction the MPC
|
|
232
|
-
* signed (see {@link
|
|
235
|
+
* signed (see {@link signBidirectionalEventToUnsignedEvmTransaction}) and
|
|
233
236
|
* attach the signature. Does NOT check that the signature recovers to the
|
|
234
|
-
* requester's derived address
|
|
237
|
+
* requester's derived address: the response log is unauthenticated, so
|
|
235
238
|
* verify first with `verifySignatureRespondedEvent`.
|
|
236
239
|
*
|
|
237
240
|
* @param request - The on-ledger request record.
|
|
238
241
|
* @param response - The posted signature record answering it.
|
|
239
|
-
* @returns The signed ethers transaction
|
|
242
|
+
* @returns The signed ethers transaction: `serialized` is the raw payload for
|
|
240
243
|
* `eth_sendRawTransaction`, `hash` its on-chain hash, `from` the recovered
|
|
241
244
|
* sender.
|
|
242
245
|
* @throws Error if the request record is malformed (see
|
|
243
|
-
* {@link
|
|
246
|
+
* {@link signBidirectionalEventToUnsignedEvmTransaction}) or the response
|
|
244
247
|
* is not a decodable signature.
|
|
245
248
|
*/
|
|
246
|
-
export declare function
|
|
249
|
+
export declare function signBidirectionalEventToSignedEvmTransaction(request: SignBidirectionalEvent, response: SignatureRespondedEvent): Transaction;
|
|
247
250
|
//# sourceMappingURL=signet-evtype2tx-requests.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAAc,SAAS,EAAW,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAMjF,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,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,YA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