@mikeargento/bitgraph-verify 1.10.0 → 1.11.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.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * What makes a proof an Ethereum anchor.
3
+ *
4
+ * One definition, because this was five copies of a string literal: the
5
+ * website's ledger feed, its anchor lookup and its digest route, the audit
6
+ * package, and the published proof-format page all decided independently, and
7
+ * all of them decided on `attribution.name`.
8
+ *
9
+ * ⚠️ THE NAME IS THE WEAK TEST, AND IT IS ALSO IN THE WAY. `attribution` holds
10
+ * exactly one name, so a proof cannot say "Ethereum Anchor" and carry the
11
+ * `bitgraph-fuse/1` marker at the same time — which is what blocks an anchor
12
+ * from being fused like every other artifact on the ledger. The strong test
13
+ * was already there: the enclave writes `commit.anchor` only after verifying
14
+ * the anchor service's Ed25519 signature over the claim against a public key
15
+ * baked into its image, and refuses the reserved attribution name to anyone
16
+ * who cannot produce one. The proof-format docs already said as much: a proof
17
+ * whose attribution says anchor but which lacks `commit.anchor` is not an
18
+ * anchor.
19
+ *
20
+ * ⚠️ AND THE NAME CANNOT SIMPLY BE DROPPED. `commit.anchor` arrived with
21
+ * enclave v7 on 2026-09-06, and the ledger holds anchors from months before
22
+ * it — the oldest carry the attribution name and no `commit.anchor` at all.
23
+ * Testing only the signed field would silently un-anchor the entire history.
24
+ *
25
+ * So both are accepted and they are told apart, because they are not equally
26
+ * strong and a caller that cares should be able to say so.
27
+ */
28
+ import type { BitGraphProof } from "./types.js";
29
+ /** The reserved attribution name. Signed, and refused by the enclave without a valid claim. */
30
+ export declare const ANCHOR_ATTRIBUTION_NAME = "Ethereum Anchor";
31
+ export type AnchorKind =
32
+ /** `commit.anchor` is present: the enclave verified the anchor service's signature over the claim. */
33
+ "authenticated"
34
+ /** Pre-v7. Only the signed attribution name says so, and nothing in the proof backs it. */
35
+ | "legacy-attribution";
36
+ /**
37
+ * How this proof claims to be an anchor, or null if it does not.
38
+ *
39
+ * Prefers the authenticated form. A proof that satisfies both — every anchor
40
+ * written since v7 — reports "authenticated", because that is the claim worth
41
+ * acting on.
42
+ */
43
+ export declare function anchorKindOf(proof: unknown): AnchorKind | null;
44
+ /** The block an authenticated anchor commits to, as the enclave signed it. */
45
+ export interface AnchorMark {
46
+ blockNumber: number;
47
+ blockHash: string;
48
+ }
49
+ /**
50
+ * The authenticated anchor mark, or null when there is none.
51
+ *
52
+ * This is where an anchor's block should be read from. The same block also
53
+ * appears in `attribution.message` and `attribution.title`, but only by
54
+ * convention, and that convention is what stops an anchor's attribution being
55
+ * used for anything else. Reading `commit.anchor` frees it.
56
+ */
57
+ export declare function anchorMarkOf(proof: unknown): AnchorMark | null;
58
+ /**
59
+ * Whether this proof is an Ethereum anchor, in either form.
60
+ *
61
+ * Use this wherever a display or a lookup needs to know. Where the strength of
62
+ * the claim matters — an audit, anything that reports on trust — call
63
+ * `anchorKindOf` and treat the two differently.
64
+ */
65
+ export declare function isAnchorProof(proof: unknown): proof is BitGraphProof;
66
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,+FAA+F;AAC/F,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AAEzD,MAAM,MAAM,UAAU;AACpB,sGAAsG;AACpG,eAAe;AACjB,2FAA2F;GACzF,oBAAoB,CAAC;AAQzB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAY9D;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAU9D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEpE"}
package/dist/anchor.js ADDED
@@ -0,0 +1,60 @@
1
+ // Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
2
+ /** The reserved attribution name. Signed, and refused by the enclave without a valid claim. */
3
+ export const ANCHOR_ATTRIBUTION_NAME = "Ethereum Anchor";
4
+ function record(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value)
6
+ ? value
7
+ : null;
8
+ }
9
+ /**
10
+ * How this proof claims to be an anchor, or null if it does not.
11
+ *
12
+ * Prefers the authenticated form. A proof that satisfies both — every anchor
13
+ * written since v7 — reports "authenticated", because that is the claim worth
14
+ * acting on.
15
+ */
16
+ export function anchorKindOf(proof) {
17
+ const p = record(proof);
18
+ if (p === null)
19
+ return null;
20
+ const commit = record(p["commit"]);
21
+ if (commit !== null && commit["anchor"] !== undefined && commit["anchor"] !== null) {
22
+ return "authenticated";
23
+ }
24
+ const attribution = record(p["attribution"]);
25
+ if (attribution !== null && attribution["name"] === ANCHOR_ATTRIBUTION_NAME) {
26
+ return "legacy-attribution";
27
+ }
28
+ return null;
29
+ }
30
+ /**
31
+ * The authenticated anchor mark, or null when there is none.
32
+ *
33
+ * This is where an anchor's block should be read from. The same block also
34
+ * appears in `attribution.message` and `attribution.title`, but only by
35
+ * convention, and that convention is what stops an anchor's attribution being
36
+ * used for anything else. Reading `commit.anchor` frees it.
37
+ */
38
+ export function anchorMarkOf(proof) {
39
+ const p = record(proof);
40
+ const commit = p === null ? null : record(p["commit"]);
41
+ const mark = commit === null ? null : record(commit["anchor"]);
42
+ if (mark === null)
43
+ return null;
44
+ const blockNumber = mark["blockNumber"];
45
+ const blockHash = mark["blockHash"];
46
+ return typeof blockNumber === "number" && Number.isFinite(blockNumber) && typeof blockHash === "string"
47
+ ? { blockNumber, blockHash }
48
+ : null;
49
+ }
50
+ /**
51
+ * Whether this proof is an Ethereum anchor, in either form.
52
+ *
53
+ * Use this wherever a display or a lookup needs to know. Where the strength of
54
+ * the claim matters — an audit, anything that reports on trust — call
55
+ * `anchorKindOf` and treat the two differently.
56
+ */
57
+ export function isAnchorProof(proof) {
58
+ return anchorKindOf(proof) !== null;
59
+ }
60
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.js","sourceRoot":"","sources":["../src/anchor.ts"],"names":[],"mappings":"AAAA,qFAAqF;AA+BrF,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAQzD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnC,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QACnF,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7C,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,uBAAuB,EAAE,CAAC;QAC5E,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAQD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/D,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IACpC,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,SAAS,KAAK,QAAQ;QACrG,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE;QAC5B,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AACtC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * Permissionless by design: this package is MIT-licensed so that anyone
6
6
  * can verify a proof without asking permission.
