@sig-net/midnight 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +133 -48
  2. package/dist/constants.d.ts +55 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +85 -5
  5. package/dist/constants.js.map +1 -1
  6. package/dist/ecdsa-attestation.d.ts +6 -5
  7. package/dist/ecdsa-attestation.d.ts.map +1 -1
  8. package/dist/ecdsa-attestation.js +5 -4
  9. package/dist/ecdsa-attestation.js.map +1 -1
  10. package/dist/index.d.ts +1 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/managed/compiler/contract-info.json +12 -1
  15. package/dist/managed/compiler/contract-manifest.json +8 -8
  16. package/dist/managed/contract/index.d.ts +8 -6
  17. package/dist/managed/contract/index.js +76 -60
  18. package/dist/managed/contract/index.js.map +1 -1
  19. package/dist/signature-requests-state-reader.d.ts +29 -10
  20. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  21. package/dist/signature-requests-state-reader.js +67 -21
  22. package/dist/signature-requests-state-reader.js.map +1 -1
  23. package/dist/signature-response-verification.d.ts +1 -1
  24. package/dist/signature-response-verification.d.ts.map +1 -1
  25. package/dist/signature-response-verification.js +3 -3
  26. package/dist/signature-response-verification.js.map +1 -1
  27. package/dist/signature-state-reading.d.ts +17 -25
  28. package/dist/signature-state-reading.d.ts.map +1 -1
  29. package/dist/signature-state-reading.js +39 -59
  30. package/dist/signature-state-reading.js.map +1 -1
  31. package/dist/signet-contract-events.d.ts +262 -0
  32. package/dist/signet-contract-events.d.ts.map +1 -0
  33. package/dist/signet-contract-events.js +266 -0
  34. package/dist/signet-contract-events.js.map +1 -0
  35. package/dist/signet-evtype2tx-requests.d.ts +4 -4
  36. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  37. package/dist/signet-evtype2tx-requests.js +3 -3
  38. package/dist/signet-request-feed.d.ts +59 -34
  39. package/dist/signet-request-feed.d.ts.map +1 -1
  40. package/dist/signet-request-feed.js +95 -62
  41. package/dist/signet-request-feed.js.map +1 -1
  42. package/dist/signet-request-response-reader.d.ts +70 -62
  43. package/dist/signet-request-response-reader.d.ts.map +1 -1
  44. package/dist/signet-request-response-reader.js +88 -102
  45. package/dist/signet-request-response-reader.js.map +1 -1
  46. package/dist/signet-requests.js +2 -2
  47. package/dist/signet-requests.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/Signet.compact +90 -43
  50. package/dist/signet-contract-state-reader.d.ts +0 -241
  51. package/dist/signet-contract-state-reader.d.ts.map +0 -1
  52. package/dist/signet-contract-state-reader.js +0 -345
  53. package/dist/signet-contract-state-reader.js.map +0 -1
  54. package/dist/signet-request-resolver.d.ts +0 -60
  55. package/dist/signet-request-resolver.d.ts.map +0 -1
  56. package/dist/signet-request-resolver.js +0 -78
  57. package/dist/signet-request-resolver.js.map +0 -1
