@forestrie/forestrie-cli 0.8.1 → 0.9.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/dist/cli.js +1179 -341
- package/dist/lib/decode-receipt-labels.d.ts +7 -0
- package/dist/lib/decode-receipt-labels.d.ts.map +1 -1
- package/dist/lib/decode-receipt-labels.js +15 -0
- package/dist/lib/decode-receipt-labels.js.map +1 -1
- package/package.json +8 -8
- package/src/lib/checkpoint-provider.ts +30 -4
- package/src/lib/consistency-proof.ts +14 -6
- package/src/lib/decode-checkpoint-calldata.ts +12 -3
- package/src/lib/decode-receipt-labels.ts +16 -0
- package/src/lib/resolve-receipt-freshen.ts +10 -1
|
@@ -25,6 +25,13 @@ export declare const CWT_CLAIMS_LABEL = 15;
|
|
|
25
25
|
export declare const DELEGATION_CERT_LABEL = 1000;
|
|
26
26
|
/** Pre-signed peak inclusion receipts on a checkpoint (`SealPeakReceiptsLabel`). */
|
|
27
27
|
export declare const SEAL_PEAK_RECEIPTS_LABEL = -65931;
|
|
28
|
+
/**
|
|
29
|
+
* Signed `tree-size-2` on a checkpoint's PROTECTED header (ADR-0066 D1 as
|
|
30
|
+
* amended 2026-09-20, `@forestrie/encoding` `COSE_LABEL_TREE_SIZE_2`): the
|
|
31
|
+
* only sealed size a checkpoint signs. Label -65932 (`tree-size-1`) was
|
|
32
|
+
* withdrawn before use and must not be registered here.
|
|
33
|
+
*/
|
|
34
|
+
export declare const TREE_SIZE_2_LABEL = -65933;
|
|
28
35
|
/** Inclusion proofs key inside header 396. */
|
|
29
36
|
export declare const PROOFS_INCLUSION_KEY = -1;
|
|
30
37
|
/** Consistency proofs key inside header 396. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode-receipt-labels.d.ts","sourceRoot":"","sources":["../../src/lib/decode-receipt-labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,c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AS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAIhD,CAAC;AAEH,wDAAwD;AACxD,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAStD,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAO3D,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAGvD,CAAC;AAEH,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE/D"}
|
|
@@ -25,6 +25,13 @@ export const CWT_CLAIMS_LABEL = 15;
|
|
|
25
25
|
export const DELEGATION_CERT_LABEL = 1000;
|
|
26
26
|
/** Pre-signed peak inclusion receipts on a checkpoint (`SealPeakReceiptsLabel`). */
|
|
27
27
|
export const SEAL_PEAK_RECEIPTS_LABEL = -65931;
|
|
28
|
+
/**
|
|
29
|
+
* Signed `tree-size-2` on a checkpoint's PROTECTED header (ADR-0066 D1 as
|
|
30
|
+
* amended 2026-09-20, `@forestrie/encoding` `COSE_LABEL_TREE_SIZE_2`): the
|
|
31
|
+
* only sealed size a checkpoint signs. Label -65932 (`tree-size-1`) was
|
|
32
|
+
* withdrawn before use and must not be registered here.
|
|
33
|
+
*/
|
|
34
|
+
export const TREE_SIZE_2_LABEL = -65933;
|
|
28
35
|
/** Inclusion proofs key inside header 396. */
|
|
29
36
|
export const PROOFS_INCLUSION_KEY = -1;
|
|
30
37
|
/** Consistency proofs key inside header 396. */
|
|
@@ -78,6 +85,14 @@ export const HEADER_LABELS = new Map([
|
|
|
78
85
|
note: "forestrie SealPeakReceiptsLabel (checkpoint header)",
|
|
79
86
|
},
|
|
80
87
|
],
|
|
88
|
+
[
|
|
89
|
+
TREE_SIZE_2_LABEL,
|
|
90
|
+
{
|
|
91
|
+
name: "tree-size-2",
|
|
92
|
+
note: "forestrie: signed sealed size (ADR-0066 D1 as amended, checkpoint " +
|
|
93
|
+
"protected header)",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
81
96
|
[
|
|
82
97
|
-66535,
|
|
83
98
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode-receipt-labels.js","sourceRoot":"","sources":["../../src/lib/decode-receipt-labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,oFAAoF;AACpF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"decode-receipt-labels.js","sourceRoot":"","sources":["../../src/lib/decode-receipt-labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,uFAAuF;AACvF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,oFAAoF;AACpF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAK,CAAC;AAC/C;;;;;GAKG;AACH,MAAM,CA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AC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forestrie/forestrie-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "forestrie — participant CLI for forestrie transparency logs (SCITT / COSE receipts)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"forestrie",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"prepack": "bun run build"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@forestrie/chain-rpc": "^0.
|
|
67
|
+
"@forestrie/chain-rpc": "^0.3.0",
|
|
68
68
|
"@forestrie/cli-kit": "^0.1.1",
|
|
69
|
-
"@forestrie/delegation-cose": "^0.3.
|
|
69
|
+
"@forestrie/delegation-cose": "^0.3.2",
|
|
70
70
|
"@forestrie/deploy-core": "^0.7.1",
|
|
71
|
-
"@forestrie/encoding": "^0.
|
|
72
|
-
"@forestrie/grant-builder": "^0.
|
|
73
|
-
"@forestrie/merklelog": "^0.
|
|
74
|
-
"@forestrie/receipt-verify": "^
|
|
75
|
-
"@forestrie/scrapi-client": "^0.
|
|
71
|
+
"@forestrie/encoding": "^0.8.0",
|
|
72
|
+
"@forestrie/grant-builder": "^0.5.0",
|
|
73
|
+
"@forestrie/merklelog": "^0.4.0",
|
|
74
|
+
"@forestrie/receipt-verify": "^2.0.0",
|
|
75
|
+
"@forestrie/scrapi-client": "^0.2.2",
|
|
76
76
|
"citty": "^0.2.2",
|
|
77
77
|
"viem": "^2.31.0"
|
|
78
78
|
},
|
|
@@ -55,6 +55,23 @@ export type CheckpointSeal =
|
|
|
55
55
|
}
|
|
56
56
|
| { kind: "sth"; checkpointBytes: Uint8Array };
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Fold-relevant fields of a consistency proof, shared by calldata-decoded
|
|
60
|
+
* proofs (`CalldataConsistencyProof` — no per-proof signed size; on-chain
|
|
61
|
+
* calldata carries no protected header) and sth-decoded
|
|
62
|
+
* `CheckpointConsistencyProof` (which adds `signedTreeSize2`, cross-checked
|
|
63
|
+
* against the checkpoint's protected header at decode time). Neither
|
|
64
|
+
* `computeCheckpointAccumulator` nor `freshenReceipt` reads `signedTreeSize2`
|
|
65
|
+
* — only the trusted base SIZE (passed separately, never off the proof) and
|
|
66
|
+
* `treeSize1`/`treeSize2`/`paths`/`rightPeaks` matter to the fold — so this
|
|
67
|
+
* provider carries the narrower shape and backfills `signedTreeSize2` with
|
|
68
|
+
* `treeSize2` only where receipt-verify's stricter parameter type demands it.
|
|
69
|
+
*/
|
|
70
|
+
export type FoldableConsistencyProof = Pick<
|
|
71
|
+
CheckpointConsistencyProof,
|
|
72
|
+
"treeSize1" | "treeSize2" | "paths" | "rightPeaks"
|
|
73
|
+
>;
|
|
74
|
+
|
|
58
75
|
/** One folded link: the accumulator committed at `treeSize2`. */
|
|
59
76
|
export type CheckpointLink = {
|
|
60
77
|
treeSize1: bigint;
|
|
@@ -64,7 +81,7 @@ export type CheckpointLink = {
|
|
|
64
81
|
/** The raw consistency proof this link was folded from — its per-peak `paths`
|
|
65
82
|
* (the tile-free climb material). Retained so a path-extending consumer
|
|
66
83
|
* (freshen) gets it without a re-decode; folding consumers ignore it. */
|
|
67
|
-
proof:
|
|
84
|
+
proof: FoldableConsistencyProof;
|
|
68
85
|
/** The signature material to verify this link's accumulator, when directly
|
|
69
86
|
* signed (see {@link CheckpointSeal}). The provider does NOT verify it. */
|
|
70
87
|
seal?: CheckpointSeal;
|
|
@@ -81,7 +98,7 @@ export type CheckpointLink = {
|
|
|
81
98
|
* start at base 0.
|
|
82
99
|
*/
|
|
83
100
|
export async function foldProofChain(
|
|
84
|
-
proofs: readonly
|
|
101
|
+
proofs: readonly FoldableConsistencyProof[],
|
|
85
102
|
opts: {
|
|
86
103
|
accumulatorFrom?: Uint8Array[];
|
|
87
104
|
accumulatorFromSize?: bigint;
|
|
@@ -109,7 +126,16 @@ export async function foldProofChain(
|
|
|
109
126
|
`checkpoint chain is not contiguous at link ${i}: base ${p.treeSize1} != expected ${expectedBase}`,
|
|
110
127
|
);
|
|
111
128
|
}
|
|
112
|
-
|
|
129
|
+
// receipt-verify 2.0.0: the trusted base size is a parameter, never read
|
|
130
|
+
// off the proof (ADR-0066 D5.4) — `expectedBase` is exactly that, already
|
|
131
|
+
// checked against `p.treeSize1` above. `signedTreeSize2` is backfilled
|
|
132
|
+
// from `treeSize2` only to satisfy the parameter type; the fold does not
|
|
133
|
+
// read it (see `FoldableConsistencyProof`'s doc comment above).
|
|
134
|
+
accumulator = await computeCheckpointAccumulator(
|
|
135
|
+
{ ...p, signedTreeSize2: p.treeSize2 },
|
|
136
|
+
accumulator,
|
|
137
|
+
expectedBase,
|
|
138
|
+
);
|
|
113
139
|
const link: CheckpointLink = {
|
|
114
140
|
treeSize1: p.treeSize1,
|
|
115
141
|
treeSize2: p.treeSize2,
|
|
@@ -220,7 +246,7 @@ export async function calldataCheckpointChain(opts: {
|
|
|
220
246
|
}),
|
|
221
247
|
);
|
|
222
248
|
|
|
223
|
-
const proofs:
|
|
249
|
+
const proofs: FoldableConsistencyProof[] = [];
|
|
224
250
|
const seals: (CheckpointSeal | undefined)[] = [];
|
|
225
251
|
const sourceRefs: string[] = [];
|
|
226
252
|
const finalLinkIndex: number[] = []; // link index of each tx's last proof
|
|
@@ -180,10 +180,16 @@ export async function buildConsistencyProofArtifact(opts: {
|
|
|
180
180
|
// supplied massifs fails HERE, not at the holder.
|
|
181
181
|
const accumulatorTo = peakMMRIndexes(opts.toSize - 1n).map(opts.get);
|
|
182
182
|
const hasher = await createSyncHasher();
|
|
183
|
+
// merklelog 0.4.0: both sizes are CALLER-TRUSTED state, never read off
|
|
184
|
+
// `proof` (ADR-0066 D5.4) — `opts.fromSize`/`opts.toSize` are exactly what
|
|
185
|
+
// this builder already trusts (they seeded `accumulatorFrom`/`accumulatorTo`
|
|
186
|
+
// above).
|
|
183
187
|
const check = await verifyConsistency(
|
|
184
188
|
hasher,
|
|
185
|
-
|
|
189
|
+
opts.fromSize,
|
|
190
|
+
opts.toSize,
|
|
186
191
|
accumulatorFrom,
|
|
192
|
+
proof.paths,
|
|
187
193
|
accumulatorTo,
|
|
188
194
|
);
|
|
189
195
|
if (!check.ok) {
|
|
@@ -249,14 +255,16 @@ export async function checkReceiptAnchoredViaConsistencyProof(opts: {
|
|
|
249
255
|
};
|
|
250
256
|
}
|
|
251
257
|
const hasher = await createSyncHasher();
|
|
258
|
+
// merklelog 0.4.0: sizes are caller-trusted parameters, not read off a
|
|
259
|
+
// proof object — `artifact.toSize` was already checked equal to
|
|
260
|
+
// `opts.trustedSize` above, and `artifact.fromSize` is the base whose
|
|
261
|
+
// accumulator `recomputedPeak` was just matched against.
|
|
252
262
|
const check = await verifyConsistency(
|
|
253
263
|
hasher,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
mmrSizeB: artifact.toSize,
|
|
257
|
-
paths: artifact.paths,
|
|
258
|
-
},
|
|
264
|
+
artifact.fromSize,
|
|
265
|
+
artifact.toSize,
|
|
259
266
|
artifact.accumulatorFrom,
|
|
267
|
+
artifact.paths,
|
|
260
268
|
opts.trustedAccumulator,
|
|
261
269
|
);
|
|
262
270
|
if (!check.ok) {
|
|
@@ -13,15 +13,20 @@
|
|
|
13
13
|
* consumes it lands in later phases.
|
|
14
14
|
*
|
|
15
15
|
* The ABI is written in viem's readable form, mirroring univocity
|
|
16
|
-
* `src/interfaces/types.sol
|
|
17
|
-
* foundry-generated `
|
|
16
|
+
* `src/interfaces/types.sol` at v0.3.0; its selector is asserted against the
|
|
17
|
+
* foundry-generated `0x295e6ade` in the tests. `DelegationProof.algData`
|
|
18
|
+
* (ADR-0008, univocity #36) is the alg-specific material — empty for ES256
|
|
19
|
+
* and KS256, the WebAuthn assertion parts for ES256-WebAuthn. Transactions
|
|
20
|
+
* to the pre-ADR-0008 contracts (selector `0x87ce4c61`, five-field
|
|
21
|
+
* delegation) are not `publishCheckpoint` calls on the current ABI and are
|
|
22
|
+
* rejected at the selector.
|
|
18
23
|
*/
|
|
19
24
|
import { decodeFunctionData, parseAbi } from "viem";
|
|
20
25
|
|
|
21
26
|
/** `publishCheckpoint` ABI — struct shapes mirror univocity types.sol. */
|
|
22
27
|
export const PUBLISH_CHECKPOINT_ABI = parseAbi([
|
|
23
28
|
"struct ConsistencyProof { uint64 treeSize1; uint64 treeSize2; bytes32[][] paths; bytes32[] rightPeaks; }",
|
|
24
|
-
"struct DelegationProof { bytes protectedHeader; bytes delegationKey; uint64 mmrStart; uint64 mmrEnd; bytes signature; }",
|
|
29
|
+
"struct DelegationProof { bytes protectedHeader; bytes delegationKey; uint64 mmrStart; uint64 mmrEnd; bytes signature; bytes[] algData; }",
|
|
25
30
|
"struct ConsistencyReceipt { bytes protectedHeader; bytes signature; ConsistencyProof[] consistencyProofs; DelegationProof delegationProof; }",
|
|
26
31
|
"struct InclusionProof { uint64 index; bytes32[] path; }",
|
|
27
32
|
"struct PublishGrant { bytes32 logId; uint256 grant; uint256 request; uint64 maxHeight; uint64 minGrowth; bytes32 ownerLogId; bytes grantData; }",
|
|
@@ -46,6 +51,8 @@ export type CalldataDelegation = {
|
|
|
46
51
|
mmrStart: bigint;
|
|
47
52
|
mmrEnd: bigint;
|
|
48
53
|
signature: Uint8Array;
|
|
54
|
+
/** Alg-specific material (ADR-0008); empty for ES256 / KS256. */
|
|
55
|
+
algData: Uint8Array[];
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
/** The full `ConsistencyReceipt` recovered from `publishCheckpoint` calldata. */
|
|
@@ -98,6 +105,7 @@ export function decodePublishCheckpointCalldata(
|
|
|
98
105
|
mmrStart: bigint;
|
|
99
106
|
mmrEnd: bigint;
|
|
100
107
|
signature: string;
|
|
108
|
+
algData: readonly string[];
|
|
101
109
|
};
|
|
102
110
|
};
|
|
103
111
|
|
|
@@ -128,6 +136,7 @@ export function decodePublishCheckpointCalldata(
|
|
|
128
136
|
mmrStart: receipt.delegationProof.mmrStart,
|
|
129
137
|
mmrEnd: receipt.delegationProof.mmrEnd,
|
|
130
138
|
signature: hexToBytes(receipt.delegationProof.signature),
|
|
139
|
+
algData: receipt.delegationProof.algData.map(hexToBytes),
|
|
131
140
|
},
|
|
132
141
|
};
|
|
133
142
|
}
|
|
@@ -27,6 +27,13 @@ export const CWT_CLAIMS_LABEL = 15;
|
|
|
27
27
|
export const DELEGATION_CERT_LABEL = 1000;
|
|
28
28
|
/** Pre-signed peak inclusion receipts on a checkpoint (`SealPeakReceiptsLabel`). */
|
|
29
29
|
export const SEAL_PEAK_RECEIPTS_LABEL = -65931;
|
|
30
|
+
/**
|
|
31
|
+
* Signed `tree-size-2` on a checkpoint's PROTECTED header (ADR-0066 D1 as
|
|
32
|
+
* amended 2026-09-20, `@forestrie/encoding` `COSE_LABEL_TREE_SIZE_2`): the
|
|
33
|
+
* only sealed size a checkpoint signs. Label -65932 (`tree-size-1`) was
|
|
34
|
+
* withdrawn before use and must not be registered here.
|
|
35
|
+
*/
|
|
36
|
+
export const TREE_SIZE_2_LABEL = -65933;
|
|
30
37
|
|
|
31
38
|
/** Inclusion proofs key inside header 396. */
|
|
32
39
|
export const PROOFS_INCLUSION_KEY = -1;
|
|
@@ -90,6 +97,15 @@ export const HEADER_LABELS: ReadonlyMap<number, LabelInfo> = new Map([
|
|
|
90
97
|
note: "forestrie SealPeakReceiptsLabel (checkpoint header)",
|
|
91
98
|
},
|
|
92
99
|
],
|
|
100
|
+
[
|
|
101
|
+
TREE_SIZE_2_LABEL,
|
|
102
|
+
{
|
|
103
|
+
name: "tree-size-2",
|
|
104
|
+
note:
|
|
105
|
+
"forestrie: signed sealed size (ADR-0066 D1 as amended, checkpoint " +
|
|
106
|
+
"protected header)",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
93
109
|
[
|
|
94
110
|
-66535,
|
|
95
111
|
{
|
|
@@ -102,7 +102,16 @@ async function emitFreshened(opts: {
|
|
|
102
102
|
const result = await freshenReceipt({
|
|
103
103
|
oldReceiptBytes: opts.oldReceiptBytes,
|
|
104
104
|
leafValue: opts.leafValue,
|
|
105
|
-
|
|
105
|
+
// `freshenReceipt`'s consistency-proof array type carries
|
|
106
|
+
// `signedTreeSize2` (checked at `.sth` decode time), but the fold itself
|
|
107
|
+
// never reads it — see `FoldableConsistencyProof`'s doc comment in
|
|
108
|
+
// checkpoint-provider.ts. Backfilled from `treeSize2` to satisfy the
|
|
109
|
+
// parameter type for calldata-sourced links, which have no per-proof
|
|
110
|
+
// signed size.
|
|
111
|
+
consistencyProofs: opts.links.map((l) => ({
|
|
112
|
+
...l.proof,
|
|
113
|
+
signedTreeSize2: l.proof.treeSize2,
|
|
114
|
+
})),
|
|
106
115
|
latestCheckpointBytes: opts.latestCheckpointBytes,
|
|
107
116
|
});
|
|
108
117
|
|