7
7
  */
8
+ export { ANCHOR_ATTRIBUTION_NAME, anchorKindOf, anchorMarkOf, isAnchorProof, type AnchorKind, type AnchorMark, } from "./anchor.js";
8
9
  export type { BitGraphProof, BitGraphPolicy, VerificationPolicy, SignedBody, EnforcementTier, Attribution, PolicyBinding, SlotAllocation, ActorIdentity, AuthorizationPayload, WebAuthnAuthorization, AgencyEnvelope, } from "./types.js";
9
10
  export { verify, verifyProofIntegrity, resetEpochLinkState } from "./verifier.js";
10
11
  export type { VerifyResult, ProofIntegrityResult } from "./verifier.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAClF,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EA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E,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACzP,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAM1H,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,12 @@
1
1
  // Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
2
+ /**
3
+ * @mikeargento/bitgraph-verify
4
+ *
5
+ * Offline, deterministic verification of BitGraph proofs.
6
+ * Permissionless by design: this package is MIT-licensed so that anyone
7
+ * can verify a proof without asking permission.
8
+ */
9
+ export { ANCHOR_ATTRIBUTION_NAME, anchorKindOf, anchorMarkOf, isAnchorProof, } from "./anchor.js";
2
10
  export { verify, verifyProofIntegrity, resetEpochLinkState } from "./verifier.js";
3
11
  export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyHash } from "./proof-hash.js";
4
12
  export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAyBrF,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAA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E,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeargento/bitgraph-verify",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Offline verification of BitGraph proofs. Permissionless by design.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/anchor.ts ADDED
