@sig-net/midnight 0.22.0-rc.1 → 0.22.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 CHANGED
@@ -72,6 +72,7 @@ What clients import from `@sig-net/midnight`:
72
72
  | Compose expected calldata words off chain (UIs, expected-record builders, tests) | The builders `numericAbiWord`, `evmAddressAbiWord` and `boolAbiWord`, and the readers `abiWordToUint128` and `abiWordToBool`: TS twins of the circuits under identical names. |
73
73
  | Convert a foreign execution output into respond bytes | `deserializeEvmOutput` (raw EVM return data to named values) and `serializeRespondOutput` (named values to the packed respond payload the MPC attests): together they rebuild the `serializedOutput` of steps 4 and 5. |
74
74
  | Recognise a failed remote execution | `MPC_FAILURE_OUTPUT` and `isMpcFailureOutput`: the MPC's fixed 5-byte failure payload for reverted or replaced transactions (see [Handling Failure](https://github.com/sig-net/midnight-integration/blob/main/README.md#handling-failure)). |
75
+ | Read the attested output bytes from the MPC's output cache | `MpcOutputCacheReader`: one reader per network and Signet singleton pair, over the public bucket an MPC configured with output storage writes each request's exact attested bytes to before posting, defaulting to the bucket `getMpcOutputCacheUrl` publishes for the network. `fetchSerializedOutput` yields the bytes step 5 verifies, `undefined` while the object is not written yet. |
75
76
  | Verify attestations without the reader | `verifyRespondBidirectionalSignature`: the check the reader runs internally, exposed for custom pipelines. |
76
77
  | Mint attestations in your contract's unit tests | The `@sig-net/midnight/testing` entry point, see [Testing entry point](#testing-entry-point). |
77
78
  | Discover requests MPC-side (responders, background workers) | The discovery primitives: decode the signet contract's emitted notification events with `decodeSignBidirectionalEventNotificationPayload` and `decodeSignBidirectionalNotification`, then resolve each pointer against the named caller's own request map with `lookupSignetRequestAt` (the authenticated read). The polling loop belongs to the responder. |
@@ -86,4 +86,16 @@ export declare function getMpcRootPublicKey(networkId: DeployedNetwork): string;
86
86
  * package.
87
87
  */
88
88
  export declare function getSignetContractAddress(networkId: DeployedNetwork): string;
89
+ /**
90
+ * The public URL of the MPC's output cache on a deployed Midnight network,
91
+ * down to the MPC's object prefix: the `cacheUrl` an `MpcOutputCacheReader`
92
+ * defaults to. A local standalone stack has no published cache: its
93
+ * responder serves its own.
94
+ *
95
+ * @param networkId - The deployed network to look up.
96
+ * @returns The network's output cache URL.
97
+ * @throws {Error} When no cache is published for the network in this
98
+ * package.
99
+ */
100
+ export declare function getMpcOutputCacheUrl(networkId: DeployedNetwork): string;
89
101
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AASA,+DAA+D;AAC/D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wFAAwF;AACxF,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,yBAAiD,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,UAAU,GAAG,OAAO,CAKxE;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUpE;AAED;;;GAGG;AACH,oBAAY,eAAe;IACzB,mFAAmF;IACnF,UAAU,eAAe;IACzB,2CAA2C;IAC3C,QAAQ,aAAa;IACrB,iFAAiF;IACjF,OAAO,YAAY;IACnB,+EAA+E;IAC/E,OAAO,YAAY;IACnB,6CAA6C;IAC7C,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;AAgBnF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAMtE;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAM3E"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AASA,+DAA+D;AAC/D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wFAAwF;AACxF,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,yBAAiD,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,UAAU,GAAG,OAAO,CAKxE;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUpE;AAED;;;GAGG;AACH,oBAAY,eAAe;IACzB,mFAAmF;IACnF,UAAU,eAAe;IACzB,2CAA2C;IAC3C,QAAQ,aAAa;IACrB,iFAAiF;IACjF,OAAO,YAAY;IACnB,+EAA+E;IAC/E,OAAO,YAAY;IACnB,6CAA6C;IAC7C,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;AAgBnF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAMtE;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAM3E;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAMvE"}
package/dist/constants.js CHANGED
@@ -133,4 +133,32 @@ export function getSignetContractAddress(networkId) {
133
133
  }
