kxco-pq-network 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,84 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ First release. This package is the boundary between what is free and what is
6
+ sold, and it exists because that boundary needed a name.
7
+
8
+ The maths stays free. `kxco-post-quantum` and `kxco-verify` are Apache-2.0,
9
+ chain-agnostic, and work with the network unplugged. Nothing here changes that.
10
+
11
+ What this adds is the answer to a question offline cryptography cannot answer:
12
+ is this key still allowed to sign, today. A signature made by a key that was
13
+ revoked an hour ago is still a perfectly valid signature, and a verifier that
14
+ only checks the maths will accept it forever.
15
+
16
+ ### The three modes
17
+
18
+ - `signature` — the maths. Offline, free, no server in the path.
19
+ - `anchored` — plus an Armature L1 anchor carried by the envelope. Still no
20
+ HTTP at verify time, so an air-gapped verifier can check it.
21
+ - `anchored+live` — plus a live registry lookup. Needs a licence.
22
+
23
+ `applyVerifyMode` does no cryptography. Each package owns its own envelope
24
+ shape and signing message, and a second definition of "valid signature" here
25
+ would be one definition too many. The caller checks the maths and hands the
26
+ outcome in.
27
+
28
+ ### It fails closed
29
+
30
+ An unreachable registry makes `anchored+live` return **invalid**, not
31
+ valid-with-a-warning. A mode whose entire purpose is to catch a revoked key
32
+ must not degrade into the mode that cannot, precisely when the network is
33
+ behaving oddly — which is precisely when an attacker would arrange for it to
34
+ be.
35
+
36
+ A **JSON** 404 is treated as an **answer**, not a failure: the registry was
37
+ reached and has never heard of that key. That reports as `kid_unknown`, not
38
+ `registry_unreachable`. The distinction is the whole design.
39
+
40
+ A 404 that is not JSON is the opposite, and this was found by probing the live
41
+ endpoint rather than by reasoning about it. `https://chain.kxco.ai/kids/<kid>`
42
+ currently serves the marketing site's HTML 404 page, and an earlier draft of
43
+ this client read that as a confident "this key is unknown" — stating a fact
44
+ about a key on the strength of a misconfigured URL. The content type now
45
+ decides which of the two a 404 is.
46
+
47
+ ### Caching, and what it costs
48
+
49
+ Lookups are cached by kid for `registryTtlMs`, 60 seconds by default, and
50
+ concurrent lookups of one kid collapse into a single request. **At the default,
51
+ a revoked key stays accepted for up to a minute.** That is a real limit, it is
52
+ stated in the README rather than buried, and `registryTtlMs: 0` or
53
+ `clearCache()` trades it away.
54
+
55
+ ### Refusals
56
+
57
+ `chainId` is not configurable. Anything but 1111111 throws at construction:
58
+ accepting another chain would mean an anchor written elsewhere could satisfy a
59
+ KXCO verify, which is the one thing the anchor exists to prove.
60
+
61
+ A registry record whose kid does not match what was asked for is refused, using
62
+ the constant-time comparison from `kxco-post-quantum`. A status this build does
63
+ not recognise becomes `unknown` rather than passing through, so a status added
64
+ in a later release cannot fall out of the "is it active" check as though it
65
+ were active.
66
+
67
+ ### Metering
68
+
69
+ `meter()` and `usageEvent()` emit structured records. They emit; they do not
70
+ aggregate, invoice, or phone home. **The licence key is never emitted in full**
71
+ — only its first 8 characters, which is enough to attribute an event and
72
+ useless to whoever reads the log. The test suite asserts a full key never
73
+ appears in a record.
74
+
75
+ ### Why a separate package
76
+
77
+ `kxco-pq-sdk` already depends on `kxco-pq-attest`. Putting this module inside
78
+ the SDK and having attest import it would make a dependency cycle. It is
79
+ separate because it has to be, not for tidiness.
80
+
81
+ ### Not assessed
82
+
83
+ No third party has assessed this code. `@noble/post-quantum`, reached through
84
+ `kxco-post-quantum`, has been self-audited by its maintainer only — The other Noble packages have been audited, but separately and at different times: `@noble/hashes` by Cure53 in January 2022, `@noble/curves` by Trail of Bits in February 2023, Kudelski in September 2023 and Cure53 in September 2024, and `@noble/ciphers` by Cure53 in September 2024. None of those engagements covered the post-quantum package.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # kxco-pq-network
2
+
3
+ Verification modes for KXCO post-quantum envelopes.
4
+
5
+ This package is the boundary between what is free and what is sold.
6
+
7
+ The maths is free and stays free. `kxco-post-quantum` and `kxco-verify` are Apache-2.0, chain-agnostic, and work offline with no KXCO server anywhere in the path. Nothing here changes that.
8
+
9
+ What this package adds is the answer to a question offline cryptography cannot answer: **is this key still allowed to sign, today?** A signature made by a key that was revoked an hour ago is still a perfectly valid signature. A verifier that only checks the maths will accept it forever.
10
+
11
+ ---
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install kxco-pq-network
17
+ ```
18
+
19
+ Node 20.19+. ESM only.
20
+
21
+ ---
22
+
23
+ ## The three modes
24
+
25
+ | Mode | Checks | Network at verify time | Licence |
26
+ |---|---|---|---|
27
+ | `signature` | The maths | None | No |
28
+ | `anchored` | The maths, plus an Armature L1 anchor carried by the envelope | None | No |
29
+ | `anchored+live` | Anchored, plus a live key-registry lookup | Yes, fails closed | **Yes** |
30
+
31
+ `signature` is what `kxco-post-quantum` has always done. It works offline, forever.
32
+
33
+ `anchored` additionally requires the envelope to carry chain id `1111111` and a transaction hash. The anchor travels inside the envelope, so an air-gapped verifier can check it. What it cannot tell you is whether the key is still good.
34
+
35
+ `anchored+live` answers "should I act on this now". It needs a hosted registry, and that is the part we sell.
36
+
37
+ ```js
38
+ import { networkConfigFromEnv, applyVerifyMode, FAILURE } from 'kxco-pq-network'
39
+ import { verify } from 'kxco-pq-attest'
40
+
41
+ const config = networkConfigFromEnv() // reads KXCO_VERIFY_MODE etc.
42
+ const signature = verify(envelope, publicKey) // your own crypto check
43
+
44
+ const result = await applyVerifyMode({
45
+ envelope,
46
+ signatureValid: signature.valid,
47
+ kid: envelope.kid,
48
+ config,
49
+ })
50
+
51
+ if (!result.valid) {
52
+ switch (result.reason) {
53
+ case FAILURE.SIGNATURE_INVALID: // the document is not what it claims
54
+ case FAILURE.KID_REVOKED: // valid signature, key no longer trusted
55
+ case FAILURE.REGISTRY_UNREACHABLE: // we could not ask; see below
56
+ }
57
+ }
58
+ ```
59
+
60
+ `applyVerifyMode` does no cryptography. Each package owns its own envelope shape and signing message, and a second definition of "valid signature" here would be one definition too many. You check the maths; this decides what the mode requires on top of it.
61
+
62
+ ---
63
+
64
+ ## It fails closed
65
+
66
+ If the registry cannot be reached, `anchored+live` returns **invalid**. Not valid-with-a-warning.
67
+
68
+ A mode whose entire purpose is to catch a revoked key must not quietly degrade into the mode that cannot, precisely when the network is behaving oddly — which is precisely when an attacker would arrange for it to be. Callers who would rather have the weaker answer than no answer should ask for `anchored` and get it deterministically.
69
+
70
+ A **JSON** `404` is treated as an **answer**, not a failure: the registry was reached and has never heard of that key. That is a definite "do not trust", and it is reported as `kid_unknown`, not `registry_unreachable`. The distinction is the whole design.
71
+
72
+ A `404` that is **not** JSON is the opposite. Point `registryUrl` at a web app and you get that app's 404 page back, and reading a page of HTML as "this key is unknown" would state a fact about a key on the strength of a misconfigured URL. The content type decides which of the two it is.
73
+
74
+ ---
75
+
76
+ ## Caching, and what it costs you
77
+
78
+ Lookups are cached by kid for `registryTtlMs`, 60 seconds by default. Concurrent lookups of the same kid collapse into one request, so a batch of envelopes from one signer arriving on a cold cache opens one connection, not one per envelope.
79
+
80
+ **The limit this creates, stated plainly:** at the 60 second default, a revoked key stays accepted for up to a minute after revocation. Set `registryTtlMs: 0` to trade that for a lookup per verification, or call `registry.clearCache()` when you receive a rotation webhook.
81
+
82
+ ---
83
+
84
+ ## Configuration
85
+
86
+ Everything a customer sets to go live:
87
+
88
+ ```bash
89
+ KXCO_VERIFY_MODE=anchored+live
90
+ KXCO_LICENCE_KEY=kxco_live_...
91
+ KXCO_REGISTRY_URL=https://chain.kxco.ai # default
92
+ KXCO_RELAY_URL=https://relay.kxco.ai # default
93
+ KXCO_REGISTRY_TTL_MS=60000 # default
94
+ ```
95
+
96
+ `chainId` is not a configuration option. It is `1111111` and passing anything else throws. Accepting another chain would mean an anchor written somewhere else could satisfy a KXCO verify, which is the one thing the anchor exists to prove.
97
+
98
+ ---
99
+
100
+ ## Registry contract
101
+
102
+ `GET /kids/:kid` on the registry base URL. `kid` is 16 lowercase hex characters.
103
+
104
+ > **Status, 3 September 2026.** This endpoint is **implemented but not yet deployed**. The handler lives in `kxco-chain-live/explorer-public` (`src/pages/api/kids/[kid].js`, published at `/kids/:kid` by a rewrite) and reads the `KXCOIdentityRegistry` contract at `0x87776E97F981DdEF0b77469c67E222B106B94319` on chain 1111111. It is verified end to end against a scripted chain, including the `kxco-pq-network` client itself.
105
+ >
106
+ > Until it is deployed, `https://chain.kxco.ai/kids/<kid>` still serves the marketing site's HTML 404. The client detects that and reports `REGISTRY_UNREACHABLE` rather than reading it as "this key is unknown", so `anchored+live` fails closed against production and `anchored` is the strongest mode that works end to end today.
107
+
108
+ ```json
109
+ {
110
+ "kid": "aa29f37ab7f4b2cf",
111
+ "publicKey": "<hex or jwk>",
112
+ "status": "active",
113
+ "rotatedTo": null,
114
+ "institutionId": "org_...",
115
+ "chainId": 1111111,
116
+ "asOfBlock": 1234567
117
+ }
118
+ ```
119
+
120
+ `status` is `active`, `revoked` or `rotated`. **Any value this build does not recognise is treated as `unknown`**, so a status added in a later release cannot fall out of the "is it active" check as though it were active.
121
+
122
+ A record whose `kid` does not match what was asked for is refused. The comparison is constant-time. A registry that answers about a different key is either broken or being interposed, and either way its answer is unusable.
123
+
124
+ The registry read is metered where a licence is configured and rate-limited where one is not. Reads without a licence are allowed — that is how the free path stays free.
125
+
126
+ ---
127
+
128
+ ## Metering
129
+
130
+ `meter()` and `usageEvent()` emit structured events for `anchor_written`, `kid_registered`, `kid_revoked`, `kid_rotated`, `relay_post`, `registry_read` and `verify`.
131
+
132
+ They emit; they do not aggregate, invoice, or phone home. The default sink is one JSON line on stdout, because that is what every log shipper already parses.
133
+
134
+ **The licence key is never emitted in full.** Only the first 8 characters, which is enough to attribute an event and useless to anyone who reads the log. Logs get shipped to places the key was never meant to reach.
135
+
136
+ ---
137
+
138
+ ## Where this fits
139
+
140
+ This decides what a verification mode *requires* on top of a signature check
141
+ you have already performed. Keeping that decision separate from the
142
+ cryptography is deliberate: policy changes without touching a signature path.
143
+
144
+ - [`kxco-post-quantum`](https://www.npmjs.com/package/kxco-post-quantum) performs the signature check itself
145
+ - [`kxco-pq-chain`](https://www.npmjs.com/package/kxco-pq-chain) performs relay writes
146
+
147
+ ## Why this is its own package
148
+
149
+ `kxco-pq-sdk` already depends on `kxco-pq-attest`. Putting this module inside the SDK and having attest import it would make a dependency cycle. It is separate because it has to be, not for tidiness.
150
+
151
+ ---
152
+
153
+ ## Security
154
+
155
+ **ML-DSA-65** (NIST FIPS 204) via [`kxco-post-quantum`](https://www.npmjs.com/package/kxco-post-quantum), running on the OpenSSL 3.5 primitives where the runtime provides them. No custom cryptography.
156
+
157
+ This package adds no cryptography of its own, so the evidence that matters is the
158
+ base package's, and it is reproducible on your own machine:
159
+
160
+ - **2,103 NIST ACVP vectors (0 failed)** across FIPS 203, 204 and 205, pinned by digest
161
+ - **225 interoperability checks** against OpenSSL 3.5, liboqs, Bouncy Castle and dilithium-py/kyber-py, in both directions and with negative controls
162
+ - **SLSA provenance** on every [`kxco-post-quantum`](https://www.npmjs.com/package/kxco-post-quantum) release — verify with `npm audit signatures kxco-post-quantum`
163
+ - `npm run evidence` in that package regenerates the whole bundle from source
164
+
165
+ Third-party dependencies here are pinned to exact versions, never ranges, so the
166
+ code that performs the cryptography cannot change without a release.
167
+
168
+ Dependency audit history is recorded in [AUDIT.md](https://github.com/KnightsbridgeAIQ/kxco-post-quantum/blob/main/AUDIT.md).
169
+
170
+ This package adds no cryptography of its own. It decides what a verification mode requires on top of a signature check the caller performed, and it fails closed: an unreachable registry returns invalid, never valid-with-a-warning.
171
+
172
+ To report a vulnerability, email **security@kxco.ai**.
173
+
174
+ ---
175
+
176
+ ## License
177
+
178
+ Apache-2.0. Use of the hosted registry, relay and anchoring service is governed separately — see `LICENCE-PRODUCT.md`.
179
+
180
+ ---
181
+
182
+ ## Maintainers
183
+
184
+ Shayne Heffernan and John Heffernan — [KXCO by Knightsbridge](https://kxco.ai)
package/SALES-SKU.md ADDED
@@ -0,0 +1,134 @@
1
+ # Seats and metering
2
+
3
+ What is sold, how it is counted, and where in the code the counting happens.
4
+
5
+ Prices are **USD, per seat, per year**, invoiced. No customer holds ARMR, runs a node, sets a gas price or touches a wallet. If that changes, this document is wrong and should be corrected rather than quietly reinterpreted.
6
+
7
+ Commercial terms: **hello@kxco.ai**
8
+
9
+ ---
10
+
11
+ ## The line
12
+
13
+ Free: the maths. `kxco-post-quantum` and `kxco-verify` are Apache-2.0, chain-agnostic, and work with the network unplugged. They keep working if KXCO stops existing.
14
+
15
+ Paid: **an answer about the present.** A signature made by a key that was revoked an hour ago is still a perfectly valid signature. No offline check can tell you it was revoked. Only an operated service can, and only an operated service can be held to an answer.
16
+
17
+ See [`LICENCE-PRODUCT.md`](https://github.com/KnightsbridgeAIQ/kxco-post-quantum/blob/main/LICENCE-PRODUCT.md).
18
+
19
+ ---
20
+
21
+ ## Seats
22
+
23
+ ### 1. Network seat
24
+
25
+ The unit of subscription. One institution, one licence key.
26
+
27
+ Entitles: registry reads at metered volume, `anchored+live` verification, relay writes, and the `KXCO Verified` mark under contract.
28
+
29
+ Counted by `institutionId`. A licence key belongs to exactly one institution; sharing one across legal entities is what the contract prohibits, not what the code prevents.
30
+
31
+ ### 2. Anchor quota
32
+
33
+ On-chain writes to Armature L1 — `anchorHash`, `anchorAuditRoot`, `anchorAttestation`.
34
+
35
+ Each anchor is an EVM transaction whose gas KXCO pays in ARMR. That is a real cost per write, which is why this is a quota and not unlimited.
36
+
37
+ Sold in blocks per year. Overage is invoiced, not blocked: a compliance anchor that fails because a counter rolled over is worse for the customer than an invoice.
38
+
39
+ ### 3. Agent kids
40
+
41
+ Machine identities registered under an institution — `registerAgent` / `issueAgentCredential` for `llm`, `robot`, `iot` and `process` types.
42
+
43
+ Counted as **distinct agent kids ever registered**, not concurrent. A kid revoked and replaced counts as two, because registering it consumed a chain write either way.
44
+
45
+ ### 4. Webhook verified
46
+
47
+ Outbound deliveries signed with ML-DSA-65, and the optional compact-JWS path, from `kxco-post-quantum-webhook`.
48
+
49
+ **Signing and verifying webhooks needs no licence.** The package is Apache-2.0 and does not call anything. What is sold here is the hosted key-rotation endpoint and the registry lookup that lets a receiver confirm a signing kid is still current, which is the part a receiver cannot do for themselves.
50
+
51
+ ### 5. SLA
52
+
53
+ Availability commitment on `chain.kxco.ai` and `relay.kxco.ai`, an escalation path, and a named contact.
54
+
55
+ Worth stating plainly: `anchored+live` **fails closed**. When the registry is unreachable, verification returns invalid. That is deliberate — a revocation check that quietly passes when it could not run is not a check — and it means registry availability is directly a customer's availability. That is what the SLA is for, and it is why a customer who cannot tolerate it should use `anchored`, which needs no registry at all.
56
+
57
+ ---
58
+
59
+ ## Metering hooks
60
+
61
+ Billing is metered **server-side**. The relay and the registry are the source of truth, because a client-side counter is a counter the customer controls.
62
+
63
+ The hooks below exist for the customer's own observability, and to reconcile an invoice against their own logs. They emit; they do not aggregate, invoice, or phone home.
64
+
65
+ | Event | Emitted by |
66
+ |---|---|
67
+ | `relay_post` | `kxco-pq-chain`, on every relay write |
68
+ | `anchor_written` | callers, on a successful anchor |
69
+ | `kid_registered` | callers, on identity or agent registration |
70
+ | `kid_revoked`, `kid_rotated` | callers, on revocation or rotation |
71
+ | `registry_read` | `kxco-pq-network`, on a registry lookup |
72
+ | `verify` | callers, per verification |
73
+
74
+ Every record carries:
75
+
76
+ ```json
77
+ {
78
+ "event": "relay_post",
79
+ "at": "2026-09-03T00:00:00.000Z",
80
+ "chainId": 1111111,
81
+ "operation": "anchorHash",
82
+ "institutionKid": "aa29f37ab7f4b2cf",
83
+ "kid": "bb29f37ab7f4b2cf",
84
+ "licencePrefix": "kxco_liv",
85
+ "txHash": "0x…",
86
+ "blockNumber": 90633
87
+ }
88
+ ```
89
+
90
+ **`licencePrefix` is the first 8 characters and never more.** Enough to attribute an event to a customer, useless to whoever reads the log. Logs get shipped to places the key was never meant to reach, and the test suites in both packages assert that a full licence key never appears in an emitted record.
91
+
92
+ ### Turning them on
93
+
94
+ ```js
95
+ // kxco-pq-chain — off by default; a library should not write to your logs uninvited
96
+ new KxcoChain({ identity, licenceKey, onUsageEvent: (e) => logger.info(e) })
97
+
98
+ // kxco-pq-network — build a record, or emit one through your own sink
99
+ import { meter, usageEvent } from 'kxco-pq-network'
100
+ meter('registry_read', { institutionId, kid, licenceKey }, (r) => logger.info(r))
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Going live
106
+
107
+ Everything a customer sets:
108
+
109
+ ```bash
110
+ KXCO_LICENCE_KEY=kxco_live_... # required for relay writes and anchored+live
111
+ KXCO_VERIFY_MODE=anchored+live # or anchored, or signature
112
+ KXCO_REGISTRY_URL=https://chain.kxco.ai # default
113
+ KXCO_RELAY_URL=https://relay.kxco.ai # default
114
+ KXCO_REGISTRY_TTL_MS=60000 # default
115
+ ```
116
+
117
+ A missing licence throws at **construction**, not at the first write. A service that boots looking healthy and fails on a customer's first transaction has already told someone their onboarding succeeded.
118
+
119
+ `KXCO_LICENSE_KEY` is accepted as well, because half the world spells it that way and a failed deployment over a vowel helps nobody.
120
+
121
+ ---
122
+
123
+ ## What the buyer is getting
124
+
125
+ - **A named counterparty.** Four known validators under QBFT proof-of-authority, an operator with a legal entity behind it, and a contract. The question a supervisor asks — who approved this — has an answer here and does not on a permissionless chain.
126
+ - **On-chain post-quantum verification.** Armature L1 verifies ML-DSA-65 in consensus at precompile `0x0b`, executed by every validator, ~50,000 gas.
127
+ - **Category 5 available today.** ML-DSA-87 and ML-KEM-1024, the parameter sets CNSA 2.0 specifies, shipped and ACVP-checked.
128
+ - **Evidence, not assertions.** 2,103 NIST ACVP vectors, a 225-check interoperability matrix, SLSA provenance and a CycloneDX SBOM on every release — all reproducible by the customer.
129
+
130
+ ## What is not sold
131
+
132
+ - **Not the cryptography.** It is Apache-2.0 and it is not going to stop being.
133
+ - **Not a token.** No ARMR to buy, no wallet, no gas.
134
+ - **Not an audit.** What is sold is the operated service. The cryptographic evidence — ACVP vectors, the interoperability matrix, provenance, SBOM — is published and free to re-run; see the `evidence` job in `kxco-post-quantum`.
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "kxco-pq-network",
3
+ "version": "1.0.0",
4
+ "description": "Three levels of proof for KXCO post-quantum envelopes: the signature alone, offline; the signature plus an Armature L1 anchor; and both plus a live key-registry lookup that fails closed. Shared by kxco-pq-sdk, kxco-pq-attest, kxco-post-quantum-webhook and kxco-pq-agent.",
5
+ "keywords": [
6
+ "post-quantum",
7
+ "pqc",
8
+ "ml-dsa",
9
+ "verification",
10
+ "revocation",
11
+ "key-registry",
12
+ "anchoring",
13
+ "armature",
14
+ "kxco",
15
+ "identity",
16
+ "compliance",
17
+ "fail-closed"
18
+ ],
19
+ "license": "Apache-2.0",
20
+ "author": "Shayne Heffernan and John Heffernan",
21
+ "contributors": [
22
+ {
23
+ "name": "Shayne Heffernan"
24
+ },
25
+ {
26
+ "name": "John Heffernan"
27
+ }
28
+ ],
29
+ "homepage": "https://kxco.ai",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/KnightsbridgeAIQ/kxco-pq-network.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/KnightsbridgeAIQ/kxco-pq-network/issues"
36
+ },
37
+ "type": "module",
38
+ "sideEffects": false,
39
+ "main": "./src/index.js",
40
+ "types": "./src/index.d.ts",
41
+ "exports": {
42
+ ".": {
43
+ "types": "./src/index.d.ts",
44
+ "import": "./src/index.js"
45
+ }
46
+ },
47
+ "files": [
48
+ "CHANGELOG.md",
49
+ "LICENSE",
50
+ "README.md",
51
+ "SALES-SKU.md",
52
+ "src"
53
+ ],
54
+ "engines": {
55
+ "node": ">=20.19"
56
+ },
57
+ "dependencies": {
58
+ "kxco-post-quantum": "^1.6.0"
59
+ },
60
+ "scripts": {
61
+ "test": "node --test --test-timeout=30000 test/network.test.js test/registry.test.js"
62
+ },
63
+ "funding": "https://kxco.ai",
64
+ "publishConfig": {
65
+ "access": "public"
66
+ }
67
+ }