@sig-net/midnight 0.0.5 → 0.0.7
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 +8 -0
- package/dist/constants.d.ts +4 -16
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -16
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +79 -0
- package/dist/ecdsa-attestation.d.ts.map +1 -0
- package/dist/ecdsa-attestation.js +140 -0
- package/dist/ecdsa-attestation.js.map +1 -0
- package/dist/epsilon-derivation.d.ts +60 -0
- package/dist/epsilon-derivation.d.ts.map +1 -1
- package/dist/epsilon-derivation.js +106 -5
- package/dist/epsilon-derivation.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +70 -95
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +38 -42
- package/dist/managed/contract/index.js +225 -478
- package/dist/managed/contract/index.js.map +2 -2
- package/dist/signature-requests-state-reader.d.ts +14 -13
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +31 -20
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +5 -5
- package/dist/signature-response-verification.d.ts.map +1 -1
- package/dist/signature-response-verification.js +4 -4
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-state-reader.d.ts +102 -109
- package/dist/signet-contract-state-reader.d.ts.map +1 -1
- package/dist/signet-contract-state-reader.js +125 -119
- package/dist/signet-contract-state-reader.js.map +1 -1
- package/dist/signet-request-feed.d.ts +4 -3
- package/dist/signet-request-feed.d.ts.map +1 -1
- package/dist/signet-request-feed.js +9 -8
- package/dist/signet-request-feed.js.map +1 -1
- package/dist/signet-request-resolver.d.ts +6 -4
- package/dist/signet-request-resolver.d.ts.map +1 -1
- package/dist/signet-request-resolver.js +8 -6
- package/dist/signet-request-resolver.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +21 -20
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +35 -23
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +93 -59
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +84 -67
- package/dist/signet-requests.js.map +1 -1
- package/package.json +2 -2
- package/src/Signet.compact +275 -413
- package/src/circuits.compact +24 -25
- package/dist/schnorr.d.ts +0 -100
- package/dist/schnorr.d.ts.map +0 -1
- package/dist/schnorr.js +0 -144
- package/dist/schnorr.js.map +0 -1
- package/src/Schnorr.compact +0 -63
|
@@ -38,15 +38,17 @@ export class SignetRequestResolver {
|
|
|
38
38
|
/**
|
|
39
39
|
* Resolve a notification to its authenticated request, or `undefined` when it
|
|
40
40
|
* cannot be trusted: the caller contract has no state, or `requestId` is not
|
|
41
|
-
* a member of the
|
|
41
|
+
* a member of the map at `requestsIndexField` (forged, stale, wrong field,
|
|
42
42
|
* or not yet indexed — poll again). Never throws on an untrusted
|
|
43
43
|
* notification; a bad one is dropped, not surfaced as an error.
|
|
44
44
|
*
|
|
45
|
+
* @param requestId - The request id the notification was registered under
|
|
46
|
+
* (the registry map key — the V1 payload does not carry one).
|
|
45
47
|
* @param notification - The decoded notification.
|
|
46
48
|
* @returns The authenticated request, or `undefined` to drop the notification.
|
|
47
49
|
*/
|
|
48
|
-
async resolve(notification) {
|
|
49
|
-
const cached = this.resolvedCache.get(
|
|
50
|
+
async resolve(requestId, notification) {
|
|
51
|
+
const cached = this.resolvedCache.get(requestId);
|
|
50
52
|
if (cached !== undefined) {
|
|
51
53
|
return cached;
|
|
52
54
|
}
|
|
@@ -60,16 +62,16 @@ export class SignetRequestResolver {
|
|
|
60
62
|
if (!state?.data) {
|
|
61
63
|
return undefined; // no state at the named caller — cannot authenticate
|
|
62
64
|
}
|
|
63
|
-
const request = lookupSignetRequestAt(state.data, notification.requestsIndexField,
|
|
65
|
+
const request = lookupSignetRequestAt(state.data, notification.requestsIndexField, requestId);
|
|
64
66
|
if (request === undefined) {
|
|
65
67
|
return undefined; // membership check failed — drop the notification
|
|
66
68
|
}
|
|
67
69
|
const resolved = {
|
|
68
70
|
callerAddress: notification.callerAddress,
|
|
69
|
-
requestId
|
|
71
|
+
requestId,
|
|
70
72
|
request,
|
|
71
73
|
};
|
|
72
|
-
this.resolvedCache.set(
|
|
74
|
+
this.resolvedCache.set(requestId, resolved);
|
|
73
75
|
return resolved;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-resolver.js","sourceRoot":"","sources":["../src/signet-request-resolver.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uDAAuD;AACvD,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,6DAA6D;AAC7D,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,qCAAqC;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAiC7E;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,qBAAqB;IACf,MAAM,CAA0B;IAEjD,8EAA8E;IAC9E,4DAA4D;IAC3C,aAAa,GAAG,IAAI,GAAG,EAAuC,CAAC;IAEhF;;OAEG;IACH,YAAY,MAAmC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"signet-request-resolver.js","sourceRoot":"","sources":["../src/signet-request-resolver.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uDAAuD;AACvD,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,6DAA6D;AAC7D,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,q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Q,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PublicDataProvider } from "@midnight-ntwrk/midnight-js-types";
|
|
2
2
|
import type { Transaction } from "ethers";
|
|
3
|
-
import { type
|
|
3
|
+
import { type SignatureRespondedEvent, type RespondBidirectionalEvent } from "./signet-contract-state-reader.ts";
|
|
4
4
|
import type { RawContractState } from "./signature-state-reading.ts";
|
|
5
|
-
import { type
|
|
5
|
+
import { type SignBidirectionalEvent, type RequestIdHex } from "./signet-requests.ts";
|
|
6
6
|
/**
|
|
7
7
|
* The least of midnight-js's `PublicDataProvider` the reader needs: raw
|
|
8
8
|
* contract state by address. Declared structurally (rather than a `Pick`) so
|
|
@@ -42,19 +42,19 @@ export interface SignatureResponseVerdict {
|
|
|
42
42
|
/** 0-based position of the post in the request's response log. */
|
|
43
43
|
count: bigint;
|
|
44
44
|
/** The posted signature record, verbatim. */
|
|
45
|
-
response:
|
|
45
|
+
response: SignatureRespondedEvent;
|
|
46
46
|
/** Recovered signer address — absent when the signature did not decode. */
|
|
47
47
|
signer?: string;
|
|
48
48
|
/** Why the post was rejected; absent when the post is valid. */
|
|
49
49
|
rejectedReason?: string;
|
|
50
50
|
}
|
|
51
|
-
/** Result of {@link SignetRequestResponseReader['
|
|
51
|
+
/** Result of {@link SignetRequestResponseReader['getVerifiedSignatureRespondedEvent']}. */
|
|
52
52
|
export interface VerifiedSignatureResponseResult {
|
|
53
53
|
/**
|
|
54
54
|
* The first valid response (lowest count), or `undefined` when no valid
|
|
55
55
|
* response has been posted yet — poll again.
|
|
56
56
|
*/
|
|
57
|
-
verified?:
|
|
57
|
+
verified?: SignatureRespondedEvent;
|
|
58
58
|
/**
|
|
59
59
|
* One verdict per post, count order. Pure data: the reader never logs, so
|
|
60
60
|
* callers decide how to surface rejected posts.
|
|
@@ -93,18 +93,18 @@ export declare class SignetRequestResponseReader {
|
|
|
93
93
|
* @throws Error when the requester contract has no state or holds no
|
|
94
94
|
* request under `requestId` at the configured index field.
|
|
95
95
|
*/
|
|
96
|
-
getSignatureRequest(requestId: RequestIdHex): Promise<
|
|
96
|
+
getSignatureRequest(requestId: RequestIdHex): Promise<SignBidirectionalEvent>;
|
|
97
97
|
/**
|
|
98
98
|
* Fetch every response posted for `requestId`, in post (count) order.
|
|
99
99
|
* UNVERIFIED — any of them may be garbage; see
|
|
100
|
-
* {@link
|
|
100
|
+
* {@link getVerifiedSignatureRespondedEvent}.
|
|
101
101
|
*
|
|
102
102
|
* @param requestId - The request id whose posts to enumerate.
|
|
103
103
|
* @returns The posted payloads, index = count; empty when none yet.
|
|
104
104
|
* @throws Error when the responses contract has no state, or its counter
|
|
105
105
|
* disagrees with the log (inconsistent ledger).
|
|
106
106
|
*/
|
|
107
|
-
getSignatureResponses(requestId: RequestIdHex): Promise<
|
|
107
|
+
getSignatureResponses(requestId: RequestIdHex): Promise<SignatureRespondedEvent[]>;
|
|
108
108
|
/**
|
|
109
109
|
* Fetch and verify the responses posted for `requestId`: each post's
|
|
110
110
|
* `{ bigR, s, recoveryId }` signature must recover to `expectedSigner`
|
|
@@ -119,7 +119,7 @@ export declare class SignetRequestResponseReader {
|
|
|
119
119
|
* @throws Error when either contract has no state, the request is not on
|
|
120
120
|
* the requester's ledger, or the responses ledger is inconsistent.
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
getVerifiedSignatureRespondedEvent(requestId: RequestIdHex, expectedSigner: string): Promise<VerifiedSignatureResponseResult>;
|
|
123
123
|
/**
|
|
124
124
|
* Rebuild the unsigned EIP-1559 transaction for `requestId` — the exact
|
|
125
125
|
* transaction the MPC signs, assembled from the request record's decomposed
|
|
@@ -136,7 +136,7 @@ export declare class SignetRequestResponseReader {
|
|
|
136
136
|
/**
|
|
137
137
|
* Assemble the broadcast-ready signed EIP-1559 transaction for `requestId`:
|
|
138
138
|
* rebuild the request's transaction and attach the first VERIFIED response
|
|
139
|
-
* signed by `expectedSigner` (see {@link
|
|
139
|
+
* signed by `expectedSigner` (see {@link getVerifiedSignatureRespondedEvent} — the
|
|
140
140
|
* response log is unauthenticated, so an `expectedSigner` is required and
|
|
141
141
|
* unverified posts are never attached).
|
|
142
142
|
*
|
|
@@ -151,17 +151,18 @@ export declare class SignetRequestResponseReader {
|
|
|
151
151
|
*/
|
|
152
152
|
getSignedEVMTransaction(requestId: RequestIdHex, expectedSigner: string): Promise<Transaction | undefined>;
|
|
153
153
|
/**
|
|
154
|
-
* Fetch
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* again.
|
|
154
|
+
* Fetch every respond-bidirectional response posted for `requestId`, in
|
|
155
|
+
* post (count) order. UNVERIFIED — the signet contract stores posts without
|
|
156
|
+
* checking them, so any entry may be garbage: verify each candidate before
|
|
157
|
+
* trusting it (in-circuit at claim time, or off-chain via the compiled
|
|
158
|
+
* `pureCircuits.verifyRespondBidirectionalEvent` against the MPC derived
|
|
159
|
+
* key you expect). An empty array simply means none posted yet, poll again.
|
|
160
160
|
*
|
|
161
|
-
* @param requestId - The request id whose
|
|
162
|
-
* @returns The
|
|
163
|
-
* @throws Error when the signet contract has no state
|
|
161
|
+
* @param requestId - The request id whose responses to enumerate.
|
|
162
|
+
* @returns The posted records, index = count; empty when none yet.
|
|
163
|
+
* @throws Error when the signet contract has no state, or its counter
|
|
164
|
+
* disagrees with the log (inconsistent ledger).
|
|
164
165
|
*/
|
|
165
|
-
|
|
166
|
+
getRespondBidirectionalEvents(requestId: RequestIdHex): Promise<RespondBidirectionalEvent[]>;
|
|
166
167
|
}
|
|
167
168
|
//# sourceMappingURL=signet-request-response-reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.d.ts","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,M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AAE,MAAM,CAAC;CACzB;AAED,2FAA2F;AAC3F,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC;;;OAGG;IACH,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACtC;AAED;;;;;GAKG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAG3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAGzB;IAEJ;;OAEG;gBACS,MAAM,EAAE,iCAAiC;IAIrD;;;;;;;OAOG;YACW,aAAa;IAc3B;;;;;;;;;OASG;IACG,mBAAmB,CACvB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,sBAAsB,CAAC;IAwBlC;;;;;;;;;OASG;IACG,qBAAqB,CACzB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAwBrC;;;;;;;;;;;;;OAaG;IACG,kCAAkC,CACtC,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,+BAA+B,CAAC;IAiC3C;;;;;;;;;;;OAWG;IACG,yBAAyB,CAC7B,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,WAAW,CAAC;IAMvB;;;;;;;;;;;;;;;OAeG;IACG,uBAAuB,CAC3B,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAcnC;;;;;;;;;;;;OAYG;IACG,6BAA6B,CACjC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAuBxC"}
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
// implementation. Single-shot by design: each call queries state once; the
|
|
10
10
|
// caller owns any poll loop.
|
|
11
11
|
import { lookupSignetRequestAt } from "./signature-requests-state-reader.js";
|
|
12
|
-
import { readSignetContractLedgerFromState,
|
|
12
|
+
import { readSignetContractLedgerFromState, signetMapEntryKey, } from "./signet-contract-state-reader.js";
|
|
13
13
|
import { recoverSignatureResponseSigner } from "./signature-response-verification.js";
|
|
14
|
-
import {
|
|
14
|
+
import { signBidirectionalEventToSignedEVMTransaction, signBidirectionalEventToUnsignedEVMTransaction, } from "./signet-requests.js";
|
|
15
15
|
/**
|
|
16
16
|
* Reader over one requester contract / signet contract pair.
|
|
17
17
|
* Construct once per pair and reuse: fetched request records are cached (they
|
|
@@ -70,7 +70,7 @@ export class SignetRequestResponseReader {
|
|
|
70
70
|
/**
|
|
71
71
|
* Fetch every response posted for `requestId`, in post (count) order.
|
|
72
72
|
* UNVERIFIED — any of them may be garbage; see
|
|
73
|
-
* {@link
|
|
73
|
+
* {@link getVerifiedSignatureRespondedEvent}.
|
|
74
74
|
*
|
|
75
75
|
* @param requestId - The request id whose posts to enumerate.
|
|
76
76
|
* @returns The posted payloads, index = count; empty when none yet.
|
|
@@ -79,11 +79,11 @@ export class SignetRequestResponseReader {
|
|
|
79
79
|
*/
|
|
80
80
|
async getSignatureResponses(requestId) {
|
|
81
81
|
const raw = await this.queryRawState(this.config.signetContractAddress, "signet contract");
|
|
82
|
-
const {
|
|
83
|
-
const totalPosts =
|
|
82
|
+
const { signatureResponseCounterMap, signatureResponseMap } = readSignetContractLedgerFromState(raw);
|
|
83
|
+
const totalPosts = signatureResponseCounterMap.get(requestId) ?? 0n;
|
|
84
84
|
const responses = [];
|
|
85
85
|
for (let count = 0n; count < totalPosts; count++) {
|
|
86
|
-
const response =
|
|
86
|
+
const response = signatureResponseMap.get(signetMapEntryKey(requestId, count));
|
|
87
87
|
if (response === undefined) {
|
|
88
88
|
throw new Error(`response log has no entry ${count} for request ${requestId} ` +
|
|
89
89
|
`despite its counter reading ${totalPosts} — ledger state is inconsistent`);
|
|
@@ -106,7 +106,7 @@ export class SignetRequestResponseReader {
|
|
|
106
106
|
* @throws Error when either contract has no state, the request is not on
|
|
107
107
|
* the requester's ledger, or the responses ledger is inconsistent.
|
|
108
108
|
*/
|
|
109
|
-
async
|
|
109
|
+
async getVerifiedSignatureRespondedEvent(requestId, expectedSigner) {
|
|
110
110
|
const request = await this.getSignatureRequest(requestId);
|
|
111
111
|
const responses = await this.getSignatureResponses(requestId);
|
|
112
112
|
const verdicts = responses.map((response, index) => {
|
|
@@ -150,12 +150,12 @@ export class SignetRequestResponseReader {
|
|
|
150
150
|
* request under `requestId`.
|
|
151
151
|
*/
|
|
152
152
|
async getUnsignedEVMTransaction(requestId) {
|
|
153
|
-
return
|
|
153
|
+
return signBidirectionalEventToUnsignedEVMTransaction(await this.getSignatureRequest(requestId));
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Assemble the broadcast-ready signed EIP-1559 transaction for `requestId`:
|
|
157
157
|
* rebuild the request's transaction and attach the first VERIFIED response
|
|
158
|
-
* signed by `expectedSigner` (see {@link
|
|
158
|
+
* signed by `expectedSigner` (see {@link getVerifiedSignatureRespondedEvent} — the
|
|
159
159
|
* response log is unauthenticated, so an `expectedSigner` is required and
|
|
160
160
|
* unverified posts are never attached).
|
|
161
161
|
*
|
|
@@ -169,30 +169,42 @@ export class SignetRequestResponseReader {
|
|
|
169
169
|
* requester's ledger, or the responses ledger is inconsistent.
|
|
170
170
|
*/
|
|
171
171
|
async getSignedEVMTransaction(requestId, expectedSigner) {
|
|
172
|
-
const { verified } = await this.
|
|
172
|
+
const { verified } = await this.getVerifiedSignatureRespondedEvent(requestId, expectedSigner);
|
|
173
173
|
if (verified === undefined) {
|
|
174
174
|
return undefined;
|
|
175
175
|
}
|
|
176
|
-
// getSignatureRequest is cached —
|
|
176
|
+
// getSignatureRequest is cached — getVerifiedSignatureRespondedEvent already
|
|
177
177
|
// fetched it, so this is a free lookup, not a second query.
|
|
178
178
|
const request = await this.getSignatureRequest(requestId);
|
|
179
|
-
return
|
|
179
|
+
return signBidirectionalEventToSignedEVMTransaction(request, verified);
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
* Fetch
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* again.
|
|
182
|
+
* Fetch every respond-bidirectional response posted for `requestId`, in
|
|
183
|
+
* post (count) order. UNVERIFIED — the signet contract stores posts without
|
|
184
|
+
* checking them, so any entry may be garbage: verify each candidate before
|
|
185
|
+
* trusting it (in-circuit at claim time, or off-chain via the compiled
|
|
186
|
+
* `pureCircuits.verifyRespondBidirectionalEvent` against the MPC derived
|
|
187
|
+
* key you expect). An empty array simply means none posted yet, poll again.
|
|
188
188
|
*
|
|
189
|
-
* @param requestId - The request id whose
|
|
190
|
-
* @returns The
|
|
191
|
-
* @throws Error when the signet contract has no state
|
|
189
|
+
* @param requestId - The request id whose responses to enumerate.
|
|
190
|
+
* @returns The posted records, index = count; empty when none yet.
|
|
191
|
+
* @throws Error when the signet contract has no state, or its counter
|
|
192
|
+
* disagrees with the log (inconsistent ledger).
|
|
192
193
|
*/
|
|
193
|
-
async
|
|
194
|
+
async getRespondBidirectionalEvents(requestId) {
|
|
194
195
|
const raw = await this.queryRawState(this.config.signetContractAddress, "signet contract");
|
|
195
|
-
|
|
196
|
+
const { respondBidirectionalCounterMap, respondBidirectionalMap } = readSignetContractLedgerFromState(raw);
|
|
197
|
+
const totalPosts = respondBidirectionalCounterMap.get(requestId) ?? 0n;
|
|
198
|
+
const responses = [];
|
|
199
|
+
for (let count = 0n; count < totalPosts; count++) {
|
|
200
|
+
const response = respondBidirectionalMap.get(signetMapEntryKey(requestId, count));
|
|
201
|
+
if (response === undefined) {
|
|
202
|
+
throw new Error(`respond-bidirectional log has no entry ${count} for request ${requestId} ` +
|
|
203
|
+
`despite its counter reading ${totalPosts} — ledger state is inconsistent`);
|
|
204
|
+
}
|
|
205
|
+
responses.push(response);
|
|
206
|
+
}
|
|
207
|
+
return responses;
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
//# sourceMappingURL=signet-request-response-reader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,uBAAuB;AACvB,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,6BAA6B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,iCAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,uBAAuB;AACvB,yEAAyE;AACzE,4EAA4E;AAC5E,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,6BAA6B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,iCAAiC,EACjC,iBAAiB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAG/C,MAAM,sBAAsB,CAAC;AAgE9B;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACrB,MAAM,CAAoC;IAE3D,qEAAqE;IACpD,YAAY,GAAG,IAAI,GAAG,EAGpC,CAAC;IAEJ;;OAEG;IACH,YAAY,MAAyC;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,aAAa,CACzB,eAAuB,EACvB,IAAY;QAEZ,MAAM,KAAK,GACT,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;YACjB,MA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CAAC;QACvE,MAAM,SAAS,GAAgC,EAAE,CAAC;QAClD,KAAK,IAAI,KAAK,GAAG,EAAE,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC;YACjD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,GAAG,CAC1C,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CACpC,CAAC;YACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,0CAA0C,KAAK,gBAAgB,SAAS,GAAG;oBACzE,+BAA+B,UAAU,iCAAiC,CAC7E,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { type CompactType } from "@midnight-ntwrk/compact-runtime";
|
|
2
2
|
import { Signature, Transaction } from "ethers";
|
|
3
|
-
import type {
|
|
3
|
+
import type { SignatureRespondedEvent } from "./signet-contract-state-reader.ts";
|
|
4
4
|
/**
|
|
5
5
|
* 32-byte signet request id (Compact: `new type RequestId = Bytes<32>`).
|
|
6
6
|
* Chain-agnostic: downstream consumers treat it as an opaque key. Ids are
|
|
7
|
-
* minted by `calculateRequestId` in Signet.compact — the
|
|
8
|
-
*
|
|
7
|
+
* minted by `calculateRequestId` in Signet.compact — the persistent hash of
|
|
8
|
+
* the full {@link SignBidirectionalEvent} record (which includes the sender
|
|
9
|
+
* contract address, scoping ids per contract).
|
|
9
10
|
*/
|
|
10
11
|
export type RequestId = Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* A Midnight contract address as the generated code represents it in struct
|
|
14
|
+
* fields (Compact `ContractAddress`): a single-field wrapper around the raw
|
|
15
|
+
* 32 address bytes.
|
|
16
|
+
*/
|
|
17
|
+
export interface ContractAddress {
|
|
18
|
+
bytes: Uint8Array;
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Which transaction-param decomposition a request carries (Compact:
|
|
13
22
|
* `enum TxParamType`), as the generated code represents enums: a `number`
|
|
@@ -24,6 +33,26 @@ export declare const TxParamType: {
|
|
|
24
33
|
*/
|
|
25
34
|
readonly reserved: 1;
|
|
26
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Which signature algorithm the MPC uses (Compact:
|
|
38
|
+
* `enum MPCSignatureAlgorithm`), 0-based variant index.
|
|
39
|
+
*/
|
|
40
|
+
export declare const MPCSignatureAlgorithm: {
|
|
41
|
+
/** ECDSA over secp256k1. */
|
|
42
|
+
readonly ecdsa: 0;
|
|
43
|
+
/** Never emitted — the >= 2 variants padding (see {@link TxParamType}). */
|
|
44
|
+
readonly reserved: 1;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The MPC destination field (Compact: `enum MPCDestination`), 0-based
|
|
48
|
+
* variant index. Reserved for future use.
|
|
49
|
+
*/
|
|
50
|
+
export declare const MPCDestination: {
|
|
51
|
+
/** The only currently-valid value. */
|
|
52
|
+
readonly unused: 0;
|
|
53
|
+
/** Never emitted — the >= 2 variants padding (see {@link TxParamType}). */
|
|
54
|
+
readonly reserved: 1;
|
|
55
|
+
};
|
|
27
56
|
/**
|
|
28
57
|
* Compact's standard-library `Maybe<T>` as the compiler generates it: a
|
|
29
58
|
* plain struct. Even when `is_some` is false, `value` carries a full
|
|
@@ -71,7 +100,7 @@ export interface EVMAccessListEntry {
|
|
|
71
100
|
export interface EVMType2TxParams {
|
|
72
101
|
/** Call target (e.g. the ERC20 contract), 20 bytes. */
|
|
73
102
|
to: Uint8Array;
|
|
74
|
-
/** EVM chain id (also expressed in {@link
|
|
103
|
+
/** EVM chain id (also expressed in {@link SignBidirectionalEvent.caip2Id}). */
|
|
75
104
|
chainId: bigint;
|
|
76
105
|
/** Account nonce of the MPC-derived sender address. */
|
|
77
106
|
nonce: bigint;
|
|
@@ -92,35 +121,39 @@ export interface EVMType2TxParams {
|
|
|
92
121
|
}
|
|
93
122
|
/**
|
|
94
123
|
* Canonical signet request record (Compact:
|
|
95
|
-
* `
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* the type parameter at {@link EVMType2TxParams} — the only
|
|
100
|
-
* so far; new tx kinds add a union here alongside their
|
|
101
|
-
|
|
102
|
-
|
|
124
|
+
* `SignBidirectionalEvent<TxParams, #LenOutputDeserialization,
|
|
125
|
+
* #LenRespondSerialization>`), stored per {@link RequestId} in a requesting
|
|
126
|
+
* contract's `SignBidirectionalEventMap` (at whichever ledger field the
|
|
127
|
+
* contract declares it — its notifications name the position). The TS twin
|
|
128
|
+
* fixes the tx-params type parameter at {@link EVMType2TxParams} — the only
|
|
129
|
+
* decomposition so far; new tx kinds add a union here alongside their
|
|
130
|
+
* Compact struct. The schema fields carry their contract-declared byte
|
|
131
|
+
* widths in their array lengths.
|
|
132
|
+
*/
|
|
133
|
+
export interface SignBidirectionalEvent {
|
|
134
|
+
/** Address of the client contract that stores this event (`kernel.self()`). */
|
|
135
|
+
sender: ContractAddress;
|
|
103
136
|
/** Contract-local nonce captured when the request was created. */
|
|
104
137
|
requestNonce: bigint;
|
|
138
|
+
/** MPC root-key version to derive from (>= 1). */
|
|
139
|
+
keyVersion: bigint;
|
|
140
|
+
/** Key-derivation path: 32 opaque bytes of the client contract's choosing. */
|
|
141
|
+
path: Uint8Array;
|
|
142
|
+
/** An {@link MPCSignatureAlgorithm} value. */
|
|
143
|
+
algo: number;
|
|
144
|
+
/** An {@link MPCDestination} value. */
|
|
145
|
+
dest: number;
|
|
146
|
+
/** Extra MPC parameters, reserved; 64 bytes. */
|
|
147
|
+
params: Uint8Array;
|
|
105
148
|
/** A {@link TxParamType} value tagging the txParams decomposition. */
|
|
106
149
|
txParamType: number;
|
|
107
150
|
/** The transaction decomposition. */
|
|
108
151
|
txParams: EVMType2TxParams;
|
|
109
152
|
/** Target chain in CAIP-2 form (https://chainagnostic.org/CAIPs/caip-2), zero-padded; 32 bytes. */
|
|
110
153
|
caip2Id: Uint8Array;
|
|
111
|
-
/** MPC
|
|
112
|
-
keyVersion: bigint;
|
|
113
|
-
/** Key-derivation path: canonical lowercase hex of the caller's identity commitment, zero-padded; 256 bytes. */
|
|
114
|
-
path: Uint8Array;
|
|
115
|
-
/** Signature scheme, zero-padded ASCII, e.g. "ecdsa"; 32 bytes. */
|
|
116
|
-
algo: Uint8Array;
|
|
117
|
-
/** Response destination, zero-padded ASCII, e.g. "ethereum"; 32 bytes. */
|
|
118
|
-
dest: Uint8Array;
|
|
119
|
-
/** Scheme-specific extras, opaque; 64 bytes. */
|
|
120
|
-
params: Uint8Array;
|
|
121
|
-
/** MPC output_deserialization_schema (destination chain -> MPC); 128 bytes. */
|
|
154
|
+
/** MPC output_deserialization_schema (destination chain -> MPC); contract-declared width. */
|
|
122
155
|
outputDeserializationSchema: Uint8Array;
|
|
123
|
-
/** MPC respond_serialization_schema (MPC ->
|
|
156
|
+
/** MPC respond_serialization_schema (MPC -> Midnight); contract-declared width. */
|
|
124
157
|
respondSerializationSchema: Uint8Array;
|
|
125
158
|
}
|
|
126
159
|
/**
|
|
@@ -151,25 +184,31 @@ export declare function evmAccessListEntryDescriptor(maxStorageKeys: number): Co
|
|
|
151
184
|
*/
|
|
152
185
|
export declare function evmType2TxParamsDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number): CompactType<EVMType2TxParams>;
|
|
153
186
|
/**
|
|
154
|
-
* Descriptor of {@link
|
|
187
|
+
* Descriptor of {@link SignBidirectionalEvent} at one capacity instantiation.
|
|
155
188
|
*
|
|
156
189
|
* @param maxCalldataWords - Calldata word capacity.
|
|
157
190
|
* @param maxAccessListEntries - Access-list entry capacity.
|
|
158
191
|
* @param maxStorageKeysPerEntry - Storage-key capacity per entry.
|
|
159
|
-
* @
|
|
192
|
+
* @param lenOutputDeserialization - Declared byte width of
|
|
193
|
+
* `outputDeserializationSchema` (Compact `#LenOutputDeserialization`).
|
|
194
|
+
* @param lenRespondSerialization - Declared byte width of
|
|
195
|
+
* `respondSerializationSchema` (Compact `#LenRespondSerialization`).
|
|
196
|
+
* @returns The event record descriptor.
|
|
160
197
|
*/
|
|
161
|
-
export declare function
|
|
198
|
+
export declare function signBidirectionalEventDescriptor(maxCalldataWords: number, maxAccessListEntries: number, maxStorageKeysPerEntry: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent>;
|
|
162
199
|
/**
|
|
163
|
-
* Canonical id of a signet request: the
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
200
|
+
* Canonical id of a signet request: the persistent hash of the entire event
|
|
201
|
+
* record (which commits to every field, the sender address included — there
|
|
202
|
+
* is deliberately no extra domain tag). TS twin of Signet.compact's
|
|
203
|
+
* `calculateRequestId` circuit (see the deviation note atop this section),
|
|
204
|
+
* generic over the capacity instantiation via the record's own array
|
|
205
|
+
* lengths — pass the record exactly as the ledger stores it, unused slots
|
|
206
|
+
* included and schemas at their declared widths.
|
|
168
207
|
*
|
|
169
|
-
* @param request - The full
|
|
208
|
+
* @param request - The full event record (contract-shaped, all slots).
|
|
170
209
|
* @returns The 32-byte request id — the record's ledger map key.
|
|
171
210
|
*/
|
|
172
|
-
export declare function calculateRequestId(request:
|
|
211
|
+
export declare function calculateRequestId(request: SignBidirectionalEvent): RequestId;
|
|
173
212
|
/**
|
|
174
213
|
* The 32-byte value of a numeric ABI word: the little-endian field embed of
|
|
175
214
|
* the number, exactly what Compact's `x as Field as Bytes<32>` cast produces
|
|
@@ -218,7 +257,7 @@ export declare function assembleCalldata(calldata: Maybe<EVMCalldata>): string;
|
|
|
218
257
|
* MPC signs).
|
|
219
258
|
* @throws Error if a calldata word carries an unknown kind.
|
|
220
259
|
*/
|
|
221
|
-
export declare function
|
|
260
|
+
export declare function signBidirectionalEventToUnsignedEVMTransaction(request: SignBidirectionalEvent): Transaction;
|
|
222
261
|
/**
|
|
223
262
|
* Decode a response signature record (as posted to the signet contract's
|
|
224
263
|
* signature response log — the canonical MPC `Signature { big_r, s,
|
|
@@ -229,10 +268,10 @@ export declare function signBidirectionalRequestToUnsignedEVMTransaction(request
|
|
|
229
268
|
* @returns The ethers signature.
|
|
230
269
|
* @throws Error if the recovery id is not 0 or 1.
|
|
231
270
|
*/
|
|
232
|
-
export declare function
|
|
271
|
+
export declare function signatureRespondedEventToSignature(response: SignatureRespondedEvent): Signature;
|
|
233
272
|
/**
|
|
234
273
|
* Encode an ECDSA signature as the response record posted to the signet
|
|
235
|
-
* contract — the inverse of {@link
|
|
274
|
+
* contract — the inverse of {@link signatureRespondedEventToSignature},
|
|
236
275
|
* for MPC-side posters (the fakenet signer, tests). The canonical record
|
|
237
276
|
* carries `bigR` as a full affine point but an `r || s || v` signature only
|
|
238
277
|
* has R.x and the parity of R.y, so R.y is recovered by decompressing the
|
|
@@ -247,14 +286,14 @@ export declare function signatureResponseToSignature(response: SignatureResponse
|
|
|
247
286
|
* @returns The response record, ready to post.
|
|
248
287
|
* @throws Error if `r` is not the x coordinate of a curve point.
|
|
249
288
|
*/
|
|
250
|
-
export declare function
|
|
289
|
+
export declare function signatureToSignatureRespondedEvent(signature: Pick<Signature, "r" | "s" | "yParity">): SignatureRespondedEvent;
|
|
251
290
|
/**
|
|
252
291
|
* Assemble the broadcast-ready signed EIP-1559 transaction for a request from
|
|
253
292
|
* its MPC signature response: rebuild the exact unsigned transaction the MPC
|
|
254
|
-
* signed (see {@link
|
|
293
|
+
* signed (see {@link signBidirectionalEventToUnsignedEVMTransaction}) and
|
|
255
294
|
* attach the signature. Does NOT check that the signature recovers to the
|
|
256
295
|
* requester's derived address — the response log is unauthenticated, so
|
|
257
|
-
* verify first with `
|
|
296
|
+
* verify first with `verifySignatureRespondedEvent`.
|
|
258
297
|
*
|
|
259
298
|
* @param request - The on-ledger request record.
|
|
260
299
|
* @param response - The posted signature record answering it.
|
|
@@ -262,16 +301,16 @@ export declare function signatureToSignatureResponse(signature: Pick<Signature,
|
|
|
262
301
|
* `eth_sendRawTransaction`, `hash` its on-chain hash, `from` the recovered
|
|
263
302
|
* sender.
|
|
264
303
|
* @throws Error if the request record is malformed (see
|
|
265
|
-
* {@link
|
|
304
|
+
* {@link signBidirectionalEventToUnsignedEVMTransaction}) or the response
|
|
266
305
|
* is not a decodable signature.
|
|
267
306
|
*/
|
|
268
|
-
export declare function
|
|
307
|
+
export declare function signBidirectionalEventToSignedEVMTransaction(request: SignBidirectionalEvent, response: SignatureRespondedEvent): Transaction;
|
|
269
308
|
/**
|
|
270
|
-
* The generated ledger shape of `Map<RequestId,
|
|
309
|
+
* The generated ledger shape of `Map<RequestId, SignBidirectionalEvent>`:
|
|
271
310
|
* what a contract's `ledger(state).signetRequestsIndex` provides. Structural,
|
|
272
311
|
* so any contract exposing the index satisfies it.
|
|
273
312
|
*/
|
|
274
|
-
export interface
|
|
313
|
+
export interface SignBidirectionalEventLedgerMap extends Iterable<[RequestId, SignBidirectionalEvent]> {
|
|
275
314
|
/** @returns `true` when the index holds no requests. */
|
|
276
315
|
isEmpty(): boolean;
|
|
277
316
|
/** @returns Number of requests in the index. */
|
|
@@ -286,7 +325,7 @@ export interface SignBidirectionalRequestLedgerIndex extends Iterable<[RequestId
|
|
|
286
325
|
* @returns The stored request record; throws when absent — guard with
|
|
287
326
|
* {@link member} first.
|
|
288
327
|
*/
|
|
289
|
-
lookup(requestId: RequestId):
|
|
328
|
+
lookup(requestId: RequestId): SignBidirectionalEvent;
|
|
290
329
|
}
|
|
291
330
|
declare const requestIdHexBrand: unique symbol;
|
|
292
331
|
/**
|
|
@@ -303,7 +342,7 @@ export type RequestIdHex = string & {
|
|
|
303
342
|
readonly [requestIdHexBrand]: true;
|
|
304
343
|
};
|
|
305
344
|
/** Plain-JS index parsed out of the ledger, keyed by hex request id. */
|
|
306
|
-
export type
|
|
345
|
+
export type SignBidirectionalEventIndex = Map<RequestIdHex, SignBidirectionalEvent>;
|
|
307
346
|
/**
|
|
308
347
|
* Render bytes as a lowercase hex string, no `0x` prefix.
|
|
309
348
|
*
|
|
@@ -352,27 +391,22 @@ export declare function parseRequestIdHex(value: string): RequestIdHex;
|
|
|
352
391
|
* @returns The 32-byte request id.
|
|
353
392
|
*/
|
|
354
393
|
export declare function requestIdBytes(id: RequestIdHex): RequestId;
|
|
355
|
-
/** Byte width of the path field (Compact `Bytes<256>`). */
|
|
356
|
-
export declare const PATH_BYTES = 256;
|
|
357
394
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* @param commitment - 32-byte identity commitment.
|
|
364
|
-
* @returns The 256-byte path field value.
|
|
395
|
+
* Byte width of the path field (Compact `Bytes<32>`): 32 opaque bytes of the
|
|
396
|
+
* client contract's choosing. Keys the MPC signs with are derived from
|
|
397
|
+
* (contract address, path), so a contract can only ever reach keys scoped to
|
|
398
|
+
* itself.
|
|
365
399
|
*/
|
|
366
|
-
export declare
|
|
400
|
+
export declare const PATH_BYTES = 32;
|
|
367
401
|
/**
|
|
368
402
|
* Parse the on-ledger request map into a plain-JS index keyed by hex
|
|
369
403
|
* request id.
|
|
370
404
|
*
|
|
371
405
|
* @param ledgerIndex - Iterable of `[requestId, request]` entries — e.g. a
|
|
372
|
-
* contract's `ledger(state).
|
|
373
|
-
* {@link
|
|
406
|
+
* contract's `ledger(state).signBidirectionalEventMap` (any
|
|
407
|
+
* {@link SignBidirectionalEventLedgerMap}).
|
|
374
408
|
* @returns A new `Map` from {@link requestIdHex} key to request record.
|
|
375
409
|
*/
|
|
376
|
-
export declare function
|
|
410
|
+
export declare function toSignBidirectionalEventIndex(ledgerIndex: Iterable<[RequestId, SignBidirectionalEvent]>): SignBidirectionalEventIndex;
|
|
377
411
|
export {};
|
|
378
412
|
//# sourceMappingURL=signet-requests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAgBA,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAwB,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAgBA,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAwB,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,CAAC;CACnB;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB,6DAA6D;;IAE7D;;;;OAIG;;CAEK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAChC,4BAA4B;;IAE5B,2EAA2E;;CAEnE,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB,sCAAsC;;IAEtC,2EAA2E;;CAEnE,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,QAAQ,EAAE,UAAU,CAAC;IACrB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,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,sEAA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