@mikeargento/bitgraph-player 0.2.0 → 0.3.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/README.md +1 -1
- package/SPEC.md +91 -5
- package/dist/__tests__/sig-v2.test.d.ts +2 -0
- package/dist/__tests__/sig-v2.test.d.ts.map +1 -0
- package/dist/__tests__/sig-v2.test.js +266 -0
- package/dist/__tests__/sig-v2.test.js.map +1 -0
- package/dist/evaluate.d.ts +8 -21
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +93 -2
- package/dist/evaluate.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/play.d.ts +12 -2
- package/dist/play.d.ts.map +1 -1
- package/dist/play.js +39 -4
- package/dist/play.js.map +1 -1
- package/dist/rule.d.ts +0 -13
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +84 -8
- package/dist/rule.js.map +1 -1
- package/dist/sig.d.ts +38 -0
- package/dist/sig.d.ts.map +1 -0
- package/dist/sig.js +154 -0
- package/dist/sig.js.map +1 -0
- package/dist/types.d.ts +21 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/verdict.d.ts +1 -1
- package/dist/verdict.d.ts.map +1 -1
- package/dist/verdict.js +17 -2
- package/dist/verdict.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/sig-v2.test.ts +315 -0
- package/src/evaluate.ts +107 -2
- package/src/index.ts +7 -3
- package/src/play.ts +43 -5
- package/src/rule.ts +93 -9
- package/src/sig.ts +170 -0
- package/src/types.ts +21 -4
- package/src/verdict.ts +18 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Deterministic evaluation of causal rules over BitGraph proof bundles.
|
|
4
4
|
|
|
5
|
-
BitGraph records. Player
|
|
5
|
+
BitGraph records. Player evaluates.
|
|
6
6
|
|
|
7
7
|
A BitGraph proof bundle establishes facts: these bits were recorded at
|
|
8
8
|
these causal positions, anchored to a public timeline. Player
|
package/SPEC.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
# BitGraph Player specification
|
|
1
|
+
# BitGraph Player specification
|
|
2
2
|
|
|
3
|
-
This document is the normative semantics of `bitgraph-player/1`
|
|
4
|
-
`bitgraph-player
|
|
3
|
+
This document is the normative semantics of `bitgraph-player/1` and
|
|
4
|
+
`bitgraph-player/2` rules and their verdicts (`bitgraph-player-verdict/1`
|
|
5
|
+
and `/2`). Sections 1 through 8 define format 1; section 9 defines the
|
|
6
|
+
format 2 extension. A format 1 rule MUST evaluate identically under an
|
|
7
|
+
evaluator that also implements format 2, to the byte. The TypeScript package in this
|
|
5
8
|
directory is the reference implementation; a conforming Player in any
|
|
6
9
|
language MUST reach the same result and, for the serialization defined in
|
|
7
10
|
section 7, the same bytes.
|
|
8
11
|
|
|
9
|
-
BitGraph records. Player
|
|
12
|
+
BitGraph records. Player evaluates. Player is a pure function:
|
|
10
13
|
|
|
11
14
|
evaluate(rule, verified evidence) -> verdict
|
|
12
15
|
|
|
@@ -41,11 +44,12 @@ A rule is a JSON object with exactly these top-level fields:
|
|
|
41
44
|
|
|
42
45
|
| field | required | value |
|
|
43
46
|
|---|---|---|
|
|
44
|
-
| `rule` | yes |
|
|
47
|
+
| `rule` | yes | `"bitgraph-player/1"`, or `"bitgraph-player/2"` (section 9) |
|
|
45
48
|
| `id` | yes | non-empty string naming the rule |
|
|
46
49
|
| `cast` | yes | object of at least one role (section 3) |
|
|
47
50
|
| `world` | yes | the string `"closed"` (the only defined value) |
|
|
48
51
|
| `requires` | yes | `{ "ordering": "hash-linked" \| "assumption-dependent" }` |
|
|
52
|
+
| `trustedKeys` | no | format 2 only (section 9.1) |
|
|
49
53
|
| `claim` | yes | a claim (section 5) |
|
|
50
54
|
| `then` | no | `{ "label": <non-empty string> }` |
|
|
51
55
|
|
|
@@ -237,3 +241,85 @@ These requirements govern evaluation invocations. A command-line Player
|
|
|
237
241
|
MAY offer authoring conveniences (such as rule scaffolding) as distinct
|
|
238
242
|
subcommands; those are outside this specification and MUST NOT change
|
|
239
243
|
the behavior of evaluation invocations.
|
|
244
|
+
|
|
245
|
+
## 9. Format 2: trustedKeys and signedBy
|
|
246
|
+
|
|
247
|
+
Format 2 (`"rule": "bitgraph-player/2"`) is format 1 plus signature
|
|
248
|
+
claims. Everything in sections 1 through 8 applies unchanged. Two
|
|
249
|
+
additions:
|
|
250
|
+
|
|
251
|
+
### 9.1 trustedKeys
|
|
252
|
+
|
|
253
|
+
An optional top-level object naming keys the rule author trusts:
|
|
254
|
+
|
|
255
|
+
"trustedKeys": { "<name>": { "alg": "ed25519" | "es256",
|
|
256
|
+
"publicKey": "<base64>" } }
|
|
257
|
+
|
|
258
|
+
Key names obey the role-name grammar (at least one non-digit). For
|
|
259
|
+
`ed25519` the publicKey is the raw 32-byte key in standard base64 — the
|
|
260
|
+
spelling bitgraph/1 proofs use for signer keys. For `es256` (ECDSA P-256
|
|
261
|
+
over SHA-256) it is SPKI DER in base64.
|
|
262
|
+
|
|
263
|
+
The name-to-key binding is DECLARED trust: the verdict surfaces every
|
|
264
|
+
entry in `declared` as `{ assertion: "trusted-key", verifiedHere: false }`.
|
|
265
|
+
Player verifies signature MATH against the key material; that the key
|
|
266
|
+
belongs to the named party is the rule author's assertion, exactly like a
|
|
267
|
+
cast digest's `means`. SIGNED_BY remains not a BitGraph primitive:
|
|
268
|
+
format 2 does not change what the chain knows, only what a rule can
|
|
269
|
+
verify about supplied evidence.
|
|
270
|
+
|
|
271
|
+
### 9.2 The bitgraph-sig/1 evidence file
|
|
272
|
+
|
|
273
|
+
A signature file is a JSON object:
|
|
274
|
+
|
|
275
|
+
{ "sig": "bitgraph-sig/1", "over": <digest>, "alg": <alg>,
|
|
276
|
+
"publicKey": <base64>, "signature": <base64> }
|
|
277
|
+
|
|
278
|
+
`over` accepts the digest spellings of section 3. The signed message is
|
|
279
|
+
the UTF-8 bytes of:
|
|
280
|
+
|
|
281
|
+
"bitgraph-sig/1\n" + lowercase hex SHA-256 of the target bytes
|
|
282
|
+
|
|
283
|
+
Domain separation is deliberate: a signature made in any other protocol
|
|
284
|
+
over the same digest is not a bitgraph-sig. For `ed25519` the signature
|
|
285
|
+
is the raw 64-byte form, base64; for `es256` it is DER-encoded ECDSA,
|
|
286
|
+
base64, verified over SHA-256 of the message.
|
|
287
|
+
|
|
288
|
+
### 9.3 The signedBy claim
|
|
289
|
+
|
|
290
|
+
{ "signedBy": [<roleName>, <trustedKeyName>] }
|
|
291
|
+
|
|
292
|
+
Valid only in format 2. The key name MUST be declared in trustedKeys;
|
|
293
|
+
an unresolvable reference is a parse error. Semantics:
|
|
294
|
+
|
|
295
|
+
| situation | result |
|
|
296
|
+
|---|---|
|
|
297
|
+
| role not declared in the cast | UNDETERMINED |
|
|
298
|
+
| trusted key material not decodable | UNDETERMINED |
|
|
299
|
+
| a supplied evidence file parses as bitgraph-sig/1, its `over` decodes to the role's digest bytes, its alg and publicKey equal the trusted key's, and the signature verifies | TRUE |
|
|
300
|
+
| otherwise | UNDETERMINED |
|
|
301
|
+
|
|
302
|
+
**signedBy is TRUE or UNDETERMINED, never FALSE.** "This key never
|
|
303
|
+
signed these bytes" is a negative over an open world: signatures can
|
|
304
|
+
exist outside any bundle, so absence of one proves nothing, and
|
|
305
|
+
`not(signedBy(...))` is therefore permanently UNDETERMINED under the
|
|
306
|
+
section 1 tables. A malformed or non-verifying signature file is not
|
|
307
|
+
evidence and not an error.
|
|
308
|
+
|
|
309
|
+
The claim is about BITS, not occurrences: it evaluates against the
|
|
310
|
+
declared role digest whether or not the role resolved to a recording.
|
|
311
|
+
Signature claims carry no ordering tier and never contribute to
|
|
312
|
+
`weakestEvidence`; a signature file's own causal position, when it has
|
|
313
|
+
been recorded, is claimed with the ordinary ordering predicates over a
|
|
314
|
+
role declaring the signature file's digest.
|
|
315
|
+
|
|
316
|
+
### 9.4 Evidence supply
|
|
317
|
+
|
|
318
|
+
Evaluation is a pure function; candidate signature bytes are an input.
|
|
319
|
+
A command-line Player evaluating a bundle MUST take as candidates every
|
|
320
|
+
bundle artifact that is matched to an observed proof and no larger than
|
|
321
|
+
1,048,576 bytes, keyed by content hash; embedders MAY supply additional
|
|
322
|
+
candidates. Candidates are scanned in ascending content-hash order and
|
|
323
|
+
the first verifying file decides, so the verdict is deterministic for a
|
|
324
|
+
given evidence set. A format 2 verdict is `bitgraph-player-verdict/2`;
|
|
325
|
+
the serialization discipline of section 7 is unchanged.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sig-v2.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sig-v2.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* Format 2: trustedKeys + signedBy.
|
|
4
|
+
*
|
|
5
|
+
* The invariants under test:
|
|
6
|
+
* - signedBy is TRUE or UNDETERMINED, never FALSE, so not(signedBy)
|
|
7
|
+
* is permanently UNDETERMINED: no open-world negative escapes.
|
|
8
|
+
* - Signature math is derived; the name-to-key binding is declared.
|
|
9
|
+
* - A /1 rule parses and evaluates exactly as before (verdict/1), and
|
|
10
|
+
* /2-only syntax in a /1 rule is a parse error.
|
|
11
|
+
* - Broken signature files are noise, never evidence and never errors.
|
|
12
|
+
*
|
|
13
|
+
* All evidence is synthetic and in-memory. No ledger writes, ever.
|
|
14
|
+
*/
|
|
15
|
+
import { strict as assert } from "node:assert";
|
|
16
|
+
import { createHash, generateKeyPairSync, sign as cryptoSign } from "node:crypto";
|
|
17
|
+
import { test } from "node:test";
|
|
18
|
+
import { evaluate } from "../evaluate.js";
|
|
19
|
+
import { playAudit, claimUsesSignatures } from "../play.js";
|
|
20
|
+
import { parseRule, RuleError } from "../rule.js";
|
|
21
|
+
import { parseSigFile, sigMessage } from "../sig.js";
|
|
22
|
+
import { resolveCast } from "../cast.js";
|
|
23
|
+
import { digestFor, makeAudit } from "./fixtures.js";
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Key + signature helpers (in-memory, per-run keys; verification is the
|
|
26
|
+
// deterministic part under test, not key generation)
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
function ed25519Pair() {
|
|
29
|
+
const { publicKey, privateKey } = generateKeyPairSync("ed25519");
|
|
30
|
+
const spki = publicKey.export({ format: "der", type: "spki" });
|
|
31
|
+
// Raw key = last 32 bytes of the SPKI encoding.
|
|
32
|
+
return { publicKeyB64: spki.subarray(spki.length - 32).toString("base64"), privateKey };
|
|
33
|
+
}
|
|
34
|
+
function es256Pair() {
|
|
35
|
+
const { publicKey, privateKey } = generateKeyPairSync("ec", { namedCurve: "P-256" });
|
|
36
|
+
const spki = publicKey.export({ format: "der", type: "spki" });
|
|
37
|
+
return { publicKeyB64: spki.toString("base64"), privateKey };
|
|
38
|
+
}
|
|
39
|
+
function hexOfB64(digestB64) {
|
|
40
|
+
return Buffer.from(digestB64, "base64").toString("hex");
|
|
41
|
+
}
|
|
42
|
+
function makeSigBytes(alg, publicKeyB64, privateKey, overHex) {
|
|
43
|
+
const message = sigMessage(overHex);
|
|
44
|
+
const signature = alg === "ed25519"
|
|
45
|
+
? cryptoSign(null, message, privateKey)
|
|
46
|
+
: cryptoSign("sha256", message, privateKey);
|
|
47
|
+
return Buffer.from(JSON.stringify({
|
|
48
|
+
sig: "bitgraph-sig/1",
|
|
49
|
+
over: `sha256:${overHex}`,
|
|
50
|
+
alg,
|
|
51
|
+
publicKey: publicKeyB64,
|
|
52
|
+
signature: signature.toString("base64"),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
function evidenceOf(...items) {
|
|
56
|
+
const map = new Map();
|
|
57
|
+
for (const bytes of items) {
|
|
58
|
+
map.set(createHash("sha256").update(bytes).digest("hex"), bytes);
|
|
59
|
+
}
|
|
60
|
+
return map;
|
|
61
|
+
}
|
|
62
|
+
const WORK = digestFor("work");
|
|
63
|
+
function v2Rule(publicKeyB64, alg, claim) {
|
|
64
|
+
return JSON.stringify({
|
|
65
|
+
rule: "bitgraph-player/2",
|
|
66
|
+
id: "test-v2",
|
|
67
|
+
cast: { work: { digest: WORK } },
|
|
68
|
+
world: "closed",
|
|
69
|
+
requires: { ordering: "assumption-dependent" },
|
|
70
|
+
trustedKeys: { mike: { alg, publicKey: publicKeyB64 } },
|
|
71
|
+
claim,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function auditWithWork() {
|
|
75
|
+
return makeAudit({
|
|
76
|
+
proofs: [{ name: "w", digestB64: WORK, epochId: "e1", counter: "1" }],
|
|
77
|
+
partitions: [{ epochId: "e1", members: ["w"] }],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Parsing
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
test("signedBy in a /1 rule is a parse error", () => {
|
|
84
|
+
const text = JSON.stringify({
|
|
85
|
+
rule: "bitgraph-player/1",
|
|
86
|
+
id: "r",
|
|
87
|
+
cast: { work: { digest: WORK } },
|
|
88
|
+
world: "closed",
|
|
89
|
+
requires: { ordering: "hash-linked" },
|
|
90
|
+
claim: { signedBy: ["work", "mike"] },
|
|
91
|
+
});
|
|
92
|
+
assert.throws(() => parseRule(text), RuleError);
|
|
93
|
+
});
|
|
94
|
+
test("trustedKeys in a /1 rule is a parse error", () => {
|
|
95
|
+
const text = JSON.stringify({
|
|
96
|
+
rule: "bitgraph-player/1",
|
|
97
|
+
id: "r",
|
|
98
|
+
cast: { work: { digest: WORK } },
|
|
99
|
+
world: "closed",
|
|
100
|
+
requires: { ordering: "hash-linked" },
|
|
101
|
+
trustedKeys: { mike: { alg: "ed25519", publicKey: "A".repeat(43) + "=" } },
|
|
102
|
+
claim: { exists: "work" },
|
|
103
|
+
});
|
|
104
|
+
assert.throws(() => parseRule(text), RuleError);
|
|
105
|
+
});
|
|
106
|
+
test("signedBy referencing an undeclared trusted key is a parse error", () => {
|
|
107
|
+
const { publicKeyB64 } = ed25519Pair();
|
|
108
|
+
const text = v2Rule(publicKeyB64, "ed25519", { signedBy: ["work", "ghost"] });
|
|
109
|
+
assert.throws(() => parseRule(text), /does not declare/);
|
|
110
|
+
});
|
|
111
|
+
test("trustedKeys entries are strictly validated", () => {
|
|
112
|
+
for (const bad of [
|
|
113
|
+
{ alg: "rsa", publicKey: "x" },
|
|
114
|
+
{ alg: "ed25519" },
|
|
115
|
+
{ publicKey: "x" },
|
|
116
|
+
{ alg: "ed25519", publicKey: "x", extra: 1 },
|
|
117
|
+
]) {
|
|
118
|
+
const text = JSON.stringify({
|
|
119
|
+
rule: "bitgraph-player/2",
|
|
120
|
+
id: "r",
|
|
121
|
+
cast: { work: { digest: WORK } },
|
|
122
|
+
world: "closed",
|
|
123
|
+
requires: { ordering: "hash-linked" },
|
|
124
|
+
trustedKeys: { mike: bad },
|
|
125
|
+
claim: { exists: "work" },
|
|
126
|
+
});
|
|
127
|
+
assert.throws(() => parseRule(text), RuleError, JSON.stringify(bad));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
test("pure-integer trusted key names are rejected", () => {
|
|
131
|
+
const text = JSON.stringify({
|
|
132
|
+
rule: "bitgraph-player/2",
|
|
133
|
+
id: "r",
|
|
134
|
+
cast: { work: { digest: WORK } },
|
|
135
|
+
world: "closed",
|
|
136
|
+
requires: { ordering: "hash-linked" },
|
|
137
|
+
trustedKeys: { "42": { alg: "ed25519", publicKey: "A".repeat(43) + "=" } },
|
|
138
|
+
claim: { exists: "work" },
|
|
139
|
+
});
|
|
140
|
+
assert.throws(() => parseRule(text), /non-digit/);
|
|
141
|
+
});
|
|
142
|
+
test("claimUsesSignatures walks the tree", () => {
|
|
143
|
+
assert.equal(claimUsesSignatures({ exists: "x" }), false);
|
|
144
|
+
assert.equal(claimUsesSignatures({ all: [{ exists: "x" }, { not: { signedBy: ["x", "k"] } }] }), true);
|
|
145
|
+
});
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Signature file parsing
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
test("parseSigFile accepts a well-formed file and rejects noise", () => {
|
|
150
|
+
const { publicKeyB64, privateKey } = ed25519Pair();
|
|
151
|
+
const good = makeSigBytes("ed25519", publicKeyB64, privateKey, hexOfB64(WORK));
|
|
152
|
+
assert.notEqual(parseSigFile(good), undefined);
|
|
153
|
+
assert.equal(parseSigFile(Buffer.from("not json")), undefined);
|
|
154
|
+
assert.equal(parseSigFile(Buffer.from(JSON.stringify({ sig: "other/1" }))), undefined);
|
|
155
|
+
assert.equal(parseSigFile(Buffer.from(JSON.stringify({ sig: "bitgraph-sig/1", over: "x", alg: "rsa" }))), undefined);
|
|
156
|
+
});
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
// Evaluation: ed25519 and es256
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
for (const alg of ["ed25519", "es256"]) {
|
|
161
|
+
test(`signedBy(${alg}): valid signature in evidence evaluates TRUE with derived math`, () => {
|
|
162
|
+
const pair = alg === "ed25519" ? ed25519Pair() : es256Pair();
|
|
163
|
+
const rule = parseRule(v2Rule(pair.publicKeyB64, alg, { signedBy: ["work", "mike"] }));
|
|
164
|
+
const audit = auditWithWork();
|
|
165
|
+
const evidence = evidenceOf(makeSigBytes(alg, pair.publicKeyB64, pair.privateKey, hexOfB64(WORK)));
|
|
166
|
+
const result = playAudit(rule, "0".repeat(64), audit, evidence);
|
|
167
|
+
assert.equal(result.verdict.result, "TRUE");
|
|
168
|
+
assert.equal(result.verdict.verdict, "bitgraph-player-verdict/2");
|
|
169
|
+
const step = result.verdict.derived.find((s) => s.claim.startsWith("signedBy"));
|
|
170
|
+
assert.ok(step !== undefined);
|
|
171
|
+
assert.equal(step.result, "TRUE");
|
|
172
|
+
// The binding is declared, alongside the math being derived.
|
|
173
|
+
const trusted = result.verdict.declared.find((d) => d.assertion === "trusted-key");
|
|
174
|
+
assert.ok(trusted !== undefined);
|
|
175
|
+
assert.equal(trusted["keyName"], "mike");
|
|
176
|
+
assert.equal(trusted.verifiedHere, false);
|
|
177
|
+
});
|
|
178
|
+
test(`signedBy(${alg}): tampered signature is noise, evaluates UNDETERMINED`, () => {
|
|
179
|
+
const pair = alg === "ed25519" ? ed25519Pair() : es256Pair();
|
|
180
|
+
const rule = parseRule(v2Rule(pair.publicKeyB64, alg, { signedBy: ["work", "mike"] }));
|
|
181
|
+
const bytes = makeSigBytes(alg, pair.publicKeyB64, pair.privateKey, hexOfB64(WORK));
|
|
182
|
+
const parsed = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
183
|
+
const sigBytes = Buffer.from(parsed["signature"], "base64");
|
|
184
|
+
sigBytes[0] = sigBytes[0] ^ 0xff;
|
|
185
|
+
parsed["signature"] = sigBytes.toString("base64");
|
|
186
|
+
const tampered = Buffer.from(JSON.stringify(parsed));
|
|
187
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork(), evidenceOf(tampered));
|
|
188
|
+
assert.equal(result.verdict.result, "UNDETERMINED");
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
test("a non-P-256 key declared as es256 is undecodable key material: UNDETERMINED, never a verify", () => {
|
|
192
|
+
const { publicKey, privateKey } = generateKeyPairSync("ec", { namedCurve: "secp384r1" });
|
|
193
|
+
const spki = publicKey.export({ format: "der", type: "spki" }).toString("base64");
|
|
194
|
+
const rule = parseRule(v2Rule(spki, "es256", { signedBy: ["work", "mike"] }));
|
|
195
|
+
const evidence = evidenceOf(makeSigBytes("es256", spki, privateKey, hexOfB64(WORK)));
|
|
196
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork(), evidence);
|
|
197
|
+
assert.equal(result.verdict.result, "UNDETERMINED");
|
|
198
|
+
const step = result.verdict.derived.find((s) => s.claim.startsWith("signedBy"));
|
|
199
|
+
assert.ok(step !== undefined);
|
|
200
|
+
assert.match(String(step.because["reason"]), /not decodable/);
|
|
201
|
+
});
|
|
202
|
+
test("signedBy with empty evidence is UNDETERMINED, and not(signedBy) stays UNDETERMINED", () => {
|
|
203
|
+
const { publicKeyB64 } = ed25519Pair();
|
|
204
|
+
const rule = parseRule(v2Rule(publicKeyB64, "ed25519", { not: { signedBy: ["work", "mike"] } }));
|
|
205
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork());
|
|
206
|
+
// Never FALSE and never TRUE: the open world stays open.
|
|
207
|
+
assert.equal(result.verdict.result, "UNDETERMINED");
|
|
208
|
+
});
|
|
209
|
+
test("signedBy by the wrong key is UNDETERMINED, never FALSE", () => {
|
|
210
|
+
const right = ed25519Pair();
|
|
211
|
+
const wrong = ed25519Pair();
|
|
212
|
+
const rule = parseRule(v2Rule(right.publicKeyB64, "ed25519", { signedBy: ["work", "mike"] }));
|
|
213
|
+
const evidence = evidenceOf(makeSigBytes("ed25519", wrong.publicKeyB64, wrong.privateKey, hexOfB64(WORK)));
|
|
214
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork(), evidence);
|
|
215
|
+
assert.equal(result.verdict.result, "UNDETERMINED");
|
|
216
|
+
});
|
|
217
|
+
test("signedBy over a different digest does not satisfy the role's claim", () => {
|
|
218
|
+
const pair = ed25519Pair();
|
|
219
|
+
const rule = parseRule(v2Rule(pair.publicKeyB64, "ed25519", { signedBy: ["work", "mike"] }));
|
|
220
|
+
const other = digestFor("other");
|
|
221
|
+
const evidence = evidenceOf(makeSigBytes("ed25519", pair.publicKeyB64, pair.privateKey, hexOfB64(other)));
|
|
222
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork(), evidence);
|
|
223
|
+
assert.equal(result.verdict.result, "UNDETERMINED");
|
|
224
|
+
});
|
|
225
|
+
test("signedBy evaluates against the declared digest even when the role has no recording", () => {
|
|
226
|
+
const pair = ed25519Pair();
|
|
227
|
+
const text = JSON.stringify({
|
|
228
|
+
rule: "bitgraph-player/2",
|
|
229
|
+
id: "r",
|
|
230
|
+
cast: { work: { digest: WORK, optional: true } },
|
|
231
|
+
world: "closed",
|
|
232
|
+
requires: { ordering: "hash-linked" },
|
|
233
|
+
trustedKeys: { mike: { alg: "ed25519", publicKey: pair.publicKeyB64 } },
|
|
234
|
+
claim: { signedBy: ["work", "mike"] },
|
|
235
|
+
});
|
|
236
|
+
const rule = parseRule(text);
|
|
237
|
+
const audit = makeAudit({ proofs: [], partitions: [] });
|
|
238
|
+
const evidence = evidenceOf(makeSigBytes("ed25519", pair.publicKeyB64, pair.privateKey, hexOfB64(WORK)));
|
|
239
|
+
const resolutions = resolveCast(rule.cast, audit);
|
|
240
|
+
const evaluation = evaluate(rule, resolutions, audit, evidence);
|
|
241
|
+
assert.equal(evaluation.result, "TRUE");
|
|
242
|
+
});
|
|
243
|
+
test("a /1 rule still yields a /1 verdict and ignores supplied evidence", () => {
|
|
244
|
+
const text = JSON.stringify({
|
|
245
|
+
rule: "bitgraph-player/1",
|
|
246
|
+
id: "r",
|
|
247
|
+
cast: { work: { digest: WORK } },
|
|
248
|
+
world: "closed",
|
|
249
|
+
requires: { ordering: "assumption-dependent" },
|
|
250
|
+
claim: { exists: "work" },
|
|
251
|
+
});
|
|
252
|
+
const rule = parseRule(text);
|
|
253
|
+
const result = playAudit(rule, "0".repeat(64), auditWithWork(), evidenceOf(Buffer.from("junk")));
|
|
254
|
+
assert.equal(result.verdict.verdict, "bitgraph-player-verdict/1");
|
|
255
|
+
assert.equal(result.verdict.result, "TRUE");
|
|
256
|
+
});
|
|
257
|
+
test("multiple candidates: the winner is deterministic and reported by content hash", () => {
|
|
258
|
+
const pair = ed25519Pair();
|
|
259
|
+
const rule = parseRule(v2Rule(pair.publicKeyB64, "ed25519", { signedBy: ["work", "mike"] }));
|
|
260
|
+
const sig = makeSigBytes("ed25519", pair.publicKeyB64, pair.privateKey, hexOfB64(WORK));
|
|
261
|
+
const junk = Buffer.from("{}");
|
|
262
|
+
const a = playAudit(rule, "0".repeat(64), auditWithWork(), evidenceOf(sig, junk));
|
|
263
|
+
const b = playAudit(rule, "0".repeat(64), auditWithWork(), evidenceOf(junk, sig));
|
|
264
|
+
assert.equal(a.bytes, b.bytes);
|
|
265
|
+
});
|
|
266
|
+
//# sourceMappingURL=sig-v2.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sig-v2.test.js","sourceRoot":"","sources":["../../src/__tests__/sig-v2.test.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErD,8EAA8E;AAC9E,wEAAwE;AACxE,qDAAqD;AACrD,8EAA8E;AAE9E,SAAS,WAAW;IAClB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAW,CAAC;IACzE,gDAAgD;IAChD,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAA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CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAClF,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAClF,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
|
package/dist/evaluate.d.ts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The evaluator: walks the claim tree over resolved recordings and the
|
|
3
|
-
* ordering adapter, under strong Kleene semantics.
|
|
4
|
-
*
|
|
5
|
-
* Deliberate properties:
|
|
6
|
-
*
|
|
7
|
-
* - FULL WALK, no short-circuit. Every sub-claim is evaluated and recorded
|
|
8
|
-
* so the verdict is a complete replayable trace, not just an outcome.
|
|
9
|
-
*
|
|
10
|
-
* - CLOSED WORLD, scoped to the cast. An absent OPTIONAL role is a
|
|
11
|
-
* definite absence within the declared universe: positive claims about
|
|
12
|
-
* it are FALSE, so negatives over it hold. An absent REQUIRED role, an
|
|
13
|
-
* ambiguous role, and a role the cast never declared are UNDETERMINED —
|
|
14
|
-
* the evidence does not decide, and saying FALSE would be a lie.
|
|
15
|
-
*
|
|
16
|
-
* - THE FLOOR GATES EVIDENCE, NOT POLARITY. When an ordering answer rests
|
|
17
|
-
* on a tier below requires.ordering, the answer is UNDETERMINED whether
|
|
18
|
-
* it would have been TRUE or FALSE: the rule author said not to trust
|
|
19
|
-
* that evidence in either direction.
|
|
20
|
-
*/
|
|
21
1
|
import type { AuditResult } from "@mikeargento/bitgraph-audit";
|
|
22
2
|
import type { DerivedStep, EvidenceTier, Resolution, Rule, ThreeValued } from "./types.js";
|
|
23
3
|
export interface Evaluation {
|
|
@@ -26,5 +6,12 @@ export interface Evaluation {
|
|
|
26
6
|
/** Weakest tier among ordering answers that actually decided a step. */
|
|
27
7
|
weakestEvidence?: EvidenceTier;
|
|
28
8
|
}
|
|
29
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Signature evidence for format-2 signedBy claims: candidate file bytes
|
|
11
|
+
* keyed by lowercase hex SHA-256. Collected by the caller (play() streams
|
|
12
|
+
* size-capped matched artifacts from the bundle); evaluate() itself stays
|
|
13
|
+
* a pure function over its arguments.
|
|
14
|
+
*/
|
|
15
|
+
export type SigEvidence = ReadonlyMap<string, Uint8Array>;
|
|
16
|
+
export declare function evaluate(rule: Rule, resolutions: Map<string, Resolution>, audit: AuditResult, sigEvidence?: SigEvidence): Evaluation;
|
|
30
17
|
//# sourceMappingURL=evaluate.d.ts.map
|
package/dist/evaluate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,6BAA6B,CAAC;AAM9E,OAAO,KAAK,EAEV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,wEAAwE;IACxE,eAAe,CAAC,EAAE,YAAY,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AA2Q1D,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,KAAK,EAAE,WAAW,EAClB,WAAW,GAAE,WAAuB,GACnC,UAAU,CAkBZ"}
|
package/dist/evaluate.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
2
|
import { kleeneAll, kleeneAny, kleeneNot } from "./logic.js";
|
|
3
3
|
import { compare } from "./order.js";
|
|
4
|
+
import { decodeDigestBytes, normalizeDigest } from "./rule.js";
|
|
5
|
+
import { keyObjectFor, parseSigFile, verifySigFile } from "./sig.js";
|
|
4
6
|
import { basisTier, meetsFloor } from "./types.js";
|
|
5
7
|
function positionOf(proof) {
|
|
6
8
|
const out = { proofHash: proof.proofHash };
|
|
@@ -137,9 +139,90 @@ function evalPrecedes(ctx, claim, x, y) {
|
|
|
137
139
|
because,
|
|
138
140
|
});
|
|
139
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* signedBy(role, keyName): TRUE when a valid bitgraph-sig/1 by the named
|
|
144
|
+
* trusted key over the role's digest is present in the supplied evidence;
|
|
145
|
+
* UNDETERMINED otherwise, NEVER FALSE. Absence of a signature from a
|
|
146
|
+
* bundle proves nothing about the world, and `not(signedBy(...))` is
|
|
147
|
+
* therefore permanently UNDETERMINED by the Kleene table.
|
|
148
|
+
*
|
|
149
|
+
* The claim is about BITS, not occurrences: it evaluates against the
|
|
150
|
+
* declared role digest whether or not the role resolved to a recording.
|
|
151
|
+
* Only an undeclared role is UNDETERMINED for want of a digest.
|
|
152
|
+
*/
|
|
153
|
+
function evalSignedBy(ctx, role, keyName) {
|
|
154
|
+
const claim = `signedBy(${role}, ${keyName})`;
|
|
155
|
+
const entry = ctx.rule.cast[role];
|
|
156
|
+
if (entry === undefined) {
|
|
157
|
+
return record(ctx, {
|
|
158
|
+
claim,
|
|
159
|
+
result: "UNDETERMINED",
|
|
160
|
+
because: { reason: `role "${role}" is not declared in the cast` },
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
// parseRule guarantees the key name resolves; guard for direct API use.
|
|
164
|
+
const key = ctx.rule.trustedKeys?.[keyName];
|
|
165
|
+
if (key === undefined) {
|
|
166
|
+
return record(ctx, {
|
|
167
|
+
claim,
|
|
168
|
+
result: "UNDETERMINED",
|
|
169
|
+
because: { reason: `trusted key "${keyName}" is not declared` },
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (!ctx.keyObjects.has(keyName))
|
|
173
|
+
ctx.keyObjects.set(keyName, keyObjectFor(key));
|
|
174
|
+
const keyObject = ctx.keyObjects.get(keyName);
|
|
175
|
+
if (keyObject === undefined) {
|
|
176
|
+
return record(ctx, {
|
|
177
|
+
claim,
|
|
178
|
+
result: "UNDETERMINED",
|
|
179
|
+
because: {
|
|
180
|
+
reason: `trusted key "${keyName}" is not decodable as ${key.alg} key material; no signature can verify against it`,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const digestB64 = normalizeDigest(entry.digest);
|
|
185
|
+
const targetHex = decodeDigestBytes(digestB64).toString("hex");
|
|
186
|
+
// Deterministic scan: candidates in ascending content-hash order.
|
|
187
|
+
const candidates = [...ctx.sigEvidence.keys()].sort();
|
|
188
|
+
let parsedCount = 0;
|
|
189
|
+
for (const sha256Hex of candidates) {
|
|
190
|
+
const bytes = ctx.sigEvidence.get(sha256Hex);
|
|
191
|
+
const sig = parseSigFile(bytes);
|
|
192
|
+
if (sig === undefined)
|
|
193
|
+
continue;
|
|
194
|
+
parsedCount += 1;
|
|
195
|
+
if (verifySigFile(sig, key, keyObject, targetHex, decodeDigestBytes)) {
|
|
196
|
+
return record(ctx, {
|
|
197
|
+
claim,
|
|
198
|
+
result: "TRUE",
|
|
199
|
+
because: {
|
|
200
|
+
signatureSha256Hex: sha256Hex,
|
|
201
|
+
alg: key.alg,
|
|
202
|
+
keyName,
|
|
203
|
+
over: `sha256:${targetHex}`,
|
|
204
|
+
note: "signature math verified here; that this key belongs to the named party is declared, never derived",
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return record(ctx, {
|
|
210
|
+
claim,
|
|
211
|
+
result: "UNDETERMINED",
|
|
212
|
+
because: {
|
|
213
|
+
reason: `no valid bitgraph-sig/1 by trusted key "${keyName}" over the role digest is present in the ` +
|
|
214
|
+
`supplied evidence (${ctx.sigEvidence.size} candidate file(s), ${parsedCount} parsed as signatures); ` +
|
|
215
|
+
`absence of a signature from a bundle proves nothing`,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
}
|
|
140
219
|
function evalClaim(ctx, claim) {
|
|
141
220
|
if ("exists" in claim)
|
|
142
221
|
return evalExists(ctx, claim.exists);
|
|
222
|
+
if ("signedBy" in claim) {
|
|
223
|
+
const [role, keyName] = claim.signedBy;
|
|
224
|
+
return evalSignedBy(ctx, role, keyName);
|
|
225
|
+
}
|
|
143
226
|
if ("before" in claim) {
|
|
144
227
|
const [x, y] = claim.before;
|
|
145
228
|
return evalPrecedes(ctx, `before(${x}, ${y})`, x, y);
|
|
@@ -162,8 +245,16 @@ function evalClaim(ctx, claim) {
|
|
|
162
245
|
return kleeneAny(claim.any.map((c) => evalClaim(ctx, c)));
|
|
163
246
|
return kleeneNot(evalClaim(ctx, claim.not));
|
|
164
247
|
}
|
|
165
|
-
export function evaluate(rule, resolutions, audit) {
|
|
166
|
-
const ctx = {
|
|
248
|
+
export function evaluate(rule, resolutions, audit, sigEvidence = new Map()) {
|
|
249
|
+
const ctx = {
|
|
250
|
+
rule,
|
|
251
|
+
resolutions,
|
|
252
|
+
audit,
|
|
253
|
+
steps: [],
|
|
254
|
+
usedTiers: new Set(),
|
|
255
|
+
sigEvidence,
|
|
256
|
+
keyObjects: new Map(),
|
|
257
|
+
};
|
|
167
258
|
const result = evalClaim(ctx, rule.claim);
|
|
168
259
|
const evaluation = { result, steps: ctx.steps };
|
|
169
260
|
if (ctx.usedTiers.has("assumption-dependent")) {
|
package/dist/evaluate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA,qFAAqF;
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAyBrF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAmCnD,SAAS,UAAU,CAAC,KAAoB;IACtC,MAAM,GAAG,GAA4B,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IACpE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAChE,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,GAAG,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAChE,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS;QAAE,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5E,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CACf,GAAQ,EACR,IAAY;IAKZ,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,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