franscor 0.0.0-stage → 0.2.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.
Files changed (59) hide show
  1. package/README.md +234 -2
  2. package/dist/adapters.d.ts +36 -0
  3. package/dist/adapters.js +54 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/blackbox.d.ts +76 -0
  6. package/dist/blackbox.js +226 -0
  7. package/dist/blackbox.js.map +1 -0
  8. package/dist/canonical.d.ts +8 -0
  9. package/dist/canonical.js +85 -0
  10. package/dist/canonical.js.map +1 -0
  11. package/dist/capabilities.d.ts +35 -0
  12. package/dist/capabilities.js +39 -0
  13. package/dist/capabilities.js.map +1 -0
  14. package/dist/cli.d.ts +2 -0
  15. package/dist/cli.js +189 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/client.d.ts +160 -0
  18. package/dist/client.js +804 -0
  19. package/dist/client.js.map +1 -0
  20. package/dist/detect.d.ts +28 -0
  21. package/dist/detect.js +72 -0
  22. package/dist/detect.js.map +1 -0
  23. package/dist/envelope.d.ts +31 -0
  24. package/dist/envelope.js +88 -0
  25. package/dist/envelope.js.map +1 -0
  26. package/dist/errors.d.ts +42 -0
  27. package/dist/errors.js +48 -0
  28. package/dist/errors.js.map +1 -0
  29. package/dist/evidence.d.ts +50 -0
  30. package/dist/evidence.js +115 -0
  31. package/dist/evidence.js.map +1 -0
  32. package/dist/identity.d.ts +41 -0
  33. package/dist/identity.js +132 -0
  34. package/dist/identity.js.map +1 -0
  35. package/dist/index.d.ts +38 -0
  36. package/dist/index.js +31 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/mcp.d.ts +50 -0
  39. package/dist/mcp.js +61 -0
  40. package/dist/mcp.js.map +1 -0
  41. package/dist/passport.d.ts +56 -0
  42. package/dist/passport.js +104 -0
  43. package/dist/passport.js.map +1 -0
  44. package/dist/permit.d.ts +58 -0
  45. package/dist/permit.js +129 -0
  46. package/dist/permit.js.map +1 -0
  47. package/dist/policy.d.ts +23 -0
  48. package/dist/policy.js +28 -0
  49. package/dist/policy.js.map +1 -0
  50. package/dist/sealing.d.ts +28 -0
  51. package/dist/sealing.js +82 -0
  52. package/dist/sealing.js.map +1 -0
  53. package/dist/statements.d.ts +27 -0
  54. package/dist/statements.js +59 -0
  55. package/dist/statements.js.map +1 -0
  56. package/dist/telemetry.d.ts +19 -0
  57. package/dist/telemetry.js +56 -0
  58. package/dist/telemetry.js.map +1 -0
  59. package/package.json +59 -4
