@atep/core 0.0.0-stage → 0.1.0-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/LICENSE-2.0
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 AIRAD LABS
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,261 @@
1
- # Temporary Holding Version
1
+ # @atep/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ATEP is a quantum-safe trust layer for robots and AI agents. Every signature and key exchange pairs a classical algorithm with a finalized NIST post-quantum standard (Ed25519 with ML-DSA-65, X25519 with ML-KEM-768), and both halves must hold. A robot or agent can identify and verify another offline, with no internet connection, registry or central server: an identity is a hash of public keys, and everything else is checked against cached keys, revocation lists and log checkpoints.
4
+
5
+ > **Experimental alpha. Do not rely on this to protect anything of value.** There has been no independent security audit. The wire format may change between releases (the COSE labels are private-use values and the media types are unregistered), and the post-quantum crates underneath are young. "Quantum-safe" means finalized NIST algorithms (FIPS 203 and FIPS 204) in a hybrid construction; it does not mean audited or proven.
6
+
7
+ `@atep/core` is the ATEP reference core (Draft 07, `ATEP-1` suite, including `retired`, `successor`, anchors and domain binding) for JavaScript: the Rust
8
+ `atep-core` crate compiled to WebAssembly, with a TypeScript API. One ESM
9
+ package for Node, Bun, Deno and browsers, no framework and no runtime
10
+ dependencies.
11
+
12
+ ```
13
+ npm install @atep/core@alpha
14
+ ```
15
+
16
+ Pre-releases are published under the `alpha` dist-tag, so a plain `npm install @atep/core` does not pick one until a stable release exists. Node 18 or later.
17
+
18
+ A complete example (generate keys, sign, encrypt, verify) is under "Usage" below.
19
+
20
+ Everything cryptographic and every protocol rule comes from the Rust crate
21
+ (RustCrypto: `ed25519-dalek`, `ml-dsa`, `x25519-dalek`, `ml-kem`, `aes-gcm`,
22
+ `hkdf`, `sha2`). The wrapper crate `rust/atep-wasm` only converts between JS
23
+ values and the core types.
24
+
25
+ ## Build from the repository
26
+
27
+ The published package ships the built `dist/`. To build from a repository checkout (development, or to audit the build) use the steps below.
28
+ `js/dist/` is gitignored, so a fresh clone always needs `npm run build` before
29
+ the package can be imported.
30
+
31
+ ```
32
+ rustup target add wasm32-unknown-unknown
33
+ cargo install wasm-bindgen-cli --version 0.2.129 --locked --no-default-features
34
+ npm ci # in the repository root: npm workspaces (js, mcp, examples), one lockfile
35
+ cd js
36
+ npm run build # cargo (wasm32, release) -> wasm-bindgen -> tsc -> dist/
37
+ npm test # all vectors plus round trip tests, under Node
38
+ ```
39
+
40
+ The wasm-bindgen CLI version must equal the `wasm-bindgen` crate version in
41
+ `rust/Cargo.lock` (0.2.129 at the time of writing). `npm run build` checks the
42
+ target and the CLI first, reads the required version from `rust/Cargo.lock`,
43
+ and prints the exact install commands if something is missing or mismatched.
44
+ `--no-default-features` is what CI uses: the default feature set pulls in
45
+ `ring`, which needs a C compiler, so without that flag the install fails on
46
+ machines that have none. The CLI is looked up on `PATH` (or `WASM_BINDGEN=/path`).
47
+ If `wasm-opt` is on `PATH` it is applied (saves about 6 percent). On a machine
48
+ without a C compiler also point `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER`
49
+ at a linker for the build scripts; the wasm32 target itself needs no C compiler
50
+ because all dependencies are pure Rust.
51
+
52
+ The build remaps the cargo, rustup and workspace paths (`--remap-path-prefix`),
53
+ turns debug info off, and drops the wasm name and producers sections, so the
54
+ binary contains no absolute local paths. `scripts/ci/no-local-paths.sh` checks this.
55
+
56
+ Output in `dist/`: `index.js`, `index.d.ts` (generated from `src/index.ts`) and
57
+ `wasm/` (`atep_wasm.js`, `atep_wasm_bg.wasm`, typings).
58
+
59
+ ## Size
60
+
61
+ | File | Bytes |
62
+ | --- | --- |
63
+ | `dist/wasm/atep_wasm_bg.wasm` (release, LTO, opt-level 3, no wasm-opt) | 758,345 (741 KiB) |
64
+ | same, gzip -9 | 286,802 (280 KiB) |
65
+ | `wasm-opt -Oz` (optional) | not measured for this build (measured once, on an earlier 657,927 byte build: 613,961) |
66
+
67
+ The Draft 05 exports (log admission rules, domain binding, anchors) grew the binary by 85,964 bytes
68
+ over the Draft 04 build (673,191).
69
+
70
+ ## Usage
71
+
72
+ ```js
73
+ import { init, keygen, sign, encrypt, verify, hexToBytes } from "@atep/core";
74
+
75
+ await init(); // loads the wasm once (Node: from disk, browser: fetch)
76
+
77
+ const alice = keygen(false); // signing keys only
78
+ const bob = keygen(true); // plus X25519 + ML-KEM-768 to receive encrypted envelopes
79
+
80
+ const now = Math.floor(Date.now() / 1000);
81
+ const signed = sign(alice, new TextEncoder().encode("hello"), { issuedAt: now, expiresAt: now + 600 });
82
+ const sealed = encrypt(signed, bob.publicBundle); // tag 96
83
+
84
+ const r = verify(sealed, {}, { recipient: bob, now }); // spec section 10, steps 1 to 10
85
+ if (r.ok) console.log(r.signer, new TextDecoder().decode(hexToBytes(r.payload_hex)));
86
+ else console.log(`rejected at step ${r.step}: ${r.error}`);
87
+ ```
88
+
89
+ A rejection is a returned value, `{ok: false, step, error, cause?}`. Exceptions
90
+ are for malformed arguments (bad hex, wrong seed length, bad JSON) and signing
91
+ or encryption failures.
92
+
93
+ Note the protocol rule that a data envelope (`application/atep+cbor`) must be
94
+ encrypted: a bare signed data envelope is refused at step 1. Trust documents
95
+ (attestations, SRLs, checkpoints) may travel signed only.
96
+
97
+ ### Verification with a trust policy, attestations and SRLs
98
+
99
+ ```js
100
+ const root = keygen(false), agent = keygen(false);
101
+ const att = root.issueAttestation({
102
+ subject: agent.agentId, claim: "operator-of",
103
+ issuedAt: now - 10, expiresAt: now + 86400, data: { operator: "Example Corp" },
104
+ });
105
+ const msg = encrypt(withAttestations(agent.sign(payload, { issuedAt: now }), [att]), bob.publicBundle);
106
+
107
+ const policy = {
108
+ trust: { roots: [root.agentId], rules: [{ claim: "operator-of" }] }, // same format as the Rust CLI policy file
109
+ known_bundles: [root.publicBundle],
110
+ srls: [], // signed revocation lists (hex or bytes)
111
+ attestations: [], // extra attestations known out of band
112
+ seen_nonces: [], // replay set
113
+ };
114
+ const result = bob.verify(msg, policy, now); // result.claims lists each satisfied rule with its chain
115
+
116
+ const srl = root.createSrl({ sequence: 1, issuedAt: now, nextUpdate: now + 3600,
117
+ revoked: [{ attestationId: hexToBytes(result.claims[0].chain[0].id), reason: "withdrawn", revokedAt: now }] });
118
+ bob.verify(msg, { ...policy, srls: [srl] }, now); // {ok: false, step: 9, ...}
119
+ ```
120
+
121
+ `VerifyPolicy` is the exact `policy` object of the test vectors (`vectors/README.md`).
122
+
123
+ ### Retirement and succession (Draft 04)
124
+
125
+ * `policy.attestations` is the local attestation store. Step 8 reads valid `retired`
126
+ attestations from it, so an identity that retired is rejected (`8/signer_revoked`) for
127
+ anything issued at or after its retirement, including attestations checked at step 9.
128
+ * `policy.trust.follow_succession` (boolean, default false): when a rule fails with
129
+ `claim_missing`, a one-hop `successor` attestation is followed. Applies to ATEP-R rules too.
130
+ * `policy.revocations` and `policy.srls` work as before; `srls` are loaded in list order in the
131
+ verifier's own context (earlier lists, `revocations`, `attestations`).
132
+ * `verifySrl(srl, {now, onStale, cached, context})`: `context` is
133
+ `{known_bundles?, attestations?, revocations?, max_skew_secs?}`, the context in which `cached`
134
+ and then `srl` are loaded (steps 1 to 8). A list signed by a retired identity at or after its
135
+ retirement is rejected `8/signer_revoked`. Without `context` nothing is retired or revoked.
136
+ * Not provided: a stateful log (the `log-admission` vectors) and the monitor `successor_chain` alert
137
+ (this package has no log or monitor). `checkAdmission` applies the admission rules to one submission
138
+ (below), which is what the `registry-endpoint` vectors need.
139
+
140
+ ### Anchors, chain ids, `require_anchor`, registry endpoints, domain binding (Draft 05)
141
+
142
+ All of these are pure functions of their input (no network, no clock unless `now` is passed) and return
143
+ the result shapes of `vectors/ANCHOR-DISCOVERY-NOTES.md`.
144
+
145
+ ```js
146
+ chainIdKind("x-acme-ledger"); // {ok: true, kind: "extension"}
147
+ parseAnchorRecord(payload); // {ok, record} or {ok: false, error: "anchor_record_invalid"}
148
+ encodeAnchorRecord(record); // deterministic CBOR, no block-height key when null
149
+ checkpointHash(checkpointEnvelope, [logId], now); // verifyCheckpoint plus checkpoint_hash, payload_hex
150
+ checkPublishedAnchor(anchorEnvelope, logId, checkpointHashHex, now); // {ok, log, record} or step 1 to 9 rejection
151
+ parseRequireAnchor(policy); // {ok, require_anchor} or {ok: false, error: "policy_invalid"}
152
+ checkAdmission(attestation, { now, log, maxEnvelopeBytes, logged }); // {ok, document} or {ok: false, refusal, ...}
153
+ checkDomainBinding(fixture); // {well_known, dns, outcome, queried}, fetcher answers come from the fixture
154
+ ```
155
+
156
+ `verify` already knows the `application/atep-anchor+cbor` media type and the policy member `require_anchor`
157
+ (step 9 refuses with `anchor_not_supported` while a rule exists; a malformed rule makes `verify` throw,
158
+ `parseRequireAnchor` reports it as `policy_invalid`). `checkDomainBinding` takes the answers of a fake
159
+ fetcher; wiring it to real HTTPS and DNS is the caller's job.
160
+
161
+ ### API summary
162
+
163
+ | Function | Purpose |
164
+ | --- | --- |
165
+ | `init(source?)`, `initSync(bytes)` | load the wasm; required once |
166
+ | `keygen(withEncryption)`, `Identity.generate`, `Identity.fromSeeds`, `fromSeedsHex`, `fromSecret` | create identities |
167
+ | `identity.agentId`, `.did`, `.publicBundle`, `.agentIdBytes`, `.hasEncryption`, `.exportSecret()`, `.free()` | identity access |
168
+ | `agentId(bundle)`, `parseAgentId(text)` | Agent ID derivation and parsing (`atep:` and `did:atep:`) |
169
+ | `sign(identity, payload, opts)` / `identity.sign` | hybrid Ed25519 + ML-DSA-65 signature, tag 98 |
170
+ | `encrypt(signedEnvelope, recipientBundle)` | hybrid X25519 + ML-KEM-768 with AES-256-GCM, tag 96 |
171
+ | `decrypt(identity, data)` | returns the inner signed envelope (unverified) |
172
+ | `verify(data, policy, {now, recipient})` / `identity.verify` | full verification, policy, chains, SRLs, inclusion proofs, ATEP-R |
173
+ | `view(data)` | JSON debug rendering of any ATEP CBOR object |
174
+ | `identity.issueAttestation(opts)` | issue an attestation |
175
+ | `identity.createSrl(opts)`, `verifySrl(srl, {now, onStale, cached, context})` | revocation lists |
176
+ | `identity.createCheckpoint(opts)`, `verifyCheckpoint`, `verifyInclusion`, `checkConsistency`, `checkSplitView` | transparency log documents |
177
+ | `merkleRoot`, `auditPath`, `submittedFormOf`, `withInclusionProof`, `withAttestations` | log and envelope helpers |
178
+ | `chainIdKind`, `parseAnchorRecord`, `encodeAnchorRecord`, `checkpointHash`, `checkPublishedAnchor` | chain ids, anchor records, checkpoint hash, published anchors |
179
+ | `parseRequireAnchor`, `checkAdmission`, `checkDomainBinding` | `require_anchor` parse, log admission rules for one submission, domain binding over a fixture |
180
+ | `sha256`, `hexToBytes`, `bytesToHex` | utilities |
181
+
182
+ Types are in `dist/index.d.ts`.
183
+
184
+ ### Runtimes
185
+
186
+ * Node 18+: tested (Node 25). `init()` reads the wasm next to `index.js`.
187
+ * Browsers: `init()` fetches `new URL("./wasm/atep_wasm_bg.wasm", import.meta.url)`; serve `.wasm` as `application/wasm`. Or pass your own source: `await init(fetch("/path/atep.wasm"))`, a `URL`, or bytes. Smoke page: `examples/smoke.html` (plain JS). Run `npm run smoke` and open http://127.0.0.1:8099/examples/smoke.html. The fetch + streaming instantiate path was exercised from Node against the local server; the page itself has not been opened in a real browser here.
188
+ * Bun and Deno: the package uses only standard ESM, `WebAssembly`, `fetch`, `crypto.getRandomValues` (through wasm-bindgen) and `node:fs/promises` (supported by both); not tested here (neither runtime is installed).
189
+ * Bundlers: the wasm is referenced via `new URL(..., import.meta.url)`; the export `@atep/core/atep_core_bg.wasm` points at the binary.
190
+
191
+ ## Secrets and their limits
192
+
193
+ * An `Identity` keeps its seeds only inside wasm linear memory. `atep-core`
194
+ zeroizes them (`ZeroizeOnDrop`) when the object is freed: call `identity.free()`
195
+ (or `using id = ...`). If you forget, they stay in wasm memory until the
196
+ JS garbage collector finalizes the object.
197
+ * Seeds you pass in (`fromSeeds`, `fromSecret`) are zeroized on the wasm side
198
+ after use, but the Uint8Array you passed is yours: `fill(0)` it.
199
+ * `exportSecret()` copies secret material to a JS Uint8Array, which is
200
+ garbage collected memory. Only use it for persistence, wipe the array after.
201
+ * Signing keys are not held in JS strings or objects, but the guarantees stop
202
+ at the platform: JS engines may copy or retain buffers (for example in
203
+ `TextEncoder` or structured clones), wasm memory never shrinks and is not
204
+ locked, swap and core dumps can capture it, and other code in the same
205
+ realm can read the module's memory. This is an in-process software key, not
206
+ an HSM.
207
+ * Passing `recipient_seeds` inside the policy JSON puts seed hex into JS
208
+ strings; pass `recipient: identity` instead.
209
+ * `encryptDeterministic` takes explicit randomness for test vectors only.
210
+ * Randomness comes from `crypto.getRandomValues` (the `getrandom` crate with its
211
+ `wasm_js` backend). The module has no clock: pass `now` explicitly or let the
212
+ wrapper default to `Date.now()`.
213
+ * Verification is not constant time in the places the Rust crate is not; see the
214
+ crates' documentation.
215
+
216
+ ## Timings
217
+
218
+ Node 25 on the development machine (WSL2), average over 50 to 100 calls after warm-up, 256 byte payload:
219
+ `node scripts/bench.mjs`.
220
+
221
+ | Operation | Time |
222
+ | --- | --- |
223
+ | `init()` (compile and instantiate) | about 5 ms |
224
+ | `keygen(true)` | 1.7 ms |
225
+ | `sign` (Ed25519 + ML-DSA-65) | 4.5 ms |
226
+ | `encrypt` (X25519 + ML-KEM-768 + AES-GCM) | 0.64 ms |
227
+ | `verify`, signed trust document, steps 1 to 10 | 0.91 ms |
228
+ | `verify`, encrypted envelope (decrypt, then steps 1 to 10) | 1.4 ms |
229
+ | `verify`, encrypted, with one attestation chain and trust policy | 2.6 ms |
230
+
231
+ ## Tests
232
+
233
+ `npm test` (node:test) runs, under Node, through the built package:
234
+
235
+ * `test/vectors.test.mjs`: every vector listed in `../vectors/manifest.json`: **431 passed + 5 skipped = 436**.
236
+ The first 200 (identity, signing, encryption, verify-positive/negative, attestation, chain-positive/negative,
237
+ srl, log, atep-r-positive/negative, retired-positive/negative, successor-positive/negative, srl-context,
238
+ log-admission, monitor) and the 236 of Draft 05: checkpoint-hash 9, anchor-record 36, chain-id 30,
239
+ anchor-envelope 13, anchor-media-type 3, require-anchor 27, anchor-not-supported 9, registry-endpoint 26,
240
+ domain-binding 83. The 5 skipped are named and counted in the summary: `log-admission` (4) and `monitor` (1),
241
+ because they need a stateful log or a monitor, which this package does not have. Each vector is checked for
242
+ CBOR hash, JSON view equality with the vector's `.json` (a vector whose `.json` says `not_strict_cbor` has no
243
+ view, and the runner only accepts a failing view for those), and by category: exact bytes for identity,
244
+ signing, encryption and attestation (and for anchor records, decoded and re-encoded); the full expected JSON
245
+ result for every other category. It is the same set of checks as `atep-vectors check` in `rust/`.
246
+ * `test/roundtrip.test.mjs`: two identities exchange an encrypted envelope, tampering, replay and wrong recipient,
247
+ detached payloads, secret export and import, attestation and trust policy, SRL revocation, checkpoint and inclusion proof.
248
+
249
+ ## Layout
250
+
251
+ ```
252
+ js/
253
+ package.json tsconfig.json
254
+ src/index.ts TypeScript API (src/wasm/ is generated)
255
+ scripts/build.mjs cargo -> wasm-bindgen -> tsc
256
+ scripts/bench.mjs timings
257
+ scripts/serve.mjs static server for the smoke page
258
+ examples/smoke.html browser smoke page, plain JS
259
+ test/ node:test suites
260
+ rust/atep-wasm/ the wasm-bindgen wrapper crate (workspace member)
261
+ ```