@sig-net/midnight 0.26.0-rc.3 → 0.26.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/constants.d.ts +5 -18
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -32
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +1 -1
- package/dist/ecdsa-attestation.js +1 -1
- package/dist/managed/compiler/contract-info.json +7 -21
- package/dist/managed/compiler/contract-manifest.json +12 -11
- package/dist/managed/contract/index.d.ts +2 -4
- package/dist/managed/contract/index.js +417 -313
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/raw-contract-state.d.ts +2 -2
- package/dist/record-contract-address.d.ts +10 -27
- package/dist/record-contract-address.d.ts.map +1 -1
- package/dist/record-contract-address.js +17 -54
- package/dist/record-contract-address.js.map +1 -1
- package/dist/signature-requests-state-reader.d.ts +2 -2
- package/dist/signature-requests-state-reader.js +2 -2
- package/dist/signature-response-verification.js +3 -3
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-events.d.ts +7 -7
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +9 -11
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-request-response-reader.d.ts +15 -19
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +11 -9
- package/dist/signet-request-response-reader.js.map +1 -1
- package/package.json +5 -5
- package/src/Signet.compact +15 -14
- package/src/circuits.compact +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.d.ts","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.d.ts","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAA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;;;;;;;;;;;;;;OAcG;IACG,uBAAuB,CAC3B,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAQlC;IAED;;;;;;;;OAQG;IACG,6BAA6B,CACjC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAEtC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACG,oCAAoC,CACxC,SAAS,EAAE,YAAY,EACvB,gBAAgB,EAAE,UAAU,EAC5B,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAMhD;CACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Client-side reader for the signet request/response flow: fetch a request
|
|
2
2
|
// record from the requester contract's ledger, read the request's responses
|
|
3
|
-
// out of the contract events the signet
|
|
3
|
+
// out of the contract events the signet contract emits, and verify each
|
|
4
4
|
// candidate against the request. The request id a response declares is
|
|
5
5
|
// UNAUTHENTICATED routing data: VERIFICATION establishes authenticity.
|
|
6
6
|
// Single-shot: each call queries once, and the caller owns any poll loop.
|
|
7
|
+
import { ContractState } from "@midnight-ntwrk/compact-runtime";
|
|
7
8
|
import { verifyAttestedOutput, verifyRespondBidirectionalAttestation, } from "./ecdsa-attestation.js";
|
|
8
9
|
import { lookupSignetRequestAt } from "./signature-requests-state-reader.js";
|
|
9
10
|
import { recoverSignatureResponseSigner } from "./signature-response-verification.js";
|
|
@@ -44,7 +45,7 @@ function firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey
|
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* `SignetRequestResponseReader.getVerifiedRespondBidirectionalEvent` over
|
|
47
|
-
* decoded events already in hand: no walk of the
|
|
48
|
+
* decoded events already in hand: no walk of the signet contract's event
|
|
48
49
|
* history, and no ledger read either, since the attestation verifies against
|
|
49
50
|
* the output and the response key alone.
|
|
50
51
|
*
|
|
@@ -62,7 +63,7 @@ export function findVerifiedRespondBidirectionalEvent(requestId, serializedOutpu
|
|
|
62
63
|
return firstVerifiedRespondBidirectionalEvent(serializedOutput, mpcResponseKey, signetEventRecordsOf(events, SignetEventName.RespondBidirectionalEvent, requestId));
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
|
-
* Reader over one requester contract /
|
|
66
|
+
* Reader over one requester contract / signet contract pair. Construct once
|
|
66
67
|
* per pair and reuse: fetched request records are cached, so repeated
|
|
67
68
|
* verification calls cost one event query each.
|
|
68
69
|
*/
|
|
@@ -91,10 +92,11 @@ export class SignetRequestResponseReader {
|
|
|
91
92
|
if (cached !== undefined) {
|
|
92
93
|
return cached;
|
|
93
94
|
}
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
95
|
+
const read = await this.config.publicDataProvider.queryContractState(this.config.requesterContractAddress);
|
|
96
|
+
if (read === null) {
|
|
96
97
|
throw new Error(`no state data found for requester contract '${this.config.requesterContractAddress}' (is it deployed?)`);
|
|
97
98
|
}
|
|
99
|
+
const state = read.contractState.deserialize({ v9: ContractState });
|
|
98
100
|
const request = lookupSignetRequestAt(state.data, this.config.requesterRequestsPath, requestId);
|
|
99
101
|
if (request === undefined) {
|
|
100
102
|
throw new Error(`request ${requestId} is not on the requester contract's ledger ` +
|
|
@@ -104,7 +106,7 @@ export class SignetRequestResponseReader {
|
|
|
104
106
|
return request;
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
|
-
* Fetch the
|
|
109
|
+
* Fetch the signet contract's posts of event `name` that declare
|
|
108
110
|
* `requestId`, in emission order. The declared id is routing data only.
|
|
109
111
|
*
|
|
110
112
|
* @param name - The signet event name to keep.
|
|
@@ -113,9 +115,9 @@ export class SignetRequestResponseReader {
|
|
|
113
115
|
*/
|
|
114
116
|
async getRecordsNamed(name, requestId) {
|
|
115
117
|
const records = [];
|
|
116
|
-
const events = this.config.eventSource.streamSignetEvents(this.config.
|
|
118
|
+
const events = this.config.eventSource.streamSignetEvents(this.config.signetContractAddress, this.config.signetEventsFromBlock === undefined
|
|
117
119
|
? undefined
|
|
118
|
-
: { fromBlock: this.config.
|
|
120
|
+
: { fromBlock: this.config.signetEventsFromBlock });
|
|
119
121
|
for await (const event of events) {
|
|
120
122
|
const decoded = decodeSignetEventNamed(event, name);
|
|
121
123
|
if (decoded?.requestId === requestId)
|
|
@@ -154,7 +156,7 @@ export class SignetRequestResponseReader {
|
|
|
154
156
|
/**
|
|
155
157
|
* {@link getVerifiedSignatureRespondedEvent} over decoded events already in
|
|
156
158
|
* hand: the one ledger read for the request (cached), and no walk of the
|
|
157
|
-
*
|
|
159
|
+
* signet contract's event history. For a consumer that streamed and decoded
|
|
158
160
|
* the history once and verifies many requests against it.
|
|
159
161
|
*
|
|
160
162
|
* @param requestId - The request id to verify responses for.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"signet-request-response-reader.js","sourceRoot":"","sources":["../src/signet-request-response-reader.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAOhE,OAAO,EAEL,oBAAoB,EACpB,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAEL,sBAAsB,EAGtB,eAAe,EAEf,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4CAA4C,EAC5C,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAkD,WAAW,EAAE,MAAM,s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,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAC9F,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,4CAA4C,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,6BAA6B,CACjC,SAAuB;QAEvB,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,oCAAoC,CACxC,SAAuB,EACvB,gBAA4B,EAC5B,cAA8B;QAE9B,OAAO,sCAAsC,CAC3C,gBAAgB,EAChB,cAAc,EACd,MAAM,IAAI,CAAC,6BAA6B,CAAC,SAAS,CAAC,CACpD,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight",
|
|
3
|
-
"version": "0.26.0-rc.
|
|
3
|
+
"version": "0.26.0-rc.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"src/*.compact"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
|
-
"compile": "compact compile --skip-zk
|
|
27
|
+
"compile": "compact compile --skip-zk src/circuits.compact src/managed",
|
|
28
28
|
"build": "rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig.build.json && cp -R src/managed dist/managed",
|
|
29
29
|
"prepack": "yarn build",
|
|
30
30
|
"record-contract-address": "tsx record-contract-address.ts",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@midnight-ntwrk/compact-runtime": "0.
|
|
50
|
-
"@midnight-ntwrk/midnight-js-types": "5.0.0
|
|
49
|
+
"@midnight-ntwrk/compact-runtime": "0.21.0",
|
|
50
|
+
"@midnight-ntwrk/midnight-js-types": "5.0.0",
|
|
51
51
|
"@noble/curves": "^2.2.0",
|
|
52
|
-
"@sig-net/midnight-serde": "^0.26.0-rc.
|
|
52
|
+
"@sig-net/midnight-serde": "^0.26.0-rc.6",
|
|
53
53
|
"ethers": "^6.17.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
package/src/Signet.compact
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
// Distributed MPC network to execute arbitrary transactions on foreign
|
|
9
9
|
// blockchains.
|
|
10
10
|
// - Signet singleton: a single contract on the Midnight blockchain through which clients notify
|
|
11
|
-
// the MPC of signature requests
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// the MPC of signature requests, and through which the MPC posts back
|
|
12
|
+
// signatures and signed attestations of foreign executions. Each post is
|
|
13
|
+
// emitted as a contract event (the execution outputs themselves travel off
|
|
14
|
+
// chain).
|
|
15
15
|
//
|
|
16
16
|
// Usage:
|
|
17
17
|
// // Import this module at the start of a contract (resolved through node_modules via COMPACT_PATH):
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// (executed, failed or unviable).
|
|
31
31
|
//
|
|
32
32
|
// The V1 suffix marks the wire and hash-domain artefacts of protocol version 1 (the structs the
|
|
33
|
-
// ledger stores and the
|
|
33
|
+
// ledger stores and the singleton emits, and the circuits that hash, verify or construct them).
|
|
34
34
|
// Vocabulary shared across versions (RequestId, OutputKind, Signature, the enums, the transaction
|
|
35
35
|
// parameter structs, which TxParamType tags) and the version-tagged notification carry no suffix.
|
|
36
36
|
//
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
// 2. MPC polls the Signet singleton contract's events for SignBidirectionalEventNotifications and
|
|
43
43
|
// uses each one to look the declared SignBidirectionalEvent signature request up in the named
|
|
44
44
|
// client's own ledger. It generates the signature and posts a SignatureRespondedEvent (the requested
|
|
45
|
-
// signature) through the Signet
|
|
46
|
-
// 3. Client polls the Signet
|
|
45
|
+
// signature) through the Signet singleton, which emits it as a contract event.
|
|
46
|
+
// 3. Client polls the Signet singleton contract's SignatureRespondedEvent events, identifying the response
|
|
47
47
|
// associated with their request by RequestId. Clients validate the signature is correct by checking with
|
|
48
48
|
// the requested signing key. Then it broadcasts the signed txn to the target chain.
|
|
49
49
|
// 4. MPC observes the txn's outcome in a final block on the target chain (executed, failed,
|
|
50
50
|
// or unviable when another request's transaction took its nonce) and posts a
|
|
51
|
-
// RespondBidirectionalEvent attestation through the Signet
|
|
51
|
+
// RespondBidirectionalEvent attestation through the Signet singleton, which emits it as a
|
|
52
52
|
// contract event beside the request id.
|
|
53
53
|
// The client polls its request's posts and takes the first one that verifies over the request id,
|
|
54
54
|
// block height, output kind and output. The client obtains the execution output off chain (for EVM: the mined
|
|
@@ -322,10 +322,10 @@ module Signet {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
// Counterpart to SignBidirectionalEvent: the MPC generated signature a request asked for.
|
|
325
|
-
// Posted by the MPC through the Signet
|
|
325
|
+
// Posted by the MPC through the Signet singleton for clients to extract and build a
|
|
326
326
|
// signed transaction from.
|
|
327
327
|
export struct SignatureRespondedEventV1 {
|
|
328
|
-
// The request this signature answers. Routing data: the
|
|
328
|
+
// The request this signature answers. Routing data: the singleton emits it
|
|
329
329
|
// unverified, and a reader proves the signature against the request's own key.
|
|
330
330
|
requestId: RequestId;
|
|
331
331
|
// The requested signature over the transaction the request describes.
|
|
@@ -349,7 +349,7 @@ module Signet {
|
|
|
349
349
|
// (verifyRespondBidirectionalAttestationV1), and the output checks against the
|
|
350
350
|
// event's length and hash (verifyAttestedOutputV1). The signature
|
|
351
351
|
// is the ONLY thing that distinguishes a genuine post from garbage: the
|
|
352
|
-
//
|
|
352
|
+
// singleton emits every post unverified.
|
|
353
353
|
export struct RespondBidirectionalEventV1 {
|
|
354
354
|
// The request this attestation answers. Signed into the digest: a verified
|
|
355
355
|
// post settles exactly the request it names, so a client consumes this id
|
|
@@ -447,7 +447,9 @@ module Signet {
|
|
|
447
447
|
respondBidirectionalEvent.outputHash,
|
|
448
448
|
);
|
|
449
449
|
|
|
450
|
-
|
|
450
|
+
// secp256k1EcdsaVerify aborts on the identity point, so the key check
|
|
451
|
+
// must short-circuit before it.
|
|
452
|
+
return mpcResponseKey != default<Secp256k1Point> && secp256k1EcdsaVerify(
|
|
451
453
|
digest,
|
|
452
454
|
Secp256k1EcdsaSignature {
|
|
453
455
|
r: respondBidirectionalEvent.signature.bigR.x as Secp256k1Scalar,
|
|
@@ -455,7 +457,6 @@ module Signet {
|
|
|
455
457
|
},
|
|
456
458
|
mpcResponseKey
|
|
457
459
|
);
|
|
458
|
-
return mpcResponseKey != default<Secp256k1Point> && signatureVerifies;
|
|
459
460
|
}
|
|
460
461
|
|
|
461
462
|
// Whether serializedOutput is the output an attestation declares: its width
|
|
@@ -480,7 +481,7 @@ module Signet {
|
|
|
480
481
|
// against the event's length and hash) and the event's signature verifies
|
|
481
482
|
// (verifyRespondBidirectionalAttestationV1, whose byte-order and abort
|
|
482
483
|
// contract applies here too). Client contracts run this before consuming
|
|
483
|
-
// outputs, as the
|
|
484
|
+
// outputs, as the singleton emits responses unverified. The caller supplies
|
|
484
485
|
// serializedOutput at its exact unpadded width.
|
|
485
486
|
export pure circuit verifyRespondBidirectionalEventV1<#serializedOutputLength>(
|
|
486
487
|
serializedOutput: Bytes<serializedOutputLength>,
|
package/src/circuits.compact
CHANGED
|
@@ -3,7 +3,7 @@ pragma language_version >= 0.25;
|
|
|
3
3
|
// Compiled export surface of the Signet module: a contract-less program
|
|
4
4
|
// re-exporting its pure circuits as pureCircuits for unit tests and
|
|
5
5
|
// off-chain code. Only non-generic circuits can be exported. Compile with
|
|
6
|
-
// --skip-zk
|
|
6
|
+
// --skip-zk.
|
|
7
7
|
|
|
8
8
|
import CompactStandardLibrary;
|
|
9
9
|
import "./Signet";
|