@sig-net/midnight 0.27.0-rc.2 → 0.27.0-rc.4
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 +5 -4
- package/dist/abi-serde.d.ts +27 -0
- package/dist/abi-serde.d.ts.map +1 -1
- package/dist/abi-serde.js +101 -0
- package/dist/abi-serde.js.map +1 -1
- package/dist/compact-descriptors.d.ts +6 -5
- package/dist/compact-descriptors.d.ts.map +1 -1
- package/dist/compact-descriptors.js +4 -4
- package/dist/compact-descriptors.js.map +1 -1
- package/dist/constants.d.ts +2 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -36
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +2 -1
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +4 -1
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/epsilon-derivation.d.ts +8 -8
- package/dist/epsilon-derivation.js +7 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +444 -0
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +102 -0
- package/dist/managed/contract/index.js +359 -231
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/mpc-output-cache.d.ts +2 -3
- package/dist/mpc-output-cache.d.ts.map +1 -1
- package/dist/mpc-output-cache.js +1 -2
- package/dist/mpc-output-cache.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +16 -10
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +31 -13
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +64 -16
- package/dist/signature-response-verification.d.ts.map +1 -1
- package/dist/signature-response-verification.js +104 -35
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-events.d.ts +1 -1
- package/dist/signet-contract-events.js +1 -1
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-evtype2tx-requests.d.ts +1 -1
- package/dist/signet-evtype2tx-requests.js +1 -1
- package/dist/signet-request-id.js +3 -3
- package/dist/signet-request-id.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +137 -57
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +307 -123
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +9 -5
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +6 -2
- package/dist/signet-requests.js.map +1 -1
- package/dist/signet-tron-record-decoding.d.ts +2 -0
- package/dist/signet-tron-record-decoding.d.ts.map +1 -1
- package/dist/signet-tron-record-decoding.js +2 -0
- package/dist/signet-tron-record-decoding.js.map +1 -1
- package/dist/signet-tron-requests.d.ts +7 -3
- package/dist/signet-tron-requests.d.ts.map +1 -1
- package/dist/signet-tron-requests.js +6 -2
- package/dist/signet-tron-requests.js.map +1 -1
- package/dist/tron-transactions.d.ts +25 -2
- package/dist/tron-transactions.d.ts.map +1 -1
- package/dist/tron-transactions.js +33 -3
- package/dist/tron-transactions.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +12 -10
- package/src/circuits.compact +12 -0
|
@@ -68,7 +68,7 @@ export declare const MPCDestination: {
|
|
|
68
68
|
* schemas and the reserved MPC parameters stay out.
|
|
69
69
|
*/
|
|
70
70
|
export interface RequestIdPreimage {
|
|
71
|
-
/** MPC
|
|
71
|
+
/** MPC signing key version (1). */
|
|
72
72
|
keyVersion: bigint;
|
|
73
73
|
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
74
74
|
sender: ContractAddress;
|
|
@@ -93,7 +93,7 @@ export interface RequestIdPreimage {
|
|
|
93
93
|
* contract-declared byte widths in their array lengths.
|
|
94
94
|
*/
|
|
95
95
|
export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
|
|
96
|
-
/** MPC
|
|
96
|
+
/** MPC signing key version (1). */
|
|
97
97
|
keyVersion: bigint;
|
|
98
98
|
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
99
99
|
sender: ContractAddress;
|
|
@@ -116,18 +116,22 @@ export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
|
|
|
116
116
|
/** Reserved and ignored by the MPC, contract-declared width (zero in the V1 helper). */
|
|
117
117
|
respondSerializationSchema: Uint8Array;
|
|
118
118
|
}
|
|
119
|
-
/** */
|
|
119
|
+
/** A request record of any decomposition this SDK reads: evmType2 or Tron. */
|
|
120
120
|
export type AnySignBidirectionalEvent = SignBidirectionalEvent | SignBidirectionalEvent<TronTxParams>;
|
|
121
121
|
/**
|
|
122
|
+
* Type guard: narrow a request record to the evmType2 decomposition by its tag.
|
|
123
|
+
*
|
|
122
124
|
* @param request - The request record
|
|
123
125
|
* @returns `true` iff the record is tagged {@link TxParamType.evmType2}
|
|
124
126
|
*/
|
|
125
|
-
export declare function
|
|
127
|
+
export declare function isEvmRequest(request: AnySignBidirectionalEvent): request is SignBidirectionalEvent;
|
|
126
128
|
/**
|
|
129
|
+
* Type guard: narrow a request record to the Tron decomposition by its tag.
|
|
130
|
+
*
|
|
127
131
|
* @param request - The request record
|
|
128
132
|
* @returns `true` iff the record is tagged {@link TxParamType.tron}
|
|
129
133
|
*/
|
|
130
|
-
export declare function
|
|
134
|
+
export declare function isTronRequest(request: AnySignBidirectionalEvent): request is SignBidirectionalEvent<TronTxParams>;
|
|
131
135
|
/**
|
|
132
136
|
* Descriptor of {@link RequestIdPreimage}: what {@link calculateRequestId}
|
|
133
137
|
* hashes, in Compact declaration order.
|
|
@@ -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,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,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,yBAAyB,CAAC,CAAC;AAEvF;;;;;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,yBAAyB,CAAC,CAAC,GAC5D,2BAA2B,CAM7B"}
|
package/dist/signet-requests.js
CHANGED
|
@@ -66,17 +66,21 @@ export const MPCDestination = {
|
|
|
66
66
|
reserved: 1,
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
+
* Type guard: narrow a request record to the evmType2 decomposition by its tag.
|
|
70
|
+
*
|
|
69
71
|
* @param request - The request record
|
|
70
72
|
* @returns `true` iff the record is tagged {@link TxParamType.evmType2}
|
|
71
73
|
*/
|
|
72
|
-
export function
|
|
74
|
+
export function isEvmRequest(request) {
|
|
73
75
|
return request.txParamType === TxParamType.evmType2;
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
78
|
+
* Type guard: narrow a request record to the Tron decomposition by its tag.
|
|
79
|
+
*
|
|
76
80
|
* @param request - The request record
|
|
77
81
|
* @returns `true` iff the record is tagged {@link TxParamType.tron}
|
|
78
82
|
*/
|
|
79
|
-
export function
|
|
83
|
+
export function isTronRequest(request) {
|
|
80
84
|
return request.txParamType === TxParamType.tron;
|
|
81
85
|
}
|
|
82
86
|
// ---- Runtime descriptor toolkit (TS twin of the compiled struct codecs) ----
|
|
@@ -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;AAOlC;;;;;;;;;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,sFAAsF;IACtF,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACC,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,4BAA4B;IAC5B,KAAK,EAA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AAM,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"}
|
|
@@ -2,6 +2,8 @@ import type { AlignedValue } from "@midnight-ntwrk/compact-runtime";
|
|
|
2
2
|
import type { SignBidirectionalEvent } from "./signet-requests.ts";
|
|
3
3
|
import { type TronTxParams } from "./signet-tron-requests.ts";
|
|
4
4
|
/**
|
|
5
|
+
* Decode a stored Tron request record cell, reading its schema widths from the cell.
|
|
6
|
+
*
|
|
5
7
|
* @param cell - The record cell as stored (value atoms plus alignment)
|
|
6
8
|
* @param what - Error-message subject
|
|
7
9
|
* @returns The decoded record
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-tron-record-decoding.d.ts","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMpG
|
|
1
|
+
{"version":3,"file":"signet-tron-record-decoding.d.ts","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMpG;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,GACX,sBAAsB,CAAC,YAAY,CAAC,CA0BtC"}
|
|
@@ -4,6 +4,8 @@ const TRON_FIXED_ATOMS = 20;
|
|
|
4
4
|
const TRON_HEAD_ATOMS = 15;
|
|
5
5
|
const TRON_TAIL_ATOMS = 5;
|
|
6
6
|
/**
|
|
7
|
+
* Decode a stored Tron request record cell, reading its schema widths from the cell.
|
|
8
|
+
*
|
|
7
9
|
* @param cell - The record cell as stored (value atoms plus alignment)
|
|
8
10
|
* @param what - Error-message subject
|
|
9
11
|
* @returns The decoded record
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-tron-record-decoding.js","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,oCAAoC,EAAqB,MAAM,2BAA2B,CAAC;AAEpG,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B
|
|
1
|
+
{"version":3,"file":"signet-tron-record-decoding.js","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,oCAAoC,EAAqB,MAAM,2BAA2B,CAAC;AAEpG,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,gCAAgC,CAC9C,IAAkB,EAClB,IAAY;IAEZ,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,gBAAgB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,+BAA+B;YACjE,GAAG,MAAM,CAAC,gBAAgB,CAAC,wBAAwB,CACtD,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oDAAoD,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,wBAAwB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,wBAAwB,KAAK,SAAS,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;QACpF,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,wCAAwC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,aAAa,CAClB,oCAAoC,CAClC,IAAI,GAAG,eAAe,EACtB,wBAAwB,EACxB,uBAAuB,CACxB,EACD,IAAI,CAAC,KAAK,EACV,IAAI,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -2,9 +2,7 @@ import { type CompactType } from "@midnight-ntwrk/compact-runtime";
|
|
|
2
2
|
import { type Maybe } from "./compact-descriptors.ts";
|
|
3
3
|
import { type EvmCalldata } from "./signet-evtype2tx-requests.ts";
|
|
4
4
|
import { type SignBidirectionalEvent } from "./signet-requests.ts";
|
|
5
|
-
/** */
|
|
6
|
-
export declare const TRON_CAIP2_ID = "tron:mainnet";
|
|
7
|
-
/** */
|
|
5
|
+
/** The Tron transaction decomposition of a request (Compact: `TronTxParams`): a TriggerSmartContract call. */
|
|
8
6
|
export interface TronTxParams {
|
|
9
7
|
refBlockBytes: Uint8Array;
|
|
10
8
|
refBlockHash: Uint8Array;
|
|
@@ -16,11 +14,15 @@ export interface TronTxParams {
|
|
|
16
14
|
calldata: Maybe<EvmCalldata>;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
17
|
+
* Runtime descriptor of {@link TronTxParams} at a calldata word capacity.
|
|
18
|
+
*
|
|
19
19
|
* @param maxCalldataWords - Calldata word capacity
|
|
20
20
|
* @returns The tx-params descriptor
|
|
21
21
|
*/
|
|
22
22
|
export declare function tronTxParamsDescriptor(maxCalldataWords: number): CompactType<TronTxParams>;
|
|
23
23
|
/**
|
|
24
|
+
* Runtime descriptor of a Tron request record at the given capacities.
|
|
25
|
+
*
|
|
24
26
|
* @param maxCalldataWords - Calldata word capacity
|
|
25
27
|
* @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
|
|
26
28
|
* @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
|
|
@@ -28,6 +30,8 @@ export declare function tronTxParamsDescriptor(maxCalldataWords: number): Compac
|
|
|
28
30
|
*/
|
|
29
31
|
export declare function tronSignBidirectionalEventDescriptor(maxCalldataWords: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent<TronTxParams>>;
|
|
30
32
|
/**
|
|
33
|
+
* Digest a Tron decomposition over its used calldata words: the TS twin of the `calculateTronTxParamsDigestV1` circuit.
|
|
34
|
+
*
|
|
31
35
|
* @param txParams - The transaction decomposition to digest, at any capacity
|
|
32
36
|
* @returns The 32-byte digest
|
|
33
37
|
* @throws {Error} When the calldata word count exceeds its capacity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-tron-requests.d.ts","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAWL,KAAK,KAAK,EAGX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gCAAgC,CAAC;AACzF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,
|
|
1
|
+
{"version":3,"file":"signet-tron-requests.d.ts","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAWL,KAAK,KAAK,EAGX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gCAAgC,CAAC;AACzF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,8GAA8G;AAC9G,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,CAW1F;AAED;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAClD,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EAAE,MAAM,EAChC,uBAAuB,EAAE,MAAM,GAC9B,WAAW,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAMnD;AA8BD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,YAAY,GAAG,UAAU,CAwB9E"}
|
|
@@ -3,9 +3,9 @@ import { BOOLEAN, BYTES_2, BYTES_4, BYTES_8, BYTES_21, compactMaybeDescriptor, c
|
|
|
3
3
|
import { HashDomain } from "./managed/contract/index.js";
|
|
4
4
|
import { evmCalldataDescriptor } from "./signet-evtype2tx-requests.js";
|
|
5
5
|
import { signBidirectionalEventDescriptorWith, } from "./signet-requests.js";
|
|
6
|
-
/** */
|
|
7
|
-
export const TRON_CAIP2_ID = "tron:mainnet";
|
|
8
6
|
/**
|
|
7
|
+
* Runtime descriptor of {@link TronTxParams} at a calldata word capacity.
|
|
8
|
+
*
|
|
9
9
|
* @param maxCalldataWords - Calldata word capacity
|
|
10
10
|
* @returns The tx-params descriptor
|
|
11
11
|
*/
|
|
@@ -22,6 +22,8 @@ export function tronTxParamsDescriptor(maxCalldataWords) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
+
* Runtime descriptor of a Tron request record at the given capacities.
|
|
26
|
+
*
|
|
25
27
|
* @param maxCalldataWords - Calldata word capacity
|
|
26
28
|
* @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
|
|
27
29
|
* @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
|
|
@@ -44,6 +46,8 @@ const TRON_DIGEST_HEAD = compactTupleDescriptor([
|
|
|
44
46
|
UINT_16,
|
|
45
47
|
]);
|
|
46
48
|
/**
|
|
49
|
+
* Digest a Tron decomposition over its used calldata words: the TS twin of the `calculateTronTxParamsDigestV1` circuit.
|
|
50
|
+
*
|
|
47
51
|
* @param txParams - The transaction decomposition to digest, at any capacity
|
|
48
52
|
* @returns The 32-byte digest
|
|
49
53
|
* @throws {Error} When the calldata word count exceeds its capacity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-tron-requests.js","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EAEX,OAAO,EACP,OAAO,GACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAoB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAEL,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"signet-tron-requests.js","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EAEX,OAAO,EACP,OAAO,GACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAoB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAEL,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;AAc9B;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,gBAAwB;IAC7D,OAAO,uBAAuB,CAAe;QAC3C,aAAa,EAAE,OAAO;QACtB,YAAY,EAAE,OAAO;QACrB,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,OAAO;QACjB,eAAe,EAAE,QAAQ;QACzB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,sBAAsB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oCAAoC,CAClD,gBAAwB,EACxB,wBAAgC,EAChC,uBAA+B;IAE/B,OAAO,oCAAoC,CACzC,sBAAsB,CAAC,gBAAgB,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E,GAAG,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
import { type SignBidirectionalEventKeySelector } from "./epsilon-derivation.ts";
|
|
1
2
|
import type { MpcSignature } from "./signet-contract-events.ts";
|
|
2
3
|
import type { TronTxParams } from "./signet-tron-requests.ts";
|
|
3
4
|
/**
|
|
5
|
+
* Turn a 20-byte EVM address into its 21-byte Tron address.
|
|
6
|
+
*
|
|
4
7
|
* @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
|
|
5
8
|
* @returns The 21-byte Tron address
|
|
6
9
|
* @throws {Error} If the input is not exactly 20 bytes
|
|
7
10
|
*/
|
|
8
11
|
export declare function tronAddressFromEvm(evm: string | Uint8Array): Uint8Array;
|
|
9
12
|
/**
|
|
13
|
+
* Encode a 21-byte Tron address as base58check text.
|
|
14
|
+
*
|
|
10
15
|
* @param address - The 21-byte, `0x41`-prefixed Tron address
|
|
11
16
|
* @returns The base58check text
|
|
12
17
|
* @throws {Error} If the address has the wrong length or prefix
|
|
13
18
|
*/
|
|
14
19
|
export declare function tronAddressToBase58(address: Uint8Array): string;
|
|
15
20
|
/**
|
|
21
|
+
* Decode base58check text into a 21-byte Tron address.
|
|
22
|
+
*
|
|
16
23
|
* @param text - The base58check text (`T…`)
|
|
17
24
|
* @returns The 21-byte Tron address
|
|
18
|
-
* @throws {Error} If the text is not base58, not 25 bytes, fails its checksum
|
|
25
|
+
* @throws {Error} If the text is not base58, not 25 bytes, fails its checksum, does not carry the `0x41` prefix or is not the canonical spelling of its bytes
|
|
19
26
|
*/
|
|
20
27
|
export declare function tronAddressFromBase58(text: string): Uint8Array;
|
|
21
|
-
/** */
|
|
28
|
+
/** A Tron address as its 21 bytes and its base58check text. */
|
|
22
29
|
export interface TronAddress {
|
|
23
30
|
bytes: Uint8Array;
|
|
24
31
|
base58: string;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
34
|
+
* Derive the Tron address the MPC signs from for a contract and path.
|
|
35
|
+
*
|
|
27
36
|
* @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
|
|
28
37
|
* @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
|
|
29
38
|
* @param path - The derivation path string
|
|
@@ -31,6 +40,16 @@ export interface TronAddress {
|
|
|
31
40
|
*/
|
|
32
41
|
export declare function deriveTronAddress(mpcSecp256k1PublicKey: string, contractAddress: string, path: string): TronAddress;
|
|
33
42
|
/**
|
|
43
|
+
* Derive the Tron address the MPC signs a request's transaction from.
|
|
44
|
+
*
|
|
45
|
+
* @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
|
|
46
|
+
* @param request - The on-ledger request record, or its `sender` and `path`
|
|
47
|
+
* @returns The Tron address the MPC signs that request's transaction from, in both forms
|
|
48
|
+
*/
|
|
49
|
+
export declare function deriveSignBidirectionalEventSignerTronAddress(mpcSecp256k1PublicKey: string, request: SignBidirectionalEventKeySelector): TronAddress;
|
|
50
|
+
/**
|
|
51
|
+
* Build the protobuf raw bytes of the TriggerSmartContract transaction a request describes.
|
|
52
|
+
*
|
|
34
53
|
* @param params - The request's transaction parameters
|
|
35
54
|
* @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
|
|
36
55
|
* @returns The raw transaction bytes
|
|
@@ -38,11 +57,15 @@ export declare function deriveTronAddress(mpcSecp256k1PublicKey: string, contrac
|
|
|
38
57
|
*/
|
|
39
58
|
export declare function buildTronRawTransaction(params: TronTxParams, owner: Uint8Array): Uint8Array;
|
|
40
59
|
/**
|
|
60
|
+
* The transaction id (sha256 of the raw bytes): the digest the MPC signs.
|
|
61
|
+
*
|
|
41
62
|
* @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
|
|
42
63
|
* @returns The 32-byte transaction id
|
|
43
64
|
*/
|
|
44
65
|
export declare function tronTransactionId(raw: Uint8Array): Uint8Array;
|
|
45
66
|
/**
|
|
67
|
+
* Attach the MPC signature to raw transaction bytes, giving the protobuf `Transaction` to broadcast.
|
|
68
|
+
*
|
|
46
69
|
* @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
|
|
47
70
|
* @param signature - The signature as the MPC posts it
|
|
48
71
|
* @returns The signed transaction bytes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tron-transactions.d.ts","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tron-transactions.d.ts","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAY9D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAYvE;AAMD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAG/D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAoB9D;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,qBAAqB,EAAE,MAAM,EAC7B,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,WAAW,CAEb;AAED;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC3D,qBAAqB,EAAE,MAAM,EAC7B,OAAO,EAAE,iCAAiC,GACzC,WAAW,CAIb;AAwDD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAkC3F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,GAAG,UAAU,CAW/F"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decodeBase58, encodeBase58, getBytes, sha256, toBeArray } from "ethers";
|
|
2
2
|
import { bigintToBytes32BE, hexToBytes, stripHexPrefix } from "./byte-codecs.js";
|
|
3
3
|
import { mpcSignatureToEcdsaSignature } from "./ecdsa-attestation.js";
|
|
4
|
-
import { deriveEvmAddress } from "./epsilon-derivation.js";
|
|
4
|
+
import { deriveEvmAddress, deriveSignBidirectionalEventSignerEvmAddress, } from "./epsilon-derivation.js";
|
|
5
5
|
import { pureCircuits } from "./managed/contract/index.js";
|
|
6
6
|
const TRON_ADDRESS_PREFIX = 0x41;
|
|
7
7
|
const TRON_ADDRESS_BYTES = 21;
|
|
@@ -11,6 +11,8 @@ function assertTronAddress(address, name) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
+
* Turn a 20-byte EVM address into its 21-byte Tron address.
|
|
15
|
+
*
|
|
14
16
|
* @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
|
|
15
17
|
* @returns The 21-byte Tron address
|
|
16
18
|
* @throws {Error} If the input is not exactly 20 bytes
|
|
@@ -32,6 +34,8 @@ function base58CheckChecksum(address) {
|
|
|
32
34
|
return getBytes(sha256(sha256(address))).slice(0, 4);
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
37
|
+
* Encode a 21-byte Tron address as base58check text.
|
|
38
|
+
*
|
|
35
39
|
* @param address - The 21-byte, `0x41`-prefixed Tron address
|
|
36
40
|
* @returns The base58check text
|
|
37
41
|
* @throws {Error} If the address has the wrong length or prefix
|
|
@@ -41,9 +45,11 @@ export function tronAddressToBase58(address) {
|
|
|
41
45
|
return encodeBase58(Uint8Array.from([...address, ...base58CheckChecksum(address)]));
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
48
|
+
* Decode base58check text into a 21-byte Tron address.
|
|
49
|
+
*
|
|
44
50
|
* @param text - The base58check text (`T…`)
|
|
45
51
|
* @returns The 21-byte Tron address
|
|
46
|
-
* @throws {Error} If the text is not base58, not 25 bytes, fails its checksum
|
|
52
|
+
* @throws {Error} If the text is not base58, not 25 bytes, fails its checksum, does not carry the `0x41` prefix or is not the canonical spelling of its bytes
|
|
47
53
|
*/
|
|
48
54
|
export function tronAddressFromBase58(text) {
|
|
49
55
|
let decoded;
|
|
@@ -62,16 +68,34 @@ export function tronAddressFromBase58(text) {
|
|
|
62
68
|
throw new Error("base58check checksum mismatch");
|
|
63
69
|
}
|
|
64
70
|
assertTronAddress(address, "Tron address");
|
|
71
|
+
if (encodeBase58(decoded) !== text) {
|
|
72
|
+
throw new Error(`not a canonical base58 Tron address: "${text}"`);
|
|
73
|
+
}
|
|
65
74
|
return address;
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
77
|
+
* Derive the Tron address the MPC signs from for a contract and path.
|
|
78
|
+
*
|
|
68
79
|
* @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
|
|
69
80
|
* @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
|
|
70
81
|
* @param path - The derivation path string
|
|
71
82
|
* @returns The derived address in both forms
|
|
72
83
|
*/
|
|
73
84
|
export function deriveTronAddress(mpcSecp256k1PublicKey, contractAddress, path) {
|
|
74
|
-
|
|
85
|
+
return tronAddressOfEvm(deriveEvmAddress(mpcSecp256k1PublicKey, contractAddress, path));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Derive the Tron address the MPC signs a request's transaction from.
|
|
89
|
+
*
|
|
90
|
+
* @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
|
|
91
|
+
* @param request - The on-ledger request record, or its `sender` and `path`
|
|
92
|
+
* @returns The Tron address the MPC signs that request's transaction from, in both forms
|
|
93
|
+
*/
|
|
94
|
+
export function deriveSignBidirectionalEventSignerTronAddress(mpcSecp256k1PublicKey, request) {
|
|
95
|
+
return tronAddressOfEvm(deriveSignBidirectionalEventSignerEvmAddress(mpcSecp256k1PublicKey, request));
|
|
96
|
+
}
|
|
97
|
+
function tronAddressOfEvm(evm) {
|
|
98
|
+
const bytes = tronAddressFromEvm(evm);
|
|
75
99
|
return { bytes, base58: tronAddressToBase58(bytes) };
|
|
76
100
|
}
|
|
77
101
|
const TRIGGER_SMART_CONTRACT_TYPE_URL = "type.googleapis.com/protocol.TriggerSmartContract";
|
|
@@ -113,6 +137,8 @@ function tronCalldata(params) {
|
|
|
113
137
|
return [...selector, ...words.slice(0, Number(noWords)).flatMap((word) => [...word])];
|
|
114
138
|
}
|
|
115
139
|
/**
|
|
140
|
+
* Build the protobuf raw bytes of the TriggerSmartContract transaction a request describes.
|
|
141
|
+
*
|
|
116
142
|
* @param params - The request's transaction parameters
|
|
117
143
|
* @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
|
|
118
144
|
* @returns The raw transaction bytes
|
|
@@ -154,6 +180,8 @@ export function buildTronRawTransaction(params, owner) {
|
|
|
154
180
|
]);
|
|
155
181
|
}
|
|
156
182
|
/**
|
|
183
|
+
* The transaction id (sha256 of the raw bytes): the digest the MPC signs.
|
|
184
|
+
*
|
|
157
185
|
* @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
|
|
158
186
|
* @returns The 32-byte transaction id
|
|
159
187
|
*/
|
|
@@ -161,6 +189,8 @@ export function tronTransactionId(raw) {
|
|
|
161
189
|
return getBytes(sha256(raw));
|
|
162
190
|
}
|
|
163
191
|
/**
|
|
192
|
+
* Attach the MPC signature to raw transaction bytes, giving the protobuf `Transaction` to broadcast.
|
|
193
|
+
*
|
|
164
194
|
* @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
|
|
165
195
|
* @param signature - The signature as the MPC posts it
|
|
166
196
|
* @returns The signed transaction bytes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tron-transactions.js","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"tron-transactions.js","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,4CAA4C,GAE7C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,SAAS,iBAAiB,CAAC,OAAmB,EAAE,IAAY;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,kBAAkB,IAAI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C;QACtC,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;QACrC,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;QACjD,GAAG,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC;QACrC,GAAG,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC;QAChD,GAAG,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAe;IAC/C,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAe,EAAE,SAAuB;IACjF,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;QACrC,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,UAAU;KACX,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,IAAI,CAAC;QACrB,GAAG,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC;QAC/B,GAAG,oBAAoB,CAAC,CAAC,EAAE,cAAc,CAAC;KAC3C,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.27.0-rc.
|
|
3
|
+
"version": "0.27.0-rc.4",
|
|
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.21.0",
|
|
50
50
|
"@midnight-ntwrk/midnight-js-types": "5.0.0",
|
|
51
51
|
"@noble/curves": "^2.2.0",
|
|
52
|
-
"@sig-net/midnight-serde": "^0.27.0-rc.
|
|
52
|
+
"@sig-net/midnight-serde": "^0.27.0-rc.4",
|
|
53
53
|
"ethers": "^6.17.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -93,7 +93,7 @@ module Signet {
|
|
|
93
93
|
|
|
94
94
|
// MPC Key Derivation Parameters.
|
|
95
95
|
// Every key the MPC signs with is scoped by the requesting contract:
|
|
96
|
-
// derivedSigningKey = f(mpcRootKey
|
|
96
|
+
// derivedSigningKey = f(mpcRootKey, keyVersion, caip2ChainId, sender, hex::encode(path))
|
|
97
97
|
// where caip2ChainId is the CAIP-2 id of the ORIGINATING chain (the Midnight
|
|
98
98
|
// variant for requests made from Midnight contracts), not this record's target
|
|
99
99
|
// executionDest. The path is 32 opaque bytes of the client contract's choosing (e.g. a
|
|
@@ -103,7 +103,7 @@ module Signet {
|
|
|
103
103
|
// CRITICAL: the MPC renders the path as hex::encode(path) for key derivation (lowercase hex
|
|
104
104
|
// of the full 32 bytes, no trimming, no 0x prefix). The sender is always part
|
|
105
105
|
// of the derivation, so no contract can reach another contract's derived keys.
|
|
106
|
-
keyVersion: Uint<8>; //
|
|
106
|
+
keyVersion: Uint<8>; // Version of the MPC signing keys. Always 1.
|
|
107
107
|
sender: ContractAddress; // Address of the client contract that stores and notifies of this
|
|
108
108
|
// request. Set with kernel.self().
|
|
109
109
|
path: Bytes<32>; // Key derivation path: 32 opaque bytes, client contract's choice.
|
|
@@ -178,7 +178,8 @@ module Signet {
|
|
|
178
178
|
params: Bytes<64>,
|
|
179
179
|
outputDeserializationSchema: Bytes<LenOutputDeserialization>,
|
|
180
180
|
): SignBidirectionalEventV1<TxParams, LenOutputDeserialization, 0> {
|
|
181
|
-
|
|
181
|
+
// 1 is the latest version the MPC supports, and it drops a request naming any other.
|
|
182
|
+
assert(keyVersion == 1, "keyVersion must be 1");
|
|
182
183
|
assert(signatureDest == MPCDestination.unused, "signatureDest must be unused");
|
|
183
184
|
assert(params == default<Bytes<64>>, "params must be zero");
|
|
184
185
|
// The protocol reserves the "midnight response key" path for the MPC's
|
|
@@ -344,7 +345,7 @@ module Signet {
|
|
|
344
345
|
// mpcResponseKey is derived like request signing keys, with the path set to the
|
|
345
346
|
// fixed "midnight response key" (a protocol string that enters the derivation
|
|
346
347
|
// verbatim, unlike a request's hex-encoded 32 path bytes):
|
|
347
|
-
// mpcResponseKey = f(mpcRootKey
|
|
348
|
+
// mpcResponseKey = f(mpcRootKey, keyVersion, caip2ChainId, sender, "midnight response key")
|
|
348
349
|
//
|
|
349
350
|
// The output travels off chain. The event carries everything the digest is
|
|
350
351
|
// computed from, so its signature checks without the output
|
|
@@ -371,9 +372,9 @@ module Signet {
|
|
|
371
372
|
// calculateAttestedOutputHashV1 of the serialised output, signed into the
|
|
372
373
|
// digest.
|
|
373
374
|
outputHash: Bytes<32>;
|
|
374
|
-
// The attestation digest the signature is over (calculateSignetAttestationDigestV1)
|
|
375
|
-
//
|
|
376
|
-
//
|
|
375
|
+
// The attestation digest the signature is over (calculateSignetAttestationDigestV1).
|
|
376
|
+
// The verifying circuits recompute it from the fields above and refuse an
|
|
377
|
+
// event whose copy differs.
|
|
377
378
|
digest: Bytes<32>;
|
|
378
379
|
// The MPC's ECDSA signature over the attestation digest.
|
|
379
380
|
signature: Signature;
|
|
@@ -420,8 +421,8 @@ module Signet {
|
|
|
420
421
|
|
|
421
422
|
// Verifies a RespondBidirectionalEvent's signature against the MPC response
|
|
422
423
|
// key, without the output: recomputes the digest from the event's request
|
|
423
|
-
// id, block height, output kind, output length and output hash
|
|
424
|
-
// digest field
|
|
424
|
+
// id, block height, output kind, output length and output hash, and
|
|
425
|
+
// requires the event's digest field to equal it. A true result proves the MPC attested this
|
|
425
426
|
// outcome for this request, and an output the event carries only as its
|
|
426
427
|
// length and hash: a client that consumes output bytes checks them against
|
|
427
428
|
// that length and hash with verifyAttestedOutputV1, or verifies with
|
|
@@ -454,7 +455,7 @@ module Signet {
|
|
|
454
455
|
|
|
455
456
|
// secp256k1EcdsaVerify aborts on the identity point, so the key check
|
|
456
457
|
// must short-circuit before it.
|
|
457
|
-
|
|
458
|
+
const signed = mpcResponseKey != default<Secp256k1Point> && secp256k1EcdsaVerify(
|
|
458
459
|
digest,
|
|
459
460
|
Secp256k1EcdsaSignature {
|
|
460
461
|
r: respondBidirectionalEvent.signature.bigR.x as Secp256k1Scalar,
|
|
@@ -462,6 +463,7 @@ module Signet {
|
|
|
462
463
|
},
|
|
463
464
|
mpcResponseKey
|
|
464
465
|
);
|
|
466
|
+
return respondBidirectionalEvent.digest == digest && signed;
|
|
465
467
|
}
|
|
466
468
|
|
|
467
469
|
// Whether serializedOutput is the output an attestation declares: its width
|
package/src/circuits.compact
CHANGED
|
@@ -180,3 +180,15 @@ export pure circuit calculateTronRequestIdV1_2_0(
|
|
|
180
180
|
): RequestId {
|
|
181
181
|
return calculateTronRequestIdV1<2, 0>(request);
|
|
182
182
|
}
|
|
183
|
+
|
|
184
|
+
export pure circuit calculateTronRequestIdV1_1_34(
|
|
185
|
+
request: SignBidirectionalEventV1<TronTxParams<1>, 34, 0>
|
|
186
|
+
): RequestId {
|
|
187
|
+
return calculateTronRequestIdV1<1, 34>(request);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export pure circuit calculateTronRequestIdV1_2_34(
|
|
191
|
+
request: SignBidirectionalEventV1<TronTxParams<2>, 34, 0>
|
|
192
|
+
): RequestId {
|
|
193
|
+
return calculateTronRequestIdV1<2, 34>(request);
|
|
194
|
+
}
|