@sig-net/midnight 0.18.0 → 0.20.0-rc.1

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.
Files changed (85) hide show
  1. package/README.md +42 -2
  2. package/dist/abi-serde.d.ts +32 -30
  3. package/dist/abi-serde.d.ts.map +1 -1
  4. package/dist/abi-serde.js +139 -75
  5. package/dist/abi-serde.js.map +1 -1
  6. package/dist/byte-codecs.d.ts +62 -0
  7. package/dist/byte-codecs.d.ts.map +1 -0
  8. package/dist/byte-codecs.js +116 -0
  9. package/dist/byte-codecs.js.map +1 -0
  10. package/dist/compact-descriptors.d.ts +89 -0
  11. package/dist/compact-descriptors.d.ts.map +1 -0
  12. package/dist/compact-descriptors.js +139 -0
  13. package/dist/compact-descriptors.js.map +1 -0
  14. package/dist/constants.d.ts +18 -43
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +19 -45
  17. package/dist/constants.js.map +1 -1
  18. package/dist/ecdsa-attestation.d.ts +49 -97
  19. package/dist/ecdsa-attestation.d.ts.map +1 -1
  20. package/dist/ecdsa-attestation.js +78 -142
  21. package/dist/ecdsa-attestation.js.map +1 -1
  22. package/dist/epsilon-derivation.d.ts +24 -31
  23. package/dist/epsilon-derivation.d.ts.map +1 -1
  24. package/dist/epsilon-derivation.js +52 -62
  25. package/dist/epsilon-derivation.js.map +1 -1
  26. package/dist/index.d.ts +10 -9
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +17 -8
  29. package/dist/index.js.map +1 -1
  30. package/dist/managed/compiler/contract-info.json +0 -22
  31. package/dist/managed/compiler/contract-manifest.json +8 -8
  32. package/dist/managed/contract/index.d.ts +0 -3
  33. package/dist/managed/contract/index.js +65 -80
  34. package/dist/managed/contract/index.js.map +1 -1
  35. package/dist/raw-contract-state.d.ts +25 -0
  36. package/dist/raw-contract-state.d.ts.map +1 -0
  37. package/dist/raw-contract-state.js +52 -0
  38. package/dist/raw-contract-state.js.map +1 -0
  39. package/dist/signature-requests-state-reader.d.ts +18 -44
  40. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  41. package/dist/signature-requests-state-reader.js +82 -146
  42. package/dist/signature-requests-state-reader.js.map +1 -1
  43. package/dist/signature-response-verification.d.ts +9 -8
  44. package/dist/signature-response-verification.d.ts.map +1 -1
  45. package/dist/signature-response-verification.js +20 -17
  46. package/dist/signature-response-verification.js.map +1 -1
  47. package/dist/signet-contract-events.d.ts +56 -64
  48. package/dist/signet-contract-events.d.ts.map +1 -1
  49. package/dist/signet-contract-events.js +46 -48
  50. package/dist/signet-contract-events.js.map +1 -1
  51. package/dist/signet-evtype2tx-record-decoding.d.ts +18 -0
  52. package/dist/signet-evtype2tx-record-decoding.d.ts.map +1 -0
  53. package/dist/signet-evtype2tx-record-decoding.js +97 -0
  54. package/dist/signet-evtype2tx-record-decoding.js.map +1 -0
  55. package/dist/signet-evtype2tx-requests.d.ts +43 -87
  56. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  57. package/dist/signet-evtype2tx-requests.js +59 -130
  58. package/dist/signet-evtype2tx-requests.js.map +1 -1
  59. package/dist/signet-request-id.d.ts +14 -0
  60. package/dist/signet-request-id.d.ts.map +1 -0
  61. package/dist/signet-request-id.js +27 -0
  62. package/dist/signet-request-id.js.map +1 -0
  63. package/dist/signet-request-response-reader.d.ts +34 -56
  64. package/dist/signet-request-response-reader.d.ts.map +1 -1
  65. package/dist/signet-request-response-reader.js +56 -68
  66. package/dist/signet-request-response-reader.js.map +1 -1
  67. package/dist/signet-requests.d.ts +28 -92
  68. package/dist/signet-requests.d.ts.map +1 -1
  69. package/dist/signet-requests.js +39 -141
  70. package/dist/signet-requests.js.map +1 -1
  71. package/dist/testing.d.ts +3 -0
  72. package/dist/testing.d.ts.map +1 -0
  73. package/dist/testing.js +20 -0
  74. package/dist/testing.js.map +1 -0
  75. package/package.json +13 -4
  76. package/src/Signet.compact +110 -171
  77. package/src/circuits.compact +9 -16
  78. package/dist/signature-state-reading.d.ts +0 -43
  79. package/dist/signature-state-reading.d.ts.map +0 -1
  80. package/dist/signature-state-reading.js +0 -74
  81. package/dist/signature-state-reading.js.map +0 -1
  82. package/dist/signet-request-feed.d.ts +0 -126
  83. package/dist/signet-request-feed.d.ts.map +0 -1
  84. package/dist/signet-request-feed.js +0 -216
  85. package/dist/signet-request-feed.js.map +0 -1
