@sig-net/midnight 0.19.0 → 0.21.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 +66 -96
- package/dist/ecdsa-attestation.d.ts.map +1 -1
- package/dist/ecdsa-attestation.js +115 -140
- 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 +102 -225
- 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 +67 -66
- package/dist/signet-contract-events.d.ts.map +1 -1
- package/dist/signet-contract-events.js +57 -52
- 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 +149 -198
- 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
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
"sourceRoot": "../../../",
|
|
5
5
|
"sources": ["src/circuits.compact", "src/./Signet.compact", "compiler/zkir-v3-library.compact"],
|
|
6
6
|
"names": [],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;MCoOE,MAAA,6CAsBC;;OAAA;MA2JD,MAAA,iBAEC;;OAAA;MAID,MAAA,cASC;;OAAA;MAID,MAAA,WAEC;;OAAA;MAMD,MAAA,gBAmCC;;OAAA;MAID,MAAA,aAKC;;OAAA;MDlcH,MAAA,iCAKC;;OAAA;MAED,MAAA,kCAKC;;OAAA;MAED,MAAA,mCAKC;;OAAA;MAED,MAAA,iCAYC;;OAAA;;;;GACA;EA5DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DC;EEhCD,AAAA,yBAA8B;UACtB,iBAAI;UACJ,gCACQ;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA;0CACA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mCAKC;;;;UAJC,WAAoB;UACpB,kBAA4B;;;;;;;;;;;;;;;iEAD5B,WAAoB;iEACpB,kBAA4B;GAG7B;EAED,AAAA,iCAYC;;;;UAXC,WAAoB;UACpB,kBAA2B;UAC3B,2BAAoD;UACpD,gBAA8B;;;;;;;;;;;;;;;;;;;;;;+DAH9B,WAAoB;+DACpB,kBAA2B;+DAC3B,2BAAoD;+DACpD,gBAA8B;GAQ/B;;;;;;"
|
|
8
8
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StateValue } from "@midnight-ntwrk/compact-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* What the indexer / simulator hands us: a bare `StateValue`, or anything
|
|
4
|
+
* wrapping one under `.state` (e.g. `ChargedState`,
|
|
5
|
+
* `queryContractState(address).data`).
|
|
6
|
+
*/
|
|
7
|
+
export type RawContractState = StateValue | {
|
|
8
|
+
state: StateValue;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Follow a resolved ledger-tree path to its node in raw state: the
|
|
12
|
+
* MPC-perspective primitive, given only a contract's raw state and the path
|
|
13
|
+
* a notification carries. The path is the value compactc records for a
|
|
14
|
+
* field in the client's own `contract-info.json` (`"index"`): a
|
|
15
|
+
* single-element path (`[4]`) for a flat contract's field, a longer one
|
|
16
|
+
* (`[1, 14]`) once the compiler stores fields in a chunk tree.
|
|
17
|
+
*
|
|
18
|
+
* @param raw - Raw contract state from the indexer or simulator.
|
|
19
|
+
* @param path - Resolved chunk-tree path in declaration order.
|
|
20
|
+
* @returns The `StateValue` node at the end of the path.
|
|
21
|
+
* @throws {Error} If `path` is empty, steps into a non-array, an index is out
|
|
22
|
+
* of range, or the runtime binding misreports a node as an array.
|
|
23
|
+
*/
|
|
24
|
+
export declare function signetFieldNodeByPath(raw: RawContractState, path: readonly number[]): StateValue;
|
|
25
|
+
//# sourceMappingURL=raw-contract-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-contract-state.d.ts","sourceRoot":"","sources":["../src/raw-contract-state.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAUlE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CA+BhG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Raw contract state and the walk over it: the state shape every signet
|
|
2
|
+
// reader accepts, and the resolved ledger-tree path walk that finds a
|
|
3
|
+
// contract's ledger fields in it.
|
|
4
|
+
/**
|
|
5
|
+
* Unwrap a {@link RawContractState} to the underlying `StateValue`.
|
|
6
|
+
*
|
|
7
|
+
* @param raw - Bare state value or a `.state`-carrying wrapper.
|
|
8
|
+
* @returns The bare `StateValue`.
|
|
9
|
+
*/
|
|
10
|
+
const unwrap = (raw) => ("state" in raw ? raw.state : raw);
|
|
11
|
+
/**
|
|
12
|
+
* Follow a resolved ledger-tree path to its node in raw state: the
|
|
13
|
+
* MPC-perspective primitive, given only a contract's raw state and the path
|
|
14
|
+
* a notification carries. The path is the value compactc records for a
|
|
15
|
+
* field in the client's own `contract-info.json` (`"index"`): a
|
|
16
|
+
* single-element path (`[4]`) for a flat contract's field, a longer one
|
|
17
|
+
* (`[1, 14]`) once the compiler stores fields in a chunk tree.
|
|
18
|
+
*
|
|
19
|
+
* @param raw - Raw contract state from the indexer or simulator.
|
|
20
|
+
* @param path - Resolved chunk-tree path in declaration order.
|
|
21
|
+
* @returns The `StateValue` node at the end of the path.
|
|
22
|
+
* @throws {Error} If `path` is empty, steps into a non-array, an index is out
|
|
23
|
+
* of range, or the runtime binding misreports a node as an array.
|
|
24
|
+
*/
|
|
25
|
+
export function signetFieldNodeByPath(raw, path) {
|
|
26
|
+
if (path.length === 0) {
|
|
27
|
+
throw new Error("Ledger field path is empty");
|
|
28
|
+
}
|
|
29
|
+
let node = unwrap(raw);
|
|
30
|
+
for (const [level, index] of path.entries()) {
|
|
31
|
+
if (node.type() !== "array") {
|
|
32
|
+
// A one-field contract stores its field as the bare (non-array) root,
|
|
33
|
+
// addressable only as the whole state at a final [0]. The compiled
|
|
34
|
+
// accessor reads it the same way.
|
|
35
|
+
if (index === 0 && level === path.length - 1)
|
|
36
|
+
return node;
|
|
37
|
+
throw new Error(`Ledger field path ${JSON.stringify(path)} steps into a non-array at level ${String(level)}`);
|
|
38
|
+
}
|
|
39
|
+
const entries = node.asArray();
|
|
40
|
+
if (entries === undefined) {
|
|
41
|
+
throw new Error(`Ledger state node at level ${String(level)} of path ${JSON.stringify(path)} reports ` +
|
|
42
|
+
`type "array" but asArray() returned undefined: runtime binding contract violation`);
|
|
43
|
+
}
|
|
44
|
+
const next = entries[index];
|
|
45
|
+
if (next === undefined) {
|
|
46
|
+
throw new Error(`Ledger field path ${JSON.stringify(path)} index ${String(index)} out of range at level ${String(level)}`);
|
|
47
|
+
}
|
|
48
|
+
node = next;
|
|
49
|
+
}
|
|
50
|
+
return node;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=raw-contract-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-contract-state.js","sourceRoot":"","sources":["../src/raw-contract-state.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sEAAsE;AACtE,kCAAkC;AAWlC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,GAAqB,EAAc,EAAE,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEzF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAqB,EAAE,IAAuB;IAClF,IAAI,IAAI,CAAC,MA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";
|
|
1
2
|
import { type RequestIdHex, type SignBidirectionalEvent, type SignBidirectionalEventIndex } from "./signet-requests.ts";
|
|
2
|
-
import { type RawContractState } from "./signature-state-reading.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Aligned-value entry count of an event record EXCLUDING the capacity-scaled
|
|
5
|
-
* vectors: sender (1) + requestNonce (1) + keyVersion (1) + path (1) +
|
|
6
|
-
* algo (1) + dest (1) + params (1) + txParamType (1, enums are one atom
|
|
7
|
-
* whatever their byte width) + the EvmType2TxParams fixed fields
|
|
8
|
-
* (chainId..value = 7, accessListEntryCount = 1) + the calldata Maybe's
|
|
9
|
-
* is_some (1), selector (1) and noWords (1) + caip2Id (1) + the two schema
|
|
10
|
-
* fields (1 each). A stored event cell therefore holds
|
|
11
|
-
* `REQUEST_FIXED_VALUE_ATOMS + maxCalldataWords
|
|
12
|
-
* + maxAccessListEntries·(2 + maxStorageKeysPerEntry)`
|
|
13
|
-
* entries (each calldata word is one Bytes<32> atom, and each access-list
|
|
14
|
-
* entry is address + storageKeyCount + its keys).
|
|
15
|
-
*/
|
|
16
|
-
export declare const REQUEST_FIXED_VALUE_ATOMS = 22;
|
|
17
3
|
/**
|
|
18
4
|
* The decoded signet ledger fields of a requesting contract: its request
|
|
19
5
|
* index and its contract-local request counter (Compact `Counter`), the
|
|
20
|
-
* source of each request's `requestNonce`.
|
|
21
|
-
* counter: it is decoded here only because both fields travel together in
|
|
22
|
-
* tests and diagnostics.
|
|
6
|
+
* source of each request's `requestNonce`.
|
|
23
7
|
*/
|
|
24
8
|
export interface SignetRequestsLedger {
|
|
25
9
|
/** The request counter (`Counter`). */
|
|
@@ -29,47 +13,37 @@ export interface SignetRequestsLedger {
|
|
|
29
13
|
}
|
|
30
14
|
/**
|
|
31
15
|
* MPC-style read: parse the signet ledger fields out of raw contract state
|
|
32
|
-
* by field
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* contract it points at).
|
|
16
|
+
* by caller-supplied field positions. A contract chooses its own layout, so
|
|
17
|
+
* the caller must know where the fields sit.
|
|
18
|
+
*
|
|
19
|
+
* Records are decoded, not verified against the ids they are filed under:
|
|
20
|
+
* {@link lookupSignetRequestAt} is the verified lookup.
|
|
38
21
|
*
|
|
39
22
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
40
23
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
41
24
|
* @param requestsIndexPath - Resolved ledger-tree path of the request index.
|
|
42
25
|
* @param noncePath - Resolved ledger-tree path of the request counter.
|
|
43
26
|
* @returns The decoded {@link SignetRequestsLedger}.
|
|
44
|
-
* @throws Error
|
|
45
|
-
* record
|
|
27
|
+
* @throws {Error} If a field is missing, has the wrong state-value shape, or a
|
|
28
|
+
* record is not a decodable evmType2 request record.
|
|
46
29
|
*/
|
|
47
30
|
export declare function readSignetRequestsLedgerFromState(raw: RawContractState, requestsIndexPath: readonly number[], noncePath: readonly number[]): SignetRequestsLedger;
|
|
48
31
|
/**
|
|
49
32
|
* Look up ONE request by id in a contract's request index at an arbitrary
|
|
50
|
-
* ledger field
|
|
51
|
-
* {@link readSignetRequestsLedgerFromState}
|
|
52
|
-
* event-based feed and
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* `undefined`
|
|
57
|
-
* (the pointer is forged, stale, points at the wrong field, or the request is
|
|
58
|
-
* not yet indexed) and the caller MUST drop it.
|
|
59
|
-
* Every non-membership case (field out of range, field is not a Map, id absent,
|
|
60
|
-
* a cell that fails to decode) returns `undefined` rather than throwing, so a
|
|
61
|
-
* malformed or adversarial notification can never crash the reader.
|
|
62
|
-
*
|
|
63
|
-
* Only the matched record is decoded, and it is decoded
|
|
64
|
-
* by the same {@link decodeSignBidirectionalEvent} the full reader uses, so
|
|
65
|
-
* the result is `toEqual` to `readSignetRequestsLedgerFromState(raw,
|
|
66
|
-
* fieldIndex, …).requestsIndex.get(requestId)`.
|
|
33
|
+
* ledger field: the single-record sibling of
|
|
34
|
+
* {@link readSignetRequestsLedgerFromState} and the discovery primitive of
|
|
35
|
+
* the event-based feed. The recompute-and-drop gate: the decode never sees
|
|
36
|
+
* the id, so the final recompute is the only thing binding a record's
|
|
37
|
+
* contents to the key it was filed under, and a mismatch (a spoofed or
|
|
38
|
+
* wrongly filed record) is dropped. Every non-membership case returns
|
|
39
|
+
* `undefined` rather than throwing, and the caller MUST drop such a pointer.
|
|
67
40
|
*
|
|
68
41
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`.
|
|
69
42
|
* @param requestsPath - Resolved ledger-tree path of the request index in
|
|
70
43
|
* `raw`, as the notification carries it.
|
|
71
44
|
* @param requestId - The request id to look up.
|
|
72
|
-
* @returns The stored request record, or `undefined` when it is
|
|
45
|
+
* @returns The stored, id-verified request record, or `undefined` when it is
|
|
46
|
+
* not a member.
|
|
73
47
|
*/
|
|
74
48
|
export declare function lookupSignetRequestAt(raw: RawContractState, requestsPath: readonly number[], requestId: RequestIdHex): SignBidirectionalEvent | undefined;
|
|
75
49
|
//# sourceMappingURL=signature-requests-state-reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature-requests-state-reader.d.ts","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,yBAAyB,CAAC;AAGvF,OAAO,EAEL,KAAK,YAAY,EAGjB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAEjC,MAAM,sBAAsB,CAAC;AAwC9B;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,aAAa,EAAE,2BAA2B,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,gBAAgB,EACrB,iBAAiB,EAAE,SAAS,MAAM,EAAE,EACpC,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,oBAAoB,CAoBtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,SAAS,EAAE,YAAY,GACtB,sBAAsB,GAAG,SAAS,CA+BpC"}
|
|
@@ -1,125 +1,67 @@
|
|
|
1
|
-
// MPC-style raw state reader for the signature-REQUESTS side:
|
|
2
|
-
// request ledger fields out of a contract's raw state
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
// MPC-style raw state reader for the signature-REQUESTS side: read the
|
|
2
|
+
// signet request ledger fields out of a contract's raw state by resolved
|
|
3
|
+
// ledger-tree path, as the MPC monitor and the event feed consume signet
|
|
4
|
+
// contracts. The generic tree walk lives in raw-contract-state.ts and the
|
|
5
|
+
// per-decomposition record decoding in signet-evtype2tx-record-decoding.ts.
|
|
6
|
+
//
|
|
7
|
+
// The read algorithm is the TS twin of the MPC's Rust reader
|
|
8
|
+
// (chain-signatures/chain-midnight/src/reader.rs) and must stay in lockstep
|
|
9
|
+
// with it: each record is decoded once, and id verification is a separate
|
|
10
|
+
// recompute-and-drop gate ({@link lookupSignetRequestAt}).
|
|
11
|
+
import { decodeExactly, UINT_64 } from "./compact-descriptors.js";
|
|
12
|
+
import { signetFieldNodeByPath } from "./raw-contract-state.js";
|
|
13
|
+
import { decodeEvmType2SignBidirectionalEvent } from "./signet-evtype2tx-record-decoding.js";
|
|
14
|
+
import { calculateRequestId } from "./signet-request-id.js";
|
|
15
|
+
import { requestIdBytes, requestIdHex, requestIdType, TxParamType, } from "./signet-requests.js";
|
|
16
|
+
// Atom position of `txParamType` in a stored record: the chain-agnostic head
|
|
17
|
+
// of SignBidirectionalEvent (sender through txParamType) occupies the first
|
|
18
|
+
// 8 atoms whatever the decomposition, so the tag sits at the same index in
|
|
19
|
+
// every record.
|
|
20
|
+
const TX_PARAM_TYPE_ATOM = 7;
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* (chainId..value = 7, accessListEntryCount = 1) + the calldata Maybe's
|
|
22
|
-
* is_some (1), selector (1) and noWords (1) + caip2Id (1) + the two schema
|
|
23
|
-
* fields (1 each). A stored event cell therefore holds
|
|
24
|
-
* `REQUEST_FIXED_VALUE_ATOMS + maxCalldataWords
|
|
25
|
-
* + maxAccessListEntries·(2 + maxStorageKeysPerEntry)`
|
|
26
|
-
* entries (each calldata word is one Bytes<32> atom, and each access-list
|
|
27
|
-
* entry is address + storageKeyCount + its keys).
|
|
28
|
-
*/
|
|
29
|
-
export const REQUEST_FIXED_VALUE_ATOMS = 22;
|
|
30
|
-
/**
|
|
31
|
-
* Recover a record's capacity instantiation (maxCalldataWords,
|
|
32
|
-
* maxAccessListEntries, maxStorageKeysPerEntry) from its aligned-value atom
|
|
33
|
-
* count and decode it. One atom count does not determine the capacities
|
|
34
|
-
* uniquely, so candidates are enumerated, access-list-free first (today's
|
|
35
|
-
* producers, the caller contract <1, 0, 0> and the erc20-vault example
|
|
36
|
-
* <2, 0, 0>, are all access-list-free), and validated by the decode itself:
|
|
37
|
-
* the descriptors' Bytes length checks and the enum range check reject wrong
|
|
38
|
-
* splits, and a decode that leaves atoms unconsumed is rejected here.
|
|
22
|
+
* Decode a stored request record: read the `txParamType` tag and hand the
|
|
23
|
+
* cell to that decomposition's decoder, so a foreign param type fails by
|
|
24
|
+
* name rather than as capacity arithmetic. Does NOT verify the record
|
|
25
|
+
* against the id it is filed under.
|
|
39
26
|
*
|
|
40
|
-
* The
|
|
41
|
-
* `#LenRespondSerialization`) are read from the LAST TWO atoms' actual byte
|
|
42
|
-
* lengths. That works because the state layer stores atoms with trailing
|
|
43
|
-
* zeros trimmed and schemas are exact-length by protocol convention (JSON
|
|
44
|
-
* schema strings sized to fit, never NUL-padded, never ending in a zero
|
|
45
|
-
* byte), so stored length == declared length. A contract that padded its
|
|
46
|
-
* schema capacity with trailing zeros would decode to the trimmed width and
|
|
47
|
-
* fail the request-id recompute, which is the authoritative check anyway.
|
|
48
|
-
*
|
|
49
|
-
* @param atoms - The record cell's aligned value (a fresh copy per attempt).
|
|
50
|
-
* @param expectedRequestId - The id the record is stored under, used to pick
|
|
51
|
-
* between splits when more than one decodes cleanly.
|
|
27
|
+
* @param cell - The record cell as stored (value atoms plus alignment).
|
|
52
28
|
* @returns The decoded record.
|
|
53
|
-
* @throws Error
|
|
29
|
+
* @throws {Error} If the cell is not a decodable request record of a known
|
|
30
|
+
* decomposition.
|
|
54
31
|
*/
|
|
55
|
-
function decodeSignBidirectionalEvent(
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
32
|
+
function decodeSignBidirectionalEvent(cell) {
|
|
33
|
+
const what = "request record";
|
|
34
|
+
const atom = cell.value[TX_PARAM_TYPE_ATOM];
|
|
35
|
+
if (atom === undefined) {
|
|
36
|
+
throw new Error(`${what} ends before txParamType`);
|
|
60
37
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const attempt = (maxWords, maxEntries, maxKeys) => {
|
|
64
|
-
const cursor = [...atoms];
|
|
65
|
-
try {
|
|
66
|
-
const record = signBidirectionalEventDescriptor(maxWords, maxEntries, maxKeys, lenOutputDeserialization, lenRespondSerialization).fromValue(cursor);
|
|
67
|
-
// A clean decode consumes the record exactly.
|
|
68
|
-
return cursor.length === 0 ? record : undefined;
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
// Several splits can decode cleanly (an access-list entry's 20-byte address atom
|
|
75
|
-
// re-pads into a 32-byte calldata word just as well), so only the id the record is
|
|
76
|
-
// filed under separates them. This disambiguates but does not authenticate (the MPC
|
|
77
|
-
// recomputes against the sender-bound id before signing).
|
|
78
|
-
//
|
|
79
|
-
// First match wins, so the common access-list-free case stays at one decode.
|
|
80
|
-
// `fallback` preserves the pre-recompute behaviour when no split matches the id.
|
|
81
|
-
let fallback;
|
|
82
|
-
const take = (record) => {
|
|
83
|
-
if (record === undefined)
|
|
84
|
-
return false;
|
|
85
|
-
fallback ??= record;
|
|
86
|
-
return requestIdHex(calculateRequestId(record)) === expectedRequestId;
|
|
87
|
-
};
|
|
88
|
-
// No access list: variable atoms are calldata words alone (one atom each).
|
|
89
|
-
const accessListFree = attempt(variable, 0, 0);
|
|
90
|
-
if (take(accessListFree))
|
|
91
|
-
return accessListFree;
|
|
92
|
-
// With an access list: E entries of (2 + K) atoms, the rest words.
|
|
93
|
-
for (let entries = 1; entries * 2 <= variable; entries++) {
|
|
94
|
-
for (let keys = 0; entries * (2 + keys) <= variable; keys++) {
|
|
95
|
-
const words = variable - entries * (2 + keys);
|
|
96
|
-
const record = attempt(words, entries, keys);
|
|
97
|
-
if (take(record))
|
|
98
|
-
return record;
|
|
99
|
-
}
|
|
38
|
+
if (atom.length > 1) {
|
|
39
|
+
throw new Error(`${what} txParamType atom holds ${String(atom.length)} bytes, expected at most 1`);
|
|
100
40
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
41
|
+
// The state layer trims trailing zeros, so evmType2 (0) arrives empty.
|
|
42
|
+
const paramType = atom[0] ?? 0;
|
|
43
|
+
switch (paramType) {
|
|
44
|
+
case TxParamType.evmType2:
|
|
45
|
+
return decodeEvmType2SignBidirectionalEvent(cell, what);
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`unsupported txParamType ${String(paramType)}`);
|
|
104
48
|
}
|
|
105
|
-
return fallback;
|
|
106
49
|
}
|
|
107
50
|
/**
|
|
108
51
|
* MPC-style read: parse the signet ledger fields out of raw contract state
|
|
109
|
-
* by field
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* contract it points at).
|
|
52
|
+
* by caller-supplied field positions. A contract chooses its own layout, so
|
|
53
|
+
* the caller must know where the fields sit.
|
|
54
|
+
*
|
|
55
|
+
* Records are decoded, not verified against the ids they are filed under:
|
|
56
|
+
* {@link lookupSignetRequestAt} is the verified lookup.
|
|
115
57
|
*
|
|
116
58
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`
|
|
117
59
|
* from the indexer or `ctx.currentQueryContext.state` from the simulator.
|
|
118
60
|
* @param requestsIndexPath - Resolved ledger-tree path of the request index.
|
|
119
61
|
* @param noncePath - Resolved ledger-tree path of the request counter.
|
|
120
62
|
* @returns The decoded {@link SignetRequestsLedger}.
|
|
121
|
-
* @throws Error
|
|
122
|
-
* record
|
|
63
|
+
* @throws {Error} If a field is missing, has the wrong state-value shape, or a
|
|
64
|
+
* record is not a decodable evmType2 request record.
|
|
123
65
|
*/
|
|
124
66
|
export function readSignetRequestsLedgerFromState(raw, requestsIndexPath, noncePath) {
|
|
125
67
|
const map = signetFieldNodeByPath(raw, requestsIndexPath).asMap();
|
|
@@ -128,45 +70,35 @@ export function readSignetRequestsLedgerFromState(raw, requestsIndexPath, nonceP
|
|
|
128
70
|
}
|
|
129
71
|
const requestsIndex = new Map();
|
|
130
72
|
for (const key of map.keys()) {
|
|
131
|
-
|
|
132
|
-
const requestId = requestIdHex(requestIdType.fromValue([...key.value]));
|
|
73
|
+
const requestId = requestIdHex(decodeExactly(requestIdType, key.value, "request index key"));
|
|
133
74
|
const cell = map.get(key)?.asCell();
|
|
134
75
|
if (cell === undefined)
|
|
135
76
|
continue;
|
|
136
|
-
requestsIndex.set(requestId, decodeSignBidirectionalEvent(cell
|
|
77
|
+
requestsIndex.set(requestId, decodeSignBidirectionalEvent(cell));
|
|
137
78
|
}
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
79
|
+
const nonceField = signetFieldNodeByPath(raw, noncePath);
|
|
80
|
+
if (nonceField.type() !== "cell") {
|
|
140
81
|
throw new Error(`Ledger field at path ${JSON.stringify(noncePath)} is not a Cell`);
|
|
141
82
|
}
|
|
142
|
-
const nonce =
|
|
83
|
+
const nonce = decodeExactly(UINT_64, nonceField.asCell().value, "request counter");
|
|
143
84
|
return { nonce, requestsIndex };
|
|
144
85
|
}
|
|
145
86
|
/**
|
|
146
87
|
* Look up ONE request by id in a contract's request index at an arbitrary
|
|
147
|
-
* ledger field
|
|
148
|
-
* {@link readSignetRequestsLedgerFromState}
|
|
149
|
-
* event-based feed and
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* `undefined`
|
|
154
|
-
* (the pointer is forged, stale, points at the wrong field, or the request is
|
|
155
|
-
* not yet indexed) and the caller MUST drop it.
|
|
156
|
-
* Every non-membership case (field out of range, field is not a Map, id absent,
|
|
157
|
-
* a cell that fails to decode) returns `undefined` rather than throwing, so a
|
|
158
|
-
* malformed or adversarial notification can never crash the reader.
|
|
159
|
-
*
|
|
160
|
-
* Only the matched record is decoded, and it is decoded
|
|
161
|
-
* by the same {@link decodeSignBidirectionalEvent} the full reader uses, so
|
|
162
|
-
* the result is `toEqual` to `readSignetRequestsLedgerFromState(raw,
|
|
163
|
-
* fieldIndex, …).requestsIndex.get(requestId)`.
|
|
88
|
+
* ledger field: the single-record sibling of
|
|
89
|
+
* {@link readSignetRequestsLedgerFromState} and the discovery primitive of
|
|
90
|
+
* the event-based feed. The recompute-and-drop gate: the decode never sees
|
|
91
|
+
* the id, so the final recompute is the only thing binding a record's
|
|
92
|
+
* contents to the key it was filed under, and a mismatch (a spoofed or
|
|
93
|
+
* wrongly filed record) is dropped. Every non-membership case returns
|
|
94
|
+
* `undefined` rather than throwing, and the caller MUST drop such a pointer.
|
|
164
95
|
*
|
|
165
96
|
* @param raw - Raw contract state, e.g. `queryContractState(address).data`.
|
|
166
97
|
* @param requestsPath - Resolved ledger-tree path of the request index in
|
|
167
98
|
* `raw`, as the notification carries it.
|
|
168
99
|
* @param requestId - The request id to look up.
|
|
169
|
-
* @returns The stored request record, or `undefined` when it is
|
|
100
|
+
* @returns The stored, id-verified request record, or `undefined` when it is
|
|
101
|
+
* not a member.
|
|
170
102
|
*/
|
|
171
103
|
export function lookupSignetRequestAt(raw, requestsPath, requestId) {
|
|
172
104
|
let node;
|
|
@@ -180,22 +112,26 @@ export function lookupSignetRequestAt(raw, requestsPath, requestId) {
|
|
|
180
112
|
if (map === undefined) {
|
|
181
113
|
return undefined; // the named field is not a request index
|
|
182
114
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
115
|
+
// The ledger's own keyed lookup on the ledger's own key type: toValue
|
|
116
|
+
// produces the canonical (zero-trimmed) key form the map stores.
|
|
117
|
+
const entry = map.get({
|
|
118
|
+
value: requestIdType.toValue(requestIdBytes(requestId)),
|
|
119
|
+
alignment: requestIdType.alignment(),
|
|
120
|
+
});
|
|
121
|
+
const cell = entry?.asCell();
|
|
122
|
+
if (cell === undefined) {
|
|
123
|
+
return undefined; // id absent, or its entry is not a cell
|
|
124
|
+
}
|
|
125
|
+
let record;
|
|
126
|
+
try {
|
|
127
|
+
record = decodeSignBidirectionalEvent(cell);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return undefined; // a cell that is not a decodable request record
|
|
131
|
+
}
|
|
132
|
+
if (requestIdHex(calculateRequestId(record)) !== requestId) {
|
|
133
|
+
return undefined; // spoofed or wrongly filed record
|
|
198
134
|
}
|
|
199
|
-
return
|
|
135
|
+
return record;
|
|
200
136
|
}
|
|
201
137
|
//# sourceMappingURL=signature-requests-state-reader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"signature-requests-state-reader.js","sourceRoot":"","sources":["../src/signature-requests-state-reader.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,EAAE;AACF,6DAA6D;AAC7D,4EAA4E;AAC5E,0EAA0E;AAC1E,2DAA2D;AAI3D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAyB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,oCAAoC,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,cAAc,EAEd,YAAY,EACZ,aAAa,EAGb,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,gBAAgB;AAChB,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,SAAS,4BAA4B,CAAC,IAAkB;IACtD,MAAM,IAAI,GAAG,gBAAgB,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,2BAA2B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,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C,gDAAgD;IACpE,CAAC;IACD,IAAI,YAAY,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC3D,OAAO,SAAS,CAAC,CAAC,kCAAkC;IACtD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import type { SignBidirectionalEvent } from "./signet-requests.ts";
|
|
2
1
|
import type { SignatureRespondedEvent } from "./signet-contract-events.ts";
|
|
2
|
+
import { type SignBidirectionalEvent } from "./signet-requests.ts";
|
|
3
3
|
/**
|
|
4
|
-
* Recover the
|
|
5
|
-
*
|
|
4
|
+
* Recover the address that produced a response signature, over the signing
|
|
5
|
+
* digest of the transaction the request describes: the response-side
|
|
6
|
+
* dispatch on the request's `txParamType`.
|
|
6
7
|
*
|
|
7
8
|
* @param request - The on-ledger request record the response answers.
|
|
8
9
|
* @param response - The posted signature record answering it.
|
|
9
10
|
* @returns The checksummed recovered signer address.
|
|
10
|
-
* @throws Error
|
|
11
|
-
*
|
|
11
|
+
* @throws {Error} If the request's `txParamType` names a decomposition this
|
|
12
|
+
* library does not sign-verify, the response is not a decodable signature,
|
|
13
|
+
* or the request record is malformed (see
|
|
12
14
|
* {@link signBidirectionalEventToUnsignedEvmTransaction}).
|
|
13
15
|
*/
|
|
14
16
|
export declare function recoverSignatureResponseSigner(request: SignBidirectionalEvent, response: SignatureRespondedEvent): string;
|
|
15
17
|
/**
|
|
16
18
|
* Verify a posted response against its request: does the signature recover
|
|
17
|
-
* to `expectedSigner`? Never throws: a
|
|
18
|
-
*
|
|
19
|
-
* on an unauthenticated log.
|
|
19
|
+
* to `expectedSigner`? Never throws: a malformed or wrongly-signed response
|
|
20
|
+
* is simply not valid.
|
|
20
21
|
*
|
|
21
22
|
* @param request - The on-ledger request record the response answers.
|
|
22
23
|
* @param response - The posted signature record answering it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-response-verification.d.ts","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature-response-verification.d.ts","sourceRoot":"","sources":["../src/signature-response-verification.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,EAAE,KAAK,sBAAsB,EAAe,MAAM,sBAAsB,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,GAChC,MAAM,CAUR;AAED;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,EACjC,cAAc,EAAE,MAAM,GACrB,OAAO,CAMT"}
|