134
134
  return contractAddress;
135
135
  }
136
+ // The public URL of each network's MPC output cache down to the MPC's
137
+ // configured object prefix (`publisher.output_storage.prefix`). An empty
138
+ // string means "no cache published" and makes getMpcOutputCacheUrl throw for
139
+ // that network.
140
+ const mpcOutputCacheUrls = {
141
+ [MidnightNetwork.Stagenet]: "https://storage.googleapis.com/midnight-cache-storage-dev/v1/stagenet",
142
+ [MidnightNetwork.Preview]: "",
143
+ [MidnightNetwork.Preprod]: "",
144
+ [MidnightNetwork.Mainnet]: "",
145
+ };
146
+ /**
147
+ * The public URL of the MPC's output cache on a deployed Midnight network,
148
+ * down to the MPC's object prefix: the `cacheUrl` an `MpcOutputCacheReader`
149
+ * defaults to. A local standalone stack has no published cache: its
150
+ * responder serves its own.
151
+ *
152
+ * @param networkId - The deployed network to look up.
153
+ * @returns The network's output cache URL.
154
+ * @throws {Error} When no cache is published for the network in this
155
+ * package.
156
+ */
157
+ export function getMpcOutputCacheUrl(networkId) {
158
+ const cacheUrl = mpcOutputCacheUrls[networkId];
159
+ if (!cacheUrl) {
160
+ throw new Error(`no MPC output cache URL published for the '${networkId}' network yet`);
161
+ }
162
+ return cacheUrl;
163
+ }
136
164
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,0EAA0E;AAC1E,oBAAoB;AAEpB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IA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,MAAM,eAAe,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,eAAe,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,sEAAsE;AACtE,yEAAyE;AACzE,6EAA6E;AAC7E,gBAAgB;AAChB,MAAM,kBAAkB,GAAoC;IAC1D,CAAC,eAAe,CAAC,QAAQ,CAAC,EACxB,uEAAuE;IACzE,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;IAC7B,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;IAC7B,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;CAC9B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA0B;IAC7D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,SAAS,eAAe,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./abi-serde.ts";
2
2
  export { bigintToBytes32, bigintToBytes32BE, BLS_ORDER, bytesToBigint, bytesToBigintBE, bytesToHex, hexToBytes, stripHexPrefix, } from "./byte-codecs.ts";
3
3
  export * from "./constants.ts";
4
4
  export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_CAIP2_ID, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, } from "./epsilon-derivation.ts";
5
+ export * from "./mpc-output-cache.ts";
5
6
  export { type RawContractState, signetFieldNodeByPath } from "./raw-contract-state.ts";
6
7
  export * from "./signature-requests-state-reader.ts";
7
8
  export * from "./signature-response-verification.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAI1B,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,mCAAmC,GACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,cAAc,EACd,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,OAAO,EACL,KAAK,eAAe,EACpB,sBAAsB,EACtB,KAAK,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,KAAK,SAAS,EACd,cAAc,EACd,KAAK,YAAY,EACjB,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,6BAA6B,EAC7B,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EACf,KAAK,cAAc,EACnB,kCAAkC,EACl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AsB,CAAC;AAK9B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EACf,KAAK,cAAc,EACnB,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export * from "./constants.js";
10
10
  // Selective: deriveMidnightResponseSecretKey takes the MPC root secret, so
11
11
  // it is exported through ./testing with the other secret-taking helpers.
12
12
  export { deriveEpsilon, deriveEvmAddress, deriveMidnightResponseKey, EPSILON_DERIVATION_PREFIX, MIDNIGHT_CAIP2_ID, MIDNIGHT_RESPOND_BIDIRECTIONAL_PATH, } from "./epsilon-derivation.js";
13
+ export * from "./mpc-output-cache.js";
13
14
  export { signetFieldNodeByPath } from "./raw-contract-state.js";
14
15
  export * from "./signature-requests-state-reader.js";
15
16
  export * from "./signature-response-verification.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sEAAsE;AACtE,wEAAwE;AAExE,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,uEAAuE;AACvE,4EAA4E;AAC5E,4EAA4E;AAC5E,cAAc,gBAAgB,CAAC;AAC/B,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,mCAAmC,GACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,cAAc,s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AC;AACtC,OAAO,EAAyB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EAEX,iBAAiB,EAGjB,cAAc,EACd,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAEL,sBAAsB,EAEtB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EAEV,cAAc,EAEd,YAAY,EAIZ,6BAA6B,EAC7B,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AAC9D,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,uCAAuC,EACvC,eAAe,EAEf,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,OAAO,EAAqB,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { RequestIdHex } from "./signet-requests.ts";