@@ -1,21 +1,18 @@
1
1
  import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
+ import { type ContractAddress } from "./compact-descriptors.ts";
2
3
  import type { EvmType2TxParams } from "./signet-evtype2tx-requests.ts";
4
+ export type { ContractAddress, Maybe } from "./compact-descriptors.ts";
3
5
  /**
4
6
  * 32-byte signet request id (Compact: `new type RequestId = Bytes<32>`).
5
- * Chain-agnostic: downstream consumers treat it as an opaque key. Ids are
6
- * minted by `calculateRequestId` in Signet.compact: the persistent hash of
7
- * the full {@link SignBidirectionalEvent} record (which includes the sender
8
- * contract address, scoping ids per contract).
7
+ * Chain-agnostic opaque key, minted by `calculateRequestId`.
9
8
  */
10
9
  export type RequestId = Uint8Array;
11
10
  /**
12
- * A Midnight contract address as the generated code represents it in struct
13
- * fields (Compact `ContractAddress`): a single-field wrapper around the raw
14
- * 32 address bytes.
11
+ * Descriptor of a request id ledger key (Compact `RequestId`, a nominal
12
+ * `Bytes<32>`): encodes a {@link RequestId} to the stored aligned form and
13
+ * back.
15
14
  */
16
- export interface ContractAddress {
17
- bytes: Uint8Array;
18
- }
15
+ export declare const requestIdType: CompactType<RequestId>;
19
16
  /**
20
17
  * Which transaction-param decomposition a request carries (Compact:
21
18
  * `enum TxParamType`), as the generated code represents enums: a `number`
@@ -26,9 +23,9 @@ export declare const TxParamType: {
26
23
  /** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
27
24
  readonly evmType2: 0;
28
25
  /**
29
- * Never emitted: mirrors the Compact-side padding variant that keeps the
30
- * enum at >= 2 variants (a 1-variant enum is a zero-byte value the proof
31
- * server cannot parse inside persistentHash preimages).
26
+ * Never emitted: the Compact-side padding variant that keeps the enum at
27
+ * >= 2 variants (a 1-variant enum is a zero-byte value the proof server
28
+ * cannot parse inside persistentHash preimages).
32
29
  */
33
30
  readonly reserved: 1;
34
31
  };
