@sig-net/midnight 0.19.0 → 0.20.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/abi-serde.d.ts +32 -30
- package/dist/abi-serde.d.ts.map +1 -1
- package/dist/abi-serde.js +139 -75
- package/dist/abi-serde.js.map +1 -1
- package/dist/byte-codecs.d.ts +62 -0
- package/dist/byte-codecs.d.ts.map +1 -0
- package/dist/byte-codecs.js +116 -0
- package/dist/byte-codecs.js.map +1 -0
- package/dist/compact-descriptors.d.ts +89 -0
- package/dist/compact-descriptors.d.ts.map +1 -0
- package/dist/compact-descriptors.js +139 -0
- package/dist/compact-descriptors.js.map +1 -0
- package/dist/constants.d.ts +18 -43
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -45
- package/dist/constants.js.map +1 -1
- package/dist/ecdsa-attestation.d.ts +49 -97
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +78 -142
- package/dist/ecdsa-attestation.js.map +1 -1
- package/dist/epsilon-derivation.d.ts +24 -31
- package/dist/epsilon-derivation.d.ts.map +1 -1
- package/dist/epsilon-derivation.js +52 -62
- package/dist/epsilon-derivation.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/managed/compiler/contract-info.json +0 -22
- package/dist/managed/compiler/contract-manifest.json +8 -8
- package/dist/managed/contract/index.d.ts +0 -3
- package/dist/managed/contract/index.js +65 -80
- package/dist/managed/contract/index.js.map +1 -1
- package/dist/raw-contract-state.d.ts +25 -0
- package/dist/raw-contract-state.d.ts.map +1 -0
- package/dist/raw-contract-state.js +52 -0
- package/dist/raw-contract-state.js.map +1 -0
- package/dist/signature-requests-state-reader.d.ts +18 -44
- package/dist/signature-requests-state-reader.d.ts.map +1 -1
- package/dist/signature-requests-state-reader.js +82 -146
- package/dist/signature-requests-state-reader.js.map +1 -1
- package/dist/signature-response-verification.d.ts +9 -8
- package/dist/signature-response-verification.d.ts.map +1 -1
- package/dist/signature-response-verification.js +20 -17
- package/dist/signature-response-verification.js.map +1 -1
- package/dist/signet-contract-events.d.ts +56 -64
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +46 -48
- package/dist/signet-contract-events.js.map +1 -1
- package/dist/signet-evtype2tx-record-decoding.d.ts +18 -0
- package/dist/signet-evtype2tx-record-decoding.d.ts.map +1 -0
- package/dist/signet-evtype2tx-record-decoding.js +97 -0
- package/dist/signet-evtype2tx-record-decoding.js.map +1 -0
- package/dist/signet-evtype2tx-requests.d.ts +43 -87
- package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
- package/dist/signet-evtype2tx-requests.js +59 -130
- package/dist/signet-evtype2tx-requests.js.map +1 -1
- package/dist/signet-request-id.d.ts +14 -0
- package/dist/signet-request-id.d.ts.map +1 -0
- package/dist/signet-request-id.js +27 -0
- package/dist/signet-request-id.js.map +1 -0
- package/dist/signet-request-response-reader.d.ts +34 -56
- package/dist/signet-request-response-reader.d.ts.map +1 -1
- package/dist/signet-request-response-reader.js +56 -68
- package/dist/signet-request-response-reader.js.map +1 -1
- package/dist/signet-requests.d.ts +28 -92
- package/dist/signet-requests.d.ts.map +1 -1
- package/dist/signet-requests.js +39 -141
- package/dist/signet-requests.js.map +1 -1
- package/dist/testing.d.ts +3 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +20 -0
- package/dist/testing.js.map +1 -0
- package/package.json +12 -3
- package/src/Signet.compact +110 -171
- package/src/circuits.compact +9 -16
- package/dist/signature-state-reading.d.ts +0 -43
- package/dist/signature-state-reading.d.ts.map +0 -1
- package/dist/signature-state-reading.js +0 -74
- package/dist/signature-state-reading.js.map +0 -1
- package/dist/signet-request-feed.d.ts +0 -126
- package/dist/signet-request-feed.d.ts.map +0 -1
- package/dist/signet-request-feed.js +0 -216
- package/dist/signet-request-feed.js.map +0 -1
package/dist/constants.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// structs, and the published per-network counterparty values (the MPC root
|
|
3
3
|
// public key and the signet contract address). Field widths mirror
|
|
4
4
|
// Signet.compact (the wire format: keep in lockstep), and the string
|
|
5
|
-
// constants are the values the MPC network routes on.
|
|
6
|
-
// contract-cli signet/constants.ts, adapted to the refactor's zero-padded
|
|
7
|
-
// convention (Compact `pad(N, "text")`).
|
|
5
|
+
// constants are the values the MPC network routes on.
|
|
8
6
|
//
|
|
9
7
|
// The routing constants belong in github.com/sig-net/signet.js, kept here
|
|
10
8
|
// until upstreamed.
|
|
@@ -17,32 +15,17 @@ export const SELECTOR_BYTES = 4;
|
|
|
17
15
|
/**
|
|
18
16
|
* The complete serialised output the MPC attests for a FAILED remote
|
|
19
17
|
* execution (reverted or replaced transaction): the 4-byte error marker
|
|
20
|
-
* `0xdeadbeef` followed by one `0x01` byte
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* The exact-equality check ({@link isMpcFailureOutput}) is unambiguous for
|
|
27
|
-
* every respond schema whose packed width differs from 5 bytes. A schema
|
|
28
|
-
* whose packed width is exactly 5 could in principle produce a legitimate
|
|
29
|
-
* output equal to this sentinel, and such clients must route settlement by
|
|
30
|
-
* digest-candidate matching (recompute both the real-output candidate and
|
|
31
|
-
* the failure candidate, and see which digest the MPC attested), never by
|
|
32
|
-
* inspecting output bytes.
|
|
18
|
+
* `0xdeadbeef` followed by one `0x01` byte, mirroring the canonical MPC's
|
|
19
|
+
* failure payload (sig-net/mpc, node/src/respond_bidirectional.rs). A
|
|
20
|
+
* respond schema whose packed width is exactly 5 bytes could produce a
|
|
21
|
+
* legitimate output equal to this sentinel: such clients must route
|
|
22
|
+
* settlement by digest-candidate matching, never by inspecting output
|
|
23
|
+
* bytes. See {@link isMpcFailureOutput}.
|
|
33
24
|
*/
|
|
34
25
|
export const MPC_FAILURE_OUTPUT = new Uint8Array([0xde, 0xad, 0xbe, 0xef, 0x01]);
|
|
35
26
|
/**
|
|
36
27
|
* Whether an attested serialised output IS the MPC's fixed failure payload:
|
|
37
|
-
* exact byte equality with the 5-byte {@link MPC_FAILURE_OUTPUT}
|
|
38
|
-
* must be exactly 5 and every byte must match). A prefix check would be
|
|
39
|
-
* unsafe, as a legitimate packed output can begin with the same bytes.
|
|
40
|
-
*
|
|
41
|
-
* Unambiguous for every respond schema whose packed width differs from 5
|
|
42
|
-
* bytes. A schema whose packed width is exactly 5 could in principle produce
|
|
43
|
-
* a legitimate output equal to the sentinel: such clients must route
|
|
44
|
-
* settlement by digest-candidate matching instead of inspecting output
|
|
45
|
-
* bytes (see {@link MPC_FAILURE_OUTPUT}).
|
|
28
|
+
* exact byte equality with the 5-byte {@link MPC_FAILURE_OUTPUT}.
|
|
46
29
|
*
|
|
47
30
|
* @param serializedOutput - The attested serialised output.
|
|
48
31
|
* @returns `true` when the output equals the MPC failure payload exactly.
|
|
@@ -52,9 +35,8 @@ export function isMpcFailureOutput(serializedOutput) {
|
|
|
52
35
|
MPC_FAILURE_OUTPUT.every((byte, index) => serializedOutput[index] === byte));
|
|
53
36
|
}
|
|
54
37
|
/**
|
|
55
|
-
* Default MPC key version (`keyVersion` field value).
|
|
56
|
-
*
|
|
57
|
-
* `constructSignBidirectionalEvent`) requires `keyVersion >= 1`.
|
|
38
|
+
* Default MPC key version (`keyVersion` field value). The canonical MPC
|
|
39
|
+
* (and `constructSignBidirectionalEvent`) requires `keyVersion >= 1`.
|
|
58
40
|
*/
|
|
59
41
|
export const SIGNET_DEFAULT_KEY_VERSION = 1n;
|
|
60
42
|
/**
|
|
@@ -65,12 +47,12 @@ export const SIGNET_DEFAULT_KEY_VERSION = 1n;
|
|
|
65
47
|
* @param text - The ASCII text to encode.
|
|
66
48
|
* @param length - The fixed field width in bytes.
|
|
67
49
|
* @returns `text`'s bytes followed by zero padding to exactly `length`.
|
|
68
|
-
* @throws If the encoded text does not fit in `length` bytes.
|
|
50
|
+
* @throws {Error} If the encoded text does not fit in `length` bytes.
|
|
69
51
|
*/
|
|
70
52
|
export function asciiPadded(text, length) {
|
|
71
53
|
const encoded = new TextEncoder().encode(text);
|
|
72
54
|
if (encoded.length > length) {
|
|
73
|
-
throw new Error(`"${text}" is ${encoded.length} bytes: does not fit the ${length}-byte field`);
|
|
55
|
+
throw new Error(`"${text}" is ${String(encoded.length)} bytes: does not fit the ${String(length)}-byte field`);
|
|
74
56
|
}
|
|
75
57
|
const out = new Uint8Array(length);
|
|
76
58
|
out.set(encoded);
|
|
@@ -78,10 +60,7 @@ export function asciiPadded(text, length) {
|
|
|
78
60
|
}
|
|
79
61
|
/**
|
|
80
62
|
* A named Midnight network: the single source of the network names shared
|
|
81
|
-
* across the `@sig-net/midnight*` packages.
|
|
82
|
-
* as a bare `string` with no companion enum, so the names live here, and
|
|
83
|
-
* `@sig-net/midnight-contract-deploy`'s network-id plumbing widens this
|
|
84
|
-
* enum back to the SDK's string type for its deploy config.
|
|
63
|
+
* across the `@sig-net/midnight*` packages.
|
|
85
64
|
*/
|
|
86
65
|
export var MidnightNetwork;
|
|
87
66
|
(function (MidnightNetwork) {
|
|
@@ -108,14 +87,12 @@ const mpcRootPublicKeys = {
|
|
|
108
87
|
/**
|
|
109
88
|
* The MPC root public key of a deployed Midnight network, as hex: the
|
|
110
89
|
* `mpcRootPublicKey` every client key derivation starts from (see
|
|
111
|
-
* `deriveEvmAddress`).
|
|
112
|
-
*
|
|
113
|
-
* `MPC_ROOT_KEY` per stack (the integration-test setup prints it and
|
|
114
|
-
* appends it to the repo-root `.env`).
|
|
90
|
+
* `deriveEvmAddress`). A local standalone stack has no fixed key: its setup
|
|
91
|
+
* generates a fresh `MPC_ROOT_KEY` per stack.
|
|
115
92
|
*
|
|
116
93
|
* @param networkId - The deployed network to look up.
|
|
117
94
|
* @returns The network's MPC root public key.
|
|
118
|
-
* @throws Error
|
|
95
|
+
* @throws {Error} When the network's key is not yet published in this package.
|
|
119
96
|
*/
|
|
120
97
|
export function getMpcRootPublicKey(networkId) {
|
|
121
98
|
const publicKey = mpcRootPublicKeys[networkId];
|
|
@@ -136,15 +113,12 @@ const signetContractAddresses = {
|
|
|
136
113
|
/**
|
|
137
114
|
* The address of the central signet singleton contract on a deployed
|
|
138
115
|
* Midnight network: the `signetContractAddress` a
|
|
139
|
-
* `SignetRequestResponseReader` polls.
|
|
140
|
-
*
|
|
141
|
-
* stack deploys its own singleton (the integration-test setup prints the
|
|
142
|
-
* address as `MIDNIGHT_SIGNET_CONTRACT_ADDRESS` and appends it to the
|
|
143
|
-
* repo-root `.env`).
|
|
116
|
+
* `SignetRequestResponseReader` polls. A local standalone stack has no
|
|
117
|
+
* fixed address: each stack deploys its own singleton.
|
|
144
118
|
*
|
|
145
119
|
* @param networkId - The deployed network to look up.
|
|
146
120
|
* @returns The network's signet contract address.
|
|
147
|
-
* @throws Error
|
|
121
|
+
* @throws {Error} When the singleton's address is not yet published in this
|
|
148
122
|
* package.
|
|
149
123
|
*/
|
|
150
124
|
export function getSignetContractAddress(networkId) {
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,
|
|
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,GA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import { Signature } from "ethers";
|
|
3
|
+
import type { MpcSignature, RespondBidirectionalEvent, SignatureRespondedEvent } from "./signet-contract-events.ts";
|
|
2
4
|
import type { RequestId } from "./signet-requests.ts";
|
|
3
|
-
import type { MpcSignature, RespondBidirectionalEvent } from "./signet-contract-events.ts";
|
|
4
5
|
export type { Secp256k1Point } from "@midnight-ntwrk/compact-runtime";
|
|
5
6
|
/** secp256k1 curve (group) order n. */
|
|
6
7
|
export declare const SECP256K1_ORDER: bigint;
|
|
7
|
-
/** BLS12-381 scalar field order (the Compact `Field` type modulus). */
|
|
8
|
-
export declare const BLS_ORDER = 52435875175126190479447740508185965837690552500527637822603658699938581184513n;
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param bytes - Little-endian byte array.
|
|
15
|
-
* @returns The decoded non-negative integer.
|
|
16
|
-
*/
|
|
17
|
-
export declare function bytesToBigint(bytes: Uint8Array): bigint;
|
|
18
|
-
/**
|
|
19
|
-
* Convert a bigint to exactly 32 little-endian bytes. Matches Compact's
|
|
20
|
-
* `Field as Bytes<32>` / `Secp256k1Scalar as Bytes<32>` encoding (the inverse
|
|
21
|
-
* of {@link bytesToBigint}). Negative inputs are interpreted in the BLS
|
|
22
|
-
* scalar field.
|
|
23
|
-
*
|
|
24
|
-
* @param n - The integer to encode.
|
|
25
|
-
* @returns The 32-byte little-endian encoding.
|
|
26
|
-
*/
|
|
27
|
-
export declare function bigintToBytes32(n: bigint): Uint8Array;
|
|
28
|
-
/**
|
|
29
|
-
* Convert big-endian bytes to a bigint (SEC1 coordinate order, the byte
|
|
30
|
-
* order the respond events' stored signature uses).
|
|
31
|
-
*
|
|
32
|
-
* @param bytes - Big-endian byte array.
|
|
33
|
-
* @returns The decoded non-negative integer.
|
|
34
|
-
*/
|
|
35
|
-
export declare function bytesToBigintBE(bytes: Uint8Array): bigint;
|
|
36
|
-
/**
|
|
37
|
-
* Convert a bigint to exactly 32 BIG-endian bytes (SEC1 scalar/coordinate
|
|
38
|
-
* order, also the ABI word encoding): the big-endian counterpart of
|
|
39
|
-
* {@link bigintToBytes32} and the inverse of {@link bytesToBigintBE}.
|
|
40
|
-
*
|
|
41
|
-
* @param value - The non-negative integer to encode.
|
|
42
|
-
* @returns The 32-byte big-endian encoding.
|
|
43
|
-
* @throws Error if the value is negative or does not fit 32 bytes.
|
|
44
|
-
*/
|
|
45
|
-
export declare function bigintToBytes32BE(value: bigint): Uint8Array;
|
|
46
|
-
/**
|
|
47
|
-
* An ECDSA signature over the attestation digest, in the MPC's canonical
|
|
48
|
-
* `Signature { big_r, s, recovery_id }` spirit with `r` already reduced to
|
|
49
|
-
* the scalar `big_r.x mod n`, the form Compact's `Secp256k1EcdsaSignature`
|
|
50
|
-
* takes. Build the stored form for posting in a respond event with
|
|
51
|
-
* {@link ecdsaSignatureToMpcSignature}.
|
|
9
|
+
* An ECDSA signature in scalar form: what {@link signAttestationDigest}
|
|
10
|
+
* produces, and what {@link ecdsaSignatureToMpcSignature} encodes into the
|
|
11
|
+
* stored form respond events carry.
|
|
52
12
|
*/
|
|
53
13
|
export interface EcdsaSignature {
|
|
54
14
|
/** Signature scalar r (= R.x mod n). */
|
|
@@ -60,46 +20,60 @@ export interface EcdsaSignature {
|
|
|
60
20
|
}
|
|
61
21
|
/**
|
|
62
22
|
* ECDSA-sign a 32-byte digest with a secp256k1 secret key, exactly as the
|
|
63
|
-
* MPC signs the attestation digest:
|
|
64
|
-
*
|
|
65
|
-
* convention `secp256k1EcdsaVerify` checks in-circuit.
|
|
23
|
+
* MPC signs the attestation digest: the result verifies in-circuit against
|
|
24
|
+
* the matching public key. For posters and test fixtures.
|
|
66
25
|
*
|
|
67
26
|
* @param digest - The 32-byte digest to sign (e.g. the
|
|
68
27
|
* {@link calculateSignetAttestationDigest} output).
|
|
69
28
|
* @param secretKey - The 32-byte secp256k1 secret key.
|
|
70
29
|
* @returns The signature with its recovery id.
|
|
30
|
+
* @throws {Error} If no recovery id reproduces the signer's own public key.
|
|
71
31
|
*/
|
|
72
32
|
export declare function signAttestationDigest(digest: Uint8Array, secretKey: Uint8Array): EcdsaSignature;
|
|
73
33
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* x = `r` and the parity `recoveryId` names, undoing the compression an
|
|
77
|
-
* `r || s || v` signature performs. For MPC-side posters (the fakenet
|
|
78
|
-
* signer, tests). The negligible caveat: an R.x that overflowed the curve
|
|
79
|
-
* order cannot be told apart from its reduced twin, so reconstruction picks
|
|
80
|
-
* the x equal to `r` itself.
|
|
34
|
+
* Encode a scalar-form signature as the stored-form record both respond
|
|
35
|
+
* events carry. For MPC-side posters (the fakenet signer) and test fixtures.
|
|
81
36
|
*
|
|
82
37
|
* @param signature - The scalar-form signature (the signer's output shape).
|
|
83
38
|
* @returns The stored-form signature: R as a full point, big-endian bytes.
|
|
84
|
-
* @throws Error
|
|
39
|
+
* @throws {Error} If the recovery id is not 0 or 1, or `r` is not the x
|
|
85
40
|
* coordinate of a secp256k1 point.
|
|
86
41
|
*/
|
|
87
42
|
export declare function ecdsaSignatureToMpcSignature(signature: EcdsaSignature): MpcSignature;
|
|
88
43
|
/**
|
|
89
|
-
*
|
|
44
|
+
* Decode a stored-form signature back to scalar form: the inverse of
|
|
90
45
|
* {@link ecdsaSignatureToMpcSignature}, for off-chain consumers building a
|
|
91
|
-
* transaction from the response.
|
|
92
|
-
*
|
|
93
|
-
* are unauthenticated and a malformed record is garbage. `bigR.y` is NOT
|
|
94
|
-
* checked against the curve or the recovery id: signature verification is
|
|
95
|
-
* the authority, not this decoder.
|
|
46
|
+
* transaction from the response. Checks shape only: acceptance does not mean
|
|
47
|
+
* the signature verifies.
|
|
96
48
|
*
|
|
97
49
|
* @param signature - The stored-form signature as posted.
|
|
98
50
|
* @returns The scalar-form signature.
|
|
99
|
-
* @throws Error
|
|
51
|
+
* @throws {Error} If a component has the wrong byte length or the recovery id
|
|
100
52
|
* is not 0 or 1.
|
|
101
53
|
*/
|
|
102
54
|
export declare function mpcSignatureToEcdsaSignature(signature: MpcSignature): EcdsaSignature;
|
|
55
|
+
/**
|
|
56
|
+
* Decode a posted response signature record into an ethers
|
|
57
|
+
* {@link Signature}. Ethers' `r` is the ECDSA scalar (`bigR.x` reduced mod
|
|
58
|
+
* the curve order), not the raw coordinate.
|
|
59
|
+
*
|
|
60
|
+
* @param response - The posted signature record.
|
|
61
|
+
* @returns The ethers signature.
|
|
62
|
+
* @throws {Error} If the record is malformed (see {@link mpcSignatureToEcdsaSignature}).
|
|
63
|
+
*/
|
|
64
|
+
export declare function signatureRespondedEventToSignature(response: SignatureRespondedEvent): Signature;
|
|
65
|
+
/**
|
|
66
|
+
* Encode an ethers signature as the {@link SignatureRespondedEvent} record a
|
|
67
|
+
* responder posts: the inverse of {@link signatureRespondedEventToSignature}.
|
|
68
|
+
* Responder-side (the fakenet posts through this; clients only verify), so
|
|
69
|
+
* it is exported through the `./testing` entry point with the other
|
|
70
|
+
* posting-side helpers.
|
|
71
|
+
*
|
|
72
|
+
* @param signature - The signature to encode (`r`/`s` as 0x hex, `yParity` 0 or 1).
|
|
73
|
+
* @returns The response record, ready to post.
|
|
74
|
+
* @throws {Error} If `r` is not the x coordinate of a secp256k1 point.
|
|
75
|
+
*/
|
|
76
|
+
export declare function signatureToSignatureRespondedEvent(signature: Pick<Signature, "r" | "s" | "yParity">): SignatureRespondedEvent;
|
|
103
77
|
/**
|
|
104
78
|
* Parse a secp256k1 public key from SEC1 hex (compressed or uncompressed,
|
|
105
79
|
* optional `0x` prefix) into the Compact runtime's `Secp256k1Point` shape:
|
|
@@ -107,7 +81,7 @@ export declare function mpcSignatureToEcdsaSignature(signature: MpcSignature): E
|
|
|
107
81
|
*
|
|
108
82
|
* @param value - The SEC1 hex public key.
|
|
109
83
|
* @returns The parsed point.
|
|
110
|
-
* @throws Error
|
|
84
|
+
* @throws {Error} If the value is not a valid secp256k1 public key.
|
|
111
85
|
*/
|
|
112
86
|
export declare function parseSecp256k1PublicKey(value: string): Secp256k1Point;
|
|
113
87
|
/**
|
|
@@ -130,18 +104,10 @@ export declare function secp256k1PublicKeyOf(secretKey: Uint8Array): Secp256k1Po
|
|
|
130
104
|
/**
|
|
131
105
|
* The attestation digest of a respond-bidirectional response:
|
|
132
106
|
* `keccak256(requestId || serializedOutput)`, the 32-byte digest the MPC
|
|
133
|
-
* ECDSA-signs to attest a remote execution.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* compiled, so this is the one sanctioned re-implementation, pinned
|
|
138
|
-
* byte-for-byte against the fixed-width oracle circuits in
|
|
139
|
-
* circuits.compact). The constructions agree because the circuit's keccak
|
|
140
|
-
* preimage of the `[RequestId, Bytes<N>]` pair is the raw concatenated
|
|
141
|
-
* bytes, and it matches the MPC's respond-bidirectional hash
|
|
142
|
-
* (`hash(request_id || serialized_output)`: one flat concatenation, one
|
|
143
|
-
* hash). The output is hashed AS GIVEN, at its exact length: no padding and
|
|
144
|
-
* no length binding.
|
|
107
|
+
* ECDSA-signs to attest a remote execution. TS twin of the size-generic
|
|
108
|
+
* Compact circuit of the same name, pinned against its fixed-width oracle
|
|
109
|
+
* circuits in tests. The output is hashed as given, at its exact length:
|
|
110
|
+
* no padding, no length prefix.
|
|
145
111
|
*
|
|
146
112
|
* @param requestId - The 32-byte request id the response answers.
|
|
147
113
|
* @param serializedOutput - The serialised execution output, exact unpadded bytes.
|
|
@@ -149,31 +115,17 @@ export declare function secp256k1PublicKeyOf(secretKey: Uint8Array): Secp256k1Po
|
|
|
149
115
|
*/
|
|
150
116
|
export declare function calculateSignetAttestationDigest(requestId: RequestId, serializedOutput: Uint8Array): Uint8Array;
|
|
151
117
|
/**
|
|
152
|
-
* Off-chain
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* check is the ONLY way to tell a genuine post from garbage: the signet
|
|
158
|
-
* contract's event log is unauthenticated and every post is emitted
|
|
159
|
-
* unverified. Use it to sift the candidates
|
|
160
|
-
* {@link SignetRequestResponseReader.getRespondBidirectionalEvents}
|
|
161
|
-
* returns before handing one to a contract. It is the off-chain counterpart
|
|
162
|
-
* of the in-circuit `verifyRespondBidirectionalEvent` and answers the same
|
|
163
|
-
* question, so a post this accepts is the post that proves at claim time.
|
|
164
|
-
*
|
|
165
|
-
* Malformed records are garbage, not faults: a signature whose components
|
|
166
|
-
* have the wrong width, whose `r` is off-curve, or which simply does not
|
|
167
|
-
* verify all return `false` rather than throwing. High-`s` signatures are
|
|
168
|
-
* accepted, matching the in-circuit verification (which enforces no low-`s`
|
|
169
|
-
* policy) rather than the signer's own normalisation.
|
|
118
|
+
* Off-chain twin of the in-circuit `verifyRespondBidirectionalEvent`: checks
|
|
119
|
+
* a posted respond-bidirectional attestation against the execution output
|
|
120
|
+
* and the contract's pinned MPC response key. Clients run it to sift
|
|
121
|
+
* candidate posts before calling a contract: a post this accepts verifies
|
|
122
|
+
* in-circuit. Malformed records return `false` rather than throwing.
|
|
170
123
|
*
|
|
171
124
|
* @param requestId - The 32-byte request id the response answers.
|
|
172
125
|
* @param serializedOutput - The serialised execution output, exact unpadded bytes.
|
|
173
126
|
* @param event - The posted record to check, as read off the ledger.
|
|
174
|
-
* @param mpcResponseKey - The response key the requesting contract pinned
|
|
175
|
-
*
|
|
176
|
-
* path (see {@link deriveMidnightResponseKey}).
|
|
127
|
+
* @param mpcResponseKey - The response key the requesting contract pinned
|
|
128
|
+
* (see {@link deriveMidnightResponseKey}).
|
|
177
129
|
* @returns Whether the post is a genuine attestation of that output.
|
|
178
130
|
*/
|
|
179
131
|
export declare function verifyRespondBidirectionalSignature(requestId: RequestId, serializedOutput: Uint8Array, event: RespondBidirectionalEvent, mpcResponseKey: Secp256k1Point): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecdsa-attestation.d.ts","sourceRoot":"","sources":["../src/ecdsa-attestation.ts"],"names":[],"mappings":"
|
|
1
|
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