@certen.io/sdk 0.8.2 → 0.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog — @certen.io/sdk
2
2
 
3
+ ## 0.9.0 — verify the outcome from the bundle's own bytes
4
+
5
+ ### Added — `verifyExecutionProof`, `checkAgainstHeader`, `decodeSharedBundle`
6
+
7
+ A proof bundle now carries component 5, the execution proof: the receipt of the target-chain
8
+ transaction and the Merkle-Patricia inclusion proofs the validators' RB-2 gate verified against the
9
+ block header (raw trie nodes and the leaf value, so nothing has to be fetched). This module checks
10
+ it with no dependencies and no gateway:
11
+
12
+ ```ts
13
+ import { fetchSharedProof, decodeSharedBundle, executionComponentOf, verifyExecutionProof, checkAgainstHeader } from '@certen.io/sdk';
14
+
15
+ const shared = await fetchSharedProof(link); // no API key
16
+ const bundle = decodeSharedBundle(shared.bundle)!; // the share endpoint returns bytes
17
+ const v = verifyExecutionProof(executionComponentOf(bundle)!, { address: LEDGER, topic0: CLAIM_PAID });
18
+ // v.ok: the receipt with these logs is in a receipts trie with root v.receiptsRoot
19
+ // v.expectedLogFound: the event is in it
20
+ const header = (await rpc('eth_getBlockByNumber', ['0x' + v.blockNumber.toString(16), false])).result;
21
+ checkAgainstHeader(v, header).ok; // and that root IS block N's header
22
+ ```
23
+
24
+ What it proves and what it does not, in the function's own words (`caveats`): the receipt is in a
25
+ trie with that root; that the root is the header of block N is the validator's statement until you
26
+ compare it to a header from an RPC you trust. keccak-256, RLP and the trie walk are implemented in
27
+ the module (Node has SHA-3 but not Ethereum's keccak padding); the test walks a real Base Sepolia
28
+ receipt at index 23 of block 46437431 to its root and refuses a tampered root, receipt or proof.
29
+
30
+ Bundles from validators older than certen-validator PR #5 carry no component 5; the verifier says
31
+ so rather than guessing.
32
+
3
33
  ## 0.8.2 — waits that survive a slow poll
4
34
 
5
35
  ### Fixed — `execute.wait` and `identity.createAndWait` no longer give up on one failed poll
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Independent verification of a proof bundle's component 5, the execution proof: that the receipt
3
+ * with these logs sits in the block the bundle names, under that block's receipts root.
4
+ *
5
+ * The validator's RB-2 gate built a Merkle-Patricia proof from the raw block and verified it against
6
+ * the header; the bundle now carries that proof (the raw trie nodes and the leaf value) so anyone
7
+ * can repeat the check with nothing but this file: re-hash every node with keccak-256, walk the
8
+ * trie from the root along RLP(transaction index), and compare the value found to the receipt.
9
+ *
10
+ * What this proves and what it does not, plainly:
11
+ * - proved here: the receipt (status, logs) is in a receipts trie whose root is `receipts_root`;
12
+ * - NOT proved here: that `receipts_root` is the header of block N on chain C. That root is the
13
+ * validator's statement. Fetch the block header from any RPC of your own and compare
14
+ * `receiptsRoot` (and `hash` to `block_hash`) to close the gap — `checkAgainstHeader` does it
15
+ * when handed a header.
16
+ *
17
+ * No dependencies: keccak-256 and RLP are implemented below, small and readable, because Node's
18
+ * `crypto` has SHA-3 but not the keccak padding Ethereum uses.
19
+ */
20
+ /** keccak-256 of `data` (Ethereum's keccak, not NIST SHA3-256). */
21
+ export declare function keccak256(data: Uint8Array): Uint8Array;
22
+ export declare const toHex: (b: Uint8Array) => string;
23
+ export declare function fromHex(h: string): Uint8Array;
24
+ /** The bundle writes bytes three ways: hex, base64 (Go's []byte), or a JSON array of numbers (Go's [32]byte). */
25
+ export declare function bytesFrom(v: unknown): Uint8Array;
26
+ export type Rlp = Uint8Array | Rlp[];
27
+ export declare function rlpDecode(b: Uint8Array): Rlp;
28
+ /** RLP of a non-negative integer, as Ethereum keys transaction indices in the trie. */
29
+ export declare function rlpEncodeUint(n: number): Uint8Array;
30
+ /**
31
+ * Walk a Patricia-trie proof from `root` along `key` using only `nodes`, each keyed by its own
32
+ * keccak-256 (the key the prover supplied is never trusted). Returns the value at the key, or
33
+ * throws with the reason the walk failed.
34
+ */
35
+ export declare function verifyTrieProof(root: Uint8Array, key: Uint8Array, nodes: Uint8Array[]): Uint8Array;
36
+ export interface DecodedLog {
37
+ address: string;
38
+ topics: string[];
39
+ data: string;
40
+ }
41
+ export interface DecodedReceipt {
42
+ type: number;
43
+ status: number;
44
+ cumulativeGasUsed: bigint;
45
+ logs: DecodedLog[];
46
+ }
47
+ /** Decode a consensus-encoded receipt: legacy RLP, or a typed receipt (EIP-2718: one type byte, then RLP). */
48
+ export declare function decodeReceipt(raw: Uint8Array): DecodedReceipt;
49
+ /** Component 5 of a proof bundle, as the validator writes it. */
50
+ export interface ExecutionProofComponent {
51
+ chain_id: string;
52
+ tx_hash: string;
53
+ block_number: number;
54
+ block_hash?: string;
55
+ status?: number;
56
+ receipts_root?: string;
57
+ transactions_root?: string;
58
+ raw_receipt?: string;
59
+ logs?: Array<{
60
+ address: string;
61
+ topics: string[];
62
+ data: string;
63
+ log_index?: number;
64
+ }>;
65
+ receipt_inclusion_proof?: {
66
+ leaf_index: number;
67
+ expected_root: unknown;
68
+ proof_nodes?: unknown[];
69
+ leaf_value?: unknown;
70
+ };
71
+ tx_inclusion_proof?: unknown;
72
+ verified_by?: string;
73
+ verified_at?: string;
74
+ }
75
+ export interface ExecutionVerification {
76
+ /** The receipt is in a trie with this root, and it is the receipt the bundle shows. */
77
+ ok: boolean;
78
+ chainId: string;
79
+ txHash: string;
80
+ blockNumber: number;
81
+ blockHash?: string;
82
+ receiptsRoot: string;
83
+ transactionIndex: number;
84
+ receipt?: DecodedReceipt;
85
+ /** A log matching `expect` was found (only set when `expect` was given). */
86
+ expectedLogFound?: boolean;
87
+ /** What was NOT checked here, in words. */
88
+ caveats: string[];
89
+ error?: string;
90
+ }
91
+ /**
92
+ * Verify component 5 with nothing but its own bytes. Pass `expect` to also look for a specific
93
+ * event (contract address and topic0, optionally topic1) among the receipt's logs.
94
+ */
95
+ export declare function verifyExecutionProof(c: ExecutionProofComponent, expect?: {
96
+ address?: string;
97
+ topic0?: string;
98
+ topic1?: string;
99
+ }): ExecutionVerification;
100
+ /** Close the caveat: compare the component's root and block hash to a header from your own RPC. */
101
+ export declare function checkAgainstHeader(v: ExecutionVerification, header: {
102
+ hash?: string;
103
+ receiptsRoot?: string;
104
+ number?: string | number;
105
+ }): {
106
+ ok: boolean;
107
+ reasons: string[];
108
+ };
109
+ /** Find component 5 in a bundle JSON, whatever wrapping the share endpoint gave it. */
110
+ export declare function executionComponentOf(bundle: unknown): ExecutionProofComponent | null;
111
+ //# sourceMappingURL=execution-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-proof.d.ts","sourceRoot":"","sources":["../src/execution-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAkCH,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAqBtD;AAID,eAAO,MAAM,KAAK,GAAI,GAAG,UAAU,KAAG,MAA+E,CAAC;AACtH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAM7C;AAGD,iHAAiH;AACjH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,CAUhD;AAID,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG,GAAG,EAAE,CAAC;AAqBrC,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,GAAG,CAAoC;AAEjF,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAMnD;AAMD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,CAqClG;AAID,MAAM,WAAW,UAAU;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC/E,MAAM,WAAW,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAA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Ac,CAAC;IACzB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,uBAAuB,EAC1B,MAAM,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D,qBAAqB,CAiCvB;AAED,mGAAmG;AACnG,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,qBAAqB,EACxB,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GACzE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAMpC;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAKpF"}
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Independent verification of a proof bundle's component 5, the execution proof: that the receipt
3
+ * with these logs sits in the block the bundle names, under that block's receipts root.
4
+ *
5
+ * The validator's RB-2 gate built a Merkle-Patricia proof from the raw block and verified it against
6
+ * the header; the bundle now carries that proof (the raw trie nodes and the leaf value) so anyone
7
+ * can repeat the check with nothing but this file: re-hash every node with keccak-256, walk the
8
+ * trie from the root along RLP(transaction index), and compare the value found to the receipt.
9
+ *
10
+ * What this proves and what it does not, plainly:
11
+ * - proved here: the receipt (status, logs) is in a receipts trie whose root is `receipts_root`;
12
+ * - NOT proved here: that `receipts_root` is the header of block N on chain C. That root is the
13
+ * validator's statement. Fetch the block header from any RPC of your own and compare
14
+ * `receiptsRoot` (and `hash` to `block_hash`) to close the gap — `checkAgainstHeader` does it
15
+ * when handed a header.
16
+ *
17
+ * No dependencies: keccak-256 and RLP are implemented below, small and readable, because Node's
18
+ * `crypto` has SHA-3 but not the keccak padding Ethereum uses.
19
+ */
20
+ // ---- keccak-256 ----------------------------------------------------------------------------------
21
+ const RC = [
22
+ 0x0000000000000001n, 0x0000000000008082n, 0x800000000000808an, 0x8000000080008000n,
23
+ 0x000000000000808bn, 0x0000000080000001n, 0x8000000080008081n, 0x8000000000008009n,
24
+ 0x000000000000008an, 0x0000000000000088n, 0x0000000080008009n, 0x000000008000000an,
25
+ 0x000000008000808bn, 0x800000000000008bn, 0x8000000000008089n, 0x8000000000008003n,
26
+ 0x8000000000008002n, 0x8000000000000080n, 0x000000000000800an, 0x800000008000000an,
27
+ 0x8000000080008081n, 0x8000000000008080n, 0x0000000080000001n, 0x8000000080008008n,
28
+ ];
29
+ const ROT = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14];
30
+ const PI = [0, 10, 20, 5, 15, 16, 1, 11, 21, 6, 7, 17, 2, 12, 22, 23, 8, 18, 3, 13, 14, 24, 9, 19, 4];
31
+ const M64 = (1n << 64n) - 1n;
32
+ const rotl = (x, n) => n === 0 ? x : (((x << BigInt(n)) | (x >> BigInt(64 - n))) & M64);
33
+ function keccakF(s) {
34
+ for (let round = 0; round < 24; round++) {
35
+ const c = [0n, 0n, 0n, 0n, 0n];
36
+ for (let x = 0; x < 5; x++)
37
+ c[x] = s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20];
38
+ for (let x = 0; x < 5; x++) {
39
+ const d = c[(x + 4) % 5] ^ rotl(c[(x + 1) % 5], 1);
40
+ for (let y = 0; y < 25; y += 5)
41
+ s[y + x] ^= d;
42
+ }
43
+ const b = new Array(25);
44
+ for (let i = 0; i < 25; i++)
45
+ b[PI[i]] = rotl(s[i], ROT[i]);
46
+ for (let y = 0; y < 25; y += 5) {
47
+ for (let x = 0; x < 5; x++)
48
+ s[y + x] = b[y + x] ^ ((~b[y + (x + 1) % 5]) & M64 & b[y + (x + 2) % 5]);
49
+ }
50
+ s[0] ^= RC[round];
51
+ }
52
+ }
53
+ /** keccak-256 of `data` (Ethereum's keccak, not NIST SHA3-256). */
54
+ export function keccak256(data) {
55
+ const rate = 136;
56
+ const s = new Array(25).fill(0n);
57
+ const padded = new Uint8Array(Math.ceil((data.length + 1) / rate) * rate);
58
+ padded.set(data);
59
+ padded[data.length] ^= 0x01;
60
+ padded[padded.length - 1] ^= 0x80;
61
+ for (let off = 0; off < padded.length; off += rate) {
62
+ for (let i = 0; i < rate / 8; i++) {
63
+ let lane = 0n;
64
+ for (let b = 7; b >= 0; b--)
65
+ lane = (lane << 8n) | BigInt(padded[off + i * 8 + b]);
66
+ s[i] ^= lane;
67
+ }
68
+ keccakF(s);
69
+ }
70
+ const out = new Uint8Array(32);
71
+ for (let i = 0; i < 4; i++) {
72
+ let lane = s[i];
73
+ for (let b = 0; b < 8; b++) {
74
+ out[i * 8 + b] = Number(lane & 0xffn);
75
+ lane >>= 8n;
76
+ }
77
+ }
78
+ return out;
79
+ }
80
+ // ---- bytes -----------------------------------------------------------------------------------------
81
+ export const toHex = (b) => '0x' + Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
82
+ export function fromHex(h) {
83
+ const s = h.startsWith('0x') ? h.slice(2) : h;
84
+ if (s.length % 2)
85
+ throw new Error('odd-length hex');
86
+ const out = new Uint8Array(s.length / 2);
87
+ for (let i = 0; i < out.length; i++)
88
+ out[i] = parseInt(s.slice(i * 2, i * 2 + 2), 16);
89
+ return out;
90
+ }
91
+ const eq = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
92
+ /** The bundle writes bytes three ways: hex, base64 (Go's []byte), or a JSON array of numbers (Go's [32]byte). */
93
+ export function bytesFrom(v) {
94
+ if (v instanceof Uint8Array)
95
+ return v;
96
+ if (Array.isArray(v))
97
+ return Uint8Array.from(v.map(Number));
98
+ if (typeof v === 'string') {
99
+ if (/^0x[0-9a-fA-F]*$/.test(v))
100
+ return fromHex(v);
101
+ if (/^[0-9a-fA-F]{64}$/.test(v))
102
+ return fromHex(v);
103
+ return Uint8Array.from(Buffer.from(v, 'base64'));
104
+ }
105
+ if (v && typeof v === 'object' && 'data' in v)
106
+ return bytesFrom(v.data);
107
+ throw new Error('unrecognised byte encoding');
108
+ }
109
+ function rlpDecodeAt(b, at) {
110
+ const p = b[at];
111
+ if (p === undefined)
112
+ throw new Error('rlp: truncated');
113
+ if (p < 0x80)
114
+ return { value: b.slice(at, at + 1), end: at + 1 };
115
+ const lenOfLen = (base) => {
116
+ const n = p - base;
117
+ let len = 0;
118
+ for (let i = 0; i < n; i++)
119
+ len = len * 256 + b[at + 1 + i];
120
+ return { len, start: at + 1 + n };
121
+ };
122
+ if (p < 0xb8)
123
+ return { value: b.slice(at + 1, at + 1 + (p - 0x80)), end: at + 1 + (p - 0x80) };
124
+ if (p < 0xc0) {
125
+ const { len, start } = lenOfLen(0xb7);
126
+ return { value: b.slice(start, start + len), end: start + len };
127
+ }
128
+ let start, len;
129
+ if (p < 0xf8) {
130
+ start = at + 1;
131
+ len = p - 0xc0;
132
+ }
133
+ else {
134
+ ({ len, start } = lenOfLen(0xf7));
135
+ }
136
+ const items = [];
137
+ let i = start;
138
+ while (i < start + len) {
139
+ const r = rlpDecodeAt(b, i);
140
+ items.push(r.value);
141
+ i = r.end;
142
+ }
143
+ return { value: items, end: start + len };
144
+ }
145
+ export function rlpDecode(b) { return rlpDecodeAt(b, 0).value; }
146
+ /** RLP of a non-negative integer, as Ethereum keys transaction indices in the trie. */
147
+ export function rlpEncodeUint(n) {
148
+ if (n === 0)
149
+ return Uint8Array.from([0x80]);
150
+ const bytes = [];
151
+ for (let x = n; x > 0; x = Math.floor(x / 256))
152
+ bytes.unshift(x % 256);
153
+ if (bytes.length === 1 && bytes[0] < 0x80)
154
+ return Uint8Array.from(bytes);
155
+ return Uint8Array.from([0x80 + bytes.length, ...bytes]);
156
+ }
157
+ // ---- Merkle-Patricia trie proof ------------------------------------------------------------------
158
+ const nibbles = (b) => Array.from(b).flatMap((x) => [x >> 4, x & 15]);
159
+ /**
160
+ * Walk a Patricia-trie proof from `root` along `key` using only `nodes`, each keyed by its own
161
+ * keccak-256 (the key the prover supplied is never trusted). Returns the value at the key, or
162
+ * throws with the reason the walk failed.
163
+ */
164
+ export function verifyTrieProof(root, key, nodes) {
165
+ const byHash = new Map();
166
+ for (const n of nodes)
167
+ byHash.set(toHex(keccak256(n)), n);
168
+ const path = nibbles(key);
169
+ let want = root;
170
+ let pos = 0;
171
+ let embedded = null;
172
+ for (let hop = 0; hop < 64; hop++) {
173
+ let node;
174
+ if (embedded) {
175
+ node = embedded;
176
+ embedded = null;
177
+ }
178
+ else {
179
+ const raw = byHash.get(toHex(want));
180
+ if (!raw)
181
+ throw new Error(`proof is missing the node ${toHex(want).slice(0, 18)}… (hop ${hop})`);
182
+ node = rlpDecode(raw);
183
+ }
184
+ if (!Array.isArray(node))
185
+ throw new Error('trie node is not a list');
186
+ if (node.length === 17) {
187
+ if (pos === path.length) {
188
+ const v = node[16];
189
+ if (!(v instanceof Uint8Array))
190
+ throw new Error('branch value is not bytes');
191
+ return v;
192
+ }
193
+ const next = node[path[pos++]];
194
+ if (Array.isArray(next)) {
195
+ embedded = next;
196
+ continue;
197
+ }
198
+ if (next.length === 0)
199
+ throw new Error('key is not in the trie (empty branch slot)');
200
+ want = next;
201
+ continue;
202
+ }
203
+ if (node.length === 2) {
204
+ const enc = node[0];
205
+ const flag = enc[0] >> 4;
206
+ const odd = (flag & 1) === 1, leaf = flag >= 2;
207
+ const segment = nibbles(enc).slice(odd ? 1 : 2);
208
+ for (const nb of segment) {
209
+ if (path[pos++] !== nb)
210
+ throw new Error('key diverges from the trie path');
211
+ }
212
+ const next = node[1];
213
+ if (leaf) {
214
+ if (pos !== path.length)
215
+ throw new Error('leaf reached before the key was consumed');
216
+ if (!(next instanceof Uint8Array))
217
+ throw new Error('leaf value is not bytes');
218
+ return next;
219
+ }
220
+ if (Array.isArray(next)) {
221
+ embedded = next;
222
+ continue;
223
+ }
224
+ want = next;
225
+ continue;
226
+ }
227
+ throw new Error(`trie node with ${node.length} items`);
228
+ }
229
+ throw new Error('trie walk did not terminate');
230
+ }
231
+ /** Decode a consensus-encoded receipt: legacy RLP, or a typed receipt (EIP-2718: one type byte, then RLP). */
232
+ export function decodeReceipt(raw) {
233
+ let type = 0, body = raw;
234
+ if (raw[0] < 0x80) {
235
+ type = raw[0];
236
+ body = raw.slice(1);
237
+ }
238
+ const items = rlpDecode(body);
239
+ if (!Array.isArray(items) || items.length < 4)
240
+ throw new Error('receipt is not a 4-item list');
241
+ const [statusB, gasB, , logsL] = items;
242
+ const toBig = (b) => b.reduce((acc, x) => (acc << 8n) | BigInt(x), 0n);
243
+ const logs = logsL.map((l) => {
244
+ const [addr, topics, data] = l;
245
+ return { address: toHex(addr), topics: topics.map((t) => toHex(t)), data: toHex(data) };
246
+ });
247
+ return { type, status: Number(toBig(statusB)), cumulativeGasUsed: toBig(gasB), logs };
248
+ }
249
+ /**
250
+ * Verify component 5 with nothing but its own bytes. Pass `expect` to also look for a specific
251
+ * event (contract address and topic0, optionally topic1) among the receipt's logs.
252
+ */
253
+ export function verifyExecutionProof(c, expect) {
254
+ const base = {
255
+ ok: false, chainId: String(c.chain_id ?? ''), txHash: String(c.tx_hash ?? ''), blockNumber: Number(c.block_number ?? 0),
256
+ blockHash: c.block_hash, receiptsRoot: '', transactionIndex: -1,
257
+ caveats: [
258
+ 'the receipts root is the validator\'s statement of the block header; compare it (and block_hash) to the header from an RPC you trust to make this independent of Certen',
259
+ 'this proves the receipt executed as shown; whether that was the RIGHT call is your record to compare against',
260
+ ],
261
+ };
262
+ try {
263
+ const p = c.receipt_inclusion_proof;
264
+ if (!p || !Array.isArray(p.proof_nodes) || p.proof_nodes.length === 0)
265
+ return { ...base, error: 'no receipt inclusion proof in the bundle — outcome cannot be verified from it' };
266
+ const root = bytesFrom(p.expected_root);
267
+ base.receiptsRoot = toHex(root);
268
+ if (c.receipts_root && toHex(bytesFrom(c.receipts_root)) !== base.receiptsRoot)
269
+ return { ...base, error: 'the proof\'s expected root differs from the component\'s receipts_root' };
270
+ const idx = Number(p.leaf_index);
271
+ base.transactionIndex = idx;
272
+ const nodes = p.proof_nodes.map(bytesFrom);
273
+ const value = verifyTrieProof(root, rlpEncodeUint(idx), nodes);
274
+ if (p.leaf_value != null && !eq(value, bytesFrom(p.leaf_value)))
275
+ return { ...base, error: 'the trie resolves to a different value than the proof\'s leaf_value' };
276
+ if (c.raw_receipt && !eq(value, bytesFrom(c.raw_receipt)))
277
+ return { ...base, error: 'the trie resolves to a different receipt than the bundle shows' };
278
+ const receipt = decodeReceipt(value);
279
+ base.receipt = receipt;
280
+ if (c.status != null && Number(c.status) !== receipt.status)
281
+ return { ...base, error: `the receipt's status is ${receipt.status}, the component says ${c.status}` };
282
+ if (expect) {
283
+ const a = expect.address?.toLowerCase(), t0 = expect.topic0?.toLowerCase(), t1 = expect.topic1?.toLowerCase();
284
+ base.expectedLogFound = receipt.logs.some((l) => (!a || l.address.toLowerCase() === a) && (!t0 || l.topics[0]?.toLowerCase() === t0) && (!t1 || l.topics[1]?.toLowerCase() === t1));
285
+ }
286
+ return { ...base, ok: true };
287
+ }
288
+ catch (e) {
289
+ return { ...base, error: e instanceof Error ? e.message : String(e) };
290
+ }
291
+ }
292
+ /** Close the caveat: compare the component's root and block hash to a header from your own RPC. */
293
+ export function checkAgainstHeader(v, header) {
294
+ const reasons = [];
295
+ if (header.receiptsRoot && header.receiptsRoot.toLowerCase() !== v.receiptsRoot.toLowerCase())
296
+ reasons.push(`receipts root differs: header ${header.receiptsRoot}, bundle ${v.receiptsRoot}`);
297
+ if (header.hash && v.blockHash && header.hash.toLowerCase() !== v.blockHash.toLowerCase())
298
+ reasons.push(`block hash differs: header ${header.hash}, bundle ${v.blockHash}`);
299
+ if (header.number != null && Number(header.number) !== v.blockNumber)
300
+ reasons.push(`block number differs: header ${Number(header.number)}, bundle ${v.blockNumber}`);
301
+ return { ok: reasons.length === 0, reasons };
302
+ }
303
+ /** Find component 5 in a bundle JSON, whatever wrapping the share endpoint gave it. */
304
+ export function executionComponentOf(bundle) {
305
+ const b = bundle;
306
+ const pc = (b?.proof_components ?? b?.bundle?.proof_components);
307
+ const c = pc?.['5_execution_proof'];
308
+ return c && typeof c === 'object' ? c : null;
309
+ }
310
+ //# sourceMappingURL=execution-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-proof.js","sourceRoot":"","sources":["../src/execution-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,qGAAqG;AAErG,MAAM,EAAE,GAAa;IACnB,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;IAClF,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;IAClF,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;IAClF,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;IAClF,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;IAClF,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB;CACnF,CAAC;AACF,MAAM,GAAG,GAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACrH,MAAM,EAA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pC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAA6B,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,9 @@ export type { SignFn, ProofGatedCallParams, TransferParams, OpenedIntent } from
4
4
  export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, CertenPaymentRequiredError, } from './errors.js';