@@ -0,0 +1,103 @@
1
+ // Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
2
+
3
+ /**
4
+ * What makes a proof an Ethereum anchor.
5
+ *
6
+ * One definition, because this was five copies of a string literal: the
7
+ * website's ledger feed, its anchor lookup and its digest route, the audit
8
+ * package, and the published proof-format page all decided independently, and
9
+ * all of them decided on `attribution.name`.
10
+ *
11
+ * ⚠️ THE NAME IS THE WEAK TEST, AND IT IS ALSO IN THE WAY. `attribution` holds
12
+ * exactly one name, so a proof cannot say "Ethereum Anchor" and carry the
13
+ * `bitgraph-fuse/1` marker at the same time — which is what blocks an anchor
14
+ * from being fused like every other artifact on the ledger. The strong test
15
+ * was already there: the enclave writes `commit.anchor` only after verifying
16
+ * the anchor service's Ed25519 signature over the claim against a public key
17
+ * baked into its image, and refuses the reserved attribution name to anyone
18
+ * who cannot produce one. The proof-format docs already said as much: a proof
19
+ * whose attribution says anchor but which lacks `commit.anchor` is not an
20
+ * anchor.
21
+ *
22
+ * ⚠️ AND THE NAME CANNOT SIMPLY BE DROPPED. `commit.anchor` arrived with
23
+ * enclave v7 on 2026-09-06, and the ledger holds anchors from months before
24
+ * it — the oldest carry the attribution name and no `commit.anchor` at all.
25
+ * Testing only the signed field would silently un-anchor the entire history.
26
+ *
27
+ * So both are accepted and they are told apart, because they are not equally
28
+ * strong and a caller that cares should be able to say so.
29
+ */
30
+ import type { BitGraphProof } from "./types.js";
31
+
32
+ /** The reserved attribution name. Signed, and refused by the enclave without a valid claim. */
33
+ export const ANCHOR_ATTRIBUTION_NAME = "Ethereum Anchor";
34
+
35
+ export type AnchorKind =
36
+ /** `commit.anchor` is present: the enclave verified the anchor service's signature over the claim. */
37
+ | "authenticated"
38
+ /** Pre-v7. Only the signed attribution name says so, and nothing in the proof backs it. */
39
+ | "legacy-attribution";
40
+
41
+ function record(value: unknown): Record<string, unknown> | null {
42
+ return typeof value === "object" && value !== null && !Array.isArray(value)
43
+ ? (value as Record<string, unknown>)
44
+ : null;
45
+ }
46
+
47
+ /**
48
+ * How this proof claims to be an anchor, or null if it does not.
49
+ *
50
+ * Prefers the authenticated form. A proof that satisfies both — every anchor
51
+ * written since v7 — reports "authenticated", because that is the claim worth
52
+ * acting on.
53
+ */
54
+ export function anchorKindOf(proof: unknown): AnchorKind | null {
55
+ const p = record(proof);
56
+ if (p === null) return null;
57
+ const commit = record(p["commit"]);
58
+ if (commit !== null && commit["anchor"] !== undefined && commit["anchor"] !== null) {
59
+ return "authenticated";
60
+ }
61
+ const attribution = record(p["attribution"]);
62
+ if (attribution !== null && attribution["name"] === ANCHOR_ATTRIBUTION_NAME) {
63
+ return "legacy-attribution";
64
+ }
65
+ return null;
66
+ }
67
+
68
+ /** The block an authenticated anchor commits to, as the enclave signed it. */
69
+ export interface AnchorMark {
70
+ blockNumber: number;
71
+ blockHash: string;
72
+ }
73
+
74
+ /**
75
+ * The authenticated anchor mark, or null when there is none.
76
+ *
77
+ * This is where an anchor's block should be read from. The same block also
78
+ * appears in `attribution.message` and `attribution.title`, but only by
79
+ * convention, and that convention is what stops an anchor's attribution being
80
+ * used for anything else. Reading `commit.anchor` frees it.
81
+ */
82
+ export function anchorMarkOf(proof: unknown): AnchorMark | null {
83
+ const p = record(proof);
84
+ const commit = p === null ? null : record(p["commit"]);
85
+ const mark = commit === null ? null : record(commit["anchor"]);
86
+ if (mark === null) return null;
87
+ const blockNumber = mark["blockNumber"];
88
+ const blockHash = mark["blockHash"];
89
+ return typeof blockNumber === "number" && Number.isFinite(blockNumber) && typeof blockHash === "string"
90
+ ? { blockNumber, blockHash }
91
+ : null;
92
+ }
93
+
94
+ /**
95
+ * Whether this proof is an Ethereum anchor, in either form.
96
+ *
97
+ * Use this wherever a display or a lookup needs to know. Where the strength of
98
+ * the claim matters — an audit, anything that reports on trust — call
99
+ * `anchorKindOf` and treat the two differently.
100
+ */
101
+ export function isAnchorProof(proof: unknown): proof is BitGraphProof {
102
+ return anchorKindOf(proof) !== null;
103
+ }
package/src/index.ts CHANGED
@@ -8,6 +8,15 @@
8
8
  * can verify a proof without asking permission.
9
9
  */
10
10
 
11
+ export {
12
+ ANCHOR_ATTRIBUTION_NAME,
13
+ anchorKindOf,
14
+ anchorMarkOf,
15
+ isAnchorProof,
16
+ type AnchorKind,
17
+ type AnchorMark,
18
+ } from "./anchor.js";
19
+
11
20
  export type {
12
21
  BitGraphProof,
13
22
  BitGraphPolicy,