@mikeargento/bitgraph-verify 1.21.0 → 1.22.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 +15 -12
- package/dist/__tests__/attested.test.d.ts +15 -0
- package/dist/__tests__/attested.test.d.ts.map +1 -0
- package/dist/__tests__/attested.test.js +78 -0
- package/dist/__tests__/attested.test.js.map +1 -0
- package/dist/attested.d.ts +55 -0
- package/dist/attested.d.ts.map +1 -0
- package/dist/attested.js +52 -0
- package/dist/attested.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/attested.test.ts +86 -0
- package/src/__tests__/fixtures/v12/proof-14.json +39 -0
- package/src/attested.ts +106 -0
- package/src/index.ts +3 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Offline, deterministic verification of [BitGraph](https://bitgraph.ing) proofs.
|
|
4
4
|
|
|
5
|
-
A BitGraph is made inside a hardware enclave in one atomic action: a fresh
|
|
5
|
+
A BitGraph is made inside a hardware enclave in one atomic action: a fresh nonce from the hardware's random number generator takes one count on a monotonic counter, the content's SHA-256 takes the next, and both are signed together. This package checks that proof offline. `verifyAttested` is the full check: the signature, the two counts, and the AWS Nitro attestation, pinned to the enclave images BitGraph published.
|
|
6
6
|
|
|
7
7
|
Verification of BitGraph proofs is permissionless by design. This package is MIT-licensed so that anyone, including parties adverse to the proof's issuer, can verify a proof without asking permission, online or offline, forever.
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Verification of BitGraph proofs is permissionless by design. This package is MIT
|
|
|
10
10
|
npm install @mikeargento/bitgraph-verify
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Proofs made by enclave v11 and later are plain proofs: check them with `verifyAttested`, below. Trees made on the Make page bind `merkle-root.txt` as an ordinary proof. Earlier BitGraphs were tree/1 positions: one Merkle tree of files under one proof, one file a tree of one. Their holder keeps an **export** (bitgraph-export/1) beside the files, with `SPEC.md`, the exact text the proof pins. `verifyExport` checks an export with the file it is about and answers one claim per line, each saying what it rests on:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { verifyExport, parseExport } from "@mikeargento/bitgraph-verify";
|
|
@@ -21,27 +21,30 @@ result.claims; // proof, attestation, spec pin, tree root, this file's leaf,
|
|
|
21
21
|
result.times; // floor, ceilingBase, ceilingEthereum: three time claims, never merged
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
The three time claims are kept apart. The floor is in time: the committed bytes were finished after floor block N, the Base block signed into the proof as `commit.slotFloor` (an Ethereum block, `commit.slotAnchor`, on proofs made before the switch). The ceiling on Base is in time: the record existed by Base block B, provisional until B is confirmed as Base's own. Settlement is Ethereum's record of that Base block through Base's output root (`bitgraph-output-root/1`). A pending section reads NOT_CARRIED, never FALSE. A part in a format this version does not know is UNDETERMINED. The spec hash a proof pins must be one this verifier knows: `KNOWN_TREE_SPEC_HASHES` holds SPEC.md version 1, `QazdIR0JYtHQwQuIISo7bvH1gxUvTS2cY+tW6BjUIRs=`, frozen 2026-10-04 and never changed; a later version is added beside it.
|
|
24
|
+
The three time claims are kept apart. The floor is in time: the committed bytes were finished after floor block N, the Base block signed into the proof as `commit.slotFloor` (an Ethereum block, `commit.slotAnchor`, on proofs made before the switch; v12 proofs sign no floor). The ceiling on Base is in time: the record existed by Base block B, provisional until B is confirmed as Base's own. Settlement is Ethereum's record of that Base block through Base's output root (`bitgraph-output-root/1`). A pending section reads NOT_CARRIED, never FALSE. A part in a format this version does not know is UNDETERMINED. The spec hash a proof pins must be one this verifier knows: `KNOWN_TREE_SPEC_HASHES` holds SPEC.md version 1, `QazdIR0JYtHQwQuIISo7bvH1gxUvTS2cY+tW6BjUIRs=`, frozen 2026-10-04 and never changed; a later version is added beside it.
|
|
25
25
|
|
|
26
26
|
`verifyTreeMember` checks one leaf and path against a tree/1 proof. `verifyCarrier` judges a BitGraphed file, a file that carries its own proof: carrier/2 and /3 for a single-file position, carrier/4 for one member of a tree/1 BitGraph (its bytes walked to the signed root document through the member's leaf and path). `verifyCeiling` checks a ceiling in time, `verifyOutputRootSettlement` its settlement, `verifyNitroAttestation` the attestation to the AWS Nitro root. `PUBLISHED_PCR0S` is the default measurement policy: a proof from any other enclave image is not a BitGraph.
|
|
27
27
|
|
|
28
|
-
A bare bitgraph/1 proof is checked against its bytes with `
|
|
28
|
+
A bare bitgraph/1 proof is checked against its bytes with `verifyAttested`. This is the check to rely on:
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
|
-
import {
|
|
31
|
+
import { verifyAttested } from "@mikeargento/bitgraph-verify";
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
//
|
|
36
|
-
//
|
|
33
|
+
const r = await verifyAttested({ proof, bytes }); // bytes optional; pcr0: [...] to name your own accepted images
|
|
34
|
+
if (r.valid) {
|
|
35
|
+
// the bytes match the digest; the Ed25519 signature, the nonce's record and the two consecutive counts hold;
|
|
36
|
+
// the AWS Nitro attestation verifies to the AWS root, at its own signed time, over this exact signed body;
|
|
37
|
+
// and the image it attests (r.pcr0, r.image) is one BitGraph published. r.attestedAtMs is when it was bound.
|
|
37
38
|
} else {
|
|
38
|
-
console.error(
|
|
39
|
+
console.error(r.reason);
|
|
39
40
|
}
|
|
40
41
|
```
|
|
41
42
|
|
|
43
|
+
`verify({ proof, bytes })` is the lower layer: structure, the Ed25519 signature, the slot record, the counts and the digest match. It checks the signature against the key **the proof itself carries**, and does not open the attestation, so on its own it cannot tell BitGraph's enclave from anyone who made a key and signed a body. Use it only beneath `verifyAttested`, or with your own `allowedPublicKeys`.
|
|
44
|
+
|
|
42
45
|
Verification runs entirely locally: the artifact bytes and the proof JSON are the only inputs. No network access, no account, no contact with BitGraph.
|
|
43
46
|
|
|
44
|
-
What a
|
|
47
|
+
What a valid result does **not** assert: anything about when or how the content was made (only where and when its digest was bound); that the proof is in BitGraph's ledger; and `commit.prevB64` is checked as a field, never against the predecessor proof, which this call does not have (`verifyStretch` checks a run of consecutive proofs you hold).
|
|
45
48
|
|
|
46
49
|
Verification is a function of its inputs. The single-successor (fork) history is the one piece of state it keeps, and only a proof that passed every check records anything in it. Pass a context of your own to keep one run's history separate:
|
|
47
50
|
|
|
@@ -54,7 +57,7 @@ await verify({ proof, bytes, context });
|
|
|
54
57
|
|
|
55
58
|
The proof schema (`bitgraph/1`), canonical serialization, and proofHash computation live here as well, so independent implementations can be checked against this one. The normative text is `spec/SPEC.md` in the repository; earlier formats (plain recordings, single fused files, set/1, set/2, carrier/1) keep verifying.
|
|
56
59
|
|
|
57
|
-
See [bitgraph.ing/
|
|
60
|
+
See [bitgraph.ing/tools](https://bitgraph.ing/tools) for the verification checklist and attestation handling, and [CHANGELOG.md](./CHANGELOG.md) for what 1.16.0 added.
|
|
58
61
|
|
|
59
62
|
Making a BitGraph is separate and proprietary: [`@mikeargento/bitgraph-sdk`](https://www.npmjs.com/package/@mikeargento/bitgraph-sdk) for software, built on [`@mikeargento/bitgraph`](https://www.npmjs.com/package/@mikeargento/bitgraph).
|
|
60
63
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verifyAttested: the full check of a plain proof (2026-10-18 audit, finding D.1).
|
|
3
|
+
*
|
|
4
|
+
* The fixture is a real production proof: BitGraph #14 of epoch 1TYU…, made by enclave v12 (PCR0 cf1ca497…) on
|
|
5
|
+
* 2026-10-18, binding merkle-root.txt of a five-file tree. Its attestation is AWS-signed, so this test checks the
|
|
6
|
+
* real chain to the AWS Nitro root at the document's own instant.
|
|
7
|
+
*
|
|
8
|
+
* The point of the test is the forgery: a key anyone can make, signing a body that claims "measured-tee" and the
|
|
9
|
+
* published PCR0. verify() alone passes it (it checks the signature against the key the proof carries); the full
|
|
10
|
+
* check refuses it, because the hardware document is not about that body.
|
|
11
|
+
*
|
|
12
|
+
* cd packages/verify && npx tsc -p . && node --test dist/__tests__/attested.test.js
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=attested.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attested.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/attested.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verifyAttested: the full check of a plain proof (2026-10-18 audit, finding D.1).
|
|
3
|
+
*
|
|
4
|
+
* The fixture is a real production proof: BitGraph #14 of epoch 1TYU…, made by enclave v12 (PCR0 cf1ca497…) on
|
|
5
|
+
* 2026-10-18, binding merkle-root.txt of a five-file tree. Its attestation is AWS-signed, so this test checks the
|
|
6
|
+
* real chain to the AWS Nitro root at the document's own instant.
|
|
7
|
+
*
|
|
8
|
+
* The point of the test is the forgery: a key anyone can make, signing a body that claims "measured-tee" and the
|
|
9
|
+
* published PCR0. verify() alone passes it (it checks the signature against the key the proof carries); the full
|
|
10
|
+
* check refuses it, because the hardware document is not about that body.
|
|
11
|
+
*
|
|
12
|
+
* cd packages/verify && npx tsc -p . && node --test dist/__tests__/attested.test.js
|
|
13
|
+
*/
|
|
14
|
+
import { test } from "node:test";
|
|
15
|
+
import { strict as assert } from "node:assert";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { getPublicKeyAsync, signAsync, utils } from "@noble/ed25519";
|
|
18
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
19
|
+
import { verifyAttested } from "../attested.js";
|
|
20
|
+
import { verify, createVerificationContext } from "../verifier.js";
|
|
21
|
+
import { buildSignedBody } from "../proof-hash.js";
|
|
22
|
+
import { canonicalize } from "../canonical.js";
|
|
23
|
+
const proof = JSON.parse(readFileSync(new URL("../../src/__tests__/fixtures/v12/proof-14.json", import.meta.url), "utf8"));
|
|
24
|
+
const bytes = new TextEncoder().encode("Merkle root (RFC 6962, SHA-256) of 5 files:\n48c297f66dd6535a173662db20083164ee46d527f6e8db18d1044af8e394e1a8\n");
|
|
25
|
+
const b64 = (u) => Buffer.from(u).toString("base64");
|
|
26
|
+
const clone = (p) => JSON.parse(JSON.stringify(p));
|
|
27
|
+
test("the real proof is BitGraph's: signature, atomic counts, attestation chain, binding and published image", async () => {
|
|
28
|
+
assert.equal(b64(sha256(bytes)), proof.artifact.digestB64, "the fixture's bytes are its committed bytes");
|
|
29
|
+
const r = await verifyAttested({ proof, bytes });
|
|
30
|
+
assert.equal(r.valid, true, r.reason);
|
|
31
|
+
assert.equal(r.artifactBinding, "checked");
|
|
32
|
+
assert.equal(r.image?.version, "v12");
|
|
33
|
+
assert.ok(r.attestedAtMs && new Date(r.attestedAtMs).toISOString().startsWith("2026-10-18"));
|
|
34
|
+
assert.ok(r.checks.every((c) => c.pass));
|
|
35
|
+
});
|
|
36
|
+
test("without the bytes, everything but the digest comparison is checked, and said", async () => {
|
|
37
|
+
const r = await verifyAttested({ proof });
|
|
38
|
+
assert.equal(r.valid, true, r.reason);
|
|
39
|
+
assert.equal(r.artifactBinding, "not-checked");
|
|
40
|
+
});
|
|
41
|
+
test("other bytes do not verify", async () => {
|
|
42
|
+
const r = await verifyAttested({ proof, bytes: new TextEncoder().encode("something else") });
|
|
43
|
+
assert.equal(r.valid, false);
|
|
44
|
+
});
|
|
45
|
+
test("a forged proof signed by anyone's key passes verify() alone, and fails the full check", async () => {
|
|
46
|
+
const forged = clone(proof);
|
|
47
|
+
forged.artifact.digestB64 = b64(sha256(new TextEncoder().encode("a file BitGraph never saw")));
|
|
48
|
+
const priv = utils.randomPrivateKey();
|
|
49
|
+
const pub = b64(await getPublicKeyAsync(priv));
|
|
50
|
+
forged.signer.publicKeyB64 = pub;
|
|
51
|
+
// Re-sign the slot record and the body with the forger's key, keeping the real attestation and the real PCR0 string.
|
|
52
|
+
const slot = forged.slotAllocation;
|
|
53
|
+
slot["publicKeyB64"] = pub;
|
|
54
|
+
const { signatureB64: _s, ...slotBody } = slot;
|
|
55
|
+
slot["signatureB64"] = b64(await signAsync(canonicalize(slotBody), priv));
|
|
56
|
+
forged.commit.slotHashB64 = b64(sha256(canonicalize(slotBody)));
|
|
57
|
+
forged.signer.signatureB64 = b64(await signAsync(canonicalize(buildSignedBody(forged)), priv));
|
|
58
|
+
const plain = await verify({ proof: forged, bytes: new TextEncoder().encode("a file BitGraph never saw"), context: createVerificationContext() });
|
|
59
|
+
assert.equal(plain.valid, true, "verify() alone accepts the forgery: this is the gap verifyAttested closes");
|
|
60
|
+
const full = await verifyAttested({ proof: forged, bytes: new TextEncoder().encode("a file BitGraph never saw") });
|
|
61
|
+
assert.equal(full.valid, false);
|
|
62
|
+
assert.match(full.reason ?? "", /attestation does not verify/);
|
|
63
|
+
});
|
|
64
|
+
test("no attestation, or an image the verifier does not accept, is not BitGraph's", async () => {
|
|
65
|
+
const none = clone(proof);
|
|
66
|
+
delete none.environment.attestation;
|
|
67
|
+
assert.equal((await verifyAttested({ proof: none, bytes })).valid, false);
|
|
68
|
+
const other = await verifyAttested({ proof, bytes, pcr0: ["00".repeat(48)] });
|
|
69
|
+
assert.equal(other.valid, false);
|
|
70
|
+
assert.match(other.reason ?? "", /not an image this verifier accepts/);
|
|
71
|
+
});
|
|
72
|
+
test("a changed count breaks the proof", async () => {
|
|
73
|
+
const gap = clone(proof);
|
|
74
|
+
gap.commit.counter = String(Number(gap.commit.counter) + 2);
|
|
75
|
+
const r = await verifyAttested({ proof: gap, bytes });
|
|
76
|
+
assert.equal(r.valid, false);
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=attested.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attested.test.js","sourceRoot":"","sources":["../../src/__tests__/attested.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAA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AAG,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The full check of a plain BitGraph proof: the one every BitGraph tool runs (2026-10-18 audit, finding D.1).
|
|
3
|
+
*
|
|
4
|
+
* verify() checks a proof's own consistency: its Ed25519 signature, its slot record, its counts and its structure.
|
|
5
|
+
* The key it checks against is the one the proof carries, so on its own it cannot tell BitGraph's enclave from anyone
|
|
6
|
+
* who made a key and signed a body. What makes a proof BitGraph's is the hardware: the AWS Nitro attestation document
|
|
7
|
+
* the enclave requested over the signed body. verifyAttested() adds exactly that:
|
|
8
|
+
*
|
|
9
|
+
* 1. verify() itself, requiring the atomic form (count N+1 right after the nonce's N) whenever the proof says it
|
|
10
|
+
* is atomic, and on any proof whose image is v11 or later;
|
|
11
|
+
* 2. the attestation in full (nitro.ts verifyNitroAttestation): its ES384 signature, its certificate chain to the
|
|
12
|
+
* AWS Nitro root, every certificate valid at the document's own instant, the PCR0 the proof declares, and
|
|
13
|
+
* user_data equal to SHA-256 of the signed body, so the document is about this proof and no other;
|
|
14
|
+
* 3. the image: the PCR0 inside the hardware-signed document must be one the caller accepts, by default an image
|
|
15
|
+
* BitGraph published (measurements.ts). A valid attestation from some other enclave is not BitGraph's.
|
|
16
|
+
*
|
|
17
|
+
* Valid means: these bytes (when given) were bound at this position by the published BitGraph enclave image, as the
|
|
18
|
+
* AWS hardware attests. It says nothing about when or how the content was made.
|
|
19
|
+
*/
|
|
20
|
+
import type { BitGraphProof, VerificationPolicy } from "./types.js";
|
|
21
|
+
import { type VerificationContext } from "./verifier.js";
|
|
22
|
+
import { type NitroCheck } from "./nitro.js";
|
|
23
|
+
export interface AttestedOptions {
|
|
24
|
+
/** The proof to check. */
|
|
25
|
+
proof: BitGraphProof;
|
|
26
|
+
/** The committed bytes. Omitted: everything but the bytes-versus-digest comparison is checked. */
|
|
27
|
+
bytes?: Uint8Array;
|
|
28
|
+
/** The enclave images accepted, by PCR0 (hex). Default: every image BitGraph has published. */
|
|
29
|
+
pcr0?: readonly string[];
|
|
30
|
+
/** A different root certificate (DER), for testing against a non-AWS chain. Default: the AWS Nitro root. */
|
|
31
|
+
rootDer?: Uint8Array;
|
|
32
|
+
/** Extra policy for verify(). requireAtomic is set here whenever the proof is atomic. */
|
|
33
|
+
trustAnchors?: VerificationPolicy;
|
|
34
|
+
context?: VerificationContext;
|
|
35
|
+
}
|
|
36
|
+
export interface AttestedResult {
|
|
37
|
+
valid: boolean;
|
|
38
|
+
/** Why it is not valid; absent when valid. */
|
|
39
|
+
reason?: string;
|
|
40
|
+
/** Each attestation check, in order, with its detail. */
|
|
41
|
+
checks: NitroCheck[];
|
|
42
|
+
/** The PCR0 inside the hardware-signed document (lowercase hex), when it could be read. */
|
|
43
|
+
pcr0: string | null;
|
|
44
|
+
/** The published image that PCR0 names, when it is one of BitGraph's. */
|
|
45
|
+
image: {
|
|
46
|
+
version: string;
|
|
47
|
+
since: string;
|
|
48
|
+
} | null;
|
|
49
|
+
/** The document's own signed time (ms since the epoch): when the enclave bound this proof. */
|
|
50
|
+
attestedAtMs: number | null;
|
|
51
|
+
/** Whether the bytes were compared with the proof's digest. */
|
|
52
|
+
artifactBinding: "checked" | "not-checked";
|
|
53
|
+
}
|
|
54
|
+
export declare function verifyAttested(opts: AttestedOptions): Promise<AttestedResult>;
|
|
55
|
+
//# sourceMappingURL=attested.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attested.d.ts","sourceRoot":"","sources":["../src/attested.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAA2D,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAIrE,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,kGAAkG;IAClG,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,4GAA4G;IAC5G,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,yFAAyF;IACzF,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,2FAA2F;IAC3F,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,yEAAyE;IACzE,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,8FAA8F;IAC9F,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,+DAA+D;IAC/D,eAAe,EAAE,SAAS,GAAG,aAAa,CAAC;CAC5C;AAKD,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA4CnF"}
|
package/dist/attested.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
import { verify, verifyProofIntegrity, createVerificationContext } from "./verifier.js";
|
|
3
|
+
import { verifyNitroAttestation } from "./nitro.js";
|
|
4
|
+
import { computeSignedBodyHash } from "./proof-hash.js";
|
|
5
|
+
import { PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
|
|
6
|
+
/** Images from v11 on make every proof atomic; a proof from one must be in the atomic form. */
|
|
7
|
+
const ATOMIC_FROM = new Set(["v11", "v12"]);
|
|
8
|
+
export async function verifyAttested(opts) {
|
|
9
|
+
const { proof, bytes } = opts;
|
|
10
|
+
const artifactBinding = bytes !== undefined ? "checked" : "not-checked";
|
|
11
|
+
const out = (valid, reason, checks, pcr0, attestedAtMs) => {
|
|
12
|
+
const pub = pcr0 ? publishedMeasurement(pcr0) : null;
|
|
13
|
+
return { valid, ...(reason !== undefined ? { reason } : {}), checks, pcr0, image: pub ? { version: pub.version, since: pub.since } : null, attestedAtMs, artifactBinding };
|
|
14
|
+
};
|
|
15
|
+
// 2 first, because it decides 1's atomic rule: the hardware's word about which image made this proof.
|
|
16
|
+
const att = proof?.environment?.attestation;
|
|
17
|
+
if (!att || att.format !== "aws-nitro" || typeof att.reportB64 !== "string" || att.reportB64.length === 0) {
|
|
18
|
+
return out(false, "no AWS Nitro attestation: a proof without one is not BitGraph's", [], null, null);
|
|
19
|
+
}
|
|
20
|
+
const declared = typeof proof.environment?.measurement === "string" ? proof.environment.measurement.toLowerCase() : null;
|
|
21
|
+
const n = verifyNitroAttestation(att.reportB64, {
|
|
22
|
+
...(declared !== null ? { expectedPcr0: declared } : {}),
|
|
23
|
+
expectedUserDataB64: computeSignedBodyHash(proof),
|
|
24
|
+
...(opts.rootDer ? { rootDer: opts.rootDer } : {}),
|
|
25
|
+
});
|
|
26
|
+
const docPcr0 = n.doc?.pcrs?.[0];
|
|
27
|
+
const pcr0 = typeof docPcr0 === "string" ? docPcr0.toLowerCase() : null;
|
|
28
|
+
const attestedAtMs = n.valid && typeof n.doc?.timestampMs === "number" ? n.doc.timestampMs : null;
|
|
29
|
+
if (!n.valid) {
|
|
30
|
+
const bad = n.checks.find((c) => !c.pass);
|
|
31
|
+
return out(false, `the attestation does not verify: ${bad ? `${bad.name}: ${bad.detail}` : "incomplete"}`, n.checks, pcr0, null);
|
|
32
|
+
}
|
|
33
|
+
if (pcr0 === null)
|
|
34
|
+
return out(false, "the attestation names no PCR0", n.checks, null, null);
|
|
35
|
+
// 3. The image.
|
|
36
|
+
const accepted = (opts.pcr0 ?? PUBLISHED_PCR0S).map((x) => String(x).toLowerCase());
|
|
37
|
+
if (!accepted.includes(pcr0)) {
|
|
38
|
+
return out(false, opts.pcr0 ? `PCR0 ${pcr0.slice(0, 16)}… is not an image this verifier accepts` : `PCR0 ${pcr0.slice(0, 16)}… is not an enclave image BitGraph published`, n.checks, pcr0, attestedAtMs);
|
|
39
|
+
}
|
|
40
|
+
// 1. The proof's own consistency, with the atomic rule where it applies.
|
|
41
|
+
const image = publishedMeasurement(pcr0);
|
|
42
|
+
const atomic = proof.commit?.atomic === true || (image !== null && ATOMIC_FROM.has(image.version));
|
|
43
|
+
const trustAnchors = { ...(opts.trustAnchors ?? {}), ...(atomic ? { requireAtomic: true } : {}) };
|
|
44
|
+
const context = opts.context ?? createVerificationContext();
|
|
45
|
+
const r = bytes !== undefined
|
|
46
|
+
? await verify({ proof, bytes, trustAnchors, context })
|
|
47
|
+
: await verifyProofIntegrity({ proof, trustAnchors, context });
|
|
48
|
+
if (!r.valid)
|
|
49
|
+
return out(false, r.reason ?? "the proof does not verify", n.checks, pcr0, attestedAtMs);
|
|
50
|
+
return out(true, undefined, n.checks, pcr0, attestedAtMs);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=attested.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attested.js","sourceRoot":"","sources":["../src/attested.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAuB9F,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,yBAAyB,EAA4B,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAmB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CA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BAAyB,EAAE,CAAC;IAC5D,MAAM,CAAC,GAAG,KAAK,KAAK,SAAS;QAC3B,CAAC,CAAC,MAAM,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;QACvD,CAAC,CAAC,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,CAAC,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,IAAI,2BAA2B,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACvG,OAAO,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type { VerifyResult, ProofIntegrityResult, VerificationContext } from "./
|
|
|
12
12
|
export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyHash } from "./proof-hash.js";
|
|
13
13
|
export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
|
|
14
14
|
export { verifyStretch, verifyBetween } from "./stretch.js";
|
|
15
|
+
export { verifyAttested } from "./attested.js";
|
|
16
|
+
export type { AttestedOptions, AttestedResult } from "./attested.js";
|
|
15
17
|
export type { StretchResult } from "./stretch.js";
|
|
16
18
|
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, SET_PLACEMENT_ID, SET_METADATA_KEY, buildSetManifest, parseSetManifest, readSetMetadata, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, FUSE2_PROFILE, FUSE2_DOMAIN, FUSE2_ATTRIBUTION_NAME, FUSE3_PROFILE, FUSE3_DOMAIN, FUSE3_ATTRIBUTION_NAME, fuseNameOfVersion, signedFloorOf, slotCommitment3Preimage, computeSlotCommitment3, fuseVersionOfName, isFuseMarkerName, slotCommitment2Preimage, computeSlotCommitment2, commitmentForProof, producerCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
17
19
|
export type { PlacementId, Placement, Located, FusePayload, FuseFrame, FuseMarker, MarkerSource, SetMember, SetManifest, FusedFrame, FuseVersion, SignedFloor } from "./fuse.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,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,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7G,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE7F,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,EAAE,aAAa,EAAE,aAAa,EAAE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,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACxJ,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export { computeProofHash, computeChainHash, buildSignedBody, computeSignedBodyH
|
|
|
12
12
|
export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonical.js";
|
|
13
13
|
// The sandwich (enclave v11 binds): an unbroken stretch from A to B.
|
|
14
14
|
export { verifyStretch, verifyBetween } from "./stretch.js";
|
|
15
|
+
// The full check of a plain proof: verify() plus the AWS Nitro attestation and the published image (2026-10-18).
|
|
16
|
+
export { verifyAttested } from "./attested.js";
|
|
15
17
|
// BitGraph Fuse (profile bitgraph-fuse/1): construction, parsing, verification.
|
|
16
18
|
export { FUSE_PROFILE, FUSE_DOMAIN, FUSE_ATTRIBUTION_NAME, TRAILER_MAGIC, TRAILER_LENGTH, CONTAINER_MANIFEST_PATH, CONTAINER_ORIGINAL_PATH, PLACEMENTS, getPlacement, SET_PLACEMENT_ID, SET_METADATA_KEY, buildSetManifest, parseSetManifest, readSetMetadata, canonicalSlotBody, computeSlotRecordHash, slotCommitmentPreimage, computeSlotCommitment, FUSE2_PROFILE, FUSE2_DOMAIN, FUSE2_ATTRIBUTION_NAME, FUSE3_PROFILE, FUSE3_DOMAIN, FUSE3_ATTRIBUTION_NAME, fuseNameOfVersion, signedFloorOf, slotCommitment3Preimage, computeSlotCommitment3, fuseVersionOfName, isFuseMarkerName, slotCommitment2Preimage, computeSlotCommitment2, commitmentForProof, producerCommitment, buildFusePayload, parseFusePayload, fuseAttribution, readFuseAttribution, mergeMarkers, buildFrame, parseFrame, readFrameMarker, bytesToBase64, base64ToBytes, bytesToHex, hexToBytes, bytesEqual, } from "./fuse.js";
|
|
17
19
|
export { MAX_CONTAINER_ENTRY_BYTES } from "./fuse.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,GAGd,MAAM,aAAa,CAAC;AAiBrB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG7G,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;AAEvF,qEAAqE;AACrE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,GAGd,MAAM,aAAa,CAAC;AAiBrB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG7G,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EA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G,OAAO,EACL,mBAAmB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,yBAAyB,EAC7F,iBAAiB,EAAE,WAAW,EAAE,0BAA0B,GAC3D,MAAM,kBAAkB,CAAC;AAG1B,yHAAyH;AACzH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC7E,qFAAqF;AACrF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAExJ,kGAAkG;AAClG,OAAO,EAAE,8BAA8B,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verifyAttested: the full check of a plain proof (2026-10-18 audit, finding D.1).
|
|
3
|
+
*
|
|
4
|
+
* The fixture is a real production proof: BitGraph #14 of epoch 1TYU…, made by enclave v12 (PCR0 cf1ca497…) on
|
|
5
|
+
* 2026-10-18, binding merkle-root.txt of a five-file tree. Its attestation is AWS-signed, so this test checks the
|
|
6
|
+
* real chain to the AWS Nitro root at the document's own instant.
|
|
7
|
+
*
|
|
8
|
+
* The point of the test is the forgery: a key anyone can make, signing a body that claims "measured-tee" and the
|
|
9
|
+
* published PCR0. verify() alone passes it (it checks the signature against the key the proof carries); the full
|
|
10
|
+
* check refuses it, because the hardware document is not about that body.
|
|
11
|
+
*
|
|
12
|
+
* cd packages/verify && npx tsc -p . && node --test dist/__tests__/attested.test.js
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { test } from "node:test";
|
|
16
|
+
import { strict as assert } from "node:assert";
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { getPublicKeyAsync, signAsync, utils } from "@noble/ed25519";
|
|
19
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
20
|
+
import { verifyAttested } from "../attested.js";
|
|
21
|
+
import { verify, createVerificationContext } from "../verifier.js";
|
|
22
|
+
import { buildSignedBody } from "../proof-hash.js";
|
|
23
|
+
import { canonicalize } from "../canonical.js";
|
|
24
|
+
import type { BitGraphProof } from "../types.js";
|
|
25
|
+
|
|
26
|
+
const proof = JSON.parse(readFileSync(new URL("../../src/__tests__/fixtures/v12/proof-14.json", import.meta.url), "utf8")) as BitGraphProof;
|
|
27
|
+
const bytes = new TextEncoder().encode("Merkle root (RFC 6962, SHA-256) of 5 files:\n48c297f66dd6535a173662db20083164ee46d527f6e8db18d1044af8e394e1a8\n");
|
|
28
|
+
const b64 = (u: Uint8Array) => Buffer.from(u).toString("base64");
|
|
29
|
+
const clone = (p: BitGraphProof): BitGraphProof => JSON.parse(JSON.stringify(p)) as BitGraphProof;
|
|
30
|
+
|
|
31
|
+
test("the real proof is BitGraph's: signature, atomic counts, attestation chain, binding and published image", async () => {
|
|
32
|
+
assert.equal(b64(sha256(bytes)), proof.artifact.digestB64, "the fixture's bytes are its committed bytes");
|
|
33
|
+
const r = await verifyAttested({ proof, bytes });
|
|
34
|
+
assert.equal(r.valid, true, r.reason);
|
|
35
|
+
assert.equal(r.artifactBinding, "checked");
|
|
36
|
+
assert.equal(r.image?.version, "v12");
|
|
37
|
+
assert.ok(r.attestedAtMs && new Date(r.attestedAtMs).toISOString().startsWith("2026-10-18"));
|
|
38
|
+
assert.ok(r.checks.every((c) => c.pass));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("without the bytes, everything but the digest comparison is checked, and said", async () => {
|
|
42
|
+
const r = await verifyAttested({ proof });
|
|
43
|
+
assert.equal(r.valid, true, r.reason);
|
|
44
|
+
assert.equal(r.artifactBinding, "not-checked");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("other bytes do not verify", async () => {
|
|
48
|
+
const r = await verifyAttested({ proof, bytes: new TextEncoder().encode("something else") });
|
|
49
|
+
assert.equal(r.valid, false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("a forged proof signed by anyone's key passes verify() alone, and fails the full check", async () => {
|
|
53
|
+
const forged = clone(proof);
|
|
54
|
+
forged.artifact.digestB64 = b64(sha256(new TextEncoder().encode("a file BitGraph never saw")));
|
|
55
|
+
const priv = utils.randomPrivateKey();
|
|
56
|
+
const pub = b64(await getPublicKeyAsync(priv));
|
|
57
|
+
forged.signer.publicKeyB64 = pub;
|
|
58
|
+
// Re-sign the slot record and the body with the forger's key, keeping the real attestation and the real PCR0 string.
|
|
59
|
+
const slot = forged.slotAllocation as unknown as Record<string, unknown>;
|
|
60
|
+
slot["publicKeyB64"] = pub;
|
|
61
|
+
const { signatureB64: _s, ...slotBody } = slot;
|
|
62
|
+
slot["signatureB64"] = b64(await signAsync(canonicalize(slotBody), priv));
|
|
63
|
+
forged.commit.slotHashB64 = b64(sha256(canonicalize(slotBody)));
|
|
64
|
+
forged.signer.signatureB64 = b64(await signAsync(canonicalize(buildSignedBody(forged)), priv));
|
|
65
|
+
const plain = await verify({ proof: forged, bytes: new TextEncoder().encode("a file BitGraph never saw"), context: createVerificationContext() });
|
|
66
|
+
assert.equal(plain.valid, true, "verify() alone accepts the forgery: this is the gap verifyAttested closes");
|
|
67
|
+
const full = await verifyAttested({ proof: forged, bytes: new TextEncoder().encode("a file BitGraph never saw") });
|
|
68
|
+
assert.equal(full.valid, false);
|
|
69
|
+
assert.match(full.reason ?? "", /attestation does not verify/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("no attestation, or an image the verifier does not accept, is not BitGraph's", async () => {
|
|
73
|
+
const none = clone(proof);
|
|
74
|
+
delete (none.environment as { attestation?: unknown }).attestation;
|
|
75
|
+
assert.equal((await verifyAttested({ proof: none, bytes })).valid, false);
|
|
76
|
+
const other = await verifyAttested({ proof, bytes, pcr0: ["00".repeat(48)] });
|
|
77
|
+
assert.equal(other.valid, false);
|
|
78
|
+
assert.match(other.reason ?? "", /not an image this verifier accepts/);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("a changed count breaks the proof", async () => {
|
|
82
|
+
const gap = clone(proof);
|
|
83
|
+
gap.commit.counter = String(Number(gap.commit.counter) + 2);
|
|
84
|
+
const r = await verifyAttested({ proof: gap, bytes });
|
|
85
|
+
assert.equal(r.valid, false);
|
|
86
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "bitgraph/1",
|
|
3
|
+
"artifact": {
|
|
4
|
+
"hashAlg": "sha256",
|
|
5
|
+
"digestB64": "k9KH/ko56y31H9ZnC7eS9vejuWyopZYZpbxoW2wm7P8="
|
|
6
|
+
},
|
|
7
|
+
"commit": {
|
|
8
|
+
"nonceB64": "75XVcYa/7bRimyZFymeC2V2o5bESEIKXi3hm2VQ7UjA=",
|
|
9
|
+
"counter": "14",
|
|
10
|
+
"slotCounter": "13",
|
|
11
|
+
"slotHashB64": "LJyKTCGvZ+tSBg4OGR8wF0QX9GePhiTXCbhOgZlwmdI=",
|
|
12
|
+
"epochId": "1TYUXFlUoe9TprYecnpc3kbMlI4RYnulmgoNEWy9m44=",
|
|
13
|
+
"atomic": true,
|
|
14
|
+
"prevB64": "7wu45Fwpfg5Xtc4Nmh5OeGKK9WTRWQXZHxu5dnc9+uQ=",
|
|
15
|
+
"chainId": "bitgraph:main"
|
|
16
|
+
},
|
|
17
|
+
"signer": {
|
|
18
|
+
"publicKeyB64": "YaYaqCXle3xoKlbeFXAwIPllK0WX3pQHgogn7CGE3J4=",
|
|
19
|
+
"signatureB64": "sgM0qi1lH7Gy++PCo4+3Q2O224aDbLkay1zJyFrtT8eTpSK3UACCr3Xlf7kP9OShpZQpzuYcTKrX8f8Ck8gMCA=="
|
|
20
|
+
},
|
|
21
|
+
"environment": {
|
|
22
|
+
"enforcement": "measured-tee",
|
|
23
|
+
"measurement": "cf1ca497e1c3f678cce99ec2215f3991c72fd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zANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMTkwNwYDVQQDDDBpLTA2NTAyNzM0MjNmZjY3NTY3LnVzLWVhc3QtMi5hd3Mubml0cm8tZW5jbGF2ZXMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQ4aDBVHG/Gz+QtU9zf6AI1uQJHWBdeJs3HEBfdEg1FngundrV0aDJvVV0IR9KVsPB393ZeByKaLoyj93RzQwXHCfAeHSn328FMp9vQlmTYOG1VwJLouWlWtuzd/+hks5yjZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgIEMB0GA1UdDgQWBBSNxM+VQ9qvFhsYD6YnxtC3PzNNszAfBgNVHSMEGDAWgBRptaC+op4zY7CIufjxDbefvjtfuzAKBggqhkjOPQQDAwNpADBmAjEA2xTjAbH1yMmdaIyxwmcWaK1dV9DwuUhkRe5RC/8YQqKzk+xdoUMaQEDP465EJrSUAjEAm2jmhGcBk3D2qRnMvxi/YEwntM291w5sj+jmSx5XUZNiVzsuj0CJAVH6eEdLyTr4anB1YmxpY19rZXn2aXVzZXJfZGF0YVggCOVSDlXbxDt7htqo21Bj8lupJFhsiRJs1+VTP0wQZaJlbm9uY2X2/1hgoOGWzy15kMAu3MCtnVdiRbt+uUBiUDcwUfXNx1oYXBSiASOdYIkRWo4AO8f0ETQdtKw5apCKntwrwQv3unhZTEmJBzoSsaz7rj7OM34HysT8PtCyzqnHiV8prFHAKd57"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"slotAllocation": {
|
|
30
|
+
"version": "bitgraph/slot/1",
|
|
31
|
+
"nonceB64": "75XVcYa/7bRimyZFymeC2V2o5bESEIKXi3hm2VQ7UjA=",
|
|
32
|
+
"counter": "13",
|
|
33
|
+
"epochId": "1TYUXFlUoe9TprYecnpc3kbMlI4RYnulmgoNEWy9m44=",
|
|
34
|
+
"publicKeyB64": "YaYaqCXle3xoKlbeFXAwIPllK0WX3pQHgogn7CGE3J4=",
|
|
35
|
+
"chainId": "bitgraph:main",
|
|
36
|
+
"signatureB64": "gtsmy5jgBQP2Sytf/qjRkXFC82liqrz9mBTqG+jR+cJl5LMOuwbg6q/Rv8ylkaHt/EPzMH6hdgbvVHhRyII+Cw=="
|
|
37
|
+
},
|
|
38
|
+
"proofHash": "COVSDlXbxDt7htqo21Bj8lupJFhsiRJs1+VTP0wQZaI="
|
|
39
|
+
}
|
package/src/attested.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The full check of a plain BitGraph proof: the one every BitGraph tool runs (2026-10-18 audit, finding D.1).
|
|
5
|
+
*
|
|
6
|
+
* verify() checks a proof's own consistency: its Ed25519 signature, its slot record, its counts and its structure.
|
|
7
|
+
* The key it checks against is the one the proof carries, so on its own it cannot tell BitGraph's enclave from anyone
|
|
8
|
+
* who made a key and signed a body. What makes a proof BitGraph's is the hardware: the AWS Nitro attestation document
|
|
9
|
+
* the enclave requested over the signed body. verifyAttested() adds exactly that:
|
|
10
|
+
*
|
|
11
|
+
* 1. verify() itself, requiring the atomic form (count N+1 right after the nonce's N) whenever the proof says it
|
|
12
|
+
* is atomic, and on any proof whose image is v11 or later;
|
|
13
|
+
* 2. the attestation in full (nitro.ts verifyNitroAttestation): its ES384 signature, its certificate chain to the
|
|
14
|
+
* AWS Nitro root, every certificate valid at the document's own instant, the PCR0 the proof declares, and
|
|
15
|
+
* user_data equal to SHA-256 of the signed body, so the document is about this proof and no other;
|
|
16
|
+
* 3. the image: the PCR0 inside the hardware-signed document must be one the caller accepts, by default an image
|
|
17
|
+
* BitGraph published (measurements.ts). A valid attestation from some other enclave is not BitGraph's.
|
|
18
|
+
*
|
|
19
|
+
* Valid means: these bytes (when given) were bound at this position by the published BitGraph enclave image, as the
|
|
20
|
+
* AWS hardware attests. It says nothing about when or how the content was made.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { BitGraphProof, VerificationPolicy } from "./types.js";
|
|
24
|
+
import { verify, verifyProofIntegrity, createVerificationContext, type VerificationContext } from "./verifier.js";
|
|
25
|
+
import { verifyNitroAttestation, type NitroCheck } from "./nitro.js";
|
|
26
|
+
import { computeSignedBodyHash } from "./proof-hash.js";
|
|
27
|
+
import { PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
|
|
28
|
+
|
|
29
|
+
export interface AttestedOptions {
|
|
30
|
+
/** The proof to check. */
|
|
31
|
+
proof: BitGraphProof;
|
|
32
|
+
/** The committed bytes. Omitted: everything but the bytes-versus-digest comparison is checked. */
|
|
33
|
+
bytes?: Uint8Array;
|
|
34
|
+
/** The enclave images accepted, by PCR0 (hex). Default: every image BitGraph has published. */
|
|
35
|
+
pcr0?: readonly string[];
|
|
36
|
+
/** A different root certificate (DER), for testing against a non-AWS chain. Default: the AWS Nitro root. */
|
|
37
|
+
rootDer?: Uint8Array;
|
|
38
|
+
/** Extra policy for verify(). requireAtomic is set here whenever the proof is atomic. */
|
|
39
|
+
trustAnchors?: VerificationPolicy;
|
|
40
|
+
context?: VerificationContext;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AttestedResult {
|
|
44
|
+
valid: boolean;
|
|
45
|
+
/** Why it is not valid; absent when valid. */
|
|
46
|
+
reason?: string;
|
|
47
|
+
/** Each attestation check, in order, with its detail. */
|
|
48
|
+
checks: NitroCheck[];
|
|
49
|
+
/** The PCR0 inside the hardware-signed document (lowercase hex), when it could be read. */
|
|
50
|
+
pcr0: string | null;
|
|
51
|
+
/** The published image that PCR0 names, when it is one of BitGraph's. */
|
|
52
|
+
image: { version: string; since: string } | null;
|
|
53
|
+
/** The document's own signed time (ms since the epoch): when the enclave bound this proof. */
|
|
54
|
+
attestedAtMs: number | null;
|
|
55
|
+
/** Whether the bytes were compared with the proof's digest. */
|
|
56
|
+
artifactBinding: "checked" | "not-checked";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Images from v11 on make every proof atomic; a proof from one must be in the atomic form. */
|
|
60
|
+
const ATOMIC_FROM = new Set(["v11", "v12"]);
|
|
61
|
+
|
|
62
|
+
export async function verifyAttested(opts: AttestedOptions): Promise<AttestedResult> {
|
|
63
|
+
const { proof, bytes } = opts;
|
|
64
|
+
const artifactBinding = bytes !== undefined ? "checked" : "not-checked";
|
|
65
|
+
const out = (valid: boolean, reason: string | undefined, checks: NitroCheck[], pcr0: string | null, attestedAtMs: number | null): AttestedResult => {
|
|
66
|
+
const pub = pcr0 ? publishedMeasurement(pcr0) : null;
|
|
67
|
+
return { valid, ...(reason !== undefined ? { reason } : {}), checks, pcr0, image: pub ? { version: pub.version, since: pub.since } : null, attestedAtMs, artifactBinding };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// 2 first, because it decides 1's atomic rule: the hardware's word about which image made this proof.
|
|
71
|
+
const att = proof?.environment?.attestation as { format?: string; reportB64?: string } | undefined;
|
|
72
|
+
if (!att || att.format !== "aws-nitro" || typeof att.reportB64 !== "string" || att.reportB64.length === 0) {
|
|
73
|
+
return out(false, "no AWS Nitro attestation: a proof without one is not BitGraph's", [], null, null);
|
|
74
|
+
}
|
|
75
|
+
const declared = typeof proof.environment?.measurement === "string" ? proof.environment.measurement.toLowerCase() : null;
|
|
76
|
+
const n = verifyNitroAttestation(att.reportB64, {
|
|
77
|
+
...(declared !== null ? { expectedPcr0: declared } : {}),
|
|
78
|
+
expectedUserDataB64: computeSignedBodyHash(proof),
|
|
79
|
+
...(opts.rootDer ? { rootDer: opts.rootDer } : {}),
|
|
80
|
+
});
|
|
81
|
+
const docPcr0 = (n.doc?.pcrs as Record<number, unknown> | undefined)?.[0];
|
|
82
|
+
const pcr0 = typeof docPcr0 === "string" ? docPcr0.toLowerCase() : null;
|
|
83
|
+
const attestedAtMs = n.valid && typeof n.doc?.timestampMs === "number" ? n.doc.timestampMs : null;
|
|
84
|
+
if (!n.valid) {
|
|
85
|
+
const bad = n.checks.find((c) => !c.pass);
|
|
86
|
+
return out(false, `the attestation does not verify: ${bad ? `${bad.name}: ${bad.detail}` : "incomplete"}`, n.checks, pcr0, null);
|
|
87
|
+
}
|
|
88
|
+
if (pcr0 === null) return out(false, "the attestation names no PCR0", n.checks, null, null);
|
|
89
|
+
|
|
90
|
+
// 3. The image.
|
|
91
|
+
const accepted = (opts.pcr0 ?? PUBLISHED_PCR0S).map((x) => String(x).toLowerCase());
|
|
92
|
+
if (!accepted.includes(pcr0)) {
|
|
93
|
+
return out(false, opts.pcr0 ? `PCR0 ${pcr0.slice(0, 16)}… is not an image this verifier accepts` : `PCR0 ${pcr0.slice(0, 16)}… is not an enclave image BitGraph published`, n.checks, pcr0, attestedAtMs);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 1. The proof's own consistency, with the atomic rule where it applies.
|
|
97
|
+
const image = publishedMeasurement(pcr0);
|
|
98
|
+
const atomic = proof.commit?.atomic === true || (image !== null && ATOMIC_FROM.has(image.version));
|
|
99
|
+
const trustAnchors: VerificationPolicy = { ...(opts.trustAnchors ?? {}), ...(atomic ? { requireAtomic: true } : {}) };
|
|
100
|
+
const context = opts.context ?? createVerificationContext();
|
|
101
|
+
const r = bytes !== undefined
|
|
102
|
+
? await verify({ proof, bytes, trustAnchors, context })
|
|
103
|
+
: await verifyProofIntegrity({ proof, trustAnchors, context });
|
|
104
|
+
if (!r.valid) return out(false, r.reason ?? "the proof does not verify", n.checks, pcr0, attestedAtMs);
|
|
105
|
+
return out(true, undefined, n.checks, pcr0, attestedAtMs);
|
|
106
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -41,6 +41,9 @@ export { canonicalize, canonicalizeToString, constantTimeEqual } from "./canonic
|
|
|
41
41
|
|
|
42
42
|
// The sandwich (enclave v11 binds): an unbroken stretch from A to B.
|
|
43
43
|
export { verifyStretch, verifyBetween } from "./stretch.js";
|
|
44
|
+
// The full check of a plain proof: verify() plus the AWS Nitro attestation and the published image (2026-10-18).
|
|
45
|
+
export { verifyAttested } from "./attested.js";
|
|
46
|
+
export type { AttestedOptions, AttestedResult } from "./attested.js";
|
|
44
47
|
export type { StretchResult } from "./stretch.js";
|
|
45
48
|
|
|
46
49
|
// BitGraph Fuse (profile bitgraph-fuse/1): construction, parsing, verification.
|