@sig-net/midnight 0.23.0 → 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 +10 -7
- package/dist/compact-descriptors.d.ts +8 -6
- package/dist/compact-descriptors.d.ts.map +1 -1
- package/dist/compact-descriptors.js +26 -8
- 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 -11
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +45 -12
- 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 +290 -6
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +69 -5
- package/dist/managed/contract/index.js +436 -154
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +6 -13
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +9 -15
- package/dist/signature-requests-state-reader.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 +4 -4
- 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.map +1 -1
- package/dist/signet-request-response-reader.js +5 -6
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +43 -10
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +24 -5
- 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 -39
- package/src/circuits.compact +37 -9
|
@@ -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,14 +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
29
|
* @param serializedOutput - The serialised execution output, exact unpadded bytes.
|
|
31
30
|
* @param mpcResponseKey - The MPC response key the requesting contract pinned.
|
|
32
31
|
* @param posts - The request's posts, in emission order.
|
|
33
32
|
* @returns The first verifying post, or `undefined` when none verifies.
|
|
34
33
|
*/
|
|
35
|
-
function firstVerifiedRespondBidirectionalEvent(
|
|
36
|
-
return posts.find((post) => verifyRespondBidirectionalSignature(
|
|
34
|
+
function firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, posts) {
|
|
35
|
+
return posts.find((post) => verifyRespondBidirectionalSignature(serializedOutput, post, mpcResponseKey));
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* `SignetRequestResponseReader.getVerifiedRespondBidirectionalEvent` over
|
|
@@ -52,7 +51,7 @@ function firstVerifiedRespondBidirectionalEvent(requestId, serializedOutput, mpc
|
|
|
52
51
|
* @returns The first verifying post, or `undefined` when none attests this output.
|
|
53
52
|
*/
|
|
54
53
|
export function findVerifiedRespondBidirectionalEvent(requestId, serializedOutput, mpcResponseKey, events) {
|
|
55
|
-
return firstVerifiedRespondBidirectionalEvent(
|
|
54
|
+
return firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, signetEventRecordsOf(events, SignetEventName.RespondBidirectionalEvent, requestId));
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* Reader over one requester contract / signet contract pair. Construct once
|
|
@@ -272,7 +271,7 @@ export class SignetRequestResponseReader {
|
|
|
272
271
|
* posted yet (poll again) or none attests this output.
|
|
273
272
|
*/
|
|
274
273
|
async getVerifiedRespondBidirectionalEvent(requestId, serializedOutput, mpcResponseKey) {
|
|
275
|
-
return firstVerifiedRespondBidirectionalEvent(
|
|
274
|
+
return firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, await this.getRespondBidirectionalEvents(requestId));
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
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;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,OAA+B;IAC5D,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,sCAAsC,CAC7C,gBAA4B,EAC5B,cAA8B,EAC9B,KAA2C;IAE3C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CACzB,mCAAmC,CAAC,gBAAgB,EAAE,IAAI,EAAE,cAAc,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qCAAqC,CACnD,SAAuB,EACvB,gBAA4B,EAC5B,cAA8B,EAC9B,MAAqC;IAErC,OAAO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ACvB,cAAsB;QAEtB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC1D,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,kCAAkC,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAC9F,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,4CAA4C,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,6BAA6B,CACjC,SAAuB;QAEvB,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,oCAAoC,CACxC,SAAuB,EACvB,gBAA4B,EAC5B,cAA8B;QAE9B,OAAO,sCAAsC,CAC3C,gBAAgB,EAChB,cAAc,EACd,MAAM,IAAI,CAAC,6BAA6B,CAAC,SAAS,CAAC,CACpD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -60,42 +60,75 @@ 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()`). */
|
|
73
98
|
sender: ContractAddress;
|
|
74
|
-
/** Contract-local nonce captured when the request was created. */
|
|
75
|
-
requestNonce: bigint;
|
|
76
99
|
/** MPC root-key version to derive from (>= 1). */
|
|
77
100
|
keyVersion: bigint;
|
|
78
101
|
/** Key-derivation path: 32 opaque bytes of the client contract's choosing. */
|
|
79
102
|
path: Uint8Array;
|
|
80
103
|
/** An {@link MPCSignatureAlgorithm} value. */
|
|
81
104
|
algo: number;
|
|
82
|
-
/** An {@link MPCDestination} value. */
|
|
83
|
-
|
|
105
|
+
/** An {@link MPCDestination} value: the signature destination, reserved. */
|
|
106
|
+
signatureDest: number;
|
|
84
107
|
/** Extra MPC parameters: 64 opaque bytes, reserved, zero-filled. */
|
|
85
108
|
params: Uint8Array;
|
|
86
109
|
/** A {@link TxParamType} value tagging the txParams decomposition. */
|
|
87
110
|
txParamType: number;
|
|
88
111
|
/** The transaction decomposition. */
|
|
89
112
|
txParams: TxParams;
|
|
90
|
-
/**
|
|
91
|
-
|
|
113
|
+
/** Execution destination: the target chain in CAIP-2 form (https://chainagnostic.org/CAIPs/caip-2), zero-padded, 32 bytes. */
|
|
114
|
+
executionDest: Uint8Array;
|
|
92
115
|
/** MPC output_deserialization_schema (destination chain -> MPC), contract-declared width. */
|
|
93
116
|
outputDeserializationSchema: Uint8Array;
|
|
94
117
|
/** MPC respond_serialization_schema (MPC -> Midnight), contract-declared width. */
|
|
95
118
|
respondSerializationSchema: Uint8Array;
|
|
96
119
|
}
|
|
97
120
|
/**
|
|
98
|
-
|
|
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
|
+
/**
|
|
99
132
|
* Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
|
|
100
133
|
* decomposition: the TS analogue of Compact's generic
|
|
101
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,
|
|
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;IACR,0EAA0E;aAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,sCAAsC;aACtC,MAAM,EAAE,CAAC;IACT,0EAA0E;aAC1E,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB,CAAC,QAAQ,GAAG,gBAAgB;IAC5D,+EAA+E;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,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAc/C;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAAgC,SAAQ,QAAQ,CAC/D;IAAC,SAAS;IAAE,sBAAsB;CAAC,CACpC;IACC,wDAAwD;IACxD,OAAO,IAAI,OAAO,CAAC;IACnB,gDAAgD;IAChD,IAAI,IAAI,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;IACtC;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,sBAAsB,CAAC;CACtD;AAED,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAClC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACpC,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,YAAY,GAAG,SAAS,CAE1D;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,GACzD,2BAA2B,CAM7B"}
|
package/dist/signet-requests.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// packages/test-caller-contract/tests/contract.test.ts).
|
|
11
11
|
import { CompactTypeBytes, CompactTypeEnum, } from "@midnight-ntwrk/compact-runtime";
|
|
12
12
|
import { bytesToHex, hexToBytes, stripHexPrefix } from "./byte-codecs.js";
|
|
13
|
-
import { BYTES_32, BYTES_64, compactStructDescriptor, CONTRACT_ADDRESS, UINT_8,
|
|
13
|
+
import { BYTES_32, BYTES_64, compactStructDescriptor, CONTRACT_ADDRESS, UINT_8, } from "./compact-descriptors.js";
|
|
14
14
|
/**
|
|
15
15
|
* Parse a contract address from its hex rendering (optional `0x`/`0X`
|
|
16
16
|
* prefix): the form the deploy flow prints, the environment carries and the
|
|
@@ -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
|
|
@@ -109,15 +129,14 @@ const MPC_DESTINATION = new CompactTypeEnum(1, 1);
|
|
|
109
129
|
export function signBidirectionalEventDescriptorWith(txParams, lenOutputDeserialization, lenRespondSerialization) {
|
|
110
130
|
return compactStructDescriptor({
|
|
111
131
|
sender: CONTRACT_ADDRESS,
|
|
112
|
-
requestNonce: UINT_64,
|
|
113
132
|
keyVersion: UINT_8,
|
|
114
133
|
path: BYTES_32,
|
|
115
134
|
algo: MPC_SIGNATURE_ALGORITHM,
|
|
116
|
-
|
|
135
|
+
signatureDest: MPC_DESTINATION,
|
|
117
136
|
params: BYTES_64,
|
|
118
137
|
txParamType: TX_PARAM_TYPE,
|
|
119
138
|
txParams,
|
|
120
|
-
|
|
139
|
+
executionDest: BYTES_32,
|
|
121
140
|
outputDeserializationSchema: new CompactTypeBytes(lenOutputDeserialization),
|
|
122
141
|
respondSerializationSchema: new CompactTypeBytes(lenRespondSerialization),
|
|
123
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,
|
|
1
|
+
{"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA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AAU,YAAY,CAAC,SAAoB;IAC/C,OAAO,UAAU,CAAC,SAAS,CAAiB,CAAC;AAC/C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,GAAmB,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAgB;IAC7C,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAA0D;IAE1D,MAAM,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;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, 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.
|
|
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.
|
|
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.
|
|
@@ -71,15 +72,12 @@ module Signet {
|
|
|
71
72
|
// Set with kernel.self().
|
|
72
73
|
sender: ContractAddress;
|
|
73
74
|
|
|
74
|
-
// Optional nonce, set by client contracts to make otherwise-identical requests unique.
|
|
75
|
-
requestNonce: Uint<64>;
|
|
76
|
-
|
|
77
75
|
// MPC Key Derivation Parameters.
|
|
78
76
|
// Every key the MPC signs with is scoped by the requesting contract:
|
|
79
77
|
// derivedSigningKey = f(mpcRootKey[keyVersion], caip2ChainId, sender, hex::encode(path))
|
|
80
78
|
// where caip2ChainId is the CAIP-2 id of the ORIGINATING chain (the Midnight
|
|
81
79
|
// variant for requests made from Midnight contracts), not this record's target
|
|
82
|
-
//
|
|
80
|
+
// executionDest. The path is 32 opaque bytes of the client contract's choosing (e.g. a
|
|
83
81
|
// fixed literal for a contract-owned account or a hash of a caller's secret for
|
|
84
82
|
// per-user accounts): no format is enforced, any 32 bytes are valid.
|
|
85
83
|
// CRITICAL: the MPC renders the path as hex::encode(path) for key derivation (lowercase hex
|
|
@@ -89,17 +87,17 @@ module Signet {
|
|
|
89
87
|
path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
|
|
90
88
|
|
|
91
89
|
// MPC Parameters.
|
|
92
|
-
algo: MPCSignatureAlgorithm;
|
|
93
|
-
|
|
94
|
-
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.
|
|
95
93
|
|
|
96
94
|
// Specific destination chain Transaction parameters.
|
|
97
|
-
txParamType: TxParamType;
|
|
98
|
-
txParams: TxParams;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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.
|
|
103
101
|
|
|
104
102
|
// Serialisation Schemas.
|
|
105
103
|
// outputDeserializationSchema tells the MPC how to deserialise the destination chain's
|
|
@@ -136,31 +134,33 @@ module Signet {
|
|
|
136
134
|
// Construction helper for the canonical Signet SignBidirectionalEvent.
|
|
137
135
|
export pure circuit constructSignBidirectionalEvent<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
|
|
138
136
|
sender: ContractAddress,
|
|
139
|
-
requestNonce: Uint<64>,
|
|
140
137
|
keyVersion: Uint<8>,
|
|
141
138
|
path: Bytes<32>,
|
|
142
139
|
algo: MPCSignatureAlgorithm,
|
|
143
|
-
|
|
140
|
+
signatureDest: MPCDestination,
|
|
144
141
|
params: Bytes<64>,
|
|
145
142
|
txParamType: TxParamType,
|
|
146
143
|
txParams: TxParams,
|
|
147
|
-
|
|
144
|
+
executionDest: Bytes<32>,
|
|
148
145
|
outputDeserializationSchema: Bytes<LenOutputDeserialization>,
|
|
149
146
|
respondSerializationSchema: Bytes<LenRespondSerialization>,
|
|
150
147
|
): SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
|
|
151
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");
|
|
152
153
|
|
|
153
154
|
return SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization> {
|
|
154
155
|
sender,
|
|
155
|
-
requestNonce,
|
|
156
156
|
keyVersion,
|
|
157
157
|
path,
|
|
158
158
|
algo,
|
|
159
|
-
|
|
159
|
+
signatureDest,
|
|
160
160
|
params,
|
|
161
161
|
txParamType,
|
|
162
162
|
txParams,
|
|
163
|
-
|
|
163
|
+
executionDest,
|
|
164
164
|
outputDeserializationSchema,
|
|
165
165
|
respondSerializationSchema,
|
|
166
166
|
};
|
|
@@ -168,14 +168,33 @@ module Signet {
|
|
|
168
168
|
|
|
169
169
|
// ---- SignBidirectionalEvent RequestId --------------------------------------------------------------
|
|
170
170
|
|
|
171
|
-
// 32 byte chain agnostic nominal id, calculated as the
|
|
172
|
-
//
|
|
171
|
+
// 32 byte chain agnostic nominal id of a SignBidirectionalEvent, calculated as the
|
|
172
|
+
// transientHash of its RequestIdPreimage (see calculateRequestId).
|
|
173
173
|
export new type RequestId = Bytes<32>;
|
|
174
174
|
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
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.
|
|
179
198
|
//
|
|
180
199
|
// Two properties follow from the field-aligned representation and matter to anyone
|
|
181
200
|
// reasoning about these ids:
|
|
@@ -187,7 +206,16 @@ module Signet {
|
|
|
187
206
|
export pure circuit calculateRequestId<TxParams, #LenOutputDeserialization, #LenRespondSerialization>(
|
|
188
207
|
request: SignBidirectionalEvent<TxParams, LenOutputDeserialization, LenRespondSerialization>
|
|
189
208
|
): RequestId {
|
|
190
|
-
|
|
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;
|
|
191
219
|
}
|
|
192
220
|
|
|
193
221
|
// ---- Client Contract: SignBidirectionalEvent Map ---------------------------------------------------
|
|
@@ -282,6 +310,9 @@ module Signet {
|
|
|
282
310
|
// Posted by the MPC through the Signet singleton for clients to extract and build a
|
|
283
311
|
// signed transaction from.
|
|
284
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;
|
|
285
316
|
// The requested signature over the transaction the request describes.
|
|
286
317
|
signature: Signature;
|
|
287
318
|
}
|
|
@@ -289,7 +320,7 @@ module Signet {
|
|
|
289
320
|
// RespondBidirectionalEvent: the MPC's attestation of a foreign execution, the
|
|
290
321
|
// final step of the sign bidirectional flow.
|
|
291
322
|
//
|
|
292
|
-
// attestationDigest = upgradeFromTransient(transientHash([requestId, serializedOutputLength, serializedOutput]))
|
|
323
|
+
// attestationDigest = upgradeFromTransient(transientHash([requestId, blockHeight, outputKind, serializedOutputLength, serializedOutput]))
|
|
293
324
|
// signature = signSECP256k1(mpcResponseKey, attestationDigest)
|
|
294
325
|
//
|
|
295
326
|
// mpcResponseKey is derived like request signing keys, with the path set to the
|
|
@@ -302,42 +333,79 @@ module Signet {
|
|
|
302
333
|
// distinguishes a genuine post from garbage: the singleton emits every post
|
|
303
334
|
// unverified.
|
|
304
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>;
|
|
305
354
|
// The MPC's ECDSA signature over the attestation digest.
|
|
306
355
|
signature: Signature;
|
|
307
356
|
}
|
|
308
357
|
|
|
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
|
+
|
|
309
367
|
// The 32-byte attestation digest of a remote execution output:
|
|
310
|
-
// attestationDigest = upgradeFromTransient(transientHash([requestId, serializedOutputLength, serializedOutput]))
|
|
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).
|
|
311
372
|
// Off-chain code uses the TypeScript twin:
|
|
312
373
|
// import { calculateSignetAttestationDigest } from "@sig-net/midnight";
|
|
313
374
|
export pure circuit calculateSignetAttestationDigest<#serializedOutputLength>(
|
|
314
375
|
requestId: RequestId,
|
|
376
|
+
blockHeight: Uint<64>,
|
|
377
|
+
outputKind: OutputKind,
|
|
315
378
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
316
379
|
): Bytes<32> {
|
|
317
|
-
return upgradeFromTransient(transientHash<[RequestId, Uint<64>, Bytes<serializedOutputLength>]>([requestId, serializedOutputLength, serializedOutput]));
|
|
380
|
+
return upgradeFromTransient(transientHash<[RequestId, Uint<64>, OutputKind, Uint<64>, Bytes<serializedOutputLength>]>([requestId, blockHeight, outputKind, serializedOutputLength, serializedOutput]));
|
|
318
381
|
}
|
|
319
382
|
|
|
320
383
|
// Verifies a RespondBidirectionalEvent against its execution output and MPC
|
|
321
|
-
// response key: recomputes the attestation digest
|
|
322
|
-
//
|
|
323
|
-
//
|
|
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
|
|
324
388
|
// serializedOutput at its exact unpadded width, and the event record with
|
|
325
389
|
// signature.bigR.x and signature.s byte-reversed into LITTLE-endian: the
|
|
326
390
|
// scalar casts below read little-endian bytes, and the wire/ledger records
|
|
327
391
|
// are big-endian, so the reversal happens off-chain where it costs nothing
|
|
328
392
|
// (the TS SDK's respondBidirectionalEventToCircuitInput does it). A wrong
|
|
329
|
-
// byte order fails verification, never a false accept.
|
|
330
|
-
//
|
|
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
|
|
331
398
|
// circuit rather than returning false, so sift candidate posts off chain
|
|
332
399
|
// first (verifyRespondBidirectionalSignature).
|
|
333
400
|
export pure circuit verifyRespondBidirectionalEvent<#serializedOutputLength>(
|
|
334
|
-
requestId: RequestId,
|
|
335
401
|
serializedOutput: Bytes<serializedOutputLength>,
|
|
336
402
|
respondBidirectionalEvent: RespondBidirectionalEvent,
|
|
337
403
|
mpcResponseKey: Secp256k1Point
|
|
338
404
|
): Boolean {
|
|
339
405
|
const digest = calculateSignetAttestationDigest<serializedOutputLength>(
|
|
340
|
-
requestId,
|
|
406
|
+
respondBidirectionalEvent.requestId,
|
|
407
|
+
respondBidirectionalEvent.blockHeight,
|
|
408
|
+
respondBidirectionalEvent.outputKind,
|
|
341
409
|
serializedOutput,
|
|
342
410
|
);
|
|
343
411
|
|