@@ -52,26 +49,13 @@ export declare const MPCDestination: {
52
49
  /** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
53
50
  readonly reserved: 1;
54
51
  };
55
- /**
56
- * Compact's standard-library `Maybe<T>` as the compiler generates it: a
57
- * plain struct. Even when `is_some` is false, `value` carries a full
58
- * default-valued `T` (so vector capacities remain inferable).
59
- */
60
- export interface Maybe<T> {
61
- is_some: boolean;
62
- value: T;
63
- }
64
52
  /**
65
53
  * Canonical signet request record (Compact:
66
54
  * `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
67
55
  * #LenRespondSerialization>`), stored per {@link RequestId} in a requesting
68
- * contract's `SignBidirectionalEventMap` (at whichever ledger field the
69
- * contract declares it: its notifications name the position). Generic over
70
- * the tx-params decomposition, exactly like the Compact struct. The default
71
- * instantiation is {@link EvmType2TxParams}, the only decomposition so far:
72
- * new tx kinds supply their own type argument alongside their Compact struct.
73
- * The schema fields carry their contract-declared byte widths in their array
74
- * lengths.
56
+ * contract's `SignBidirectionalEventMap`. Generic over the tx-params
57
+ * decomposition, {@link EvmType2TxParams} by default. The schema fields
58
+ * carry their contract-declared byte widths in their array lengths.
75
59
  */
76
60
  export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
77
61
  /** Address of the client contract that stores this event (`kernel.self()`). */
@@ -86,7 +70,7 @@ export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
86
70
  algo: number;
87
71
  /** An {@link MPCDestination} value. */
88
72
  dest: number;
89
- /** Extra MPC parameters, reserved, 64 bytes. */
73
+ /** Extra MPC parameters: 64 opaque bytes, reserved, zero-filled. */
90
74
  params: Uint8Array;
91
75
  /** A {@link TxParamType} value tagging the txParams decomposition. */
92
76
  txParamType: number;
@@ -100,33 +84,10 @@ export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
100
84
  respondSerializationSchema: Uint8Array;
101
85
  }
102
86
  /**
103
- * Build the runtime descriptor of a Compact struct from its per-field
104
- * descriptors: the generic form of the struct descriptor classes the
105
- * compiler generates (field-by-field concatenation of alignments and values).
106
- *
107
- * Field ORDER must match the Compact struct declaration order. Object
108
- * literals preserve insertion order for string keys, so pass fields in
109
- * declaration order.
110
- *
111
- * @param fields - One runtime descriptor per struct field, in declaration order.
112
- * @returns The composed struct descriptor.
113
- */
114
- export declare function compactStructDescriptor<T extends object>(fields: {
115
- readonly [K in keyof T]-?: CompactType<T[K]>;
116
- }): CompactType<T>;
117
- /**
118
- * Descriptor of Compact's standard-library `Maybe<T>`: the compiler
119
- * generates it as the struct `{ is_some: Boolean, value: T }`.
120
- *
121
- * @param inner - Descriptor of the wrapped type.
122
- * @returns The Maybe struct descriptor.
123
- */
124
- export declare function compactMaybeDescriptor<T>(inner: CompactType<T>): CompactType<Maybe<T>>;
125
- /**
87
+
126
88
  * Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
127
89
  * decomposition: the TS analogue of Compact's generic
128
- * `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
129
- * #LenRespondSerialization>`. Each decomposition wraps this with its own
90
+ * `SignBidirectionalEvent`. Each decomposition wraps this with its own
130
91
  * capacity-parameterised convenience (see `signBidirectionalEventDescriptor`
131
92
  * in signet-evtype2tx-requests.ts for the EVM Type-2 one).
132
93
  *
@@ -144,7 +105,10 @@ export declare function signBidirectionalEventDescriptorWith<TxParams>(txParams:
144
105
  * what a contract's `ledger(state).signetRequestsIndex` provides. Structural,
145
106
  * so any contract exposing the index satisfies it.
146
107
  */