2
+ /** Where the MPC's output cache lives and which of its namespaces to read. */
3
+ export interface MpcOutputCacheConfig {
4
+ /**
5
+ * The cache's public URL down to the MPC's configured object prefix, e.g.
6
+ * `https://storage.googleapis.com/<bucket>/<prefix>`. A trailing slash is
7
+ * tolerated. Defaults to the cache this package publishes for `networkId`
8
+ * ({@link getMpcOutputCacheUrl}), so a network with none (the local
9
+ * standalone stack) must pass it.
10
+ */
11
+ readonly cacheUrl?: string;
12
+ /** The Midnight network id the MPC serves: the path segment after the prefix. */
13
+ readonly networkId: string;
14
+ /** The signet singleton the MPC publishes through, 64 hex chars: the segment after the network. */
15
+ readonly signetContractAddress: string;
16
+ }
17
+ /**
18
+ * Reads attested serialised outputs out of the MPC's output cache. The MPC
19
+ * writes a request's bytes to
20
+ * `<prefix>/<networkId>/<signetContractAddress>/<requestId>.bin` before it
21
+ * posts the matching attestation, so once an attestation is on chain a
22
+ * missing object is the MPC's cache write being lost, and an object found
23
+ * before any attestation is still unverified.
24
+ */
25
+ export declare class MpcOutputCacheReader {
26
+ private readonly namespaceUrl;
27
+ /**
28
+ * @param config - The cache location and the namespace to read.
29
+ * @throws {Error} When `cacheUrl` is omitted for a network this package
30
+ * publishes no cache for.
31
+ */
32
+ constructor(config: MpcOutputCacheConfig);
33
+ /**
34
+ * The URL of the object holding `requestId`'s attested output.
35
+ *
36
+ * @param requestId - The request whose output object to locate.
37
+ * @returns The object's public URL.
38
+ */
39
+ objectUrl(requestId: RequestIdHex): string;
40
+ /**
41
+ * Download the serialised output the MPC cached for `requestId`, verbatim.
42
+ * UNTRUSTED: verify the attestation signature over the returned bytes.
43
+ *
44
+ * @param requestId - The request whose attested output to fetch.
45
+ * @returns The cached bytes, or `undefined` when the cache holds no object
46
+ * for the request (the MPC has not written it yet).
47
+ * @throws {Error} If the cache cannot be reached or answers with a status
48
+ * other than 200 or 404.
49
+ */
50
+ fetchSerializedOutput(requestId: RequestIdHex): Promise<Uint8Array | undefined>;
51
+ }
52
+ //# sourceMappingURL=mpc-output-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpc-output-cache.d.ts","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mGAAmG;IACnG,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAwBD;;;;;;;GAOG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;OAIG;IACH,YAAY,MAAM,EAAE,oBAAoB,EAMvC;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAEzC;IAED;;;;;;;;;OASG;IACG,qBAAqB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAYpF;CACF"}
@@ -0,0 +1,79 @@
1
+ // Reader over the MPC's output cache: the exact serialised output bytes the
2
+ // MPC attests for a bidirectional request, stored as one object per request
3
+ // id in a public bucket BEFORE the attestation is posted on chain. A Compact
4
+ // circuit fixes its byte-payload width at compile time while serialised
5
+ // outputs vary in size across requests, so the signet contract carries the
6
+ // signature alone and the cache carries the bytes. An object holds nothing
7
+ // but the packed output, and is UNTRUSTED until the attestation signature
8
+ // verifies over it (`verifyRespondBidirectionalSignature`).
9
+ import { getMpcOutputCacheUrl, MidnightNetwork } from "./constants.js";
10
+ /** The networks this package may publish an output cache for: every named one but the local stack. */
11
+ const DEPLOYED_NETWORKS = Object.values(MidnightNetwork).filter((network) => network !== MidnightNetwork.Undeployed);
12
+ /**
13
+ * The cache URL this package publishes for `networkId`.
14
+ *
15
+ * @param networkId - The Midnight network id the MPC serves.
16
+ * @returns The published cache URL.
17
+ * @throws {Error} When `networkId` is not a deployed network, or is one with
18
+ * no cache published yet.
19
+ */
20
+ function publishedCacheUrl(networkId) {
21
+ if (!DEPLOYED_NETWORKS.includes(networkId)) {
22
+ throw new Error(`no MPC output cache is published for the '${networkId}' network: pass cacheUrl`);
23
+ }
24
+ return getMpcOutputCacheUrl(networkId);
25
+ }
26
+ /**
27
+ * Reads attested serialised outputs out of the MPC's output cache. The MPC
28
+ * writes a request's bytes to
29
+ * `<prefix>/<networkId>/<signetContractAddress>/<requestId>.bin` before it
30
+ * posts the matching attestation, so once an attestation is on chain a
31
+ * missing object is the MPC's cache write being lost, and an object found
32
+ * before any attestation is still unverified.
33
+ */
34
+ export class MpcOutputCacheReader {
35
+ namespaceUrl;
36
+ /**
37
+ * @param config - The cache location and the namespace to read.
38
+ * @throws {Error} When `cacheUrl` is omitted for a network this package
39
+ * publishes no cache for.
40
+ */
41
+ constructor(config) {
42
+ let prefixUrl = config.cacheUrl ?? publishedCacheUrl(config.networkId);
43
+ while (prefixUrl.endsWith("/")) {
44
+ prefixUrl = prefixUrl.slice(0, -1);
45
+ }
46
+ this.namespaceUrl = `${prefixUrl}/${config.networkId}/${config.signetContractAddress}`;
47
+ }
48
+ /**
49
+ * The URL of the object holding `requestId`'s attested output.
50
+ *
51
+ * @param requestId - The request whose output object to locate.
52
+ * @returns The object's public URL.
53
+ */
54
+ objectUrl(requestId) {
55
+ return `${this.namespaceUrl}/${requestId}.bin`;
56
+ }
57
+ /**
58
+ * Download the serialised output the MPC cached for `requestId`, verbatim.
59
+ * UNTRUSTED: verify the attestation signature over the returned bytes.
60
+ *
61
+ * @param requestId - The request whose attested output to fetch.
62
+ * @returns The cached bytes, or `undefined` when the cache holds no object
63
+ * for the request (the MPC has not written it yet).
64
+ * @throws {Error} If the cache cannot be reached or answers with a status
65
+ * other than 200 or 404.
66
+ */
67
+ async fetchSerializedOutput(requestId) {
68
+ const url = this.objectUrl(requestId);
69
+ const response = await fetch(url);
70
+ if (response.status === 404) {
71
+ return undefined;
72
+ }
73
+ if (!response.ok) {
74
+ throw new Error(`MPC output cache answered HTTP ${String(response.status)} for ${url}: ${await response.text()}`);
75
+ }
76
+ return new Uint8Array(await response.arrayBuffer());
77
+ }
78
+ }
79
+ //# sourceMappingURL=mpc-output-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpc-output-cache.js","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAA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AAC,SAAS,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,kCAAkC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,GAAG,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CACjG,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sig-net/midnight",
3
- "version": "0.22.0-rc.1",
3
+ "version": "0.22.0-rc.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sig-net/midnight-integration",
@@ -43,10 +43,10 @@
43
43
  // 4. MPC observes txn execution on destination chain and posts a RespondBidirectionalEvent attestation
44
44
  // through the Signet singleton, which emits it as a contract event beside the request id.
45
45
  // The client polls its request's posts and takes the first one that verifies over the request id
46
- // and output. The client recovers the execution output itself off chain (for EVM: the mined
47
- // call's return data via debug_traceTransaction, also served by the fakenet
48
- // responder's /responses/{requestId} helper API) and hands output plus attestation
49
- // to its verify circuit. See "Output recovery" in this package's README.
46
+ // and output. The client obtains the execution output off chain (for EVM: the mined
47
+ // call's return data via debug_traceTransaction, or the exact attested bytes from the
48
+ // MPC's output cache) and hands output plus attestation to its verify circuit. See
49
+ // "Output Recovery" in the repository README.
50
50
  //
51
51
  // Read more:
52
52
  // - The sign bidirectional flow and key derivation: this package's README