@real-life/trust-protocol 0.1.1 → 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 +18 -11
- package/dist/carrier-identity.d.ts +9 -0
- package/dist/carrier-identity.d.ts.map +1 -1
- package/dist/carrier-identity.js +32 -2
- package/dist/carrier-identity.js.map +1 -1
- package/dist/ceremony.d.ts +3 -0
- package/dist/ceremony.d.ts.map +1 -0
- package/dist/ceremony.js +29 -0
- package/dist/ceremony.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/probe/acks.d.ts +27 -0
- package/dist/probe/acks.d.ts.map +1 -0
- package/dist/probe/acks.js +152 -0
- package/dist/probe/acks.js.map +1 -0
- package/dist/probe/continuity.d.ts +3 -82
- package/dist/probe/continuity.d.ts.map +1 -1
- package/dist/probe/continuity.js +636 -147
- package/dist/probe/continuity.js.map +1 -1
- package/dist/probe/encounter.d.ts +26 -0
- package/dist/probe/encounter.d.ts.map +1 -0
- package/dist/probe/encounter.js +938 -0
- package/dist/probe/encounter.js.map +1 -0
- package/dist/probe/trust.d.ts +114 -74
- package/dist/probe/trust.d.ts.map +1 -1
- package/dist/probe/trust.js +1120 -232
- package/dist/probe/trust.js.map +1 -1
- package/dist/probe.d.ts +0 -2
- package/dist/probe.d.ts.map +1 -1
- package/dist/probe.js +8 -7
- package/dist/probe.js.map +1 -1
- package/dist/schemas.js +22 -22
- package/dist/schemas.js.map +1 -1
- package/dist/visibility.d.ts +6 -0
- package/dist/visibility.d.ts.map +1 -0
- package/dist/visibility.js +31 -0
- package/dist/visibility.js.map +1 -0
- package/dist/wire.d.ts +28 -26
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ look in the code:
|
|
|
35
35
|
| `carrier-identity` | Identity §7a | The carrier-relationship principal: one Ed25519 control key per (relationship × carrier), derived so that no computable relation to the relationship's other principals or its `rkid` exists — which is why registration must *prove* the binding instead of computing it. |
|
|
36
36
|
| `carrier` | Delivery §4.4 + §5a | The carrier side of the port as one transport-agnostic state machine: the five guarantees, the proof rule, the total binding lifecycle (unbound → live → closing → released), the verdict sets in their normative evaluation orders, wind-up and binding tombstones. The clock is injected. |
|
|
37
37
|
| `holder` | Delivery §5a + Identity §9.3 | The holder's half: proof construction for all four purposes, the closed verdict set, and the two-exchange recovery flow for a lost carrier entry. |
|
|
38
|
+
| `visibility` | Network Visibility 0.29 on Delivery 0.79 | The trust act (`anchor-mapping@2` + `grade-declaration@1`), the blinded star (`star@1`, 5.2a chunks), the admission layer and the 5.4 reconciliation automaton, §6a continuity (probe + mapping — chains instead of duplicates), and the deniable `delivery-ack/0.1`. Namespaced: `visibility.trust`, `.continuity`, `.acks`. Graduated from `/probe` on 04.09.2026 after a 39-round conformance loop. |
|
|
39
|
+
| `ceremony` | Encounter 0.29 (`encounter-scan@0.25`) on Delivery 0.79 | The ceremony's transmission: `encounter-bundle/0.1`, `encounter-credential-delivery/0.1` (counter-step in the bundle's thread), the signed `delivery-ack/0.1`; the own-challenge state model with its aging latch, the enactment record as the serialization point, the eight-step acceptance, connected and offline path with free switching; one commit discipline (prepare → verify → commit) under the §6.2 lock set; resumable issuance. Graduated from `/probe` on 05.09.2026 after a 25-round conformance loop. |
|
|
38
40
|
|
|
39
41
|
Everything is re-exported from the package root; the table is a map, not an
|
|
40
42
|
import instruction.
|
|
@@ -46,17 +48,20 @@ import { labeledContext, signCard, seal, sameDigest } from '@real-life/trust-pro
|
|
|
46
48
|
## Two entry points
|
|
47
49
|
|
|
48
50
|
```ts
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
import { …, visibility } from '@real-life/trust-protocol' // wire-normative core
|
|
52
|
+
const { trust, continuity, acks } = visibility // Network Visibility, graduated
|
|
53
|
+
import { introduce, membership }
|
|
54
|
+
from '@real-life/trust-protocol/probe' // draft — will change
|
|
52
55
|
```
|
|
53
56
|
|
|
54
57
|
The **`/probe` subpath is deliberate.** Its modules exercise the converged
|
|
55
58
|
*semantics* of their layers, but their transport shapes carry `@probe` and
|
|
56
|
-
are **not wire-normative**: mediated introductions over a rendezvous drop
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
are **not wire-normative**: mediated introductions over a rendezvous drop
|
|
60
|
+
and group membership (founding, VIC invite, admission, vouching). The
|
|
61
|
+
trust act, the blinded star, §6a continuity and the deniable ack **left
|
|
62
|
+
this subpath on 04.09.2026** — they are wire-normative now and live under
|
|
63
|
+
`visibility` at the package root; the Encounter ceremony's transmission
|
|
64
|
+
**left on 05.09.2026** and lives under `ceremony`. Experiment with the rest; do not treat its wire forms
|
|
60
65
|
as an interoperability target. A subpath import is a decision someone has
|
|
61
66
|
to make — nothing behind it can be reached by accident.
|
|
62
67
|
|
|
@@ -75,15 +80,17 @@ This package uses its own semver; the specification uses castings. Each
|
|
|
75
80
|
release states, per module, whose **wire forms** it implements — and what
|
|
76
81
|
it deliberately does not:
|
|
77
82
|
|
|
78
|
-
| Module (0.
|
|
83
|
+
| Module (0.3.x) | Casting | Implemented | Not in this package |
|
|
79
84
|
|---|---|---|---|
|
|
80
85
|
| `identity` | Identity 0.50 | context derivation under the closed label registry (§6.1, unchanged since 0.13) with the ordered persona pipeline (§6.2, Unicode 15.0 pinned) | recovery derivation (§5.3), service identities (§7), the label register and its state |
|
|
81
86
|
| `carrier-identity` | Identity 0.51 (§7a) | the carrier-relationship principal derivation, identifier validation | the register's generation state (held by the holder's store) |
|
|
82
|
-
| `carrier` + `holder` | Delivery 0.
|
|
83
|
-
| `encounter` | Encounter 0.29 — wire `0.25` (`rltp-card/0.25`, `encounter-scan@0.25`) | challenges, both card profiles, the enactment binding, encounter credentials | the ceremony
|
|
87
|
+
| `carrier` + `holder` | Delivery 0.79 (§4.4, §5a) + Identity 0.51 (§9.3) | the port state machine, proofs for all four purposes, verdicts, recovery | transport adapters and their policies (a carrier's budgets enter through hooks) |
|
|
88
|
+
| `encounter` | Encounter 0.29 — wire `0.25` (`rltp-card/0.25`, `encounter-scan@0.25`) | challenges, both card profiles, the enactment binding, encounter credentials (the primitives) | — (the ceremony machine lives in `ceremony`) |
|
|
89
|
+
| `ceremony` | Encounter 0.29 §5.3–5.8 + Delivery 0.79 (§3, §4.1–4.3, §6) | `encounter-bundle/0.1`, `encounter-credential-delivery/0.1`, signed `delivery-ack/0.1`; own-challenge state model (aging latch, whole seconds), enactment record + record-key lock set, 5.6 acceptance in order, both 5.8 paths, thread freshness incl. re-issue, resumable issuance, chain-head carry | storage, transport adapters, the host's UI correlation (duties listed in the handoff) |
|
|
84
90
|
| `delivery` | Delivery 0.64 | the sealed envelope (§5) and the generic receive stages 1–4 | the type-specific stages, residual bookkeeping, transport adapters |
|
|
85
91
|
| `core`, `crypto` | cross-layer | canonical form, digest equality, timestamps, validator; primitives + `eddsa-jcs-2022` proof | — |
|
|
86
|
-
|
|
|
92
|
+
| `visibility` | Network Visibility 0.29 + Delivery 0.79 (§3, §4.2, §4.4) | the trust act (`anchor-mapping@2`, `grade-declaration@1`), `star@1` with 5.2a chunk assembly, the admission layer (Section 2), the 5.4 reconciliation automaton with completion via deniable acks, §6a continuity (`continuity-probe@1`, `continuity-mapping@1`, chaining), the registered task documents and `delivery-ack/0.1` with the 4.2 class rule; full §6.2 stage order on every receive path, peek→build→commit issuance on every producer | storage, transport adapters and their policies (the Encounter ceremony's flows live in `ceremony`) |
|
|
93
|
+
| `/probe` | Network Visibility (introductions) · Membership Tasks + Access | mediated introductions, group membership — semantics of the running castings, transport shapes `@probe` | any wire-form stability whatsoever |
|
|
87
94
|
|
|
88
95
|
Persona-name validation is **pinned to Unicode 15.0** as Identity §6.2
|
|
89
96
|
requires: the repertoire ships with the package (`unicode15.ts`, ~5 kB of
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { KeyPair } from './crypto.js';
|
|
2
2
|
export declare const CARRIER_INFO_PREFIX = "rltp/v1/carrier-relationship/ed25519/v1/";
|
|
3
|
+
export declare const CONNECTION_INFO_PREFIX = "rltp/v1/carrier-connection/ed25519/v1/";
|
|
4
|
+
export declare const EGRESS_INFO_PREFIX = "rltp/v1/carrier-egress/ed25519/v1/";
|
|
3
5
|
export declare function validCarrierIdentifier(c: unknown): c is string;
|
|
4
6
|
export interface CarrierPrincipal {
|
|
5
7
|
principal: string;
|
|
@@ -8,4 +10,11 @@ export interface CarrierPrincipal {
|
|
|
8
10
|
keyAgreement: null;
|
|
9
11
|
}
|
|
10
12
|
export declare function carrierPrincipal(rootIkm: Uint8Array, carrier: string, nonce: Uint8Array): Promise<CarrierPrincipal>;
|
|
13
|
+
export interface CarrierScopedIdentity {
|
|
14
|
+
did: string;
|
|
15
|
+
key: KeyPair;
|
|
16
|
+
info: string;
|
|
17
|
+
scope: 'connection' | 'egress';
|
|
18
|
+
}
|
|
19
|
+
export declare function carrierScopedIdentity(rootIkm: Uint8Array, carrier: string, nonce: Uint8Array, scope: 'connection' | 'egress'): Promise<CarrierScopedIdentity>;
|
|
11
20
|
//# sourceMappingURL=carrier-identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carrier-identity.d.ts","sourceRoot":"","sources":["../src/carrier-identity.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,eAAO,MAAM,mBAAmB,6CAA6C,CAAA;
|
|
1
|
+
{"version":3,"file":"carrier-identity.d.ts","sourceRoot":"","sources":["../src/carrier-identity.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAK1C,eAAO,MAAM,mBAAmB,6CAA6C,CAAA;AAS7E,eAAO,MAAM,sBAAsB,2CAA2C,CAAA;AAC9E,eAAO,MAAM,kBAAkB,uCAAuC,CAAA;AA4BtE,wBAAgB,sBAAsB,CAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAmB/D;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,OAAO,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,IAAI,CAAA;CACnB;AAKD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAY3B;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,OAAO,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,YAAY,GAAG,QAAQ,CAAA;CAC/B;AAKD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EACvD,KAAK,EAAE,YAAY,GAAG,QAAQ,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAUhC"}
|
package/dist/carrier-identity.js
CHANGED
|
@@ -20,6 +20,15 @@ import { sha, hkdf, edFromSeed, anchorOfEd } from './crypto.js';
|
|
|
20
20
|
import { WHITE_SPACE_15 } from './unicode15.js';
|
|
21
21
|
const te = new TextEncoder();
|
|
22
22
|
export const CARRIER_INFO_PREFIX = 'rltp/v1/carrier-relationship/ed25519/v1/';
|
|
23
|
+
// Adapter-scoped identities (profile spec/adapter-vti-mediator.md,
|
|
24
|
+
// Delivery §5a.10): the mediation connection DID and the sender-side
|
|
25
|
+
// egress identity. Both derive from the same root as the control
|
|
26
|
+
// principal but under distinct info prefixes — each is derivable from
|
|
27
|
+
// the root, none from any other. That is exactly the §5a.10 sentence
|
|
28
|
+
// "never a control principal or derivable from one", satisfied by
|
|
29
|
+
// construction: without rootIkm no party can compute one from another.
|
|
30
|
+
export const CONNECTION_INFO_PREFIX = 'rltp/v1/carrier-connection/ed25519/v1/';
|
|
31
|
+
export const EGRESS_INFO_PREFIX = 'rltp/v1/carrier-egress/ed25519/v1/';
|
|
23
32
|
// multihash(sha2-256) in base64url — the digest form Identity §7a.4 fixes
|
|
24
33
|
const mh = async (bytes) => 'u' + b64uOf(cat(Uint8Array.from([0x12, 0x20]), await sha(bytes)));
|
|
25
34
|
// Identity §7a.2 — the ordered validation pipeline for C, fail closed
|
|
@@ -77,9 +86,30 @@ export async function carrierPrincipal(rootIkm, carrier, nonce) {
|
|
|
77
86
|
throw new Error('invalid carrier identifier (7a.2)');
|
|
78
87
|
if (nonce.length !== 32)
|
|
79
88
|
throw new Error('carrier nonce must be 32 bytes (7a.3)');
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
// M-3: the derivation reads its inputs at entry, once. Caller-held
|
|
90
|
+
// buffers can be mutated while the HKDF awaits; copies make the
|
|
91
|
+
// derived principal a function of the arguments as passed.
|
|
92
|
+
const ikm = rootIkm.slice();
|
|
93
|
+
const n = nonce.slice();
|
|
94
|
+
const info = CARRIER_INFO_PREFIX + await mh(te.encode(carrier)) + await mh(n);
|
|
95
|
+
const seed = await hkdf(ikm, info);
|
|
82
96
|
const key = await edFromSeed(seed);
|
|
83
97
|
return { principal: anchorOfEd(key.pubRaw), key, info, keyAgreement: null };
|
|
84
98
|
}
|
|
99
|
+
// One connection DID / one egress identity per (relationship × carrier),
|
|
100
|
+
// same derivation discipline and same input rules as the principal
|
|
101
|
+
// (§7a.4), distinct prefix. Retired with the principal, never reused.
|
|
102
|
+
export async function carrierScopedIdentity(rootIkm, carrier, nonce, scope) {
|
|
103
|
+
if (!validCarrierIdentifier(carrier))
|
|
104
|
+
throw new Error('invalid carrier identifier (7a.2)');
|
|
105
|
+
if (nonce.length !== 32)
|
|
106
|
+
throw new Error('carrier nonce must be 32 bytes (7a.3)');
|
|
107
|
+
const ikm = rootIkm.slice();
|
|
108
|
+
const n = nonce.slice();
|
|
109
|
+
const prefix = scope === 'connection' ? CONNECTION_INFO_PREFIX : EGRESS_INFO_PREFIX;
|
|
110
|
+
const info = prefix + await mh(te.encode(carrier)) + await mh(n);
|
|
111
|
+
const seed = await hkdf(ikm, info);
|
|
112
|
+
const key = await edFromSeed(seed);
|
|
113
|
+
return { did: anchorOfEd(key.pubRaw), key, info, scope };
|
|
114
|
+
}
|
|
85
115
|
//# sourceMappingURL=carrier-identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carrier-identity.js","sourceRoot":"","sources":["../src/carrier-identity.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,8DAA8D;AAC9D,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,uEAAuE;AACvE,uEAAuE;AACvE,wEAAwE;AACxE,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,6BAA6B;AAC7B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAA;AAE5B,MAAM,CAAC,MAAM,mBAAmB,GAAG,0CAA0C,CAAA;AAE7E,0EAA0E;AAC1E,MAAM,EAAE,GAAG,KAAK,EAAE,KAAiB,EAAmB,EAAE,CACtD,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAEpE,sEAAsE;AACtE,kEAAkE;AAClE,mEAAmE;AACnE,yEAAyE;AACzE,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACp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CACpC,OAAmB,EAAE,OAAe,EAAE,KAAiB;IAEvD,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAC1F,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IACjF,MAAM,IAAI,GAAG,mBAAmB,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAA;IACjF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACtC,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;IAClC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AAC7E,CAAC","sourcesContent":["// carrier-identity — Identity §7a: the carrier-relationship identity class.\n//\n// One control principal per (relationship × carrier), Ed25519-only. The\n// derivation shares no computable relation with the relationship's other\n// principals or with its `rkid` — that absence is the privacy property\n// the whole class exists for (§7a.5), and it is why registration must\n// PROVE the binding instead of computing it (Delivery §5a.3).\n//\n// info = \"rltp/v1/carrier-relationship/ed25519/v1/\" || Dc || Dn\n// where Dc = multihash(sha2-256, UTF-8 of the configured carrier\n// identifier C) and Dn = multihash(sha2-256, 32-byte carrier nonce N),\n// each rendered as 'u' + base64url — exactly 47 characters, so the two\n// parts are length-fixed and no concatenation ambiguity exists (§7a.4).\n//\n// NO key-agreement key is derived for this class: sealing stays at the\n// `rkid` (§7a.1), and a carrier that never holds a decryption key can\n// never be asked to use one.\nimport { b64uOf, cat } from './crypto.js'\nimport { sha, hkdf, edFromSeed, anchorOfEd } from './crypto.js'\nimport type { KeyPair } from './crypto.js'\nimport { WHITE_SPACE_15 } from './unicode15.js'\n\nconst te = new TextEncoder()\n\nexport const CARRIER_INFO_PREFIX = 'rltp/v1/carrier-relationship/ed25519/v1/'\n\n// multihash(sha2-256) in base64url — the digest form Identity §7a.4 fixes\nconst mh = async (bytes: Uint8Array): Promise<string> =>\n 'u' + b64uOf(cat(Uint8Array.from([0x12, 0x20]), await sha(bytes)))\n\n// Identity §7a.2 — the ordered validation pipeline for C, fail closed\n// and NO normalization (the deliberate difference to §6.2): valid\n// Unicode scalar values only (unpaired surrogates never repaired),\n// 1..1024 UTF-8 BYTES, and no Cc, Cf or White_Space code point anywhere.\n//\n// The category tables are PINNED to Unicode 15.0 (port-review-2 M-6):\n// evaluating against the platform's \\p{...} data would let the same\n// identifier derive a principal on one runtime and be rejected on\n// another the moment a Unicode revision moves a code point — the exact\n// defect the persona repertoire (unicode15.ts) already closed for §6.2.\n// Cc is the stable C0/C1 block; Cf is the 170-code-point Unicode-15.0\n// set, enumerated below; White_Space is unicode15.ts's pinned set.\nconst CC_15 = (cp: number): boolean => cp <= 0x1f || (cp >= 0x7f && cp <= 0x9f)\nconst CF_15_RANGES: Array<[number, number]> = [\n [0x00ad, 0x00ad], [0x0600, 0x0605], [0x061c, 0x061c], [0x06dd, 0x06dd],\n [0x070f, 0x070f], [0x0890, 0x0891], [0x08e2, 0x08e2], [0x180e, 0x180e],\n [0x200b, 0x200f], [0x202a, 0x202e], [0x2060, 0x2064], [0x2066, 0x206f],\n [0xfeff, 0xfeff], [0xfff9, 0xfffb], [0x110bd, 0x110bd], [0x110cd, 0x110cd],\n [0x13430, 0x1343f], [0x1bca0, 0x1bca3], [0x1d173, 0x1d17a],\n [0xe0001, 0xe0001], [0xe0020, 0xe007f],\n]\nconst CF_15 = (cp: number): boolean => CF_15_RANGES.some(([a, b]) => cp >= a && cp <= b)\nexport function validCarrierIdentifier (c: unknown): c is string {\n if (typeof c !== 'string' || c.length === 0) return false\n // scalar values: an unpaired surrogate is not a Unicode string\n for (let i = 0; i < c.length; i++) {\n const u = c.charCodeAt(i)\n if (u >= 0xdc00 && u <= 0xdfff) return false // lone low\n if (u >= 0xd800 && u <= 0xdbff) {\n const nxt = c.charCodeAt(i + 1)\n if (!(nxt >= 0xdc00 && nxt <= 0xdfff)) return false // lone high\n i++\n }\n }\n const bytes = new TextEncoder().encode(c)\n if (bytes.length < 1 || bytes.length > 1024) return false\n for (const ch of c) {\n const cp = ch.codePointAt(0)!\n if (CC_15(cp) || CF_15(cp) || WHITE_SPACE_15.has(cp)) return false\n }\n return true\n}\n\nexport interface CarrierPrincipal {\n principal: string // did:key:z6Mk…, the control principal\n key: KeyPair // its Ed25519 pair (for the proofs of §5a.3)\n info: string // the derivation info, for auditability\n keyAgreement: null // declared, not omitted: Ed25519-only (§7a.1)\n}\n\n// Identity §7a.4 — derive the control principal for one relationship at\n// one carrier. `carrier` is C exactly as configured (byte-exact), `nonce`\n// is the relationship's 32-byte carrier nonce N from the register (§7a.3).\nexport async function carrierPrincipal (\n rootIkm: Uint8Array, carrier: string, nonce: Uint8Array,\n): Promise<CarrierPrincipal> {\n if (!validCarrierIdentifier(carrier)) throw new Error('invalid carrier identifier (7a.2)')\n if (nonce.length !== 32) throw new Error('carrier nonce must be 32 bytes (7a.3)')\n const info = CARRIER_INFO_PREFIX + await mh(te.encode(carrier)) + await mh(nonce)\n const seed = await hkdf(rootIkm, info)\n const key = await edFromSeed(seed)\n return { principal: anchorOfEd(key.pubRaw), key, info, keyAgreement: null }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"carrier-identity.js","sourceRoot":"","sources":["../src/carrier-identity.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,8DAA8D;AAC9D,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,uEAAuE;AACvE,uEAAuE;AACvE,wEAAwE;AACxE,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,6BAA6B;AAC7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AE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC1D,CAAC","sourcesContent":["// carrier-identity — Identity §7a: the carrier-relationship identity class.\n//\n// One control principal per (relationship × carrier), Ed25519-only. The\n// derivation shares no computable relation with the relationship's other\n// principals or with its `rkid` — that absence is the privacy property\n// the whole class exists for (§7a.5), and it is why registration must\n// PROVE the binding instead of computing it (Delivery §5a.3).\n//\n// info = \"rltp/v1/carrier-relationship/ed25519/v1/\" || Dc || Dn\n// where Dc = multihash(sha2-256, UTF-8 of the configured carrier\n// identifier C) and Dn = multihash(sha2-256, 32-byte carrier nonce N),\n// each rendered as 'u' + base64url — exactly 47 characters, so the two\n// parts are length-fixed and no concatenation ambiguity exists (§7a.4).\n//\n// NO key-agreement key is derived for this class: sealing stays at the\n// `rkid` (§7a.1), and a carrier that never holds a decryption key can\n// never be asked to use one.\nimport { b64uOf, cat } from './crypto.js'\nimport { sha, hkdf, edFromSeed, anchorOfEd } from './crypto.js'\nimport type { KeyPair } from './crypto.js'\nimport { WHITE_SPACE_15 } from './unicode15.js'\n\nconst te = new TextEncoder()\n\nexport const CARRIER_INFO_PREFIX = 'rltp/v1/carrier-relationship/ed25519/v1/'\n\n// Adapter-scoped identities (profile spec/adapter-vti-mediator.md,\n// Delivery §5a.10): the mediation connection DID and the sender-side\n// egress identity. Both derive from the same root as the control\n// principal but under distinct info prefixes — each is derivable from\n// the root, none from any other. That is exactly the §5a.10 sentence\n// \"never a control principal or derivable from one\", satisfied by\n// construction: without rootIkm no party can compute one from another.\nexport const CONNECTION_INFO_PREFIX = 'rltp/v1/carrier-connection/ed25519/v1/'\nexport const EGRESS_INFO_PREFIX = 'rltp/v1/carrier-egress/ed25519/v1/'\n\n// multihash(sha2-256) in base64url — the digest form Identity §7a.4 fixes\nconst mh = async (bytes: Uint8Array): Promise<string> =>\n 'u' + b64uOf(cat(Uint8Array.from([0x12, 0x20]), await sha(bytes)))\n\n// Identity §7a.2 — the ordered validation pipeline for C, fail closed\n// and NO normalization (the deliberate difference to §6.2): valid\n// Unicode scalar values only (unpaired surrogates never repaired),\n// 1..1024 UTF-8 BYTES, and no Cc, Cf or White_Space code point anywhere.\n//\n// The category tables are PINNED to Unicode 15.0 (port-review-2 M-6):\n// evaluating against the platform's \\p{...} data would let the same\n// identifier derive a principal on one runtime and be rejected on\n// another the moment a Unicode revision moves a code point — the exact\n// defect the persona repertoire (unicode15.ts) already closed for §6.2.\n// Cc is the stable C0/C1 block; Cf is the 170-code-point Unicode-15.0\n// set, enumerated below; White_Space is unicode15.ts's pinned set.\nconst CC_15 = (cp: number): boolean => cp <= 0x1f || (cp >= 0x7f && cp <= 0x9f)\nconst CF_15_RANGES: Array<[number, number]> = [\n [0x00ad, 0x00ad], [0x0600, 0x0605], [0x061c, 0x061c], [0x06dd, 0x06dd],\n [0x070f, 0x070f], [0x0890, 0x0891], [0x08e2, 0x08e2], [0x180e, 0x180e],\n [0x200b, 0x200f], [0x202a, 0x202e], [0x2060, 0x2064], [0x2066, 0x206f],\n [0xfeff, 0xfeff], [0xfff9, 0xfffb], [0x110bd, 0x110bd], [0x110cd, 0x110cd],\n [0x13430, 0x1343f], [0x1bca0, 0x1bca3], [0x1d173, 0x1d17a],\n [0xe0001, 0xe0001], [0xe0020, 0xe007f],\n]\nconst CF_15 = (cp: number): boolean => CF_15_RANGES.some(([a, b]) => cp >= a && cp <= b)\nexport function validCarrierIdentifier (c: unknown): c is string {\n if (typeof c !== 'string' || c.length === 0) return false\n // scalar values: an unpaired surrogate is not a Unicode string\n for (let i = 0; i < c.length; i++) {\n const u = c.charCodeAt(i)\n if (u >= 0xdc00 && u <= 0xdfff) return false // lone low\n if (u >= 0xd800 && u <= 0xdbff) {\n const nxt = c.charCodeAt(i + 1)\n if (!(nxt >= 0xdc00 && nxt <= 0xdfff)) return false // lone high\n i++\n }\n }\n const bytes = new TextEncoder().encode(c)\n if (bytes.length < 1 || bytes.length > 1024) return false\n for (const ch of c) {\n const cp = ch.codePointAt(0)!\n if (CC_15(cp) || CF_15(cp) || WHITE_SPACE_15.has(cp)) return false\n }\n return true\n}\n\nexport interface CarrierPrincipal {\n principal: string // did:key:z6Mk…, the control principal\n key: KeyPair // its Ed25519 pair (for the proofs of §5a.3)\n info: string // the derivation info, for auditability\n keyAgreement: null // declared, not omitted: Ed25519-only (§7a.1)\n}\n\n// Identity §7a.4 — derive the control principal for one relationship at\n// one carrier. `carrier` is C exactly as configured (byte-exact), `nonce`\n// is the relationship's 32-byte carrier nonce N from the register (§7a.3).\nexport async function carrierPrincipal (\n rootIkm: Uint8Array, carrier: string, nonce: Uint8Array,\n): Promise<CarrierPrincipal> {\n if (!validCarrierIdentifier(carrier)) throw new Error('invalid carrier identifier (7a.2)')\n if (nonce.length !== 32) throw new Error('carrier nonce must be 32 bytes (7a.3)')\n // M-3: the derivation reads its inputs at entry, once. Caller-held\n // buffers can be mutated while the HKDF awaits; copies make the\n // derived principal a function of the arguments as passed.\n const ikm = rootIkm.slice()\n const n = nonce.slice()\n const info = CARRIER_INFO_PREFIX + await mh(te.encode(carrier)) + await mh(n)\n const seed = await hkdf(ikm, info)\n const key = await edFromSeed(seed)\n return { principal: anchorOfEd(key.pubRaw), key, info, keyAgreement: null }\n}\n\nexport interface CarrierScopedIdentity {\n did: string // did:key:z6Mk…\n key: KeyPair\n info: string\n scope: 'connection' | 'egress'\n}\n\n// One connection DID / one egress identity per (relationship × carrier),\n// same derivation discipline and same input rules as the principal\n// (§7a.4), distinct prefix. Retired with the principal, never reused.\nexport async function carrierScopedIdentity (\n rootIkm: Uint8Array, carrier: string, nonce: Uint8Array,\n scope: 'connection' | 'egress',\n): Promise<CarrierScopedIdentity> {\n if (!validCarrierIdentifier(carrier)) throw new Error('invalid carrier identifier (7a.2)')\n if (nonce.length !== 32) throw new Error('carrier nonce must be 32 bytes (7a.3)')\n const ikm = rootIkm.slice()\n const n = nonce.slice()\n const prefix = scope === 'connection' ? CONNECTION_INFO_PREFIX : EGRESS_INFO_PREFIX\n const info = prefix + await mh(te.encode(carrier)) + await mh(n)\n const seed = await hkdf(ikm, info)\n const key = await edFromSeed(seed)\n return { did: anchorOfEd(key.pubRaw), key, info, scope }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../src/ceremony.ts"],"names":[],"mappings":"AA4BA,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,cAAc,sBAAsB,CAAA"}
|
package/dist/ceremony.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @real-life/trust-protocol — ceremony: the GRADUATED transmission of the
|
|
2
|
+
// Encounter ceremony on the normative forms.
|
|
3
|
+
//
|
|
4
|
+
// Graduated 05.09.2026 after a 25-round adversarial conformance loop
|
|
5
|
+
// (design/encounter-nachzug-konvergenz-2026-09.md): this module implements
|
|
6
|
+
// the one registered ceremony `encounter-scan@0.25` (Encounter 0.29, wire
|
|
7
|
+
// 0.25) carried by the Delivery Contract 0.79 —
|
|
8
|
+
//
|
|
9
|
+
// encounter-bundle/0.1 the scanner's sent card + step
|
|
10
|
+
// credential (Delivery 4.1)
|
|
11
|
+
// encounter-credential-delivery/0.1 the counter-step in the bundle's
|
|
12
|
+
// thread (Delivery 4.3)
|
|
13
|
+
// delivery-ack/0.1 (signed class) arrival, never acceptance (4.2)
|
|
14
|
+
//
|
|
15
|
+
// The machine: the own-challenge state model with its lock-free aging
|
|
16
|
+
// latch (5.3), the enactment record as the one serialization point (5.5),
|
|
17
|
+
// the eight-step acceptance (5.6), connected and offline path of 5.8 with
|
|
18
|
+
// free switching, and ONE commit discipline for every effect —
|
|
19
|
+
// prepare (async, no mutation) → verify (sync, under the 6.2 lock set) →
|
|
20
|
+
// commit (sync). `delivered` is the sender's status only on a valid ack.
|
|
21
|
+
//
|
|
22
|
+
// The module operates on the probe WORLD (a `Person`); the host owns
|
|
23
|
+
// storage and transport and carries the duties listed in the handoff
|
|
24
|
+
// (atomic writes, resume before flush, UI correlation).
|
|
25
|
+
//
|
|
26
|
+
// show · scan · counter · captureSentCard · receiveEncounter ·
|
|
27
|
+
// resumeEncounter · flushEncounter · resolve · constants
|
|
28
|
+
export * from './probe/encounter.js';
|
|
29
|
+
//# sourceMappingURL=ceremony.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceremony.js","sourceRoot":"","sources":["../src/ceremony.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6CAA6C;AAC7C,EAAE;AACF,qEAAqE;AACrE,2EAA2E;AAC3E,0EAA0E;AAC1E,gDAAgD;AAChD,EAAE;AACF,wEAAwE;AACxE,mEAAmE;AACnE,0EAA0E;AAC1E,+DAA+D;AAC/D,yEAAyE;AACzE,EAAE;AACF,sEAAsE;AACtE,0EAA0E;AAC1E,0EAA0E;AAC1E,+DAA+D;AAC/D,yEAAyE;AACzE,yEAAyE;AACzE,EAAE;AACF,qEAAqE;AACrE,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,2DAA2D;AAG3D,cAAc,sBAAsB,CAAA","sourcesContent":["// @real-life/trust-protocol — ceremony: the GRADUATED transmission of the\n// Encounter ceremony on the normative forms.\n//\n// Graduated 05.09.2026 after a 25-round adversarial conformance loop\n// (design/encounter-nachzug-konvergenz-2026-09.md): this module implements\n// the one registered ceremony `encounter-scan@0.25` (Encounter 0.29, wire\n// 0.25) carried by the Delivery Contract 0.79 —\n//\n// encounter-bundle/0.1 the scanner's sent card + step\n// credential (Delivery 4.1)\n// encounter-credential-delivery/0.1 the counter-step in the bundle's\n// thread (Delivery 4.3)\n// delivery-ack/0.1 (signed class) arrival, never acceptance (4.2)\n//\n// The machine: the own-challenge state model with its lock-free aging\n// latch (5.3), the enactment record as the one serialization point (5.5),\n// the eight-step acceptance (5.6), connected and offline path of 5.8 with\n// free switching, and ONE commit discipline for every effect —\n// prepare (async, no mutation) → verify (sync, under the 6.2 lock set) →\n// commit (sync). `delivered` is the sender's status only on a valid ack.\n//\n// The module operates on the probe WORLD (a `Person`); the host owns\n// storage and transport and carries the duties listed in the handoff\n// (atomic writes, resume before flush, UI correlation).\n//\n// show · scan · counter · captureSentCard · receiveEncounter ·\n// resumeEncounter · flushEncounter · resolve · constants\n\nexport type { Person } from './probe/deps.js'\nexport * from './probe/encounter.js'\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,15 @@
|
|
|
22
22
|
// carrier-identity the carrier-relationship principal (Identity §7a)
|
|
23
23
|
// carrier the carrier side of the port (Delivery §4.4 + §5a)
|
|
24
24
|
// holder the holder side: proofs, verdicts, recovery (§5a, §9.3)
|
|
25
|
+
// visibility Network Visibility 0.29 on Delivery 0.79 — the trust
|
|
26
|
+
// act, the blinded star, §6a continuity, the deniable
|
|
27
|
+
// ack (namespaced: `visibility.trust`, `.continuity`,
|
|
28
|
+
// `.acks`; graduated from /probe on 04.09.2026)
|
|
29
|
+
// ceremony Encounter 0.29's registered ceremony on Delivery
|
|
30
|
+
// 0.79 — encounter-bundle, encounter-credential-
|
|
31
|
+
// delivery, the signed ack; own-challenge state
|
|
32
|
+
// model, enactment record, 5.6 acceptance, both
|
|
33
|
+
// paths of 5.8 (graduated from /probe on 05.09.2026)
|
|
25
34
|
//
|
|
26
35
|
// Specification, schemas and vectors: https://rltp.real-life.org
|
|
27
36
|
export * from './core.js';
|
|
@@ -32,4 +41,6 @@ export * from './delivery.js';
|
|
|
32
41
|
export * from './carrier-identity.js';
|
|
33
42
|
export * from './carrier.js';
|
|
34
43
|
export * from './holder.js';
|
|
44
|
+
export * as visibility from './visibility.js';
|
|
45
|
+
export * as ceremony from './ceremony.js';
|
|
35
46
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,uEAAuE;AACvE,uEAAuE;AACvE,6BAA6B;AAC7B,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,uBAAuB;AACvB,EAAE;AACF,oDAAoD;AACpD,mEAAmE;AACnE,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,8EAA8E;AAC9E,EAAE;AACF,iEAAiE;AAEjE,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA","sourcesContent":["// @real-life/trust-protocol — the cryptographic core of RLTP.\n//\n// What this entry point IS: the wire-level primitives of the converged\n// layers, reproducing the shipped test vectors byte for byte — the\n// canonical form, the derivation of identity contexts under the closed\n// label registry, the encounter wire builders, the sealed envelope and\n// the generic receive chain.\n//\n// What it is NOT (yet): the layers' full state machines. Identity's\n// recovery derivation, Encounter's ceremony record and acceptance\n// machinery, Delivery's type-specific stages and residual bookkeeping\n// live in the specification and its conformance fixtures, not here. A\n// conformant implementation builds ON this module; importing it is not\n// yet conformance. The README states per module which casting's wire\n// forms it implements.\n//\n// core the form every artifact obeys\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2)\n// encounter the ceremony's wire forms: challenges, cards, credentials\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// holder the holder side: proofs, verdicts, recovery (§5a, §9.3)\n//\n// Specification, schemas and vectors: https://rltp.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './holder.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,uEAAuE;AACvE,uEAAuE;AACvE,6BAA6B;AAC7B,EAAE;AACF,oEAAoE;AACpE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,qEAAqE;AACrE,uBAAuB;AACvB,EAAE;AACF,oDAAoD;AACpD,mEAAmE;AACnE,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,oEAAoE;AACpE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,oEAAoE;AACpE,yEAAyE;AACzE,EAAE;AACF,iEAAiE;AAEjE,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA","sourcesContent":["// @real-life/trust-protocol — the cryptographic core of RLTP.\n//\n// What this entry point IS: the wire-level primitives of the converged\n// layers, reproducing the shipped test vectors byte for byte — the\n// canonical form, the derivation of identity contexts under the closed\n// label registry, the encounter wire builders, the sealed envelope and\n// the generic receive chain.\n//\n// What it is NOT (yet): the layers' full state machines. Identity's\n// recovery derivation, Encounter's ceremony record and acceptance\n// machinery, Delivery's type-specific stages and residual bookkeeping\n// live in the specification and its conformance fixtures, not here. A\n// conformant implementation builds ON this module; importing it is not\n// yet conformance. The README states per module which casting's wire\n// forms it implements.\n//\n// core the form every artifact obeys\n// crypto the primitives, and the Data Integrity proof\n// identity context derivation under the closed registry (§6.1/§6.2)\n// encounter the ceremony's wire forms: challenges, cards, credentials\n// delivery the sealed envelope and the generic receive stages 1–4\n// carrier-identity the carrier-relationship principal (Identity §7a)\n// carrier the carrier side of the port (Delivery §4.4 + §5a)\n// holder the holder side: proofs, verdicts, recovery (§5a, §9.3)\n// visibility Network Visibility 0.29 on Delivery 0.79 — the trust\n// act, the blinded star, §6a continuity, the deniable\n// ack (namespaced: `visibility.trust`, `.continuity`,\n// `.acks`; graduated from /probe on 04.09.2026)\n// ceremony Encounter 0.29's registered ceremony on Delivery\n// 0.79 — encounter-bundle, encounter-credential-\n// delivery, the signed ack; own-challenge state\n// model, enactment record, 5.6 acceptance, both\n// paths of 5.8 (graduated from /probe on 05.09.2026)\n//\n// Specification, schemas and vectors: https://rltp.real-life.org\n\nexport * from './core.js'\nexport * from './crypto.js'\nexport * from './identity.js'\nexport * from './encounter.js'\nexport * from './delivery.js'\nexport * from './carrier-identity.js'\nexport * from './carrier.js'\nexport * from './holder.js'\nexport * as visibility from './visibility.js'\nexport * as ceremony from './ceremony.js'\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as C from './deps.js';
|
|
2
|
+
import type { Person } from './deps.js';
|
|
3
|
+
export declare const ACK_TYPE = "https://real-life.org/trust-tasks/delivery-ack/0.1";
|
|
4
|
+
/** the channel ack key — Section 5's derivation discipline, 4.2's info */
|
|
5
|
+
export declare function ackKey(ownCtx: any, counterpartKa: string, issuerAnchor: string, recipientAnchor: string): Promise<Uint8Array<ArrayBufferLike>>;
|
|
6
|
+
/**
|
|
7
|
+
* Build the sealed deniable ack for a document received on `contact`'s
|
|
8
|
+
* channel. `refDigest` is the acknowledged document's digest (the same
|
|
9
|
+
* digest the completed-effect cache keys on); `threadId` is the acked
|
|
10
|
+
* document's thread — the ack continues it (4.2).
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildAck(p: Person, contact: any, refDigest: string, threadId: string, when: number, ent?: any): Promise<{
|
|
13
|
+
to: any;
|
|
14
|
+
kind: string;
|
|
15
|
+
env: C.Envelope;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Verify a received deniable ack (4.2 consistency): MAC-form proof only,
|
|
19
|
+
* MAC under the arrival tuple's ack key, issuer = our counterpart on
|
|
20
|
+
* that tuple, recipient = our own pair anchor. Returns { ref, threadId }
|
|
21
|
+
* or null — the caller matches ref against what it actually sent.
|
|
22
|
+
*/
|
|
23
|
+
export declare function verifyAck(p: Person, contact: any, doc: any, cls?: 'signature' | 'dv'): Promise<{
|
|
24
|
+
ref: string;
|
|
25
|
+
threadId: string;
|
|
26
|
+
} | null>;
|
|
27
|
+
//# sourceMappingURL=acks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acks.d.ts","sourceRoot":"","sources":["../../src/probe/acks.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAIvC,eAAO,MAAM,QAAQ,uDAAuD,CAAA;AAa5E,0EAA0E;AAC1E,wBAAsB,MAAM,CAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,wCAI9G;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAQ;;;;GA0BxH;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,WAAW,GAAG,IAAW,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA8CrJ"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// acks — the delivery acknowledgement (Delivery 4.2/4.4, the
|
|
2
|
+
// acknowledgement CLASS rule) for the probe world. The ack DOCUMENT is
|
|
3
|
+
// the real, registered wire form (`delivery-ack/0.1`) in the form the
|
|
4
|
+
// acknowledged payload's class selects: a SIGNED ack (eddsa-jcs-2022
|
|
5
|
+
// under the issuer anchor) for signature-class payloads (the Encounter
|
|
6
|
+
// forms), the DENIABLE MAC ack for designated-verifier payloads (the
|
|
7
|
+
// Visibility forms). The MAC key regime is the normative one —
|
|
8
|
+
// byte-compatible with vectors/delivery-ack.json and
|
|
9
|
+
// lib/test/vectors4.test.mjs: one channel-keyed derivation for every
|
|
10
|
+
// DV-type ack, never the payload's internal MAC structure.
|
|
11
|
+
//
|
|
12
|
+
// k = HKDF-SHA-256(ikm = X25519(pairX_issuer, pairX_recipient),
|
|
13
|
+
// salt = empty, info = "rltp/v1/delivery/mac/ack/"
|
|
14
|
+
// || issuerPairAnchor || "/" || recipientPairAnchor,
|
|
15
|
+
// 32 bytes; all-zero shared secret rejected)
|
|
16
|
+
// proof = { mac: HMAC-SHA-256 over JCS(document without proof) }
|
|
17
|
+
//
|
|
18
|
+
// Deniable by construction: either relationship party can compute the
|
|
19
|
+
// MAC — for DV payloads the ack is evidence to the sender alone, never
|
|
20
|
+
// an attestation toward anyone else (4.2).
|
|
21
|
+
import { jcs, makeValidator } from '../core.js';
|
|
22
|
+
import { SCHEMAS } from '../schemas.js';
|
|
23
|
+
import * as C from './deps.js';
|
|
24
|
+
const te = new TextEncoder();
|
|
25
|
+
const S = globalThis.crypto.subtle;
|
|
26
|
+
export const ACK_TYPE = 'https://real-life.org/trust-tasks/delivery-ack/0.1';
|
|
27
|
+
const V = makeValidator(SCHEMAS);
|
|
28
|
+
const schemaOk = (file, data) => V.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0;
|
|
29
|
+
const hmacU = async (key, msg) => {
|
|
30
|
+
const k = await S.importKey('raw', key, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
31
|
+
return 'u' + C.b64uOf(new Uint8Array(await S.sign('HMAC', k, te.encode(msg))));
|
|
32
|
+
};
|
|
33
|
+
const contactKeyOf = (p, contact) => {
|
|
34
|
+
for (const [k, c] of p.contacts)
|
|
35
|
+
if (c === contact)
|
|
36
|
+
return k;
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
/** the channel ack key — Section 5's derivation discipline, 4.2's info */
|
|
40
|
+
export async function ackKey(ownCtx, counterpartKa, issuerAnchor, recipientAnchor) {
|
|
41
|
+
const shared = await C.ecdh(ownCtx.x.priv, C.xRawOfMk(counterpartKa));
|
|
42
|
+
if (shared.every((b) => b === 0))
|
|
43
|
+
throw new Error('all-zero X25519 output');
|
|
44
|
+
return C.hkdf(shared, 'rltp/v1/delivery/mac/ack/' + issuerAnchor + '/' + recipientAnchor);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build the sealed deniable ack for a document received on `contact`'s
|
|
48
|
+
* channel. `refDigest` is the acknowledged document's digest (the same
|
|
49
|
+
* digest the completed-effect cache keys on); `threadId` is the acked
|
|
50
|
+
* document's thread — the ack continues it (4.2).
|
|
51
|
+
*/
|
|
52
|
+
export async function buildAck(p, contact, refDigest, threadId, when, ent = {}) {
|
|
53
|
+
const own = contact.channel.own;
|
|
54
|
+
const doc = {
|
|
55
|
+
id: ent.ackId ?? globalThis.crypto.randomUUID(),
|
|
56
|
+
type: ACK_TYPE,
|
|
57
|
+
issuer: own.anchor, // = the acked document's recipient (4.2)
|
|
58
|
+
// the recipient is the counterparty anchor; `ent.recipient` names it
|
|
59
|
+
// when the tuple is not yet inserted (a record-creating effect builds
|
|
60
|
+
// its ack BEFORE the one synchronous commit, Delivery 4.1)
|
|
61
|
+
recipient: ent.recipient ?? contactKeyOf(p, contact),
|
|
62
|
+
threadId,
|
|
63
|
+
issuedAt: C.iso(when),
|
|
64
|
+
payload: { ref: refDigest, meaning: 'received' },
|
|
65
|
+
};
|
|
66
|
+
// the acknowledgement CLASS rule (4.2/4.4): a payload whose authenticity
|
|
67
|
+
// is a TRANSFERABLE SIGNATURE (the Encounter forms: card + credential
|
|
68
|
+
// under DataIntegrityProof) is acknowledged with eddsa-jcs-2022 under
|
|
69
|
+
// the ack's issuer anchor — an attestation; a DESIGNATED-VERIFIER
|
|
70
|
+
// payload with the deniable channel-keyed MAC. `ent.cls` selects.
|
|
71
|
+
if (ent.cls === 'signature') {
|
|
72
|
+
const document = await C.diSign(own, doc, doc.issuedAt);
|
|
73
|
+
return { to: contact, kind: 'delivery-ack/0.1 (signiert, eddsa-jcs-2022 unter dem Issuer-Anker)', env: await C.seal(document, contact.channel.counterpartKa, ent) };
|
|
74
|
+
}
|
|
75
|
+
const k = await ackKey(own, contact.channel.counterpartKa, doc.issuer, doc.recipient);
|
|
76
|
+
const document = { ...doc, proof: { mac: await hmacU(k, jcs(doc)) } };
|
|
77
|
+
return { to: contact, kind: 'delivery-ack/0.1 (deniabel, MAC unter dem Kanal-Ack-Key)', env: await C.seal(document, contact.channel.counterpartKa, ent) };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Verify a received deniable ack (4.2 consistency): MAC-form proof only,
|
|
81
|
+
* MAC under the arrival tuple's ack key, issuer = our counterpart on
|
|
82
|
+
* that tuple, recipient = our own pair anchor. Returns { ref, threadId }
|
|
83
|
+
* or null — the caller matches ref against what it actually sent.
|
|
84
|
+
*/
|
|
85
|
+
export async function verifyAck(p, contact, doc, cls = 'dv') {
|
|
86
|
+
try {
|
|
87
|
+
if (doc?.type !== ACK_TYPE)
|
|
88
|
+
return null;
|
|
89
|
+
// STUFENORDNUNG (Review 33, B-2): erst das DOKUMENTPROFIL + der
|
|
90
|
+
// recipient (Stufe 5), dann das Payload-Schema (Stufe 7), dann die
|
|
91
|
+
// Typ-Konsistenzregeln (Stufe 8), der MAC zuletzt
|
|
92
|
+
// — Stufe 5: Dokument-Schema, geschlossene Form, Proof-Form,
|
|
93
|
+
// Kalender, recipient = eigener Anker
|
|
94
|
+
if (!schemaOk('rltp-delivery-document.schema.json', doc))
|
|
95
|
+
return null;
|
|
96
|
+
if (!C.shaped(doc, { id: 'string', issuer: 'string', recipient: 'string', threadId: 'string', issuedAt: 'string', payload: 'object', proof: 'object' }))
|
|
97
|
+
return null;
|
|
98
|
+
// geschlossene Form + das OPTIONALE ceremony-Feld (Review 19, B-2:
|
|
99
|
+
// „ceremony — OPTIONAL, and entirely unconstrained"); der MAC läuft
|
|
100
|
+
// über JCS(Dokument ohne proof) und deckt es mit ab
|
|
101
|
+
if (Object.keys(doc).some((k) => !['id', 'type', 'issuer', 'recipient', 'threadId', 'issuedAt', 'payload', 'proof', 'ceremony'].includes(k)))
|
|
102
|
+
return null;
|
|
103
|
+
// — Stufe 7 VOR Stufe 8: das Payload-Schema zuerst
|
|
104
|
+
if (!schemaOk('payload-delivery-ack.schema.json', doc.payload))
|
|
105
|
+
return null;
|
|
106
|
+
// class rule (4.2/4.4, Stufe 8): EXACTLY the form the acknowledged
|
|
107
|
+
// payload's class selects — signature-class payload → SIGNED ack,
|
|
108
|
+
// designated-verifier payload → MAC ack. Every other combination
|
|
109
|
+
// (MAC on a signature-class payload, signature on a DV payload, a
|
|
110
|
+
// hybrid proof) is invalid
|
|
111
|
+
if (cls === 'signature') {
|
|
112
|
+
if (doc.proof.mac !== undefined || doc.proof.type !== 'DataIntegrityProof' || doc.proof.cryptosuite !== 'eddsa-jcs-2022')
|
|
113
|
+
return null;
|
|
114
|
+
if (!C.calOK(doc.proof.created))
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (Object.keys(doc.proof).length !== 1)
|
|
119
|
+
return null;
|
|
120
|
+
if (typeof doc.proof.mac !== 'string' || doc.proof.proofValue !== undefined)
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (!C.calOK(doc.issuedAt))
|
|
124
|
+
return null; // Kalender-Validität (Review 12, B-3)
|
|
125
|
+
if (doc.recipient !== contact.channel.own.anchor)
|
|
126
|
+
return null;
|
|
127
|
+
// — Stufe 8: enactment-Profilregel (Review 20, B-2: ein Ack
|
|
128
|
+
// umschließt kein Bindungsmaterial), issuer-Bindung, meaning
|
|
129
|
+
if (doc.ceremony?.enactment !== undefined)
|
|
130
|
+
return null;
|
|
131
|
+
if (doc.issuer !== contactKeyOf(p, contact))
|
|
132
|
+
return null;
|
|
133
|
+
if (!C.shaped(doc.payload, { ref: 'string', meaning: 'string' }) || doc.payload.meaning !== 'received')
|
|
134
|
+
return null;
|
|
135
|
+
if (cls === 'signature') {
|
|
136
|
+
// the attestation: verifies under the ack's issuer anchor (= the
|
|
137
|
+
// acked document's recipient, our counterpart on the tuple)
|
|
138
|
+
if (!(await C.diVerify(doc, doc.issuer)))
|
|
139
|
+
return null;
|
|
140
|
+
return { ref: doc.payload.ref, threadId: doc.threadId };
|
|
141
|
+
}
|
|
142
|
+
const { proof, ...rest } = doc;
|
|
143
|
+
const k = await ackKey(contact.channel.own, contact.channel.counterpartKa, doc.issuer, doc.recipient);
|
|
144
|
+
if ((await hmacU(k, jcs(rest))) !== proof.mac)
|
|
145
|
+
return null;
|
|
146
|
+
return { ref: doc.payload.ref, threadId: doc.threadId };
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=acks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acks.js","sourceRoot":"","sources":["../../src/probe/acks.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,qEAAqE;AACrE,+DAA+D;AAC/D,qDAAqD;AACrD,qEAAqE;AACrE,2DAA2D;AAC3D,EAAE;AACF,kEAAkE;AAClE,sEAAsE;AACtE,wEAAwE;AACxE,gEAAgE;AAChE,mEAAmE;AACnE,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,2CAA2C;AAC3C,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAG9B,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAA;AAC5B,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAA;AAClC,MAAM,CAAC,MAAM,QAAQ,GAAG,oDAAoD,CAAA;AAE5E,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;AAChC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,IAAS,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI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AAC,EAAE,OAAO,CAAC;YAAE,OAAO,IAAI,CAAA;QACxD,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,UAAU;YAAE,OAAO,IAAI,CAAA;QACnH,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxB,iEAAiE;YACjE,4DAA4D;YAC5D,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAA;YACrD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAA;QACzD,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAA;QAC9B,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;QACrG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG;YAAE,OAAO,IAAI,CAAA;QAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAA;IACzD,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAA;IAAC,CAAC;AACzB,CAAC","sourcesContent":["// acks — the delivery acknowledgement (Delivery 4.2/4.4, the\n// acknowledgement CLASS rule) for the probe world. The ack DOCUMENT is\n// the real, registered wire form (`delivery-ack/0.1`) in the form the\n// acknowledged payload's class selects: a SIGNED ack (eddsa-jcs-2022\n// under the issuer anchor) for signature-class payloads (the Encounter\n// forms), the DENIABLE MAC ack for designated-verifier payloads (the\n// Visibility forms). The MAC key regime is the normative one —\n// byte-compatible with vectors/delivery-ack.json and\n// lib/test/vectors4.test.mjs: one channel-keyed derivation for every\n// DV-type ack, never the payload's internal MAC structure.\n//\n// k = HKDF-SHA-256(ikm = X25519(pairX_issuer, pairX_recipient),\n// salt = empty, info = \"rltp/v1/delivery/mac/ack/\"\n// || issuerPairAnchor || \"/\" || recipientPairAnchor,\n// 32 bytes; all-zero shared secret rejected)\n// proof = { mac: HMAC-SHA-256 over JCS(document without proof) }\n//\n// Deniable by construction: either relationship party can compute the\n// MAC — for DV payloads the ack is evidence to the sender alone, never\n// an attestation toward anyone else (4.2).\nimport { jcs, makeValidator } from '../core.js'\nimport { SCHEMAS } from '../schemas.js'\nimport * as C from './deps.js'\nimport type { Person } from './deps.js'\n\nconst te = new TextEncoder()\nconst S = globalThis.crypto.subtle\nexport const ACK_TYPE = 'https://real-life.org/trust-tasks/delivery-ack/0.1'\n\nconst V = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: any) => V.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\nconst hmacU = async (key: Uint8Array, msg: string) => {\n const k = await S.importKey('raw', key, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign'])\n return 'u' + C.b64uOf(new Uint8Array(await S.sign('HMAC', k, te.encode(msg))))\n}\nconst contactKeyOf = (p: Person, contact: any) => {\n for (const [k, c] of p.contacts) if (c === contact) return k\n return undefined\n}\n\n/** the channel ack key — Section 5's derivation discipline, 4.2's info */\nexport async function ackKey (ownCtx: any, counterpartKa: string, issuerAnchor: string, recipientAnchor: string) {\n const shared = await C.ecdh(ownCtx.x.priv, C.xRawOfMk(counterpartKa)!)\n if (shared.every((b: number) => b === 0)) throw new Error('all-zero X25519 output')\n return C.hkdf(shared, 'rltp/v1/delivery/mac/ack/' + issuerAnchor + '/' + recipientAnchor)\n}\n\n/**\n * Build the sealed deniable ack for a document received on `contact`'s\n * channel. `refDigest` is the acknowledged document's digest (the same\n * digest the completed-effect cache keys on); `threadId` is the acked\n * document's thread — the ack continues it (4.2).\n */\nexport async function buildAck (p: Person, contact: any, refDigest: string, threadId: string, when: number, ent: any = {}) {\n const own = contact.channel.own\n const doc = {\n id: ent.ackId ?? globalThis.crypto.randomUUID(),\n type: ACK_TYPE,\n issuer: own.anchor, // = the acked document's recipient (4.2)\n // the recipient is the counterparty anchor; `ent.recipient` names it\n // when the tuple is not yet inserted (a record-creating effect builds\n // its ack BEFORE the one synchronous commit, Delivery 4.1)\n recipient: ent.recipient ?? contactKeyOf(p, contact),\n threadId,\n issuedAt: C.iso(when),\n payload: { ref: refDigest, meaning: 'received' },\n }\n // the acknowledgement CLASS rule (4.2/4.4): a payload whose authenticity\n // is a TRANSFERABLE SIGNATURE (the Encounter forms: card + credential\n // under DataIntegrityProof) is acknowledged with eddsa-jcs-2022 under\n // the ack's issuer anchor — an attestation; a DESIGNATED-VERIFIER\n // payload with the deniable channel-keyed MAC. `ent.cls` selects.\n if (ent.cls === 'signature') {\n const document = await C.diSign(own, doc, doc.issuedAt)\n return { to: contact, kind: 'delivery-ack/0.1 (signiert, eddsa-jcs-2022 unter dem Issuer-Anker)', env: await C.seal(document, contact.channel.counterpartKa, ent) }\n }\n const k = await ackKey(own, contact.channel.counterpartKa, doc.issuer, doc.recipient!)\n const document = { ...doc, proof: { mac: await hmacU(k, jcs(doc)) } }\n return { to: contact, kind: 'delivery-ack/0.1 (deniabel, MAC unter dem Kanal-Ack-Key)', env: await C.seal(document, contact.channel.counterpartKa, ent) }\n}\n\n/**\n * Verify a received deniable ack (4.2 consistency): MAC-form proof only,\n * MAC under the arrival tuple's ack key, issuer = our counterpart on\n * that tuple, recipient = our own pair anchor. Returns { ref, threadId }\n * or null — the caller matches ref against what it actually sent.\n */\nexport async function verifyAck (p: Person, contact: any, doc: any, cls: 'signature' | 'dv' = 'dv'): Promise<{ ref: string, threadId: string } | null> {\n try {\n if (doc?.type !== ACK_TYPE) return null\n // STUFENORDNUNG (Review 33, B-2): erst das DOKUMENTPROFIL + der\n // recipient (Stufe 5), dann das Payload-Schema (Stufe 7), dann die\n // Typ-Konsistenzregeln (Stufe 8), der MAC zuletzt\n // — Stufe 5: Dokument-Schema, geschlossene Form, Proof-Form,\n // Kalender, recipient = eigener Anker\n if (!schemaOk('rltp-delivery-document.schema.json', doc)) return null\n if (!C.shaped(doc, { id: 'string', issuer: 'string', recipient: 'string', threadId: 'string', issuedAt: 'string', payload: 'object', proof: 'object' })) return null\n // geschlossene Form + das OPTIONALE ceremony-Feld (Review 19, B-2:\n // „ceremony — OPTIONAL, and entirely unconstrained\"); der MAC läuft\n // über JCS(Dokument ohne proof) und deckt es mit ab\n if (Object.keys(doc).some((k) => !['id', 'type', 'issuer', 'recipient', 'threadId', 'issuedAt', 'payload', 'proof', 'ceremony'].includes(k))) return null\n // — Stufe 7 VOR Stufe 8: das Payload-Schema zuerst\n if (!schemaOk('payload-delivery-ack.schema.json', doc.payload)) return null\n // class rule (4.2/4.4, Stufe 8): EXACTLY the form the acknowledged\n // payload's class selects — signature-class payload → SIGNED ack,\n // designated-verifier payload → MAC ack. Every other combination\n // (MAC on a signature-class payload, signature on a DV payload, a\n // hybrid proof) is invalid\n if (cls === 'signature') {\n if (doc.proof.mac !== undefined || doc.proof.type !== 'DataIntegrityProof' || doc.proof.cryptosuite !== 'eddsa-jcs-2022') return null\n if (!C.calOK(doc.proof.created)) return null\n } else {\n if (Object.keys(doc.proof).length !== 1) return null\n if (typeof doc.proof.mac !== 'string' || doc.proof.proofValue !== undefined) return null\n }\n if (!C.calOK(doc.issuedAt)) return null // Kalender-Validität (Review 12, B-3)\n if (doc.recipient !== contact.channel.own.anchor) return null\n // — Stufe 8: enactment-Profilregel (Review 20, B-2: ein Ack\n // umschließt kein Bindungsmaterial), issuer-Bindung, meaning\n if (doc.ceremony?.enactment !== undefined) return null\n if (doc.issuer !== contactKeyOf(p, contact)) return null\n if (!C.shaped(doc.payload, { ref: 'string', meaning: 'string' }) || doc.payload.meaning !== 'received') return null\n if (cls === 'signature') {\n // the attestation: verifies under the ack's issuer anchor (= the\n // acked document's recipient, our counterpart on the tuple)\n if (!(await C.diVerify(doc, doc.issuer))) return null\n return { ref: doc.payload.ref, threadId: doc.threadId }\n }\n const { proof, ...rest } = doc\n const k = await ackKey(contact.channel.own, contact.channel.counterpartKa, doc.issuer, doc.recipient)\n if ((await hmacU(k, jcs(rest))) !== proof.mac) return null\n return { ref: doc.payload.ref, threadId: doc.threadId }\n } catch { return null }\n}\n"]}
|
|
@@ -4,96 +4,17 @@ export declare const snapshotPriors: (p: Person) => {
|
|
|
4
4
|
own: any[];
|
|
5
5
|
counterpart: string[];
|
|
6
6
|
};
|
|
7
|
-
export declare function buildProbe(p: Person, newKey: string, ent?: any): Promise<{
|
|
7
|
+
export declare function buildProbe(p: Person, newKey: string, when: number, ent?: any): Promise<{
|
|
8
8
|
to: any;
|
|
9
9
|
kind: string;
|
|
10
10
|
env: C.Envelope;
|
|
11
11
|
}[] | null>;
|
|
12
|
-
export declare function receiveContinuity(p: Person, env: any, when: number, ent?: any): Promise<
|
|
13
|
-
handled: boolean;
|
|
14
|
-
partial: boolean;
|
|
15
|
-
error?: undefined;
|
|
16
|
-
matches?: undefined;
|
|
17
|
-
chained?: undefined;
|
|
18
|
-
name?: undefined;
|
|
19
|
-
outbound?: undefined;
|
|
20
|
-
outboundError?: undefined;
|
|
21
|
-
} | {
|
|
22
|
-
handled: boolean;
|
|
23
|
-
matches: number;
|
|
24
|
-
error?: undefined;
|
|
25
|
-
partial?: undefined;
|
|
26
|
-
chained?: undefined;
|
|
27
|
-
name?: undefined;
|
|
28
|
-
outbound?: undefined;
|
|
29
|
-
outboundError?: undefined;
|
|
30
|
-
} | {
|
|
31
|
-
handled: boolean;
|
|
32
|
-
matches: number;
|
|
33
|
-
chained: boolean;
|
|
34
|
-
name: any;
|
|
35
|
-
outbound: {
|
|
36
|
-
to: any;
|
|
37
|
-
kind: string;
|
|
38
|
-
env: C.Envelope;
|
|
39
|
-
}[];
|
|
40
|
-
outboundError: string | undefined;
|
|
41
|
-
error?: undefined;
|
|
42
|
-
partial?: undefined;
|
|
43
|
-
} | {
|
|
44
|
-
handled: boolean;
|
|
45
|
-
error: string;
|
|
46
|
-
chained?: undefined;
|
|
47
|
-
name?: undefined;
|
|
48
|
-
outbound?: undefined;
|
|
49
|
-
outboundError?: undefined;
|
|
50
|
-
} | {
|
|
51
|
-
handled: boolean;
|
|
52
|
-
chained: boolean;
|
|
53
|
-
name: any;
|
|
54
|
-
outbound: {
|
|
55
|
-
to: any;
|
|
56
|
-
kind: string;
|
|
57
|
-
env: C.Envelope;
|
|
58
|
-
}[];
|
|
59
|
-
outboundError: string;
|
|
60
|
-
error?: undefined;
|
|
61
|
-
} | {
|
|
62
|
-
handled: boolean;
|
|
63
|
-
chained: boolean;
|
|
64
|
-
name: any;
|
|
65
|
-
outbound: {
|
|
66
|
-
to: any;
|
|
67
|
-
kind: string;
|
|
68
|
-
env: C.Envelope;
|
|
69
|
-
}[];
|
|
70
|
-
error?: undefined;
|
|
71
|
-
outboundError?: undefined;
|
|
72
|
-
} | {
|
|
73
|
-
handled: boolean;
|
|
74
|
-
doc: any;
|
|
75
|
-
} | {
|
|
76
|
-
handled: boolean;
|
|
77
|
-
duplicate: boolean;
|
|
78
|
-
} | {
|
|
79
|
-
handled: boolean;
|
|
80
|
-
duplicate?: undefined;
|
|
81
|
-
}>;
|
|
12
|
+
export declare function receiveContinuity(p: Person, env: any, when: number, ent?: any): Promise<any>;
|
|
82
13
|
/**
|
|
83
14
|
* The host's producing call for a mapping the receiver still owes
|
|
84
15
|
* (review 6, B-3): a transient seal failure during probe/mapping
|
|
85
16
|
* handling persists the obligation in contMappingDue; this call — not a
|
|
86
17
|
* redelivery, which the freshness rule forbids — builds and returns it.
|
|
87
18
|
*/
|
|
88
|
-
export declare function flushContinuity(p: Person, newKey: string, when: number, ent?: any): Promise<
|
|
89
|
-
outbound: never[];
|
|
90
|
-
pending: boolean;
|
|
91
|
-
} | {
|
|
92
|
-
outbound: {
|
|
93
|
-
to: any;
|
|
94
|
-
kind: string;
|
|
95
|
-
env: C.Envelope;
|
|
96
|
-
}[];
|
|
97
|
-
pending?: undefined;
|
|
98
|
-
}>;
|
|
19
|
+
export declare function flushContinuity(p: Person, newKey: string, when: number, ent?: any): Promise<any>;
|
|
99
20
|
//# sourceMappingURL=continuity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continuity.d.ts","sourceRoot":"","sources":["../../src/probe/continuity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"continuity.d.ts","sourceRoot":"","sources":["../../src/probe/continuity.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAoBvC,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM;;;CAGtC,CAAA;AAOF,wBAAsB,UAAU,CAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAQ;;;;YA0DvF;AA8ID,wBAAsB,iBAAiB,CAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAQ,gBAwDxF;AA4PD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,GAAQ,gBA6E5F"}
|