@@ -0,0 +1,262 @@
1
+ import { type LogEvent } from "@midnight-ntwrk/compact-runtime";
2
+ /**
3
+ * The event names the signet contract emits, exactly as the contract's
4
+ * `emit` literals spell them (the on-wire name is this string NUL-padded to
5
+ * {@link SIGNET_EVENT_NAME_LENGTH} bytes, see {@link decodeSignetEventName}).
6
+ */
7
+ export declare enum SignetEventName {
8
+ /** A client's cross-contract signature-request notification. */
9
+ SignBidirectionalEvent = "SignBidirectionalEvent",
10
+ /** The MPC's signature response to a request. */
11
+ SignatureRespondedEvent = "SignatureRespondedEvent",
12
+ /** The MPC's respond-bidirectional attestation of a foreign execution. */
13
+ RespondBidirectionalEvent = "RespondBidirectionalEvent"
14
+ }
15
+ /** Byte width of a signet event's name (Compact `pad(32, ...)`). */
16
+ export declare const SIGNET_EVENT_NAME_LENGTH = 32;
17
+ /** Byte width of every signet event's packed payload. */
18
+ export declare const SIGNET_EVENT_PAYLOAD_LENGTH = 256;
19
+ /**
20
+ * A signet contract event in decoded form: the NUL-trimmed name and the full
21
+ * re-padded {@link SIGNET_EVENT_PAYLOAD_LENGTH}-byte payload. This is the
22
+ * one shape every source (simulator log, indexer Misc event) normalizes to
23
+ * before the per-event payload decoders run.
24
+ */
25
+ export interface SignetMiscEvent {
26
+ /** The event name, NUL padding stripped (compare to {@link SignetEventName}). */
27
+ name: string;
28
+ /** The packed payload, re-padded to {@link SIGNET_EVENT_PAYLOAD_LENGTH} bytes. */
29
+ payload: Uint8Array;
30
+ }
31
+ /**
32
+ * Source of the signet contract's emitted events, the event-side sibling of
33
+ * {@link SignetPublicStateSource}. Declared structurally so tests can satisfy
34
+ * it with a plain stub; adapt a full midnight-js `PublicDataProvider` with
35
+ * {@link signetEventSourceFromPublicDataProvider}.
36
+ */
37
+ export interface SignetEventSource {
38
+ /**
39
+ * Fetch every signet event the contract has emitted so far, in emission
40
+ * order.
41
+ *
42
+ * @param contractAddress - The signet contract to read events of.
43
+ * @returns The decoded events, oldest first.
44
+ */
45
+ querySignetEvents(contractAddress: string): Promise<SignetMiscEvent[]>;
46
+ }
47
+ /**
48
+ * Strip the NUL padding off a fixed-width event name and decode it as ASCII:
49
+ * the inverse of the contract's `pad(32, "...")`.
50
+ *
51
+ * @param name - The padded name bytes.
52
+ * @returns The trimmed name string.
53
+ */
54
+ export declare function decodeSignetEventName(name: Uint8Array): string;
55
+ /**
56
+ * Decode the simulator's circuit-execution log into signet events: keep the
57
+ * `misc` emissions (of `contractAddress` when given), re-pad each to the full
58
+ * name ++ payload width, and split. Non-signet-shaped `misc` events (wrong
59
+ * atom shape or width) throw: in the simulator the emitting contract is under
60
+ * test, so a malformed event is a bug, not noise to skip.
61
+ *
62
+ * @param events - The `context.events` of a `CircuitResults`.
63
+ * @param contractAddress - Optional filter: only events this contract emitted.
64
+ * @returns The decoded events, in emission order.
65
+ * @throws Error when a `misc` event is not a single bytes atom of the signet
66
+ * name ++ payload width.
67
+ */
68
+ export declare function decodeSignetLogEvents(events: readonly LogEvent[], contractAddress?: string): SignetMiscEvent[];
69
+ /**
70
+ * The least of a midnight-js `PublicDataProvider` the event source adapter
71
+ * needs: the `Misc` contract events of one address. Structural, so any full
72
+ * provider (e.g. `indexerPublicDataProvider`) is assignable.
73
+ */
74
+ export interface SignetContractEventQuerySource {
75
+ /**
76
+ * Retrieve a contract's events; see
77
+ * `PublicDataProvider.queryContractEvents`.
78
+ *
79
+ * @param filter - The contract address and event-type narrowing.
80
+ * @returns The matching events, oldest first.
81
+ */
82
+ queryContractEvents(filter: {
83
+ contractAddress: string;
84
+ types?: "Misc"[];
85
+ }): Promise<{
86
+ eventType: string;
87
+ name?: string;
88
+ payload?: string;
89
+ }[]>;
90
+ }
91
+ /**
92
+ * Adapt a midnight-js `PublicDataProvider` (or anything exposing its
93
+ * `queryContractEvents`) into a {@link SignetEventSource}: query the `Misc`
94
+ * events and normalize each into a {@link SignetMiscEvent}. The indexer
95
+ * serves `name` and `payload` as hex-encoded byte strings; the name is
96
+ * NUL-trimmed and the payload re-padded to the full
97
+ * {@link SIGNET_EVENT_PAYLOAD_LENGTH}.
98
+ *
99
+ * @param provider - The provider to query events through.
100
+ * @returns The adapted event source.
101
+ */
102
+ export declare function signetEventSourceFromPublicDataProvider(provider: SignetContractEventQuerySource): SignetEventSource;
103
+ /**
104
+ * A curve point in affine coordinates (Compact `AffinePoint`), SEC1
105
+ * big-endian, the same shape the sig-net EVM and Solana signer contracts
106
+ * expose.
107
+ */
108
+ export interface AffinePoint {
109
+ /** The x coordinate, 32 big-endian bytes. */
110
+ x: Uint8Array;
111
+ /** The y coordinate, 32 big-endian bytes. */
112
+ y: Uint8Array;
113
+ }
114
+ /**
115
+ * The MPC's canonical ECDSA signature as both respond events carry it
116
+ * (Compact `Signature`, matching the MPC's own
117
+ * `Signature { big_r, s, recovery_id }` and the EVM/Solana signer
118
+ * contracts): `bigR` the full nonce point so consumers never decompress,
119
+ * `s` big-endian, `recoveryId` the parity of R.y. Emitted UNVERIFIED like
120
+ * everything else on the singleton. Convert with
121
+ * `ecdsaSignatureToMpcSignature` / `mpcSignatureToEcdsaSignature`.
122
+ */
123
+ export interface MpcSignature {
124
+ /** The signature's nonce point R. */
125
+ bigR: AffinePoint;
126
+ /** Signature scalar s, 32 big-endian bytes. */
127
+ s: Uint8Array;
128
+ /** Recovery id (parity of R.y): 0 or 1. */
129
+ recoveryId: bigint;
130
+ }
131
+ /**
132
+ * The MPC's signature over the requested EVM transaction (Compact
133
+ * `SignatureRespondedEvent`): decode to an ethers signature with
134
+ * `signatureRespondedEventToSignature`. The emitting event carries the
135
+ * record beside the request id it answers (see {@link SignetRespondPost});
136
+ * the id routes, and VERIFYING the signature against the transaction the
137
+ * request describes establishes authenticity (see
138
+ * {@link SignetRequestResponseReader.getVerifiedSignatureRespondedEvent}).
139
+ */
140
+ export interface SignatureRespondedEvent {
141
+ /** The requested signature over the transaction the request describes. */
142
+ signature: MpcSignature;
143
+ }
144
+ /**
145
+ * The MPC's respond-bidirectional attestation of a request's remote EVM
146
+ * execution (Compact `RespondBidirectionalEvent`): the ECDSA signature over
147
+ * the attestation digest `keccak256(requestId || serializedOutput)`. Both the
148
+ * digest and the output travel off chain: readers fetch the output, recompute
149
+ * the digest (`calculateSignetAttestationDigest`) and verify the signature
150
+ * over it. Emitted UNVERIFIED by the signet contract, beside the request id
151
+ * it answers (see {@link SignetRespondPost}), so that signature check
152
+ * against the expected MPC response key is the only thing separating a
153
+ * genuine post from garbage: in-circuit via
154
+ * `verifyRespondBidirectionalEvent`, off chain via
155
+ * {@link verifyRespondBidirectionalSignature}.
156
+ */
157
+ export interface RespondBidirectionalEvent {
158
+ /** ECDSA signature over the attestation digest. */
159
+ signature: MpcSignature;
160
+ }
161
+ /**
162
+ * A decoded respond-event payload: the request id the emitting circuit
163
+ * disclosed beside the posted record. The id is UNAUTHENTICATED routing
164
+ * data: it scopes reads to one request and proves nothing. Verifying the
165
+ * record's signature against the request remains the authenticity check
166
+ * (see {@link SignetRequestResponseReader.getVerifiedSignatureRespondedEvent}
167
+ * and {@link SignetRequestResponseReader.getVerifiedRespondBidirectionalEvent}).
168
+ */
169
+ export interface SignetRespondPost<TRecord> {
170
+ /** The request id the post declares it answers, 32 bytes. Routing data only. */
171
+ requestId: Uint8Array;
172
+ /** The posted record, verbatim. */
173
+ event: TRecord;
174
+ }
175
+ /**
176
+ * Decode a {@link SignetEventName.SignatureRespondedEvent} payload: the
177
+ * decode twin of the `respond` circuit's emit literal.
178
+ *
179
+ * @param payload - The event's payload.
180
+ * @returns The decoded post: declared request id plus record.
181
+ * @throws Error when the payload is too short to hold the packed leaves.
182
+ */
183
+ export declare function decodeSignatureRespondedEventPayload(payload: Uint8Array): SignetRespondPost<SignatureRespondedEvent>;
184
+ /**
185
+ * Decode a {@link SignetEventName.RespondBidirectionalEvent} payload: the
186
+ * decode twin of the `respondBidirectional` circuit's emit literal.
187
+ *
188
+ * @param payload - The event's payload.
189
+ * @returns The decoded post: declared request id plus record.
190
+ * @throws Error when the payload is too short to hold the packed leaves.
191
+ */
192
+ export declare function decodeRespondBidirectionalEventPayload(payload: Uint8Array): SignetRespondPost<RespondBidirectionalEvent>;
193
+ /**
194
+ * Raw twin of the Compact `SignBidirectionalEventNotification` struct as the
195
+ * `signBidirectional` circuit emits it: the version tag plus the still-packed
196
+ * 128-byte payload. Decode the payload with
197
+ * {@link decodeSignBidirectionalNotification}.
198
+ */
199
+ export interface SignBidirectionalNotificationRecord {
200
+ /** Payload layout tag (Compact `Uint<8>`): 1 = the V1 layout. */
201
+ version: bigint;
202
+ /** The packed payload bytes, exactly as the registering circuit built them. */
203
+ payload: Uint8Array;
204
+ }
205
+ /**
206
+ * Decode a {@link SignetEventName.SignBidirectionalEvent} payload into the
207
+ * raw notification record: the decode twin of the `signBidirectional`
208
+ * circuit's emit literal (version (1) ++ notification payload (128)).
209
+ *
210
+ * @param payload - The event's payload.
211
+ * @returns The raw notification record.
212
+ * @throws Error when the payload is too short to hold the record.
213
+ */
214
+ export declare function decodeSignBidirectionalEventNotificationPayload(payload: Uint8Array): SignBidirectionalNotificationRecord;
215
+ /**
216
+ * A decoded V1 notification: the flat pointer a client emitted to tell the
217
+ * MPC a request was stored, and WHERE to read the authenticated copy. The
218
+ * event carries no request id: the MPC enumerates the request map the
219
+ * notification points at and reads every request from the named caller's own
220
+ * authenticated ledger (see signet-request-feed.ts). The fields themselves
221
+ * confer no authority.
222
+ */
223
+ export interface SignBidirectionalNotification {
224
+ /** Payload layout tag: this decoder only produces version 1. */
225
+ version: number;
226
+ /**
227
+ * Address of the contract whose request map holds the request, rendered
228
+ * as lowercase hex, no `0x` prefix: directly usable as a
229
+ * `queryContractState` argument. The MPC reads requests from THIS
230
+ * contract's authenticated state. The field itself confers no authority.
231
+ */
232
+ callerAddress: string;
233
+ /**
234
+ * Resolved ledger-tree path of the `SignBidirectionalEventMap` in
235
+ * {@link callerAddress}, as compactc records it in that contract's
236
+ * `contract-info.json` (`"index"`): `[4]` for a flat contract's field 4,
237
+ * `[1, 14]` once chunking applies. The reader follows it node for node
238
+ * (see `signetFieldNodeByPath`) and never assumes a layout.
239
+ */
240
+ requestsPath: number[];
241
+ }
242
+ /**
243
+ * Unpack a {@link SignBidirectionalNotificationRecord}'s payload by the
244
+ * fixed V1 offsets: the decode twin of the compiled
245
+ * `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
246
+ * only: the pack↔decode lockstep is pinned by the unit test that round-trips
247
+ * through the real circuit). V1 layout:
248
+ * callerAddress (32) ++ requestsPathDepth (1) ++ requestsPath (4) ++ zero
249
+ * padding (91), where only the first `requestsPathDepth` path bytes are
250
+ * meaningful.
251
+ *
252
+ * Fails closed on an unrecognised `version`: a future payload layout adds a
253
+ * branch here rather than silently misinterpreting bytes under the V1 offsets.
254
+ *
255
+ * @param record - The raw notification record.
256
+ * @returns The decoded notification, its `requestsPath` trimmed to the
257
+ * declared depth.
258
+ * @throws Error if the record's `version` is not one this decoder understands,
259
+ * or its `requestsPathDepth` is zero or exceeds {@link MAX_LEDGER_PATH_DEPTH}.
260
+ */
261
+ export declare function decodeSignBidirectionalNotification(record: SignBidirectionalNotificationRecord): SignBidirectionalNotification;
262
+ //# sourceMappingURL=signet-contract-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signet-contract-events.d.ts","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAOzC;;;;GAIG;AACH,oBAAY,eAAe;IACzB,gEAAgE;IAChE,sBAAsB,2BAA2B;IACjD,iDAAiD;IACjD,uBAAuB,4BAA4B;IACnD,0EAA0E;IAC1E,yBAAyB,8BAA8B;CACxD;AAED,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,yDAAyD;AACzD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,OAAO,EAAE,UAAU,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACxE;AAOD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAM9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,eAAe,CAAC,EAAE,MAAM,GACvB,eAAe,EAAE,CAqBnB;AAED;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;;;OAMG;IACH,mBAAmB,CAAC,MAAM,EAAE;QAC1B,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,M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;;;;;GAQG;AACH,wBAAgB,+CAA+C,CAC7D,OAAO,EAAE,UAAU,GAClB,mCAAmC,CAYrC;AAqBD;;;;;;;GAOG;AACH,MAAM,WAAW,6BAA6B;IAC5C,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,mCAAmC,GAC1C,6BAA6B,CA8B/B"}
@@ -0,0 +1,266 @@
1
+ // MPC-/client-style decoders for the central SIGNET contract's emitted
2
+ // events. Every signet contract circuit emits one `Misc` contract event
3
+ // (MIP-0002 public log emission) whose 32-byte name tags the event kind and
4
+ // whose 256-byte payload packs the record:
5
+ // SignBidirectionalEvent - version (1) ++ notification payload (128) ++ zeros (127)
6
+ // SignatureRespondedEvent - requestId (32) ++ bigR.x (32) ++ bigR.y (32) ++ s (32) ++ recoveryId (1) ++ zeros (127)
7
+ // RespondBidirectionalEvent - requestId (32) ++ bigR.x (32) ++ bigR.y (32) ++ s (32) ++ recoveryId (1) ++ zeros (127)
8
+ // The decoders here are the byte-plumbing twins of the emit literals in
9
+ // signet-contract.compact: field order and offsets must match byte-for-byte
10
+ // (the signet-contract simulator tests pin the lockstep against real emits).
11
+ // Every event is UNAUTHENTICATED: verification is the reader's job. The
12
+ // request id in the two respond payloads is routing data only, so it scopes
13
+ // reads to one request and proves nothing.
14
+ import { CompactTypeBytes, } from "@midnight-ntwrk/compact-runtime";
15
+ import { bytesToHex, hexToBytes, } from "./signet-requests.js";
16
+ /**
17
+ * The event names the signet contract emits, exactly as the contract's
18
+ * `emit` literals spell them (the on-wire name is this string NUL-padded to
19
+ * {@link SIGNET_EVENT_NAME_LENGTH} bytes, see {@link decodeSignetEventName}).
20
+ */
21
+ export var SignetEventName;
22
+ (function (SignetEventName) {
23
+ /** A client's cross-contract signature-request notification. */
24
+ SignetEventName["SignBidirectionalEvent"] = "SignBidirectionalEvent";
25
+ /** The MPC's signature response to a request. */
26
+ SignetEventName["SignatureRespondedEvent"] = "SignatureRespondedEvent";
27
+ /** The MPC's respond-bidirectional attestation of a foreign execution. */
28
+ SignetEventName["RespondBidirectionalEvent"] = "RespondBidirectionalEvent";
29
+ })(SignetEventName || (SignetEventName = {}));
30
+ /** Byte width of a signet event's name (Compact `pad(32, ...)`). */
31
+ export const SIGNET_EVENT_NAME_LENGTH = 32;
32
+ /** Byte width of every signet event's packed payload. */
33
+ export const SIGNET_EVENT_PAYLOAD_LENGTH = 256;
34
+ /** Descriptor re-padding a name ++ payload event atom to its full width. */
35
+ const eventBytes = new CompactTypeBytes(SIGNET_EVENT_NAME_LENGTH + SIGNET_EVENT_PAYLOAD_LENGTH);
36
+ /**
37
+ * Strip the NUL padding off a fixed-width event name and decode it as ASCII:
38
+ * the inverse of the contract's `pad(32, "...")`.
39
+ *
40
+ * @param name - The padded name bytes.
41
+ * @returns The trimmed name string.
42
+ */
43
+ export function decodeSignetEventName(name) {
44
+ let end = name.length;
45
+ while (end > 0 && name[end - 1] === 0) {
46
+ end -= 1;
47
+ }
48
+ return new TextDecoder().decode(name.slice(0, end));
49
+ }
50
+ /**
51
+ * Decode the simulator's circuit-execution log into signet events: keep the
52
+ * `misc` emissions (of `contractAddress` when given), re-pad each to the full
53
+ * name ++ payload width, and split. Non-signet-shaped `misc` events (wrong
54
+ * atom shape or width) throw: in the simulator the emitting contract is under
55
+ * test, so a malformed event is a bug, not noise to skip.
56
+ *
57
+ * @param events - The `context.events` of a `CircuitResults`.
58
+ * @param contractAddress - Optional filter: only events this contract emitted.
59
+ * @returns The decoded events, in emission order.
60
+ * @throws Error when a `misc` event is not a single bytes atom of the signet
61
+ * name ++ payload width.
62
+ */
63
+ export function decodeSignetLogEvents(events, contractAddress) {
64
+ const out = [];
65
+ for (const event of events) {
66
+ if (event.eventType !== "misc")
67
+ continue;
68
+ if (contractAddress !== undefined && event.address !== contractAddress) {
69
+ continue;
70
+ }
71
+ if (event.data.tag !== "cell") {
72
+ throw new Error(`misc event data is a '${event.data.tag}', expected a cell`);
73
+ }
74
+ // fromValue consumes its input and re-pads the trailing zeros the state
75
+ // layer trims, so hand it a copy.
76
+ const bytes = eventBytes.fromValue([...event.data.content.value]);
77
+ out.push({
78
+ name: decodeSignetEventName(bytes.slice(0, SIGNET_EVENT_NAME_LENGTH)),
79
+ payload: bytes.slice(SIGNET_EVENT_NAME_LENGTH),
80
+ });
81
+ }
82
+ return out;
83
+ }
84
+ /**
85
+ * Normalize one indexer-served hex field that may or may not carry a `0x`
86
+ * prefix into bytes.
87
+ *
88
+ * @param hex - The hex string.
89
+ * @returns The decoded bytes.
90
+ */
91
+ function eventFieldBytes(hex) {
92
+ return hexToBytes(hex.startsWith("0x") ? hex.slice(2) : hex);
93
+ }
94
+ /**
95
+ * Adapt a midnight-js `PublicDataProvider` (or anything exposing its
96
+ * `queryContractEvents`) into a {@link SignetEventSource}: query the `Misc`
97
+ * events and normalize each into a {@link SignetMiscEvent}. The indexer
98
+ * serves `name` and `payload` as hex-encoded byte strings; the name is
99
+ * NUL-trimmed and the payload re-padded to the full
100
+ * {@link SIGNET_EVENT_PAYLOAD_LENGTH}.
101
+ *
102
+ * @param provider - The provider to query events through.
103
+ * @returns The adapted event source.
104
+ */
105
+ export function signetEventSourceFromPublicDataProvider(provider) {
106
+ return {
107
+ async querySignetEvents(contractAddress) {
108
+ const events = await provider.queryContractEvents({
109
+ contractAddress,
110
+ types: ["Misc"],
111
+ });
112
+ const out = [];
113
+ for (const event of events) {
114
+ if (event.eventType !== "Misc")
115
+ continue;
116
+ if (event.name === undefined || event.payload === undefined)
117
+ continue;
118
+ const payload = eventFieldBytes(event.payload);
119
+ const padded = new Uint8Array(SIGNET_EVENT_PAYLOAD_LENGTH);
120
+ padded.set(payload.slice(0, SIGNET_EVENT_PAYLOAD_LENGTH), 0);
121
+ out.push({
122
+ name: decodeSignetEventName(eventFieldBytes(event.name)),
123
+ payload: padded,
124
+ });
125
+ }
126
+ return out;
127
+ },
128
+ };
129
+ }
130
+ /** Offsets of the leaves both respond payloads pack, in emit order. */
131
+ const RESPOND_REQUEST_ID_OFFSET = 0;
132
+ const SIGNATURE_BIG_R_X_OFFSET = 32;
133
+ const SIGNATURE_BIG_R_Y_OFFSET = 64;
134
+ const SIGNATURE_S_OFFSET = 96;
135
+ const SIGNATURE_RECOVERY_ID_OFFSET = 128;
136
+ /**
137
+ * Unpack the leaves both respond payloads lead with:
138
+ * requestId (32) ++ bigR.x (32) ++ bigR.y (32) ++ s (32) ++ recoveryId (1).
139
+ * Bytes beyond the recovery id are padding today and are ignored, so a
140
+ * future payload extension does not break existing readers.
141
+ *
142
+ * @param payload - The full event payload.
143
+ * @returns The declared request id and the decoded signature.
144
+ * @throws Error when the payload is too short to hold the packed leaves.
145
+ */
146
+ function decodeRespondPayload(payload) {
147
+ const recoveryId = payload[SIGNATURE_RECOVERY_ID_OFFSET];
148
+ if (recoveryId === undefined) {
149
+ throw new Error(`signet event payload of ${payload.length} bytes is too short for a packed respond record`);
150
+ }
151
+ return {
152
+ requestId: payload.slice(RESPOND_REQUEST_ID_OFFSET, SIGNATURE_BIG_R_X_OFFSET),
153
+ signature: {
154
+ bigR: {
155
+ x: payload.slice(SIGNATURE_BIG_R_X_OFFSET, SIGNATURE_BIG_R_Y_OFFSET),
156
+ y: payload.slice(SIGNATURE_BIG_R_Y_OFFSET, SIGNATURE_S_OFFSET),
157
+ },
158
+ s: payload.slice(SIGNATURE_S_OFFSET, SIGNATURE_RECOVERY_ID_OFFSET),
159
+ recoveryId: BigInt(recoveryId),
160
+ },
161
+ };
162
+ }
163
+ /**
164
+ * Decode a {@link SignetEventName.SignatureRespondedEvent} payload: the
165
+ * decode twin of the `respond` circuit's emit literal.
166
+ *
167
+ * @param payload - The event's payload.
168
+ * @returns The decoded post: declared request id plus record.
169
+ * @throws Error when the payload is too short to hold the packed leaves.
170
+ */
171
+ export function decodeSignatureRespondedEventPayload(payload) {
172
+ const { requestId, signature } = decodeRespondPayload(payload);
173
+ return { requestId, event: { signature } };
174
+ }
175
+ /**
176
+ * Decode a {@link SignetEventName.RespondBidirectionalEvent} payload: the
177
+ * decode twin of the `respondBidirectional` circuit's emit literal.
178
+ *
179
+ * @param payload - The event's payload.
180
+ * @returns The decoded post: declared request id plus record.
181
+ * @throws Error when the payload is too short to hold the packed leaves.
182
+ */
183
+ export function decodeRespondBidirectionalEventPayload(payload) {
184
+ const { requestId, signature } = decodeRespondPayload(payload);
185
+ return { requestId, event: { signature } };
186
+ }
187
+ /** Offset of the notification's version tag in the event payload. */
188
+ const NOTIFICATION_EVENT_VERSION_OFFSET = 0;
189
+ /** Offset of the packed notification payload in the event payload. */
190
+ const NOTIFICATION_EVENT_PAYLOAD_OFFSET = 1;
191
+ /** Byte width of the packed notification payload (Compact `Bytes<128>`). */
192
+ const NOTIFICATION_PAYLOAD_LENGTH = 128;
193
+ /**
194
+ * Decode a {@link SignetEventName.SignBidirectionalEvent} payload into the
195
+ * raw notification record: the decode twin of the `signBidirectional`
196
+ * circuit's emit literal (version (1) ++ notification payload (128)).
197
+ *
198
+ * @param payload - The event's payload.
199
+ * @returns The raw notification record.
200
+ * @throws Error when the payload is too short to hold the record.
201
+ */
202
+ export function decodeSignBidirectionalEventNotificationPayload(payload) {
203
+ const version = payload[NOTIFICATION_EVENT_VERSION_OFFSET];
204
+ const end = NOTIFICATION_EVENT_PAYLOAD_OFFSET + NOTIFICATION_PAYLOAD_LENGTH;
205
+ if (version === undefined || payload.length < end) {
206
+ throw new Error(`signet event payload of ${payload.length} bytes is too short for a packed notification`);
207
+ }
208
+ return {
209
+ version: BigInt(version),
210
+ payload: payload.slice(NOTIFICATION_EVENT_PAYLOAD_OFFSET, end),
211
+ };
212
+ }
213
+ /** Offset of the V1 `callerAddress` in the packed payload (`Bytes<32>` at the front). */
214
+ const NOTIFICATION_CALLER_ADDRESS_OFFSET = 0;
215
+ /** Offset of the V1 `requestsPathDepth` (after the 32 callerAddress bytes). */
216
+ const NOTIFICATION_PATH_DEPTH_OFFSET = 32;
217
+ /** Offset of the V1 `requestsPath` bytes (after the 1-byte depth). */
218
+ const NOTIFICATION_PATH_OFFSET = 33;
219
+ /**
220
+ * Maximum ledger-tree path depth the V1 payload carries, matching the
221
+ * `Vector<4, Uint<8>>` the `constructSignBidirectionalEventNotificationV1`
222
+ * circuit packs. Depth 1 addresses up to 15 fields, depth 4 up to 15^4.
223
+ */
224
+ const MAX_LEDGER_PATH_DEPTH = 4;
225
+ /** The only payload interpretation {@link decodeSignBidirectionalNotification} understands today. */
226
+ const SUPPORTED_NOTIFICATION_VERSION = 1n;
227
+ /**
228
+ * Unpack a {@link SignBidirectionalNotificationRecord}'s payload by the
229
+ * fixed V1 offsets: the decode twin of the compiled
230
+ * `constructSignBidirectionalEventNotificationV1` circuit (byte plumbing
231
+ * only: the pack↔decode lockstep is pinned by the unit test that round-trips
232
+ * through the real circuit). V1 layout:
233
+ * callerAddress (32) ++ requestsPathDepth (1) ++ requestsPath (4) ++ zero
234
+ * padding (91), where only the first `requestsPathDepth` path bytes are
235
+ * meaningful.
236
+ *
237
+ * Fails closed on an unrecognised `version`: a future payload layout adds a
238
+ * branch here rather than silently misinterpreting bytes under the V1 offsets.
239
+ *
240
+ * @param record - The raw notification record.
241
+ * @returns The decoded notification, its `requestsPath` trimmed to the
242
+ * declared depth.
243
+ * @throws Error if the record's `version` is not one this decoder understands,
244
+ * or its `requestsPathDepth` is zero or exceeds {@link MAX_LEDGER_PATH_DEPTH}.
245
+ */
246
+ export function decodeSignBidirectionalNotification(record) {
247
+ if (record.version !== SUPPORTED_NOTIFICATION_VERSION) {
248
+ throw new Error(`SignBidirectionalEventNotification version ${record.version} is not supported ` +
249
+ `(this decoder understands version ${SUPPORTED_NOTIFICATION_VERSION})`);
250
+ }
251
+ const callerAddress = bytesToHex(record.payload.slice(NOTIFICATION_CALLER_ADDRESS_OFFSET, NOTIFICATION_PATH_DEPTH_OFFSET));
252
+ const depth = record.payload[NOTIFICATION_PATH_DEPTH_OFFSET];
253
+ if (depth === undefined || depth < 1 || depth > MAX_LEDGER_PATH_DEPTH) {
254
+ throw new Error(`SignBidirectionalEventNotification requestsPathDepth ${depth} is out of range ` +
255
+ `(expected 1 to ${MAX_LEDGER_PATH_DEPTH})`);
256
+ }
257
+ // payload is a re-padded Bytes<128> and depth is bounded to MAX_LEDGER_PATH_DEPTH
258
+ // above, so this slice always yields exactly `depth` bytes.
259
+ const requestsPath = Array.from(record.payload.slice(NOTIFICATION_PATH_OFFSET, NOTIFICATION_PATH_OFFSET + depth));
260
+ return {
261
+ version: Number(record.version),
262
+ callerAddress,
263
+ requestsPath,
264
+ };
265
+ }
266
+ //# sourceMappingURL=signet-contract-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signet-contract-events.js","sourceRoot":"","sources":["../src/signet-contract-events.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,2CAA2C;AAC3C,yFAAyF;AACzF,wHAAwH;AACxH,wHAAwH;AACxH,wEAAwE;AACxE,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,4EAA4E;AAC5E,2CAA2C;AAE3C,OAAO,EACL,gBAAgB,GAEjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,UAAU,EACV,UAAU,GACX,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,gEAAgE;IAChE,oEAAiD,CAAA;IACjD,iDAAiD;IACjD,sEAAmD,CAAA;IACnD,0EAA0E;IAC1E,0EAAuD,CAAA;AACzD,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,yDAAyD;AACzD,MAAM,CAAC,MA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9E,qCAAqC,8BAA8B,GAAG,CACzE,CAAC;IACJ,CAAC;IACD,MAAM,aAAa,GAAG,UAAU,CAC9B,MAAM,CAAC,OAAO,CAAC,KAAK,CAClB,kCAAkC,EAClC,8BAA8B,CAC/B,CACF,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC7D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,qBAAqB,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CACb,wDAAwD,KAAK,mBAAmB;YAC9E,kBAAkB,qBAAqB,GAAG,CAC7C,CAAC;IACJ,CAAC;IACD,kFAAkF;IAClF,4DAA4D;IAC5D,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAC7B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,wBAAwB,GAAG,KAAK,CAAC,CACjF,CAAC;IACF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/B,aAAa;QACb,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
2
  import { Signature, Transaction } from "ethers";