5
5
  export type { PaymentResolution } from './errors.js';
6
6
  export { runDoctor, CREDENTIALLED_CHECKS } from './doctor.js';
7
- export { fetchSharedProof, parseShareTarget } from './shared-proof.js';
7
+ export { fetchSharedProof, parseShareTarget, decodeSharedBundle } from './shared-proof.js';
8
+ export { verifyExecutionProof, checkAgainstHeader, executionComponentOf, decodeReceipt, verifyTrieProof, keccak256, rlpDecode, rlpEncodeUint, bytesFrom, } from './execution-proof.js';
9
+ export type { ExecutionProofComponent, ExecutionVerification, DecodedReceipt, DecodedLog } from './execution-proof.js';
8
10
  export { fetchOAuthToken, refreshOAuthToken, revokeOAuthToken } from './oauth.js';
9
11
  export { parseMnemonicTarget } from './resources/identity.js';
10
12
  export { redeemRegistrationToken } from './registration.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,oBAA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,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG3F,OAAO,EACL,oBAAoB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAC9F,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,GAC/C,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGlF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,10 @@ export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestErr
4
4
  export { runDoctor, CREDENTIALLED_CHECKS } from './doctor.js';
5
5
  // Standalone on purpose: redeeming a share link needs no API key and therefore no client. See
