@sig-net/midnight 0.24.0-rc.1 → 0.24.0-rc.2
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 +11 -8
- package/dist/compact-descriptors.d.ts +8 -6
- package/dist/compact-descriptors.d.ts.map +1 -1
- package/dist/compact-descriptors.js +18 -7
- package/dist/compact-descriptors.js.map +1 -1
- package/dist/constants.d.ts +2 -21
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -24
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +41 -13
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +44 -14
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +258 -9
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +61 -7
- package/dist/managed/contract/index.js +357 -160
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/mpc-output-cache.d.ts +5 -29
- package/dist/mpc-output-cache.d.ts.map +1 -1
- package/dist/mpc-output-cache.js +6 -40
- package/dist/mpc-output-cache.js.map +1 -1
- package/dist/signet-contract-events.d.ts +39 -9
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +79 -29
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-evtype2tx-record-decoding.js +2 -2
- package/dist/signet-evtype2tx-record-decoding.js.map +1 -1
- package/dist/signet-request-id.d.ts +2 -1
- package/dist/signet-request-id.d.ts.map +1 -1
- package/dist/signet-request-id.js +13 -3
- package/dist/signet-request-id.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +2 -4
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +7 -11
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +43 -8
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +23 -3
- package/dist/signet-requests.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -8
- package/dist/testing.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +107 -38
- package/src/circuits.compact +33 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.d.ts","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAuC,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAI5B,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.d.ts","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAuC,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EACL,KAAK,kBAAkB,EAEvB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAI5B,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,sBAAsB,EAAe,M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CAAC,CAMhD;CACF"}
|
|
@@ -9,7 +9,7 @@ import { lookupSignetRequestAt } from "./signature-requests-state-reader.js";
|
|
|
9
9
|
import { recoverSignatureResponseSigner } from "./signature-response-verification.js";
|
|
10
10
|
import { decodeSignetEventNamed, SignetEventName, signetEventRecordsOf, } from "./signet-contract-events.js";
|
|
11
11
|
import { signBidirectionalEventToSignedEvmTransaction, signBidirectionalEventToUnsignedEvmTransaction, } from "./signet-evtype2tx-requests.js";
|
|
12
|
-
import {
|
|
12
|
+
import { TxParamType } from "./signet-requests.js";
|
|
13
13
|
/**
|
|
14
14
|
* Assert a fetched request carries the evmType2 decomposition, the only one
|
|
15
15
|
* the EVM-transaction methods may read `txParams` from.
|
|
@@ -26,15 +26,13 @@ function assertEvmType2Request(request) {
|
|
|
26
26
|
* The first (oldest) of a request's respond-bidirectional posts whose
|
|
27
27
|
* signature verifies over `serializedOutput` against `mpcResponseKey`.
|
|
28
28
|
*
|
|
29
|
-
* @param requestId - The request id the attestation must commit to.
|
|
30
|
-
* @param blockHeight - The destination block height the attestation names.
|
|
31
29
|
* @param serializedOutput - The serialised execution output, exact unpadded bytes.
|
|
32
30
|
* @param mpcResponseKey - The MPC response key the requesting contract pinned.
|
|
33
31
|
* @param posts - The request's posts, in emission order.
|
|
34
32
|
* @returns The first verifying post, or `undefined` when none verifies.
|
|
35
33
|
*/
|
|
36
|
-
function firstVerifiedRespondBidirectionalEvent(
|
|
37
|
-
return posts.find((post) => verifyRespondBidirectionalSignature(
|
|
34
|
+
function firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, posts) {
|
|
35
|
+
return posts.find((post) => verifyRespondBidirectionalSignature(serializedOutput, post, mpcResponseKey));
|
|
38
36
|
}
|
|
39
37
|
/**
|
|
40
38
|
* `SignetRequestResponseReader.getVerifiedRespondBidirectionalEvent` over
|
|
@@ -44,7 +42,6 @@ function firstVerifiedRespondBidirectionalEvent(requestId, blockHeight, serializ
|
|
|
44
42
|
*
|
|
45
43
|
* @param requestId - The request id the posts must declare and the
|
|
46
44
|
* attestation must commit to.
|
|
47
|
-
* @param blockHeight - The destination block height the attestation names.
|
|
48
45
|
* @param serializedOutput - The serialised execution output the attestation
|
|
49
46
|
* must commit to, exact unpadded bytes.
|
|
50
47
|
* @param mpcResponseKey - The MPC response key the requesting contract
|
|
@@ -53,8 +50,8 @@ function firstVerifiedRespondBidirectionalEvent(requestId, blockHeight, serializ
|
|
|
53
50
|
* emission order. Only attestations declaring `requestId` are judged.
|
|
54
51
|
* @returns The first verifying post, or `undefined` when none attests this output.
|
|
55
52
|
*/
|
|
56
|
-
export function findVerifiedRespondBidirectionalEvent(requestId,
|
|
57
|
-
return firstVerifiedRespondBidirectionalEvent(
|
|
53
|
+
export function findVerifiedRespondBidirectionalEvent(requestId, serializedOutput, mpcResponseKey, events) {
|
|
54
|
+
return firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, signetEventRecordsOf(events, SignetEventName.RespondBidirectionalEvent, requestId));
|
|
58
55
|
}
|
|
59
56
|
/**
|
|
60
57
|
* Reader over one requester contract / signet contract pair. Construct once
|
|
@@ -266,7 +263,6 @@ export class SignetRequestResponseReader {
|
|
|
266
263
|
*
|
|
267
264
|
* @param requestId - The request id the posts must declare and the
|
|
268
265
|
* attestation must commit to.
|
|
269
|
-
* @param blockHeight - The destination block height the attestation names.
|
|
270
266
|
* @param serializedOutput - The serialised execution output the attestation
|
|
271
267
|
* must commit to, exact unpadded bytes.
|
|
272
268
|
* @param mpcResponseKey - The MPC response key the requesting contract
|
|
@@ -274,8 +270,8 @@ export class SignetRequestResponseReader {
|
|
|
274
270
|
* @returns The first verifying post, or `undefined` when none has been
|
|
275
271
|
* posted yet (poll again) or none attests this output.
|
|
276
272
|
*/
|
|
277
|
-
async getVerifiedRespondBidirectionalEvent(requestId,
|
|
278
|
-
return firstVerifiedRespondBidirectionalEvent(
|
|
273
|
+
async getVerifiedRespondBidirectionalEvent(requestId, serializedOutput, mpcResponseKey) {
|
|
274
|
+
return firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, await this.getRespondBidirectionalEvents(requestId));
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
277
|
//# sourceMappingURL=signet-request-response-reader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAK1E,OAAO,EAAuB,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAElG,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAEL,sBAAsB,EAGtB,eAAe,EAEf,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAK1E,OAAO,EAAuB,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAElG,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAEL,sBAAsB,EAGtB,eAAe,EAEf,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAkD,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAiEnG;;;;;;GAM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B,EAChB,cAAc,EACd,MAAM,IAAI,CAAC,6BAA6B,CAAC,SAAS,CAAC,CACpD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -60,13 +60,38 @@ export declare const MPCDestination: {
|
|
|
60
60
|
/** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
|
|
61
61
|
readonly reserved: 1;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* The fields of a {@link SignBidirectionalEvent} that mint its
|
|
65
|
+
* {@link RequestId} (Compact: `RequestIdPreimage<TxParams>`): the requesting
|
|
66
|
+
* contract, the signing key, the transaction and its execution destination.
|
|
67
|
+
* The serialisation schemas and the reserved MPC parameters stay out, so two
|
|
68
|
+
* requests for one transaction share an id whatever schemas they declare.
|
|
69
|
+
* Generic over the tx-params decomposition, {@link EvmType2TxParams} by
|
|
70
|
+
* default.
|
|
71
|
+
*/
|
|
72
|
+
export interface RequestIdPreimage<TxParams = EvmType2TxParams> {
|
|
73
|
+
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
74
|
+
sender: ContractAddress;
|
|
75
|
+
/** MPC root-key version to derive from (>= 1). */
|
|
76
|
+
keyVersion: bigint;
|
|
77
|
+
/** Key-derivation path: 32 opaque bytes of the client contract's choosing. */
|
|
78
|
+
path: Uint8Array;
|
|
79
|
+
/** An {@link MPCSignatureAlgorithm} value. */
|
|
80
|
+
algo: number;
|
|
81
|
+
/** A {@link TxParamType} value tagging the txParams decomposition. */
|
|
82
|
+
txParamType: number;
|
|
83
|
+
/** The transaction decomposition. */
|
|
84
|
+
txParams: TxParams;
|
|
85
|
+
/** Execution destination: the target chain in CAIP-2 form (https://chainagnostic.org/CAIPs/caip-2), zero-padded, 32 bytes. */
|
|
86
|
+
executionDest: Uint8Array;
|
|
87
|
+
}
|
|
63
88
|
/**
|
|
64
89
|
* Canonical signet request record (Compact:
|
|
65
90
|
* `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
|
|
66
91
|
* #LenRespondSerialization>`), stored per {@link RequestId} in a requesting
|
|
67
|
-
* contract's `SignBidirectionalEventMap
|
|
68
|
-
*
|
|
69
|
-
*
|
|
92
|
+
* contract's `SignBidirectionalEventMap`, in Compact declaration order. The
|
|
93
|
+
* {@link RequestIdPreimage} fields mint its id; the schema fields carry their
|
|
94
|
+
* contract-declared byte widths in their array lengths.
|
|
70
95
|
*/
|
|
71
96
|
export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
|
|
72
97
|
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
@@ -77,23 +102,33 @@ export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
|
|
|
77
102
|
path: Uint8Array;
|
|
78
103
|
/** An {@link MPCSignatureAlgorithm} value. */
|
|
79
104
|
algo: number;
|
|
80
|
-
/** An {@link MPCDestination} value. */
|
|
81
|
-
|
|
105
|
+
/** An {@link MPCDestination} value: the signature destination, reserved. */
|
|
106
|
+
signatureDest: number;
|
|
82
107
|
/** Extra MPC parameters: 64 opaque bytes, reserved, zero-filled. */
|
|
83
108
|
params: Uint8Array;
|
|
84
109
|
/** A {@link TxParamType} value tagging the txParams decomposition. */
|
|
85
110
|
txParamType: number;
|
|
86
111
|
/** The transaction decomposition. */
|
|
87
112
|
txParams: TxParams;
|
|
88
|
-
/**
|
|
89
|
-
|
|
113
|
+
/** Execution destination: the target chain in CAIP-2 form (https://chainagnostic.org/CAIPs/caip-2), zero-padded, 32 bytes. */
|
|
114
|
+
executionDest: Uint8Array;
|
|
90
115
|
/** MPC output_deserialization_schema (destination chain -> MPC), contract-declared width. */
|
|
91
116
|
outputDeserializationSchema: Uint8Array;
|
|
92
117
|
/** MPC respond_serialization_schema (MPC -> Midnight), contract-declared width. */
|
|
93
118
|
respondSerializationSchema: Uint8Array;
|
|
94
119
|
}
|
|
95
120
|
/**
|
|
96
|
-
|
|
121
|
+
* Descriptor of {@link RequestIdPreimage} over ANY tx-params decomposition:
|
|
122
|
+
* the TS analogue of Compact's generic `RequestIdPreimage`, what
|
|
123
|
+
* `calculateRequestId` (signet-request-id.ts) hashes. Field order is the
|
|
124
|
+
* Compact struct's, a subsequence of {@link signBidirectionalEventDescriptorWith}'s.
|
|
125
|
+
*
|
|
126
|
+
* @param txParams - Descriptor of the tx-params decomposition, already at
|
|
127
|
+
* its capacity instantiation.
|
|
128
|
+
* @returns The preimage descriptor.
|
|
129
|
+
*/
|
|
130
|
+
export declare function requestIdPreimageDescriptorWith<TxParams>(txParams: CompactType<TxParams>): CompactType<RequestIdPreimage<TxParams>>;
|
|
131
|
+
/**
|
|
97
132
|
* Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
|
|
98
133
|
* decomposition: the TS analogue of Compact's generic
|
|
99
134
|
* `SignBidirectionalEvent`. Each decomposition wraps this with its own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAMnE;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,SAAS,CAAY,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB,sFAAsF;aACtF,QAAQ,EAAE,CAAC;IACX;;;;OAIG;aACH,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAChC,4BAA4B;aAC5B,KAAK,EAAE,CAAC;I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,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,GACzD,2BAA2B,CAM7B"}
|
package/dist/signet-requests.js
CHANGED
|
@@ -91,7 +91,27 @@ const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
|
|
|
91
91
|
const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
|
|
92
92
|
const MPC_DESTINATION = new CompactTypeEnum(1, 1);
|
|
93
93
|
/**
|
|
94
|
-
|
|
94
|
+
* Descriptor of {@link RequestIdPreimage} over ANY tx-params decomposition:
|
|
95
|
+
* the TS analogue of Compact's generic `RequestIdPreimage`, what
|
|
96
|
+
* `calculateRequestId` (signet-request-id.ts) hashes. Field order is the
|
|
97
|
+
* Compact struct's, a subsequence of {@link signBidirectionalEventDescriptorWith}'s.
|
|
98
|
+
*
|
|
99
|
+
* @param txParams - Descriptor of the tx-params decomposition, already at
|
|
100
|
+
* its capacity instantiation.
|
|
101
|
+
* @returns The preimage descriptor.
|
|
102
|
+
*/
|
|
103
|
+
export function requestIdPreimageDescriptorWith(txParams) {
|
|
104
|
+
return compactStructDescriptor({
|
|
105
|
+
sender: CONTRACT_ADDRESS,
|
|
106
|
+
keyVersion: UINT_8,
|
|
107
|
+
path: BYTES_32,
|
|
108
|
+
algo: MPC_SIGNATURE_ALGORITHM,
|
|
109
|
+
txParamType: TX_PARAM_TYPE,
|
|
110
|
+
txParams,
|
|
111
|
+
executionDest: BYTES_32,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
95
115
|
* Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
|
|
96
116
|
* decomposition: the TS analogue of Compact's generic
|
|
97
117
|
* `SignBidirectionalEvent`. Each decomposition wraps this with its own
|
|
@@ -112,11 +132,11 @@ export function signBidirectionalEventDescriptorWith(txParams, lenOutputDeserial
|
|
|
112
132
|
keyVersion: UINT_8,
|
|
113
133
|
path: BYTES_32,
|
|
114
134
|
algo: MPC_SIGNATURE_ALGORITHM,
|
|
115
|
-
|
|
135
|
+
signatureDest: MPC_DESTINATION,
|
|
116
136
|
params: BYTES_64,
|
|
117
137
|
txParamType: TX_PARAM_TYPE,
|
|
118
138
|
txParams,
|
|
119
|
-
|
|
139
|
+
executionDest: BYTES_32,
|
|
120
140
|
outputDeserializationSchema: new CompactTypeBytes(lenOutputDeserialization),
|
|
121
141
|
respondSerializationSchema: new CompactTypeBytes(lenRespondSerialization),
|
|
122
142
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8CAA8C;AAC9C,yDAAyD;AAEzD,OAAO,EAEL,gBAAgB,EAChB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,gBAAgB,EAEhB,MAAM,GACP,MAAM,0BAA0B,CAAC;AAMlC;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,2CAA2C,GAAG,GAAG,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;AACvC,CAAC;AAQD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B,QAAQ,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,sFAAs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;QAC/C,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { calculateSignetAttestationDigest, type EcdsaSignature, ecdsaSignatureToMpcSignature, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.ts";
|
|
1
|
+
export { attestRespondBidirectional, calculateSignetAttestationDigest, type EcdsaSignature, ecdsaSignatureToMpcSignature, type RespondBidirectionalAttestation, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.ts";
|
|
2
2
|
export { deriveMidnightResponseSecretKey } from "./epsilon-derivation.ts";
|
|
3
3
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,KAAK,cAAc,EACnB,4BAA4B,EAC5B,KAAK,+BAA+B,EACpC,oBAAoB,EACpB,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/testing.js
CHANGED
|
@@ -7,14 +7,9 @@
|
|
|
7
7
|
// MPC's test double, posts through these same helpers, which keeps its bytes
|
|
8
8
|
// pinned to this package's decoders.
|
|
9
9
|
//
|
|
10
|
-
// The canonical fixture
|
|
11
|
-
//
|
|
12
|
-
// signAttestationDigest(
|
|
13
|
-
// calculateSignetAttestationDigest(requestId, blockHeight, serializedOutput),
|
|
14
|
-
// secretKey,
|
|
15
|
-
// ),
|
|
16
|
-
// )
|
|
10
|
+
// The canonical fixture:
|
|
11
|
+
// attestRespondBidirectional({ requestId, blockHeight, outputKind, serializedOutput }, secretKey)
|
|
17
12
|
// verifies in-circuit against secp256k1PublicKeyOf(secretKey).
|
|
18
|
-
export { calculateSignetAttestationDigest, ecdsaSignatureToMpcSignature, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.js";
|
|
13
|
+
export { attestRespondBidirectional, calculateSignetAttestationDigest, ecdsaSignatureToMpcSignature, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.js";
|
|
19
14
|
export { deriveMidnightResponseSecretKey } from "./epsilon-derivation.js";
|
|
20
15
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qEAAqE;AACrE,yEAAyE;AACzE,2EAA2E;AAC3E,4DAA4D;AAC5D,4EAA4E;AAC5E,6EAA6E;AAC7E,qCAAqC;AACrC,EAAE;AACF
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qEAAqE;AACrE,yEAAyE;AACzE,2EAA2E;AAC3E,4DAA4D;AAC5D,4EAA4E;AAC5E,6EAA6E;AAC7E,qCAAqC;AACrC,EAAE;AACF,yBAAyB;AACzB,oGAAoG;AACpG,+DAA+D;AAE/D,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAEhC,4BAA4B,EAE5B,oBAAoB,EACpB,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.24.0-rc.
|
|
3
|
+
"version": "0.24.0-rc.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
|
|
50
50
|
"@midnight-ntwrk/midnight-js-types": "5.0.0-beta.6",
|
|
51
51
|
"@noble/curves": "^2.2.0",
|
|
52
|
-
"@sig-net/midnight-serde": "^0.24.0-rc.
|
|
52
|
+
"@sig-net/midnight-serde": "^0.24.0-rc.2",
|
|
53
53
|
"ethers": "^6.17.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
//
|
|
20
20
|
// Key types at a glance (each declaration below carries the full contract):
|
|
21
21
|
// - SignBidirectionalEvent: a client contract's structured request for a signature on a transaction.
|
|
22
|
-
// - RequestId: 32-byte id of a request, the transientHash of
|
|
22
|
+
// - RequestId: 32-byte id of a request, the transientHash of its RequestIdPreimage (the record
|
|
23
|
+
// minus the serialisation schemas).
|
|
23
24
|
// - SignBidirectionalEventMap: the RequestId -> SignBidirectionalEvent map a client contract
|
|
24
25
|
// declares in its own ledger for the MPC to read requests from.
|
|
25
26
|
// - SignetSigner: the contract interface client contracts call to notify the Signet singleton.
|
|
@@ -42,8 +43,8 @@
|
|
|
42
43
|
// the requested signing key. Then it broadcasts the signed txn to the destination chain.
|
|
43
44
|
// 4. MPC observes txn execution on destination chain and posts a RespondBidirectionalEvent attestation
|
|
44
45
|
// through the Signet singleton, which emits it as a contract event beside the request id.
|
|
45
|
-
// The client polls its request's posts and takes the first one that verifies over the request id
|
|
46
|
-
// and output. The client obtains the execution output off chain (for EVM: the mined
|
|
46
|
+
// The client polls its request's posts and takes the first one that verifies over the request id,
|
|
47
|
+
// block height, output kind and output. The client obtains the execution output off chain (for EVM: the mined
|
|
47
48
|
// call's return data via debug_traceTransaction, or the exact attested bytes from the
|
|
48
49
|
// MPC's output cache) and hands output plus attestation to its verify circuit. See
|
|
49
50
|
// "Output Recovery" in the repository README.
|
|
@@ -76,7 +77,7 @@ module Signet {
|
|
|
76
77
|
// derivedSigningKey = f(mpcRootKey[keyVersion], caip2ChainId, sender, hex::encode(path))
|
|
77
78
|
// where caip2ChainId is the CAIP-2 id of the ORIGINATING chain (the Midnight
|
|
78
79
|
// variant for requests made from Midnight contracts), not this record's target
|
|
79
|
-
//
|
|
80
|
+
// executionDest. The path is 32 opaque bytes of the client contract's choosing (e.g. a
|
|
80
81
|
// fixed literal for a contract-owned account or a hash of a caller's secret for
|
|
81
82
|
// per-user accounts): no format is enforced, any 32 bytes are valid.
|
|
82
83
|
// CRITICAL: the MPC renders the path as hex::encode(path) for key derivation (lowercase hex
|
|
@@ -86,17 +87,17 @@ module Signet {
|
|
|
86
87
|
path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
|
|
87
88
|
|
|
88
89
|
// MPC Parameters.
|
|
89
|
-
algo: MPCSignatureAlgorithm;
|
|
90
|
-
|
|
91
|
-
params: Bytes<64>;
|
|
90
|
+
algo: MPCSignatureAlgorithm; // Signature algorithm scheme, e.g. ecdsa
|
|
91
|
+
signatureDest: MPCDestination; // Destination field reserved for future use. Set to unused.
|
|
92
|
+
params: Bytes<64>; // Extra MPC parameters reserved for future use. Zero-fill.
|
|
92
93
|
|
|
93
94
|
// Specific destination chain Transaction parameters.
|
|
94
|
-
txParamType: TxParamType;
|
|
95
|
-
txParams: TxParams;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
txParamType: TxParamType; // Off-chain tag indicating what type txParams is set to.
|
|
96
|
+
txParams: TxParams; // The generic transaction-param payload
|
|
97
|
+
executionDest: Bytes<32>; // The MPC's routing key for the target chain, in CAIP-2 form
|
|
98
|
+
// (https://chainagnostic.org/CAIPs/caip-2). An Ethereum target
|
|
99
|
+
// (mainnet, Sepolia or a local anvil) uses ethereumCaip2Id():
|
|
100
|
+
// the network itself is txParams' chainId.
|
|
100
101
|
|
|
101
102
|
// Serialisation Schemas.
|
|
102
103
|
// outputDeserializationSchema tells the MPC how to deserialise the destination chain's
|
|
@@ -136,26 +137,30 @@ module Signet {
|
|
|
136
137
|
keyVersion: Uint<8>,
|
|
137
138
|
path: Bytes<32>,
|
|
138
139
|
algo: MPCSignatureAlgorithm,
|
|
139
|
-
|
|
140
|
+
signatureDest: MPCDestination,
|
|
140
141
|
params: Bytes<64>,
|
|
141
142
|
txParamType: TxParamType,
|
|
142
143
|
txParams: TxParams,
|
|
143
|
-
|
|
144
|
+
executionDest: Bytes<32>,
|
|
144
145
|
outputDeserializationSchema: Bytes<LenOutputDeserialization>,
|
|
145
146
|
respondSerializationSchema: Bytes<LenRespondSerialization>,
|
|
146
147
|
): SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
|
|
147
148
|
assert(keyVersion >= 1, "keyVersion must be >= 1");
|
|
149
|
+
// The protocol reserves the "midnight response key" path for the MPC's
|
|
150
|
+
// attestation key of this contract (see RespondBidirectionalEvent), and the
|
|
151
|
+
// MPC refuses a request that names it.
|
|
152
|
+
assert(path != pad(32, "midnight response key"), "path is reserved for the MPC response key");
|
|
148
153
|
|
|
149
154
|
return SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
|
|
150
155
|
sender,
|
|
151
156
|
keyVersion,
|
|
152
157
|
path,
|
|
153
158
|
algo,
|
|
154
|
-
|
|
159
|
+
signatureDest,
|
|
155
160
|
params,
|
|
156
161
|
txParamType,
|
|
157
162
|
txParams,
|
|
158
|
-
|
|
163
|
+
executionDest,
|
|
159
164
|
outputDeserializationSchema,
|
|
160
165
|
respondSerializationSchema,
|
|
161
166
|
};
|
|
@@ -163,14 +168,33 @@ module Signet {
|
|
|
163
168
|
|
|
164
169
|
// ---- SignBidirectionalEvent RequestId --------------------------------------------------------------
|
|
165
170
|
|
|
166
|
-
// 32 byte chain agnostic nominal id, calculated as the
|
|
167
|
-
//
|
|
171
|
+
// 32 byte chain agnostic nominal id of a SignBidirectionalEvent, calculated as the
|
|
172
|
+
// transientHash of its RequestIdPreimage (see calculateRequestId).
|
|
168
173
|
export new type RequestId = Bytes<32>;
|
|
169
174
|
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
175
|
+
// The fields of a SignBidirectionalEvent that name one execution: the requesting contract,
|
|
176
|
+
// the signing key (version, path, algorithm), the transaction and its execution destination.
|
|
177
|
+
// The serialisation schemas and the reserved MPC parameters (signatureDest, params) stay
|
|
178
|
+
// out, so two requests for one transaction cannot both be outstanding whatever schemas
|
|
179
|
+
// they declare, and the id does not depend on the schemas' declared widths either.
|
|
180
|
+
//
|
|
181
|
+
// KEY: the field order follows SignBidirectionalEvent's and is relied upon for consistent
|
|
182
|
+
// hashing. The TS twin (requestIdPreimageDescriptorWith in signet-requests.ts)
|
|
183
|
+
// mirrors it field by field.
|
|
184
|
+
export struct RequestIdPreimage<TxParams> {
|
|
185
|
+
sender: ContractAddress;
|
|
186
|
+
keyVersion: Uint<8>;
|
|
187
|
+
path: Bytes<32>;
|
|
188
|
+
algo: MPCSignatureAlgorithm;
|
|
189
|
+
txParamType: TxParamType;
|
|
190
|
+
txParams: TxParams;
|
|
191
|
+
executionDest: Bytes<32>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// transientHash (Poseidon over the preimage's field-aligned representation) upgraded
|
|
195
|
+
// to Bytes<32>: the id commits to every preimage field, including the sender, and
|
|
196
|
+
// carries no domain-separation tag. Off-chain twins must reproduce the field-aligned
|
|
197
|
+
// layout exactly.
|
|
174
198
|
//
|
|
175
199
|
// Two properties follow from the field-aligned representation and matter to anyone
|
|
176
200
|
// reasoning about these ids:
|
|
@@ -182,7 +206,16 @@ module Signet {
|
|
|
182
206
|
export pure circuit calculateRequestId<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
|
|
183
207
|
request: SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>
|
|
184
208
|
): RequestId {
|
|
185
|
-
|
|
209
|
+
const preimage = RequestIdPreimage<TxParams> {
|
|
210
|
+
sender: request.sender,
|
|
211
|
+
keyVersion: request.keyVersion,
|
|
212
|
+
path: request.path,
|
|
213
|
+
algo: request.algo,
|
|
214
|
+
txParamType: request.txParamType,
|
|
215
|
+
txParams: request.txParams,
|
|
216
|
+
executionDest: request.executionDest,
|
|
217
|
+
};
|
|
218
|
+
return upgradeFromTransient(transientHash<RequestIdPreimage<TxParams>>(preimage)) as RequestId;
|
|
186
219
|
}
|
|
187
220
|
|
|
188
221
|
// ---- Client Contract: SignBidirectionalEvent Map ---------------------------------------------------
|
|
@@ -277,6 +310,9 @@ module Signet {
|
|
|
277
310
|
// Posted by the MPC through the Signet singleton for clients to extract and build a
|
|
278
311
|
// signed transaction from.
|
|
279
312
|
export struct SignatureRespondedEvent {
|
|
313
|
+
// The request this signature answers. Routing data: the singleton emits it
|
|
314
|
+
// unverified, and a reader proves the signature against the request's own key.
|
|
315
|
+
requestId: RequestId;
|
|
280
316
|
// The requested signature over the transaction the request describes.
|
|
281
317
|
signature: Signature;
|
|
282
318
|
}
|
|
@@ -284,7 +320,7 @@ module Signet {
|
|
|
284
320
|
// RespondBidirectionalEvent: the MPC's attestation of a foreign execution, the
|
|
285
321
|
// final step of the sign bidirectional flow.
|
|
286
322
|
//
|
|
287
|
-
// attestationDigest = upgradeFromTransient(transientHash([requestId, blockHeight, serializedOutputLength, serializedOutput]))
|
|
323
|
+
// attestationDigest = upgradeFromTransient(transientHash([requestId, blockHeight, outputKind, serializedOutputLength, serializedOutput]))
|
|
288
324
|
// signature = signSECP256k1(mpcResponseKey, attestationDigest)
|
|
289
325
|
//
|
|
290
326
|
// mpcResponseKey is derived like request signing keys, with the path set to the
|
|
@@ -297,46 +333,79 @@ module Signet {
|
|
|
297
333
|
// distinguishes a genuine post from garbage: the singleton emits every post
|
|
298
334
|
// unverified.
|
|
299
335
|
export struct RespondBidirectionalEvent {
|
|
336
|
+
// The request this attestation answers. Signed into the digest: a verified
|
|
337
|
+
// post settles exactly the request it names, so a client consumes this id
|
|
338
|
+
// and never one taken from elsewhere.
|
|
339
|
+
requestId: RequestId;
|
|
340
|
+
// Height of the finalised destination block holding the transaction the
|
|
341
|
+
// attestation describes, in the destination chain's own numbering (a slot
|
|
342
|
+
// on Solana). Signed into the digest.
|
|
343
|
+
blockHeight: Uint<64>;
|
|
344
|
+
// The MPC's verdict on the execution, signed into the digest.
|
|
345
|
+
outputKind: OutputKind;
|
|
346
|
+
// Byte width of the serialised output the digest commits to (0 for a failed
|
|
347
|
+
// or unviable execution), so a client holding no output yet knows which
|
|
348
|
+
// width to settle at.
|
|
349
|
+
serializedOutputLength: Uint<64>;
|
|
350
|
+
// The attestation digest the signature is over (calculateSignetAttestationDigest),
|
|
351
|
+
// so a reader holding no output can check the signature. The verifying
|
|
352
|
+
// circuit recomputes it from the output and never reads this copy.
|
|
353
|
+
digest: Bytes<32>;
|
|
300
354
|
// The MPC's ECDSA signature over the attestation digest.
|
|
301
355
|
signature: Signature;
|
|
302
356
|
}
|
|
303
357
|
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
358
|
+
// OutputKind is the MPC's verdict on a request's execution, the kind half of
|
|
359
|
+
// the protocol's outcome (kind, data). The block height the attestation
|
|
360
|
+
// commits to is the finalised destination block that settled the verdict.
|
|
361
|
+
export enum OutputKind {
|
|
362
|
+
executed, // finalised and succeeded: the attested output is the return data, serialised per the respond schema
|
|
363
|
+
failed, // finalised and reverted: the attested output is empty (Bytes<0>)
|
|
364
|
+
unviable, // a finalised transaction carrying other bytes took the nonce: the attested output is empty (Bytes<0>)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// The 32-byte attestation digest of a remote execution output:
|
|
368
|
+
// attestationDigest = upgradeFromTransient(transientHash([requestId, blockHeight, outputKind, serializedOutputLength, serializedOutput]))
|
|
369
|
+
// blockHeight is the height of the finalised destination block holding the
|
|
370
|
+
// transaction the attestation describes, in the destination chain's own
|
|
371
|
+
// numbering (a slot on Solana).
|
|
307
372
|
// Off-chain code uses the TypeScript twin:
|
|
308
373
|
// import { calculateSignetAttestationDigest } from "@sig-net/midnight";
|
|
309
374
|
export pure circuit calculateSignetAttestationDigest<#serializedOutputLength>(
|
|
310
375
|
requestId: RequestId,
|
|
311
376
|
blockHeight: Uint<64>,
|
|
377
|
+
outputKind: OutputKind,
|
|
312
378
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
313
379
|
): Bytes<32> {
|
|
314
|
-
return upgradeFromTransient(transientHash<[RequestId, Uint<64>, Uint<64>, Bytes<serializedOutputLength>]>([requestId, blockHeight, serializedOutputLength, serializedOutput]));
|
|
380
|
+
return upgradeFromTransient(transientHash<[RequestId, Uint<64>, OutputKind, Uint<64>, Bytes<serializedOutputLength>]>([requestId, blockHeight, outputKind, serializedOutputLength, serializedOutput]));
|
|
315
381
|
}
|
|
316
382
|
|
|
317
383
|
// Verifies a RespondBidirectionalEvent against its execution output and MPC
|
|
318
|
-
// response key: recomputes the attestation digest
|
|
319
|
-
//
|
|
320
|
-
//
|
|
384
|
+
// response key: recomputes the attestation digest over the event's block
|
|
385
|
+
// height and output kind and checks the ECDSA signature over it. Client
|
|
386
|
+
// contracts run this before consuming outputs, as the singleton emits
|
|
387
|
+
// responses unverified. The caller supplies
|
|
321
388
|
// serializedOutput at its exact unpadded width, and the event record with
|
|
322
389
|
// signature.bigR.x and signature.s byte-reversed into LITTLE-endian: the
|
|
323
390
|
// scalar casts below read little-endian bytes, and the wire/ledger records
|
|
324
391
|
// are big-endian, so the reversal happens off-chain where it costs nothing
|
|
325
392
|
// (the TS SDK's respondBidirectionalEventToCircuitInput does it). A wrong
|
|
326
|
-
// byte order fails verification, never a false accept.
|
|
327
|
-
//
|
|
393
|
+
// byte order fails verification, never a false accept. Of the event, requestId,
|
|
394
|
+
// blockHeight, outputKind, signature.bigR.x and signature.s enter verification:
|
|
395
|
+
// serializedOutputLength and digest serve off-chain readers. The digest binds
|
|
396
|
+
// the event's requestId, so a client MUST consume that request and no other. An s
|
|
397
|
+
// that reduces to 0 mod the curve order aborts the
|
|
328
398
|
// circuit rather than returning false, so sift candidate posts off chain
|
|
329
399
|
// first (verifyRespondBidirectionalSignature).
|
|
330
400
|
export pure circuit verifyRespondBidirectionalEvent<#serializedOutputLength>(
|
|
331
|
-
requestId: RequestId,
|
|
332
|
-
blockHeight: Uint<64>,
|
|
333
401
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
334
402
|
respondBidirectionalEvent: RespondBidirectionalEvent,
|
|
335
403
|
mpcResponseKey: Secp256k1Point
|
|
336
404
|
): Boolean {
|
|
337
405
|
const digest = calculateSignetAttestationDigest<serializedOutputLength>(
|
|
338
|
-
requestId,
|
|
339
|
-
blockHeight,
|
|
406
|
+
respondBidirectionalEvent.requestId,
|
|
407
|
+
respondBidirectionalEvent.blockHeight,
|
|
408
|
+
respondBidirectionalEvent.outputKind,
|
|
340
409
|
serializedOutput,
|
|
341
410
|
);
|
|
342
411
|
|