147
- export interface SignBidirectionalEventLedgerMap extends Iterable<[RequestId, SignBidirectionalEvent]> {
108
+ export interface SignBidirectionalEventLedgerMap extends Iterable<[
109
+ RequestId,
110
+ SignBidirectionalEvent
111
+ ]> {
148
112
  /** @returns `true` when the index holds no requests. */
149
113
  isEmpty(): boolean;
150
114
  /** @returns Number of requests in the index. */
@@ -164,11 +128,9 @@ export interface SignBidirectionalEventLedgerMap extends Iterable<[RequestId, Si
164
128
  declare const requestIdHexBrand: unique symbol;
165
129
  /**
166
130
  * 64-char lowercase hex rendering of a {@link RequestId}: THE
167
- * representation of a request id everywhere in TypeScript. Raw
168
- * {@link RequestId} bytes appear only at the Compact boundary (state
169
- * readers, compiled-circuit calls). The moment an id crosses that boundary it
170
- * becomes this type. Branded (the TS analogue of Compact's `new type`) so an
171
- * arbitrary string cannot pose as a request id: mint one with
131
+ * representation of a request id everywhere in TypeScript, with raw
132
+ * {@link RequestId} bytes appearing only at the Compact boundary. Branded
133
+ * so an arbitrary string cannot pose as a request id: mint one with
172
134
  * {@link requestIdHex} (from ledger bytes) or {@link parseRequestIdHex}
173
135
  * (from user input), and go back to bytes with {@link requestIdBytes}.
174
136
  */
@@ -178,30 +140,7 @@ export type RequestIdHex = string & {
178
140
  /** Plain-JS index parsed out of the ledger, keyed by hex request id. */
179
141
  export type SignBidirectionalEventIndex = Map<RequestIdHex, SignBidirectionalEvent>;
180
142
  /**
181
- * Render bytes as a lowercase hex string, no `0x` prefix.
182
- *
183
- * @param bytes - The bytes to render.
184
- * @returns Lowercase hex, two chars per byte.
185
- */
186
- export declare function bytesToHex(bytes: Uint8Array): string;
187
- /**
188
- * Strip an optional `0x`/`0X` prefix from a hex string.
189
- *
190
- * @param hex - A hex string, with or without a `0x` prefix.
191
- * @returns The bare hex digits.
192
- */
193
- export declare function stripHexPrefix(hex: string): string;
194
- /**
195
- * Decode a hex string into bytes: the inverse of {@link bytesToHex}.
196
- *
197
- * @param hex - Hex digits, with or without a `0x` prefix.
198
- * @returns The decoded bytes.
199
- */
200
- export declare function hexToBytes(hex: string): Uint8Array;
201
- /**
202
- * Render a request id in its canonical TS form (see
203
- * {@link RequestIdHex}), also usable as a JS `Map` key, which raw
204
- * `Uint8Array` ids are not (they compare by reference).
143
+ * Render a request id in its canonical TS form (see {@link RequestIdHex}).
205
144
  *
206
145
  * @param requestId - 32-byte request id.
207
146
  * @returns The branded 64-char lowercase hex string, no `0x` prefix.
@@ -209,12 +148,12 @@ export declare function hexToBytes(hex: string): Uint8Array;
209
148
  export declare function requestIdHex(requestId: RequestId): RequestIdHex;
210
149
  /**
211
150
  * Validate and normalise an untrusted string (CLI argument, config value)
212
- * into a {@link RequestIdHex}: an optional `0x` prefix is stripped and
213
- * the digits lowercased before validation.
151
+ * into a {@link RequestIdHex}: strips an optional `0x` prefix and
152
+ * lowercases.
214
153
  *
215
154
  * @param value - The candidate request id string.
216
155
  * @returns The branded, normalised request id hex.
217
- * @throws Error if the value is not 64 hex chars after normalisation.
156
+ * @throws {Error} If the value is not 64 hex chars after normalisation.
218
157
  */
219
158
  export declare function parseRequestIdHex(value: string): RequestIdHex;
220
159
  /**
@@ -227,9 +166,7 @@ export declare function parseRequestIdHex(value: string): RequestIdHex;
227
166
  export declare function requestIdBytes(id: RequestIdHex): RequestId;
228
167
  /**
229
168
  * Byte width of the path field (Compact `Bytes<32>`): 32 opaque bytes of the
230
- * client contract's choosing. Keys the MPC signs with are derived from
231
- * (contract address, path), so a contract can only ever reach keys scoped to
232
- * itself.
169
+ * client contract's choosing.
233
170
  */
234
171
  export declare const PATH_BYTES = 32;
235
172
  /**
@@ -242,5 +179,4 @@ export declare const PATH_BYTES = 32;
242
179
  * @returns A new `Map` from {@link requestIdHex} key to request record.
243
180
  */
244
181
  export declare function toSignBidirectionalEventIndex(ledgerIndex: Iterable<[RequestId, SignBidirectionalEvent]>): SignBidirectionalEventIndex;
245
- export {};
246
182
  //# sourceMappingURL=signet-requests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAqBA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAg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E,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"}
@@ -1,24 +1,22 @@
1
1
  // TypeScript twins of the CHAIN-AGNOSTIC request-side structs in the Compact
2
2
  // library `Signet.compact` (same directory): the request record, its enums,
3
3
  // request ids, and the runtime-descriptor toolkit shared by every tx-params
4
- // decomposition. Everything specific to the EVM Type-2 decomposition (the
5
- // only decomposition so far) lives in `signet-evtype2tx-requests.ts`.
4
+ // decomposition. Everything specific to the EVM Type-2 decomposition lives
5
+ // in `signet-evtype2tx-requests.ts`.
6
6
  //
7
- // The shapes MUST stay in lockstep with the Compact structs: the
8
- // compiler inlines struct types anonymously into each contract's generated
9
- // managed/contract/index.d.ts, and these named types match them structurally,
10
- // so ledger reads assign to them without casts.
11
- //
12
- // The lockstep is enforced by each consuming contract's simulator tests: the
13
- // "test-caller-contract ledger shape" test in packages/test-caller-contract/tests/
14
- // contract.test.ts assigns the generated `ledger().signBidirectionalEventMap`
15
- // to the named SignBidirectionalEventLedgerMap type: the assignment itself is
16
- // the assertion, so any structural drift between the generated managed types
17
- // and these twins fails that package's `yarn build` / `yarn test`.
18
- //
19
- // Read more: the module header in Signet.compact (key derivation, event
20
- // flow) and this package's README ("Sign bidirectional flow").
21
- import { CompactTypeBoolean, CompactTypeBytes, CompactTypeEnum, CompactTypeUnsignedInteger, } from "@midnight-ntwrk/compact-runtime";
7
+ // The shapes MUST stay structurally in lockstep with the Compact structs,
8
+ // field by field in declaration order. Enforced by each consuming contract's
9
+ // simulator tests (the "ledger shape" test in
10
+ // packages/test-caller-contract/tests/contract.test.ts).
11
+ import { CompactTypeBytes, CompactTypeEnum, } from "@midnight-ntwrk/compact-runtime";
12
+ import { bytesToHex, hexToBytes } from "./byte-codecs.js";
13
+ import { BYTES_32, BYTES_64, compactStructDescriptor, CONTRACT_ADDRESS, UINT_8, UINT_64, } from "./compact-descriptors.js";
14
+ /**
15
+ * Descriptor of a request id ledger key (Compact `RequestId`, a nominal
16
+ * `Bytes<32>`): encodes a {@link RequestId} to the stored aligned form and
17
+ * back.
18
+ */
19
+ export const requestIdType = BYTES_32;
22
20
  /**
23
21
  * Which transaction-param decomposition a request carries (Compact:
24
22
  * `enum TxParamType`), as the generated code represents enums: a `number`
@@ -29,9 +27,9 @@ export const TxParamType = {
29
27
  /** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
30
28
  evmType2: 0,
31
29
  /**
32
- * Never emitted: mirrors the Compact-side padding variant that keeps the
33
- * enum at >= 2 variants (a 1-variant enum is a zero-byte value the proof
34
- * server cannot parse inside persistentHash preimages).
30
+ * Never emitted: the Compact-side padding variant that keeps the enum at
31
+ * >= 2 variants (a 1-variant enum is a zero-byte value the proof server
32
+ * cannot parse inside persistentHash preimages).
35
33
  */
36
34
  reserved: 1,
37
35
  };
@@ -59,88 +57,28 @@ export const MPCDestination = {
59
57
  //
60
58
  // DEVIATION from the "pure circuits are compiled, never re-written in TS"
61
59
  // rule (see circuits.compact): the request-id circuit is generic over the
62
- // tx-params type and schema lengths, the Compact compiler cannot export
63
- // type-parameterised circuits from the top level, and a compiled copy would
64
- // have to be monomorphised at ONE capacity instantiation: a client
65
- // contract's choice that never belongs in this client-agnostic package. So
66
- // the record descriptor (and the per-decomposition `calculateRequestId`
67
- // built on it, see signet-evtype2tx-requests.ts) alone gets a TS twin here.
68
- //
69
- // Ids still come from the very `persistentHash` runtime builtin that
70
- // compiled circuits call, over runtime type descriptors mirroring the ones
71
- // the compiler generates (compare `_calculateRequestId_0` in any consuming
72
- // contract's managed/contract/index.js). What must stay in lockstep with
73
- // Signet.compact is exactly what this file already keeps in lockstep: the
74
- // struct shapes, field by field, in declaration order. Enforced by test-caller-contract's
60
+ // tx-params type and schema lengths, and the Compact compiler cannot export
61
+ // type-parameterised circuits from the top level, so the record descriptor
62
+ // (and `calculateRequestId` built on it, see signet-request-id.ts) gets a TS
63
+ // twin here. Ids come from the same
64
+ // `keccak256` runtime builtin compiled circuits call. Lockstep with
65
+ // Signet.compact is enforced by test-caller-contract's
75
66
  // "submitSignatureRequest round-trip" test, which asserts the id computed
76
- // here equals the ledger map key minted by the REAL compiled contract.
77
- // Runtime descriptors of the Compact base types the generic record fields
78
- // use. CompactTypeUnsignedInteger takes (maxValue, byte length), the same
79
- // literals the compiler emits for Uint<8/64>. CompactTypeEnum takes
80
- // (variantCount - 1, byte length). NOTE: a 1-variant enum would compile to
81
- // `CompactTypeEnum(0, 0)`, zero bytes, which the proof server cannot parse
82
- // inside persistentHash preimages. Every enum therefore carries a padding
83
- // `reserved` variant so it stays at (1, 1).
84
- const BYTES_32 = new CompactTypeBytes(32);
85
- const BYTES_64 = new CompactTypeBytes(64);
86
- const UINT_8 = new CompactTypeUnsignedInteger(2n ** 8n - 1n, 1);
87
- const UINT_64 = new CompactTypeUnsignedInteger(2n ** 64n - 1n, 8);
67
+ // here equals the ledger map key minted by the compiled contract.
68
+ // Runtime descriptors of the signet enums, at the literals the compiler
69
+ // emits. NOTE: a 1-variant enum would compile to `CompactTypeEnum(0, 0)`,
70
+ // zero bytes, which the proof server cannot parse inside persistentHash
71
+ // preimages. Every enum therefore carries a padding `reserved` variant so it
72
+ // stays at (1, 1). The Compact-generic base descriptors live in
73
+ // compact-descriptors.ts.
88
74
  const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
89
75
  const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
90
76
  const MPC_DESTINATION = new CompactTypeEnum(1, 1);
91
77
  /**
92
- * Descriptor of a Compact `ContractAddress` struct field, exactly as the
93
- * compiler generates it: a single-field `{ bytes: Bytes<32> }` wrapper.
94
- */
95
- const CONTRACT_ADDRESS = {
96
- alignment: () => BYTES_32.alignment(),
97
- fromValue: (value) => ({ bytes: BYTES_32.fromValue(value) }),
98
- toValue: (value) => BYTES_32.toValue(value.bytes),
99
- };
100
- /**
101
- * Build the runtime descriptor of a Compact struct from its per-field
102
- * descriptors: the generic form of the struct descriptor classes the
103
- * compiler generates (field-by-field concatenation of alignments and values).
104
- *
105
- * Field ORDER must match the Compact struct declaration order. Object
106
- * literals preserve insertion order for string keys, so pass fields in
107
- * declaration order.
108
- *
109
- * @param fields - One runtime descriptor per struct field, in declaration order.
110
- * @returns The composed struct descriptor.
111
- */
112
- export function compactStructDescriptor(fields) {
113
- const entries = Object.entries(fields);
114
- return {
115
- alignment: () => entries.flatMap(([, type]) => type.alignment()),
116
- toValue: (value) => entries.flatMap(([key, type]) => type.toValue(value[key])),
117
- fromValue: (value) => {
118
- const result = {};
119
- for (const [key, type] of entries) {
120
- result[key] = type.fromValue(value);
121
- }
122
- return result;
123
- },
124
- };
125
- }
126
- /**
127
- * Descriptor of Compact's standard-library `Maybe<T>`: the compiler
128
- * generates it as the struct `{ is_some: Boolean, value: T }`.
129
- *
130
- * @param inner - Descriptor of the wrapped type.
131
- * @returns The Maybe struct descriptor.
132
- */
133
- export function compactMaybeDescriptor(inner) {
134
- return compactStructDescriptor({
135
- is_some: CompactTypeBoolean,
136
- value: inner,
137
- });
138
- }
139
- /**
78
+
140
79
  * Descriptor of {@link SignBidirectionalEvent} over ANY tx-params
141
80
  * decomposition: the TS analogue of Compact's generic
142
- * `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
143
- * #LenRespondSerialization>`. Each decomposition wraps this with its own
81
+ * `SignBidirectionalEvent`. Each decomposition wraps this with its own
144
82
  * capacity-parameterised convenience (see `signBidirectionalEventDescriptor`
145
83
  * in signet-evtype2tx-requests.ts for the EVM Type-2 one).
146
84
  *
@@ -169,41 +107,7 @@ export function signBidirectionalEventDescriptorWith(txParams, lenOutputDeserial
169
107
  });
170
108
  }
171
109
  /**
172
- * Render bytes as a lowercase hex string, no `0x` prefix.
173
- *
174
- * @param bytes - The bytes to render.
175
- * @returns Lowercase hex, two chars per byte.
176
- */
177
- export function bytesToHex(bytes) {
178
- return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
179
- }
180
- /**
181
- * Strip an optional `0x`/`0X` prefix from a hex string.
182
- *
183
- * @param hex - A hex string, with or without a `0x` prefix.
184
- * @returns The bare hex digits.
185
- */
186
- export function stripHexPrefix(hex) {
187
- return hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
188
- }
189
- /**
190
- * Decode a hex string into bytes: the inverse of {@link bytesToHex}.
191
- *
192
- * @param hex - Hex digits, with or without a `0x` prefix.
193
- * @returns The decoded bytes.
194
- */
195
- export function hexToBytes(hex) {
196
- const digits = stripHexPrefix(hex);
197
- const out = new Uint8Array(digits.length >> 1);
198
- for (let i = 0; i < out.length; i++) {
199
- out[i] = Number.parseInt(digits.slice(2 * i, 2 * i + 2), 16);
200
- }
201
- return out;
202
- }
203
- /**
204
- * Render a request id in its canonical TS form (see
205
- * {@link RequestIdHex}), also usable as a JS `Map` key, which raw
206
- * `Uint8Array` ids are not (they compare by reference).
110
+ * Render a request id in its canonical TS form (see {@link RequestIdHex}).
207
111
  *
208
112
  * @param requestId - 32-byte request id.
209
113
  * @returns The branded 64-char lowercase hex string, no `0x` prefix.
@@ -213,12 +117,12 @@ export function requestIdHex(requestId) {
213
117
  }
214
118
  /**
215
119
  * Validate and normalise an untrusted string (CLI argument, config value)
216
- * into a {@link RequestIdHex}: an optional `0x` prefix is stripped and
217
- * the digits lowercased before validation.
120
+ * into a {@link RequestIdHex}: strips an optional `0x` prefix and
121
+ * lowercases.
218
122
  *
219
123
  * @param value - The candidate request id string.
220
124
  * @returns The branded, normalised request id hex.
221
- * @throws Error if the value is not 64 hex chars after normalisation.
125
+ * @throws {Error} If the value is not 64 hex chars after normalisation.
222
126
  */
223
127
  export function parseRequestIdHex(value) {
224
128
  const hex = value.replace(/^0x/i, "").toLowerCase();
@@ -235,17 +139,11 @@ export function parseRequestIdHex(value) {
235
139
  * @returns The 32-byte request id.
236
140
  */
237
141
  export function requestIdBytes(id) {
238
- const bytes = new Uint8Array(32);
239
- for (let i = 0; i < 32; i++) {
240
- bytes[i] = Number.parseInt(id.slice(2 * i, 2 * i + 2), 16);
241
- }
242
- return bytes;
142
+ return hexToBytes(id);
243
143
  }
244
144
  /**
245
145
  * Byte width of the path field (Compact `Bytes<32>`): 32 opaque bytes of the
246
- * client contract's choosing. Keys the MPC signs with are derived from
247
- * (contract address, path), so a contract can only ever reach keys scoped to
248
- * itself.
146
+ * client contract's choosing.
249
147
  */
250
148
  export const PATH_BYTES = 32;
251
149
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,sEAAsE;AACtE,EAAE;AACF,iEAAiE;AACjE,2EAA2E;AAC3E,8EAA8E;AAC9E,gDAAgD;AAChD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a;QAC1B,QAAQ;QACR,OAAO,EAAE,QAAQ;QACjB,2BAA2B,EAAE,IAAI,gBAAgB,CAAC,wBAAwB,CAAC;QAC3E,0BAA0B,EAAE,IAAI,gBAAgB,CAAC,uBAAuB,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC;AA4CD;;;;;GAKG;AACH,MAAM,UAAU,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"}
@@ -0,0 +1,3 @@
1
+ export { calculateSignetAttestationDigest, type EcdsaSignature, ecdsaSignatureToMpcSignature, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.ts";
2
+ export { deriveMidnightResponseSecretKey } from "./epsilon-derivation.ts";
3
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,gCAAgC,EAChC,KAAK,cAAc,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,20 @@
1
+ // Test-fixture surface of @sig-net/midnight (the `@sig-net/midnight/testing`
2
+ // entry point): mint a REAL respond-bidirectional attestation with a
3
+ // throwaway secret key, so a claim circuit can be unit tested in-process
4
+ // against the same record shape the MPC posts. Runtime integrations verify
5
+ // posts (root entry: `verifyRespondBidirectionalSignature`,
6
+ // `SignetRequestResponseReader`) and never sign. The fakenet responder, the
7
+ // MPC's test double, posts through these same helpers, which keeps its bytes
8
+ // pinned to this package's decoders.
9
+ //
10
+ // The canonical fixture chain:
11
+ // ecdsaSignatureToMpcSignature(
12
+ // signAttestationDigest(
13
+ // calculateSignetAttestationDigest(requestId, serializedOutput),
14
+ // secretKey,
15
+ // ),
16
+ // )
17
+ // verifies in-circuit against secp256k1PublicKeyOf(secretKey).
18
+ export { calculateSignetAttestationDigest, ecdsaSignatureToMpcSignature, secp256k1PublicKeyOf, signAttestationDigest, signatureToSignatureRespondedEvent, } from "./ecdsa-attestation.js";
19
+ export { deriveMidnightResponseSecretKey } from "./epsilon-derivation.js";
20
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +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,+BAA+B;AAC/B,kCAAkC;AAClC,6BAA6B;AAC7B,uEAAuE;AACvE,mBAAmB;AACnB,SAAS;AACT,MAAM;AACN,+DAA+D;AAE/D,OAAO,EACL,gCAAgC,EAEhC,4BAA4B,EAC5B,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.18.0",
3
+ "version": "0.20.0-rc.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sig-net/midnight-integration",
@@ -13,6 +13,10 @@
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
+ },
17
+ "./testing": {
18
+ "types": "./dist/testing.d.ts",
19
+ "default": "./dist/testing.js"
16
20
  }
17
21
  },
18
22
  "files": [
@@ -33,19 +37,24 @@
33
37
  ".": {
34
38
  "types": "./dist/index.d.ts",
35
39
  "default": "./dist/index.js"
40
+ },
41
+ "./testing": {
42
+ "types": "./dist/testing.d.ts",
43
+ "default": "./dist/testing.js"
36
44
  }
37
45
  }
38
46
  },
39
47
  "dependencies": {
40
48
  "@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
41
- "@midnight-ntwrk/midnight-js-types": "5.0.0-beta.4",
49
+ "@midnight-ntwrk/midnight-js-types": "5.0.0-beta.6",
42
50
  "@noble/curves": "^2.2.0",
43
- "@sig-net/midnight-serde": "^0.18.0",
51
+ "@sig-net/midnight-serde": "^0.20.0-rc.1",
44
52
  "ethers": "^6.17.0"
45
53
  },
46
54
  "devDependencies": {
47
55
  "@types/node": "^26.1.0",
48
- "typescript": "^6.0.3",
56
+ "@vitest/coverage-v8": "^4.1.10",
57
+ "typescript": "^7.0.2",
49
58
  "vitest": "^4.1.9"
50
59
  },
51
60
  "main": "./dist/index.js",