6
6
  // shared-proof.ts.
7
- export { fetchSharedProof, parseShareTarget } from './shared-proof.js';
7
+ export { fetchSharedProof, parseShareTarget, decodeSharedBundle } from './shared-proof.js';
8
+ // execution-proof.ts: verify a bundle's component 5 (the receipt and its trie proof) with no
9
+ // dependencies and no gateway — what a counterparty runs.
10
+ export { verifyExecutionProof, checkAgainstHeader, executionComponentOf, decodeReceipt, verifyTrieProof, keccak256, rlpDecode, rlpEncodeUint, bytesFrom, } from './execution-proof.js';
8
11
  // Standalone for the same reason: these carry their credential in the body and need no API key,
9
12
  // so a caller using OAuth is not made to hold one. See oauth.ts.
10
13
  export { fetchOAuthToken, refreshOAuthToken, revokeOAuthToken } from './oauth.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC9D,8FAA8F;AAC9F,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,gGAAgG;AAChG,iEAAiE;AACjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClF,iGAAiG;AACjG,wFAAwF;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,6FAA6F;AAC7F,sEAAsE;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,iGAAiG;AACjG,iEAAiE;AACjE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBA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AAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACxF,gGAAgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,mGAAmG;AACnG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -26,6 +26,12 @@ export declare function fetchSharedProof(tokenOrUrl: string, options?: {