3
- import type { SignatureRespondedEvent } from "./signet-contract-state-reader.ts";
3
+ import type { SignatureRespondedEvent } from "./signet-contract-events.ts";
4
4
  import { type Maybe, type RequestId, type SignBidirectionalEvent } from "./signet-requests.ts";
5
5
  /**
6
6
  * ABI calldata as a 4-byte selector + 32-byte word slots (Compact:
@@ -199,8 +199,8 @@ export declare function assembleCalldata(calldata: Maybe<EvmCalldata>): string;
199
199
  */
200
200
  export declare function signBidirectionalEventToUnsignedEvmTransaction(request: SignBidirectionalEvent): Transaction;
201
201
  /**
202
- * Decode a response signature record (as posted to the signet contract's
203
- * signature response log) into an ethers {@link Signature}. Goes through
202
+ * Decode a response signature record (as the signet contract emits it in a
203
+ * signature response event) into an ethers {@link Signature}. Goes through
204
204
  * {@link mpcSignatureToEcdsaSignature}, so this and in-circuit claims decode
205
205
  * a post identically:
206
206
  * ethers' `r` is the ECDSA scalar (`bigR.x` reduced mod the curve order),
@@ -234,7 +234,7 @@ export declare function signatureToSignatureRespondedEvent(signature: Pick<Signa
234
234
  * its MPC signature response: rebuild the exact unsigned transaction the MPC
235
235
  * signed (see {@link signBidirectionalEventToUnsignedEvmTransaction}) and
236
236
  * attach the signature. Does NOT check that the signature recovers to the
237
- * requester's derived address: the response log is unauthenticated, so
237
+ * requester's derived address: the response events are unauthenticated, so
238
238
  * verify first with `verifySignatureRespondedEvent`.
239
239
  *
240
240
  * @param request - The on-ledger request record.
@@ -1 +1 @@
1
- {"version":3,"file":"signet-evtype2tx-requests.d.ts","sourceRoot":"","sources":["../src/signet-evtype2tx-requests.ts"],"names":[],"mappings":"AAYA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAc,SAAS,EAAW,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAMjF,OAAO,EAKL,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,QAAQ,EAAE,UAAU,CAAC;IACrB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,OAAO,EAAE,UAAU,CAAC;IACpB,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAg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AG,GAAG,GAAG,SAAS,CAAC,GAChD,uBAAuB,CAQzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,GAChC,WAAW,CAIb"}
@@ -269,8 +269,8 @@ export function signBidirectionalEventToUnsignedEvmTransaction(request) {
269
269
  });
270
270
  }
271
271
  /**
272
- * Decode a response signature record (as posted to the signet contract's
273
- * signature response log) into an ethers {@link Signature}. Goes through
272
+ * Decode a response signature record (as the signet contract emits it in a
273
+ * signature response event) into an ethers {@link Signature}. Goes through
274
274
  * {@link mpcSignatureToEcdsaSignature}, so this and in-circuit claims decode
275
275
  * a post identically:
276
276
  * ethers' `r` is the ECDSA scalar (`bigR.x` reduced mod the curve order),
@@ -319,7 +319,7 @@ export function signatureToSignatureRespondedEvent(signature) {
319
319
  * its MPC signature response: rebuild the exact unsigned transaction the MPC
320
320
  * signed (see {@link signBidirectionalEventToUnsignedEvmTransaction}) and
321
321
  * attach the signature. Does NOT check that the signature recovers to the
322
- * requester's derived address: the response log is unauthenticated, so
322
+ * requester's derived address: the response events are unauthenticated, so
323
323
  * verify first with `verifySignatureRespondedEvent`.
324
324
  *
325
325
  * @param request - The on-ledger request record.