package/README.md CHANGED
@@ -1,3 +1,235 @@
1
- # Temporary Holding Version
1
+ # FRANSCOR
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **The Core of Intelligence** — a Lamstra Labs technology.
4
+
5
+ FRANSCOR connects AI agents you already have, across languages and frameworks, with a
6
+ cryptographic identity, discovery, task delegation, default-deny authorization and
7
+ signed evidence of every decision. It is not an agent framework: your business logic
8
+ stays as it is.
9
+
10
+ > Status: **0.2.0, alpha, not yet published** on PyPI or npm. Not externally audited yet:
11
+ > evaluate it before relying on it in production. See
12
+ > [ARCHITECTURE.md](https://github.com/franscor/franscor/blob/main/ARCHITECTURE.md) for what is implemented and what is planned.
13
+
14
+ ## Install (after publication)
15
+
16
+ ```bash
17
+ pip install franscor # Python ≥ 3.11
18
+ npm install franscor # Node.js ≥ 22, zero runtime dependencies
19
+ ```
20
+
21
+ Until then, from this repository:
22
+
23
+ ```bash
24
+ pip install -e packages/sdk-python
25
+ cd packages/sdk-typescript && npm install && npm run build
26
+ ```
27
+
28
+ ## Five-minute tour
29
+
30
+ Start a local hub (binds to `127.0.0.1` only):
31
+
32
+ ```bash
33
+ franscor hub
34
+ ```
35
+
36
+ **Python agent** — existing functions become capabilities:
37
+
38
+ ```python
39
+ import asyncio, franscor
40
+
41
+ @franscor.capability("math.stats", risk="R1")
42
+ def stats(values: list) -> dict:
43
+ return {"count": len(values), "mean": sum(values) / len(values)}
44
+
45
+ async def main():
46
+ agent = await franscor.connect("analyst")
47
+ print(agent.status, agent.identity["agent_id"], agent.capabilities)
48
+ print(await agent.delegate("text.analyze", {"text": "hello agents"}))
49
+ await agent.wait_closed()
50
+
51
+ asyncio.run(main())
52
+ ```
53
+
54
+ **TypeScript agent**:
55
+
56
+ ```ts
57
+ import franscor from 'franscor';
58
+
59
+ franscor.capability('text.analyze', ({ text }: { text: string }) => ({ words: text.split(/\s+/).length }), { risk: 'R1' });
60
+
61
+ const agent = await franscor.connect({ name: 'writer' });
62
+ console.log(agent.status, agent.identity.agentId, agent.capabilities);
63
+ console.log(await agent.delegate('math.stats', { values: [1.5, 2.5, 4] }));
64
+ ```
65
+
66
+ Already using LangChain or LangGraph? Pass the objects you have:
67
+
68
+ ```python
69
+ agent = await franscor.connect("researcher", tools=[search_tool, compiled_graph])
70
+ # → capabilities "tool.search", "tool.<graph name>", default risk R2
71
+ ```
72
+
73
+ ## MCP and A2A
74
+
75
+ ```bash
76
+ pip install "franscor[mcp,a2a]"
77
+
78
+ # Give any MCP host (desktop assistant, IDE) access to FSP capabilities:
79
+ franscor bridge mcp --expose math.stats,text.analyze
80
+
81
+ # Publish capabilities as an A2A agent (agent card + JSON-RPC, bearer token):
82
+ FRANSCOR_A2A_TOKEN=... franscor bridge a2a --expose math.stats --port 8800
83
+ ```
84
+
85
+ ```python
86
+ from franscor.bridges import mcp, a2a
87
+
88
+ async with await mcp.import_tools("http://localhost:8000/mcp") as tools, await a2a.import_agent("https://agent.example") as remote:
89
+ agent = await franscor.connect("hub-of-tools", tools=tools.capabilities + remote.capabilities)
90
+ ```
91
+
92
+ OpenAI Agents SDK function tools (or a whole `Agent`) and AutoGen tools can be passed to
93
+ `connect(tools=[...])` directly. TypeScript: `importMcpTools(client)`.
94
+
95
+ ## What happens on `connect()`
96
+
97
+ 1. **Detect** the runtime and installed frameworks (package metadata only, no imports).
98
+ 2. **Adapt**: built-in and plugin adapters turn your objects into capabilities.
99
+ 3. **Identify**: load or create an Ed25519 key in `~/.franscor/identities/<name>.key`
100
+ (mode 0600). The agent ID is derived from the public key.
101
+ 4. **Register** with the hub through a signed challenge–response.
102
+ 5. **Serve and delegate**: every frame is signed; the receiver re-verifies the sender,
103
+ applies its own policy, asks a human for R4+ actions, runs the handler with a
104
+ deadline, and appends a signed, chained evidence record.
105
+ 6. **Stay connected**: automatic reconnection with backoff.
106
+
107
+ ## Blocking code, keys, tracing
108
+
109
+ ```python
110
+ # Not async? A private loop thread does the work.
111
+ with franscor.connect_sync("reporter") as agent:
112
+ print(agent.delegate("math.stats", {"values": [1, 2, 3]}), agent.stats)
113
+
114
+ # async agent (from await franscor.connect):
115
+ await agent.rotate_key() # new key, hub refuses the old ID from now on
116
+ await agent.revoke_key("stolen") # permanent; or offline: franscor revoke <name>
117
+ ```
118
+
119
+ * `FRANSCOR_KEY_STORE=keyring` stores keys in the OS keychain (`pip install franscor[keyring]`).
120
+ * Tracing turns on by itself when your app has OpenTelemetry configured: spans
121
+ `franscor.delegate` and `franscor.task`, one trace across Python and TypeScript,
122
+ no inputs or outputs recorded.
123
+
124
+ ## Several hubs, end-to-end encryption
125
+
126
+ ```bash
127
+ # Hub A (region EU) and hub B (region US) allow each other, B dials A:
128
+ franscor hub --identity eu --port 7701 --allow-peer <hub-us-id>
129
+ franscor hub --identity us --port 7702 --allow-peer <hub-eu-id> --peer ws://eu-host:7701
130
+ ```
131
+
132
+ Public agents become discoverable and reachable from both hubs; revocations follow
133
+ everywhere. Payloads are encrypted from agent to agent, so hubs never read them
134
+ (`encryption="required"` refuses plaintext). Docker: `deploy/`.
135
+
136
+ ## Passports
137
+
138
+ Each hub gives its agents a signed **passport** (agent ID, organization, key, capabilities,
139
+ validity) that anyone can verify offline with the hub's public key, plus a signed
140
+ revocation list. Agents carry it in every delegated task; run receivers with
141
+ `passport="require"` to refuse anyone without a valid one.
142
+
143
+ ```bash
144
+ franscor passport issue --hub hub-eu --agent worker --org acme --capability math.add --out pp.json
145
+ franscor passport verify pp.json --hub-key hub-eu.pem --crl crl.json
146
+ franscor passport revoke pp.json --hub hub-eu --crl crl.json # a running `franscor hub --crl crl.json` applies it
147
+ ```
148
+
149
+ ## Permits
150
+
151
+ A hub started with a **peering file** admits a partner hub's agents only with a **permit**:
152
+ a document it signs, bound to the agent's passport, listing what that agent may do here —
153
+ capabilities, data scopes, a rate limit, a maximum delegation depth, an expiry. Anything
154
+ else is refused before routing, and the executing agent checks the permit again
155
+ (`permit="require"` also refuses partner agents that arrive without one). Without a peering
156
+ file, federation keeps its FSP 0.1 behaviour and the hub warns at start-up.
157
+
158
+ ```json
159
+ {"fsp": "0.2", "type": "peering",
160
+ "peers": [{"hub_id": "fsp:…", "name": "globex",
161
+ "rules": [{"orgs": ["globex"], "capabilities": ["invoice.total", "fx.*"],
162
+ "scopes": ["invoices:read"], "rate_per_min": 60, "max_depth": 1, "ttl": "1h"}]}]}
163
+ ```
164
+
165
+ ```bash
166
+ franscor hub --identity hub-eu --allow-peer fsp:… --peering peering.json
167
+ franscor permit show peering.json
168
+ franscor permit revoke pm_… --peering peering.json # the running hub applies it within a second
169
+ ```
170
+
171
+ Requesters declare scopes with `delegate(..., scopes=["invoices:read"])`; the depth of a
172
+ delegation chain is counted by the SDKs.
173
+
174
+ ## Black box
175
+
176
+ With `--audit DIR`, a hub records every routing decision — allowed, blocked, masked
177
+ (refused while answering "offline") or unreachable — as an entry of an RFC 6962 Merkle
178
+ log: metadata and hashes only, never payloads. It regularly signs a checkpoint and its
179
+ federated peers check that each new tree extends the one they saw before, then cosign it.
180
+ A hub that edits its log does not start; one that rewrites and re-signs it is caught by
181
+ its peers, who keep both signed checkpoints as evidence.
182
+
183
+ ```bash
184
+ franscor hub --identity hub-eu --allow-peer fsp:… --audit audit/
185
+ franscor audit export audit/ --out bundle.json # no private key needed
186
+ franscor audit verify bundle.json --hub-key hub-eu.pem --witness-key hub-us.pem
187
+ franscor audit verify later.json --hub-key hub-eu.pem --previous bundle.json # not rewritten since
188
+ ```
189
+
190
+ Anyone can verify a bundle with the hub's public key, in Python or Node.js.
191
+
192
+ ## Security defaults
193
+
194
+ | Default | Change it with |
195
+ |---|---|
196
+ | Visible only to your org | `visibility="public"` / `"private"` |
197
+ | Tasks accepted only from your org | `accept_orgs=[...]`, `accept_agents=[...]` (`"*"` = anyone, explicit) |
198
+ | R4 and R5 need human approval; no handler = refused | `approval=callback`, `approval_threshold="R3"` |
199
+ | Hub on loopback; `ws://` refused for remote hubs | `franscor hub --host …` behind TLS; `allow_insecure=True` |
200
+ | Evidence stores hashes only, never inputs or outputs | — |
201
+
202
+ Verify any evidence log, in either language, or with the InterMesh verifier:
203
+
204
+ ```bash
205
+ franscor verify ~/.franscor/evidence/<agent>.jsonl --key agent.pem
206
+ ```
207
+
208
+ ## Layout
209
+
210
+ ```
211
+ franscor/
212
+ ├── protocol/ FSP 0.1 spec, JSON Schemas, cross-language test vectors
213
+ ├── packages/
214
+ │ ├── sdk-python/ pip package "franscor" (SDK + reference hub + CLI)
215
+ │ └── sdk-typescript/ npm package "franscor" (SDK + CLI)
216
+ ├── examples/interop/ TypeScript agent used by the acceptance test
217
+ ├── tests/interop/ Python ↔ TypeScript acceptance test
218
+ └── benchmarks/ measured, not claimed
219
+ ```
220
+
221
+ ## Tests
222
+
223
+ ```bash
224
+ cd packages/sdk-python && pytest # unit + network
225
+ cd packages/sdk-typescript && npm test # vectors: byte-identical to Python
226
+ cd franscor && pytest tests/interop # Python ↔ TypeScript acceptance
227
+ ```
228
+
229
+ ## Relationship to InterMesh
230
+
231
+ FRANSCOR is the successor of InterMesh. It reuses InterMesh's canonical JSON, R0–R5 risk
232
+ scale and **Action Evidence v0.1** format unchanged — evidence written by FRANSCOR verifies
233
+ with `intermesh verify`. The InterMesh hub, proxy and SDKs remain available and untouched.
234
+
235
+ License: Apache-2.0.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Adapter engine. Adapters turn existing objects (registered functions,
3
+ * LangChain tools/runnables, compiled LangGraph graphs) into capabilities
4
+ * without changing them. Third-party adapters are passed explicitly via
5
+ * `connect({ adapters })` — nothing is imported implicitly.
6
+ */
7
+ import { type Capability } from './capabilities.js';
8
+ import type { Detection } from './detect.js';
9
+ export interface AdapterContext {
10
+ objects: unknown[];
11
+ detection: Detection;
12
+ }
13
+ export interface Adapter {
14
+ name: string;
15
+ version: string;
16
+ detect(ctx: AdapterContext): boolean;
17
+ capabilities(ctx: AdapterContext): Capability[];
18
+ }
19
+ export interface AdapterReport {
20
+ adapter: string;
21
+ version?: string;
22
+ active: boolean;
23
+ capabilities?: string[];
24
+ error?: string;
25
+ }
26
+ export declare const functionAdapter: Adapter;
27
+ /** LangChain.js tools and runnables, duck-typed on `name` + `invoke`. Default risk R2. */
28
+ export declare function langchainAdapter(opts?: {
29
+ defaultRisk?: number;
30
+ riskOverrides?: Record<string, number>;
31
+ }): Adapter;
32
+ export declare const builtinAdapters: () => Adapter[];
33
+ export declare function collect(ctx: AdapterContext, adapters: Adapter[]): {
34
+ caps: Map<string, Capability>;
35
+ report: AdapterReport[];
36
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Adapter engine. Adapters turn existing objects (registered functions,
3
+ * LangChain tools/runnables, compiled LangGraph graphs) into capabilities
4
+ * without changing them. Third-party adapters are passed explicitly via
5
+ * `connect({ adapters })` — nothing is imported implicitly.
6
+ */
7
+ import { defineCapability, isCapability, registered } from './capabilities.js';
8
+ export const functionAdapter = {
9
+ name: 'functions',
10
+ version: '0.1.0',
11
+ detect: (ctx) => registered().length > 0 || ctx.objects.some(isCapability),
12
+ capabilities: (ctx) => [...registered(), ...ctx.objects.filter(isCapability)],
13
+ };
14
+ const isRunnable = (o) => typeof o === 'object' && o !== null && !isCapability(o)
15
+ && typeof o.name === 'string' && typeof o.invoke === 'function';
16
+ const slug = (text) => text.toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[-.]+|[-.]+$/g, '').slice(0, 100) || 'tool';
17
+ /** LangChain.js tools and runnables, duck-typed on `name` + `invoke`. Default risk R2. */
18
+ export function langchainAdapter(opts = {}) {
19
+ return {
20
+ name: 'langchain',
21
+ version: '0.1.0',
22
+ detect: (ctx) => ctx.objects.some(isRunnable),
23
+ capabilities: (ctx) => ctx.objects.filter(isRunnable).map((tool) => {
24
+ const name = `tool.${slug(tool.name)}`;
25
+ return defineCapability(name, (input) => tool.invoke(input), { description: String(tool.description ?? ''), risk: opts.riskOverrides?.[name] ?? opts.defaultRisk ?? 2 }, 'langchain');
26
+ }),
27
+ };
28
+ }
29
+ export const builtinAdapters = () => [functionAdapter, langchainAdapter()];
30
+ export function collect(ctx, adapters) {
31
+ const caps = new Map();
32
+ const report = [];
33
+ for (const adapter of adapters) {
34
+ const entry = { adapter: adapter.name, version: adapter.version, active: false };
35
+ try {
36
+ if (adapter.detect(ctx)) {
37
+ const found = adapter.capabilities(ctx);
38
+ for (const cap of found) {
39
+ if (caps.has(cap.name))
40
+ throw new Error(`duplicate capability ${cap.name}`);
41
+ caps.set(cap.name, cap);
42
+ }
43
+ entry.active = true;
44
+ entry.capabilities = found.map((c) => c.name);
45
+ }
46
+ }
47
+ catch (err) {
48
+ entry.error = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
49
+ }
50
+ report.push(entry);
51
+ }
52
+ return { caps, report };
53
+ }
54
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AAuBhG,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;IAC1E,YAAY,EAAE,CAAC,GAAG,EAAE,E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CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,76 @@
1
+ export declare const EMPTY_ROOT: Buffer;
2
+ export declare const leafHash: (data: Uint8Array) => Buffer;
3
+ export declare const nodeHash: (left: Uint8Array, right: Uint8Array) => Buffer;
4
+ /** Root of a list of leaf hashes. */
5
+ export declare function merkleRoot(leaves: readonly Uint8Array[]): Buffer;
6
+ /** RFC 9162 §2.1.3.2. `leaf` is the leaf hash. */
7
+ export declare function verifyInclusion(leaf: Uint8Array, index: number, size: number, proof: readonly Uint8Array[], root: Uint8Array): boolean;
8
+ /** RFC 9162 §2.1.4.2, plus the trivial cases (first = 0, first = second). */
9
+ export declare function verifyConsistency(first: number, second: number, firstRoot: Uint8Array, secondRoot: Uint8Array, proof: readonly Uint8Array[]): boolean;
10
+ export interface AuditCheckpoint {
11
+ fsp: '0.2';
12
+ type: 'audit-checkpoint';
13
+ hub_id: string;
14
+ hub_public_key: string;
15
+ tree_size: number;
16
+ root: string;
17
+ ts: number;
18
+ sig: string;
19
+ }
20
+ export interface AuditCosignature {
21
+ fsp: '0.2';
22
+ type: 'audit-cosignature';
23
+ witness_id: string;
24
+ witness_public_key: string;
25
+ hub_id: string;
26
+ tree_size: number;
27
+ root: string;
28
+ checkpoint_ts: number;
29
+ ts: number;
30
+ sig: string;
31
+ }
32
+ export interface AuditBundle {
33
+ fsp: '0.2';
34
+ type: 'audit-bundle';
35
+ hub_id: string;
36
+ hub_public_key: string;
37
+ checkpoint: AuditCheckpoint;
38
+ cosignatures: AuditCosignature[];
39
+ entries: {
40
+ index: number;
41
+ leaf: string;
42
+ }[];
43
+ proofs?: Record<string, string[]>;
44
+ consistency?: {
45
+ from_size: number;
46
+ from_checkpoint?: AuditCheckpoint | null;
47
+ proof: string[];
48
+ };
49
+ }
50
+ export declare class AuditError extends Error {
51
+ name: string;
52
+ }
53
+ export declare function verifyCheckpoint(cp: unknown, hubPublicKey?: string): AuditCheckpoint;
54
+ export declare function verifyCosignature(cs: unknown, cp: AuditCheckpoint, witnessPublicKey?: string): AuditCosignature;
55
+ export interface BundleReport {
56
+ valid: boolean;
57
+ errors: string[];
58
+ entries: number;
59
+ witnesses: string[];
60
+ issuer_checked: boolean;
61
+ hub_id?: string;
62
+ tree_size?: number;
63
+ root?: string;
64
+ checkpoint_ts?: number;
65
+ extends_previous?: boolean;
66
+ }
67
+ export interface VerifyBundleOptions {
68
+ /** The hub's public key obtained independently; otherwise integrity only. */
69
+ hubPublicKey?: string;
70
+ /** witness_id -> PEM of the peers whose cosignatures count. */
71
+ witnessKeys?: Record<string, string>;
72
+ /** An earlier checkpoint of the same hub the bundle must extend. */
73
+ previous?: unknown;
74
+ }
75
+ /** Same report as Python's `verify_bundle`. Never throws. */
76
+ export declare function verifyBundle(bundle: unknown, opts?: VerifyBundleOptions): BundleReport;
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Black box (FSP 0.2 §3), verifier side — same formats and checks as the Python
3
+ * SDK (`franscor.merkle`, `franscor.blackbox`). Hubs keep the log (Python);
4
+ * anyone can verify a signed checkpoint, its cosignatures and an export bundle
5
+ * with the hub's public key only.
6
+ *
7
+ * Merkle tree of RFC 6962 / RFC 9162 §2.1: leaf = SHA-256(0x00 || bytes),
8
+ * node = SHA-256(0x01 || left || right), empty tree = SHA-256("").
9
+ */
10
+ import { createHash } from 'node:crypto';
11
+ import { canonicalHash, canonicalJson } from './canonical.js';
12
+ import { agentIdFromPem, verifyDigest } from './identity.js';
13
+ const sha = (...parts) => {
14
+ const h = createHash('sha256');
15
+ for (const p of parts)
16
+ h.update(p);
17
+ return h.digest();
18
+ };
19
+ const ZERO = Uint8Array.of(0);
20
+ const ONE = Uint8Array.of(1);
21
+ export const EMPTY_ROOT = sha();
22
+ export const leafHash = (data) => sha(ZERO, data);
23
+ export const nodeHash = (left, right) => sha(ONE, left, right);
24
+ const split = (n) => {
25
+ let k = 1;
26
+ while (k * 2 < n)
27
+ k *= 2;
28
+ return k;
29
+ };
30
+ /** Root of a list of leaf hashes. */
31
+ export function merkleRoot(leaves) {
32
+ const mth = (start, size) => {
33
+ if (size === 0)
34
+ return EMPTY_ROOT;
35
+ if (size === 1)
36
+ return Buffer.from(leaves[start]);
37
+ const k = split(size);
38
+ return nodeHash(mth(start, k), mth(start + k, size - k));
39
+ };
40
+ return mth(0, leaves.length);
41
+ }
42
+ /** RFC 9162 §2.1.3.2. `leaf` is the leaf hash. */
43
+ export function verifyInclusion(leaf, index, size, proof, root) {
44
+ if (!(Number.isSafeInteger(index) && Number.isSafeInteger(size) && index >= 0 && index < size))
45
+ return false;
46
+ let fn = BigInt(index);
47
+ let sn = BigInt(size - 1);
48
+ let r = Buffer.from(leaf);
49
+ for (const p of proof) {
50
+ if (sn === 0n)
51
+ return false;
52
+ if (fn & 1n || fn === sn) {
53
+ r = nodeHash(p, r);
54
+ if (!(fn & 1n)) {
55
+ while (!(fn & 1n) && fn !== 0n) {
56
+ fn >>= 1n;
57
+ sn >>= 1n;
58
+ }
59
+ }
60
+ }
61
+ else {
62
+ r = nodeHash(r, p);
63
+ }
64
+ fn >>= 1n;
65
+ sn >>= 1n;
66
+ }
67
+ return sn === 0n && r.equals(root);
68
+ }
69
+ /** RFC 9162 §2.1.4.2, plus the trivial cases (first = 0, first = second). */
70
+ export function verifyConsistency(first, second, firstRoot, secondRoot, proof) {
71
+ if (!(Number.isSafeInteger(first) && Number.isSafeInteger(second) && first >= 0 && first <= second))
72
+ return false;
73
+ if (first === second)
74
+ return proof.length === 0 && Buffer.from(firstRoot).equals(secondRoot);
75
+ if (first === 0)
76
+ return proof.length === 0 && Buffer.from(firstRoot).equals(EMPTY_ROOT);
77
+ if (proof.length === 0)
78
+ return false;
79
+ const path = (first & (first - 1)) === 0 ? [firstRoot, ...proof] : [...proof];
80
+ let fn = BigInt(first - 1);
81
+ let sn = BigInt(second - 1);
82
+ while (fn & 1n) {
83
+ fn >>= 1n;
84
+ sn >>= 1n;
85
+ }
86
+ let fr = Buffer.from(path[0]);
87
+ let sr = Buffer.from(path[0]);
88
+ for (const c of path.slice(1)) {
89
+ if (sn === 0n)
90
+ return false;
91
+ if (fn & 1n || fn === sn) {
92
+ fr = nodeHash(c, fr);
93
+ sr = nodeHash(c, sr);
94
+ if (!(fn & 1n)) {
95
+ while (!(fn & 1n) && fn !== 0n) {
96
+ fn >>= 1n;
97
+ sn >>= 1n;
98
+ }
99
+ }
100
+ }
101
+ else {
102
+ sr = nodeHash(sr, c);
103
+ }
104
+ fn >>= 1n;
105
+ sn >>= 1n;
106
+ }
107
+ return fr.equals(firstRoot) && sr.equals(secondRoot) && sn === 0n;
108
+ }
109
+ export class AuditError extends Error {
110
+ name = 'AuditError';
111
+ }
112
+ const digestOf = (doc) => {
113
+ const { sig: _sig, ...body } = doc;
114
+ return canonicalHash(body);
115
+ };
116
+ const sameKey = (pem, id) => {
117
+ try {
118
+ return agentIdFromPem(String(pem)) === id;
119
+ }
120
+ catch {
121
+ return false;
122
+ }
123
+ };
124
+ const fromHex = (h) => {
125
+ if (!/^[0-9a-f]{64}$/.test(h))
126
+ throw new AuditError('malformed hash');
127
+ return Buffer.from(h, 'hex');
128
+ };
129
+ export function verifyCheckpoint(cp, hubPublicKey) {
130
+ const c = cp;
131
+ if (!c || typeof c !== 'object' || c.type !== 'audit-checkpoint' || c.fsp !== '0.2')
132
+ throw new AuditError('not an audit checkpoint');
133
+ for (const [k, kind] of [['hub_id', 'string'], ['hub_public_key', 'string'], ['tree_size', 'number'], ['root', 'string'], ['ts', 'number'], ['sig', 'string']]) {
134
+ if (typeof c[k] !== kind)
135
+ throw new AuditError(`checkpoint field '${k}' missing or not ${kind}`);
136
+ }
137
+ if (!Number.isSafeInteger(c.tree_size) || c.tree_size < 0 || !Number.isSafeInteger(c.ts) || c.root.length !== 64)
138
+ throw new AuditError('malformed checkpoint');
139
+ if (!sameKey(c.hub_public_key, c.hub_id))
140
+ throw new AuditError('checkpoint hub_id does not match its key');
141
+ if (hubPublicKey !== undefined && !sameKey(hubPublicKey, c.hub_id))
142
+ throw new AuditError('checkpoint from another hub');
143
+ if (!verifyDigest(c.hub_public_key, digestOf(c), c.sig))
144
+ throw new AuditError('checkpoint signature does not verify');
145
+ return c;
146
+ }
147
+ export function verifyCosignature(cs, cp, witnessPublicKey) {
148
+ const s = cs;
149
+ if (!s || typeof s !== 'object' || s.type !== 'audit-cosignature' || s.fsp !== '0.2')
150
+ throw new AuditError('not a cosignature');
151
+ if (s.hub_id !== cp.hub_id || s.tree_size !== cp.tree_size || s.root !== cp.root || s.checkpoint_ts !== cp.ts)
152
+ throw new AuditError('cosignature is for another checkpoint');
153
+ if (!sameKey(s.witness_public_key, s.witness_id))
154
+ throw new AuditError('witness_id does not match its key');
155
+ if (witnessPublicKey !== undefined && !sameKey(witnessPublicKey, s.witness_id))
156
+ throw new AuditError('cosignature from another witness');
157
+ if (!verifyDigest(String(s.witness_public_key), digestOf(s), String(s.sig ?? '')))
158
+ throw new AuditError('cosignature does not verify');
159
+ return s;
160
+ }
161
+ /** Same report as Python's `verify_bundle`. Never throws. */
162
+ export function verifyBundle(bundle, opts = {}) {
163
+ const report = { valid: false, errors: [], entries: 0, witnesses: [], issuer_checked: opts.hubPublicKey !== undefined };
164
+ try {
165
+ const b = bundle;
166
+ if (!b || typeof b !== 'object' || b.type !== 'audit-bundle')
167
+ throw new AuditError('not an audit bundle');
168
+ const cp = verifyCheckpoint(b.checkpoint, opts.hubPublicKey ?? String(b.hub_public_key ?? ''));
169
+ if (cp.hub_id !== b.hub_id)
170
+ throw new AuditError('bundle and checkpoint name different hubs');
171
+ Object.assign(report, { hub_id: cp.hub_id, tree_size: cp.tree_size, root: cp.root, checkpoint_ts: cp.ts });
172
+ const size = cp.tree_size;
173
+ const root = fromHex(cp.root);
174
+ const entries = Array.isArray(b.entries) ? b.entries : [];
175
+ const idx = entries.map((e) => e?.index);
176
+ if (idx.length && (!idx.every((i) => Number.isSafeInteger(i)) || idx.some((i, n) => i !== idx[0] + n) || idx[0] < 0 || idx[idx.length - 1] >= size)) {
177
+ throw new AuditError('entries must be consecutive indexes of the signed tree');
178
+ }
179
+ const proofs = b.proofs;
180
+ if (proofs === undefined || proofs === null) {
181
+ if (idx.length !== size || (size > 0 && idx[0] !== 0))
182
+ throw new AuditError('a bundle without proofs must hold every entry');
183
+ if (!merkleRoot(entries.map((e) => leafHash(Buffer.from(String(e.leaf), 'utf8')))).equals(root))
184
+ throw new AuditError('entries do not produce the signed root');
185
+ }
186
+ for (const e of entries) {
187
+ const leaf = String(e.leaf);
188
+ const doc = JSON.parse(leaf);
189
+ if (canonicalJson(doc) !== leaf || doc.index !== e.index || doc.type !== 'audit-entry')
190
+ throw new AuditError(`entry ${e.index} is not a canonical audit entry`);
191
+ if (proofs) {
192
+ const proof = (proofs[String(e.index)] ?? []).map(fromHex);
193
+ if (!verifyInclusion(leafHash(Buffer.from(leaf, 'utf8')), e.index, size, proof, root))
194
+ throw new AuditError(`entry ${e.index} is not in the signed tree`);
195
+ }
196
+ }
197
+ report.entries = entries.length;
198
+ for (const cs of b.cosignatures ?? []) {
199
+ const wid = String(cs?.witness_id ?? '');
200
+ if (opts.witnessKeys && !(wid in opts.witnessKeys))
201
+ continue;
202
+ try {
203
+ verifyCosignature(cs, cp, opts.witnessKeys?.[wid]);
204
+ report.witnesses.push(wid);
205
+ }
206
+ catch (err) {
207
+ report.errors.push(`cosignature of ${wid}: ${err.message}`);
208
+ }
209
+ }
210
+ if (opts.previous !== undefined) {
211
+ const prev = verifyCheckpoint(opts.previous, opts.hubPublicKey ?? cp.hub_public_key);
212
+ const cons = b.consistency;
213
+ if (!cons || prev.tree_size !== cons.from_size)
214
+ throw new AuditError('the bundle has no consistency proof from the previous checkpoint');
215
+ if (!verifyConsistency(prev.tree_size, size, fromHex(prev.root), root, (cons.proof ?? []).map(fromHex)))
216
+ throw new AuditError('history was rewritten since the previous checkpoint');
217
+ report.extends_previous = true;
218
+ }
219
+ report.valid = report.errors.length === 0;
220
+ }
221
+ catch (err) {
222
+ report.errors.push(err.message);
223
+ }
224
+ return report;
225
+ }
226
+ //# sourceMappingURL=blackbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blackbox.js","sourceRoot":"","sources":["../src/blackbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7D,MAAM,GAAG,GAAG,CAAC,GAAG,KAAmB,EAAU,EAAE;IAC7C,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AACF,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAgB,EAAU,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAgB,EAAE,KAAiB,EAAU,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAA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;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC;YACrF,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC;YAC3B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,UAAU,CAAC,kEAAkE,CAAC,CAAC;YACzI,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAAE,MAAM,IAAI,UAAU,CAAC,qDAAqD,CAAC,CAAC;YACrL,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC;QACjC,CAAC;QACD,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare class CanonicalError extends Error {
2
+ name: string;
3
+ }
4
+ export declare function canonicalJson(value: unknown): string;
5
+ export declare function sha256Hex(data: string | Uint8Array): string;
6
+ export declare function canonicalHash(value: unknown): string;
7
+ export declare const b64: (raw: Uint8Array) => string;
8
+ export declare const unb64: (text: string) => Buffer;