26
26
  baseUrl?: string;
27
27
  timeoutMs?: number;
28
28
  }): Promise<SharedProof>;
29
+ /**
30
+ * The bundle as JSON. The share endpoint returns `bundle` as the stored bytes — serialized the
31
+ * way Node serializes a Buffer ({ type: 'Buffer', data: [...] }), sometimes gzip-compressed —
32
+ * and a counterparty should not have to know that. Returns null when the bytes are not JSON.
33
+ */
34
+ export declare function decodeSharedBundle(bundle: unknown): Record<string, unknown> | null;
29
35
  /** `https://host/v1/proof/shared/<token>`, or the token on its own. */
30
36
  export declare function parseShareTarget(tokenOrUrl: string, baseUrlOverride?: string): {
31
37
  token: string;
@@ -1 +1 @@
1
- {"version":3,"file":"shared-proof.d.ts","sourceRoot":"","sources":["../src/shared-proof.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAmBpC"}
1
+ {"version":3,"file":"shared-proof.d.ts","sourceRoot":"","sources":["../src/shared-proof.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAalF;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAmBpC"}
@@ -1,3 +1,4 @@
1
+ import { gunzipSync } from 'node:zlib';
1
2
  import axios from 'axios';
2
3
  import { DEFAULT_BASE_URL } from './client.js';
3
4
  import { CertenError } from './errors.js';
@@ -39,6 +40,38 @@ export async function fetchSharedProof(tokenOrUrl, options = {}) {
39
40
  throw translate(err);
40
41
  }
41
42
  }
43
+ /**
44
+ * The bundle as JSON. The share endpoint returns `bundle` as the stored bytes — serialized the
45
+ * way Node serializes a Buffer ({ type: 'Buffer', data: [...] }), sometimes gzip-compressed —
46
+ * and a counterparty should not have to know that. Returns null when the bytes are not JSON.
47
+ */
48
+ export function decodeSharedBundle(bundle) {
49
+ if (bundle && typeof bundle === 'object' && !('data' in bundle) && ('proof_components' in bundle || 'bundle_id' in bundle)) {
50
+ return bundle;
51
+ }
52
+ let bytes = null;
53
+ if (bundle && typeof bundle === 'object' && Array.isArray(bundle.data))
54
+ bytes = Buffer.from(bundle.data);
55
+ else if (typeof bundle === 'string')
56
+ bytes = /^[A-Za-z0-9+/=]+$/.test(bundle) && !bundle.trim().startsWith('{') ? Buffer.from(bundle, 'base64') : Buffer.from(bundle, 'utf8');
57
+ if (!bytes)
58
+ return null;
59
+ let out = bytes;
60
+ if (out[0] === 0x1f && out[1] === 0x8b) {
61
+ try {
62
+ out = gunzipSync(out);
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ try {
69
+ return JSON.parse(out.toString('utf8'));
70
+ }
71
+ catch {
72
+ return null;
73
+ }
74
+ }
42
75
  /** `https://host/v1/proof/shared/<token>`, or the token on its own. */
43
76
  export function parseShareTarget(tokenOrUrl, baseUrlOverride) {
44
77
  const trimmed = tokenOrUrl.trim();
@@ -1 +1 @@
1
- {"version":3,"file":"shared-proof.js","sourceRoot":"","sources":["../src/shared-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAkB,EAClB,UAAoD,EAAE;IAEtD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzE,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAC7E;YACE,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM;YACpC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,uFAAuF;YACvF,qBAAqB;SACtB,CACF,CAAC;QACF,OAAO,IAAmB,CAAC;I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AG,EAAE,CAAC;QACnB,OAAO,IAAI,WAAW,CACpB,WAAW,IAAI,EAAE,KAAK,IAAI,oCAAoC,wBAAwB,EACtF,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,uBAAuB,CAC3C,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,WAAW,CACpB,gEAAgE,EAChE,GAAG,EAAE,WAAW,CACjB,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,IAAI,WAAW,CACpB,WAAW,IAAI,EAAE,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE,EAC5C,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,YAAY,CACnC,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,WAAW,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC;AAC5E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certen.io/sdk",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "TypeScript client for the CERTEN Gateway API — proof-gated cross-chain execution on Accumulate",
5
5
  "license": "MIT",
6
6
  "type": "module",