@weave_protocol/yoxallismus 0.0.1 → 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +201 -17
  2. package/SECURITY.md +110 -0
  3. package/SECURITY_ADVISORIES.md +43 -0
  4. package/SKILL.md +50 -0
  5. package/THREAT_MODEL.md +170 -0
  6. package/dist/aead.d.ts +44 -0
  7. package/dist/aead.d.ts.map +1 -0
  8. package/dist/aead.js +96 -0
  9. package/dist/aead.js.map +1 -0
  10. package/dist/cli.d.ts +16 -0
  11. package/dist/cli.d.ts.map +1 -0
  12. package/dist/cli.js +451 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/index.d.ts +49 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +72 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/kdf.d.ts +33 -0
  19. package/dist/kdf.d.ts.map +1 -0
  20. package/dist/kdf.js +45 -0
  21. package/dist/kdf.js.map +1 -0
  22. package/dist/kem.d.ts +50 -0
  23. package/dist/kem.d.ts.map +1 -0
  24. package/dist/kem.js +167 -0
  25. package/dist/kem.js.map +1 -0
  26. package/dist/labels.d.ts +50 -0
  27. package/dist/labels.d.ts.map +1 -0
  28. package/dist/labels.js +92 -0
  29. package/dist/labels.js.map +1 -0
  30. package/dist/ratchet.d.ts +38 -0
  31. package/dist/ratchet.d.ts.map +1 -0
  32. package/dist/ratchet.js +91 -0
  33. package/dist/ratchet.js.map +1 -0
  34. package/dist/serialize.d.ts +20 -0
  35. package/dist/serialize.d.ts.map +1 -0
  36. package/dist/serialize.js +97 -0
  37. package/dist/serialize.js.map +1 -0
  38. package/dist/types.d.ts +67 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +6 -0
  41. package/dist/types.js.map +1 -0
  42. package/dist/v1-compat.d.ts +19 -0
  43. package/dist/v1-compat.d.ts.map +1 -0
  44. package/dist/v1-compat.js +22 -0
  45. package/dist/v1-compat.js.map +1 -0
  46. package/package.json +51 -7
  47. package/index.js +0 -27
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Symmetric ratchet for @weave_protocol/yoxallismus v0.1.0-beta.0.
3
+ *
4
+ * Each message advances the chain key via HKDF, providing forward
5
+ * secrecy within a session: if the current chain key is compromised
6
+ * at message N, messages 1..N-1 remain confidential (their per-message
7
+ * keys were derived from earlier chain state that is now unrecoverable).
8
+ *
9
+ * WHAT THIS DOESN'T DO (yet — planned for v0.2):
10
+ * - DH ratcheting (Signal Double Ratchet) — required for post-compromise
11
+ * recovery. Without it, if the chain key IS compromised at message N,
12
+ * all future messages 1..∞ from that session are readable to the
13
+ * attacker.
14
+ * - Out-of-order delivery handling — messages must be decrypted in
15
+ * order; skipped messages break the chain.
16
+ * - Skipped-message key retention — no support for holding decryption
17
+ * keys for future out-of-order arrivals.
18
+ *
19
+ * These are all real Signal Protocol features; v0.1 is deliberately
20
+ * simpler while the wire format stabilizes.
21
+ */
22
+ import { randomBytes } from 'node:crypto';
23
+ import { aeadEncryptWithNonce, aeadDecrypt } from './aead.js';
24
+ import { hkdf, deriveNonce } from './kdf.js';
25
+ const CHAIN_ADVANCE_INFO = 'weave-yoxall v0.1 chain-advance';
26
+ const MESSAGE_KEY_INFO = 'weave-yoxall v0.1 message-key';
27
+ /**
28
+ * Initialize a ratchet session from an initial 32-byte shared secret
29
+ * (typically the output of a hybrid KEM decapsulation).
30
+ */
31
+ export function initRatchet(sharedSecret) {
32
+ if (sharedSecret.length !== 32) {
33
+ throw new Error(`initRatchet: sharedSecret must be 32 bytes, got ${sharedSecret.length}`);
34
+ }
35
+ const sessionId = new Uint8Array(randomBytes(16));
36
+ // Derive initial chain key from the shared secret, salted with sessionId
37
+ const chainKey = hkdf(sharedSecret, sessionId, 'weave-yoxall v0.1 ratchet-init', 32);
38
+ return {
39
+ chainKey,
40
+ messageNumber: 0,
41
+ sessionId,
42
+ };
43
+ }
44
+ /**
45
+ * Encrypt a message, advancing the ratchet by one step.
46
+ * Mutates the session in place.
47
+ */
48
+ export function ratchetEncrypt(session, plaintext, associatedData) {
49
+ const messageKey = hkdf(session.chainKey, session.sessionId, MESSAGE_KEY_INFO, 32);
50
+ const nonce = deriveNonce(session.chainKey, session.messageNumber);
51
+ // Combine caller AAD with session ID + message number for context binding
52
+ const contextAAD = buildContextAAD(session.sessionId, session.messageNumber, associatedData);
53
+ const payload = aeadEncryptWithNonce(messageKey, plaintext, nonce, contextAAD);
54
+ // Advance chain — chainKey_new = HKDF(chainKey_old)
55
+ session.chainKey = hkdf(session.chainKey, session.sessionId, CHAIN_ADVANCE_INFO, 32);
56
+ session.messageNumber += 1;
57
+ return payload;
58
+ }
59
+ /**
60
+ * Decrypt a message, advancing the ratchet by one step.
61
+ * Both sides must process messages in the same order for chain keys to match.
62
+ */
63
+ export function ratchetDecrypt(session, payload, associatedData) {
64
+ const messageKey = hkdf(session.chainKey, session.sessionId, MESSAGE_KEY_INFO, 32);
65
+ // Rebuild the same AAD the sender bound
66
+ const contextAAD = buildContextAAD(session.sessionId, session.messageNumber, associatedData);
67
+ const plaintext = aeadDecrypt(messageKey, {
68
+ ...payload,
69
+ associatedData: contextAAD,
70
+ });
71
+ // Advance chain
72
+ session.chainKey = hkdf(session.chainKey, session.sessionId, CHAIN_ADVANCE_INFO, 32);
73
+ session.messageNumber += 1;
74
+ return plaintext;
75
+ }
76
+ function buildContextAAD(sessionId, msgNum, userAAD) {
77
+ const msgNumBytes = new Uint8Array(8);
78
+ new DataView(msgNumBytes.buffer).setBigUint64(0, BigInt(msgNum), false);
79
+ const parts = [sessionId, msgNumBytes];
80
+ if (userAAD)
81
+ parts.push(userAAD);
82
+ const total = parts.reduce((n, p) => n + p.length, 0);
83
+ const out = new Uint8Array(total);
84
+ let off = 0;
85
+ for (const p of parts) {
86
+ out.set(p, off);
87
+ off += p.length;
88
+ }
89
+ return out;
90
+ }
91
+ //# sourceMappingURL=ratchet.js.map
@@ -0,0 +1 @@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AS,EAAE,WAAW,CAAC,CAAC;IACvC,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAChB,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Wire format for @weave_protocol/yoxallismus v0.1.0-beta.0.
3
+ *
4
+ * SUBJECT TO CHANGE. This is beta. The wire format may break between
5
+ * v0.1 and v0.2 as we integrate DH ratcheting and other v0.2 pieces.
6
+ * Migration tooling will be provided when the format stabilizes.
7
+ *
8
+ * Current format: base64url-encoded JSON envelopes with explicit
9
+ * versioning. Simple, debuggable, forward-compatible via version tag.
10
+ */
11
+ import type { HybridKeypair, HybridPublicKey, HybridCiphertext, EncryptedPayload } from './types.js';
12
+ export declare function serializePublicKey(pub: HybridPublicKey): string;
13
+ export declare function deserializePublicKey(s: string): HybridPublicKey;
14
+ export declare function serializeKeypair(kp: HybridKeypair): string;
15
+ export declare function deserializeKeypair(s: string): HybridKeypair;
16
+ export declare function serializeCiphertext(ct: HybridCiphertext): string;
17
+ export declare function deserializeCiphertext(s: string): HybridCiphertext;
18
+ export declare function serializePayload(p: EncryptedPayload): string;
19
+ export declare function deserializePayload(s: string): EncryptedPayload;
20
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAarH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAO/D;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAO/D;AAID,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,CAU1D;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAS3D;AAID,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,gBAAgB,GAAG,MAAM,CAOhE;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAOjE;AAID,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAQ5D;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAQ9D"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Wire format for @weave_protocol/yoxallismus v0.1.0-beta.0.
3
+ *
4
+ * SUBJECT TO CHANGE. This is beta. The wire format may break between
5
+ * v0.1 and v0.2 as we integrate DH ratcheting and other v0.2 pieces.
6
+ * Migration tooling will be provided when the format stabilizes.
7
+ *
8
+ * Current format: base64url-encoded JSON envelopes with explicit
9
+ * versioning. Simple, debuggable, forward-compatible via version tag.
10
+ */
11
+ const WIRE_VERSION = 'yoxall/0.1.0-beta.0';
12
+ function b64(u8) {
13
+ return Buffer.from(u8).toString('base64url');
14
+ }
15
+ function u8(b64s) {
16
+ return new Uint8Array(Buffer.from(b64s, 'base64url'));
17
+ }
18
+ // ─── Public keys ────────────────────────────────────────────────
19
+ export function serializePublicKey(pub) {
20
+ return JSON.stringify({
21
+ _type: 'yoxall-pubkey',
22
+ _version: WIRE_VERSION,
23
+ x25519: b64(pub.x25519PublicKey),
24
+ mlkem: b64(pub.mlkemPublicKey),
25
+ });
26
+ }
27
+ export function deserializePublicKey(s) {
28
+ const j = JSON.parse(s);
29
+ if (j._type !== 'yoxall-pubkey')
30
+ throw new Error(`not a public key envelope: ${j._type}`);
31
+ return {
32
+ x25519PublicKey: u8(j.x25519),
33
+ mlkemPublicKey: u8(j.mlkem),
34
+ };
35
+ }
36
+ // ─── Private keypair (WARNING: contains secret material) ────────
37
+ export function serializeKeypair(kp) {
38
+ return JSON.stringify({
39
+ _type: 'yoxall-keypair',
40
+ _version: WIRE_VERSION,
41
+ _warning: 'CONTAINS PRIVATE KEY MATERIAL — protect this file',
42
+ x25519pub: b64(kp.x25519PublicKey),
43
+ x25519priv: b64(kp.x25519PrivateKey),
44
+ mlkempub: b64(kp.mlkemPublicKey),
45
+ mlkempriv: b64(kp.mlkemPrivateKey),
46
+ }, null, 2);
47
+ }
48
+ export function deserializeKeypair(s) {
49
+ const j = JSON.parse(s);
50
+ if (j._type !== 'yoxall-keypair')
51
+ throw new Error(`not a keypair envelope: ${j._type}`);
52
+ return {
53
+ x25519PublicKey: u8(j.x25519pub),
54
+ x25519PrivateKey: u8(j.x25519priv),
55
+ mlkemPublicKey: u8(j.mlkempub),
56
+ mlkemPrivateKey: u8(j.mlkempriv),
57
+ };
58
+ }
59
+ // ─── Ciphertext ─────────────────────────────────────────────────
60
+ export function serializeCiphertext(ct) {
61
+ return JSON.stringify({
62
+ _type: 'yoxall-kem-ct',
63
+ _version: WIRE_VERSION,
64
+ x25519eph: b64(ct.x25519EphemeralPublicKey),
65
+ mlkem: b64(ct.mlkemCiphertext),
66
+ });
67
+ }
68
+ export function deserializeCiphertext(s) {
69
+ const j = JSON.parse(s);
70
+ if (j._type !== 'yoxall-kem-ct')
71
+ throw new Error(`not a KEM ciphertext envelope: ${j._type}`);
72
+ return {
73
+ x25519EphemeralPublicKey: u8(j.x25519eph),
74
+ mlkemCiphertext: u8(j.mlkem),
75
+ };
76
+ }
77
+ // ─── Encrypted payload ──────────────────────────────────────────
78
+ export function serializePayload(p) {
79
+ return JSON.stringify({
80
+ _type: 'yoxall-payload',
81
+ _version: WIRE_VERSION,
82
+ nonce: b64(p.nonce),
83
+ ct: b64(p.ciphertext),
84
+ ...(p.associatedData ? { aad: b64(p.associatedData) } : {}),
85
+ });
86
+ }
87
+ export function deserializePayload(s) {
88
+ const j = JSON.parse(s);
89
+ if (j._type !== 'yoxall-payload')
90
+ throw new Error(`not a payload envelope: ${j._type}`);
91
+ return {
92
+ nonce: u8(j.nonce),
93
+ ciphertext: u8(j.ct),
94
+ ...(j.aad ? { associatedData: u8(j.aad) } : {}),
95
+ };
96
+ }
97
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C,SAAS,GAAG,CAAC,EAAc;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC;AACD,SAAS,EAAE,CAAC,IAAY;IACtB,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,mEAAmE;AAEnE,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC;QAChC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;KAC/B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAS;IAC5C,MAAM,CAAC,GAAG,IAAI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AI,KAAK,CAAC,2BAA2B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACxF,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAClB,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Public types for @weave_protocol/yoxallismus v0.1.0-beta.0.
3
+ * See THREAT_MODEL.md for the security model these types operate within.
4
+ */
5
+ /**
6
+ * A hybrid keypair combining X25519 (classical) and ML-KEM-768 (post-quantum).
7
+ *
8
+ * SIZES (v0.1.0-beta.0):
9
+ * x25519PublicKey: 32 bytes
10
+ * x25519PrivateKey: 32 bytes
11
+ * mlkemPublicKey: 1184 bytes (ML-KEM-768)
12
+ * mlkemPrivateKey: 2400 bytes (ML-KEM-768)
13
+ */
14
+ export interface HybridKeypair {
15
+ x25519PublicKey: Uint8Array;
16
+ x25519PrivateKey: Uint8Array;
17
+ mlkemPublicKey: Uint8Array;
18
+ mlkemPrivateKey: Uint8Array;
19
+ }
20
+ /**
21
+ * Public-key half of a hybrid keypair — the shareable identity.
22
+ */
23
+ export interface HybridPublicKey {
24
+ x25519PublicKey: Uint8Array;
25
+ mlkemPublicKey: Uint8Array;
26
+ }
27
+ /**
28
+ * The output of a hybrid KEM encapsulation.
29
+ *
30
+ * `sharedSecret` is a 32-byte value derived via HKDF-SHA-256 from
31
+ * BOTH the X25519 shared secret AND the ML-KEM shared secret. If
32
+ * either primitive is broken, the combined secret remains secure
33
+ * (this is the core PQ-hybrid guarantee).
34
+ *
35
+ * `ciphertext` is the encapsulated key material that the recipient
36
+ * uses to derive the same shared secret via decapsulation.
37
+ */
38
+ export interface EncapsulationResult {
39
+ sharedSecret: Uint8Array;
40
+ ciphertext: HybridCiphertext;
41
+ }
42
+ export interface HybridCiphertext {
43
+ x25519EphemeralPublicKey: Uint8Array;
44
+ mlkemCiphertext: Uint8Array;
45
+ }
46
+ /**
47
+ * An AES-256-GCM encrypted payload.
48
+ */
49
+ export interface EncryptedPayload {
50
+ nonce: Uint8Array;
51
+ ciphertext: Uint8Array;
52
+ associatedData?: Uint8Array;
53
+ }
54
+ /**
55
+ * Symmetric ratchet session state.
56
+ *
57
+ * v0.1.0-beta.0 implements only a SYMMETRIC ratchet — each message
58
+ * advances a chain key via HKDF. This provides forward secrecy but
59
+ * NOT post-compromise recovery (which requires DH ratcheting, planned
60
+ * for v0.2).
61
+ */
62
+ export interface RatchetSession {
63
+ chainKey: Uint8Array;
64
+ messageNumber: number;
65
+ sessionId: Uint8Array;
66
+ }
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,UAAU,CAAC;IAC5B,gBAAgB,EAAE,UAAU,CAAC;IAC7B,cAAc,EAAE,UAAU,CAAC;IAC3B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,UAAU,CAAC;IAC5B,cAAc,EAAE,UAAU,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,UAAU,CAAC;IACzB,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB,EAAE,UAAU,CAAC;IACrC,eAAe,EAAE,UAAU,CAAC;CAC7B;AAID;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B;AAID;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Public types for @weave_protocol/yoxallismus v0.1.0-beta.0.
3
+ * See THREAT_MODEL.md for the security model these types operate within.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Yoxallismus v1 backward-compatibility path.
3
+ *
4
+ * v1 was AES-256-GCM + ChaCha20-Poly1305 with Argon2id KDF, shipped
5
+ * embedded in @weave_protocol/hord. It was never published as a
6
+ * standalone package with a wire format spec.
7
+ *
8
+ * PLANNED FOR v0.2.0-beta:
9
+ * - Read-only decode path for Hord v1 encrypted payloads
10
+ * - Migration helper: readV1(payload, oldKey) → decrypt with v1,
11
+ * then re-encrypt with v2 keys
12
+ * - Zero-loss round-trip test suite against Hord v1 test vectors
13
+ *
14
+ * v0.1.0-beta.0 SHIPS WITH NO V1 COMPAT.
15
+ * If you're using Hord v1 encryption today, you can safely install
16
+ * yoxallismus v2 side-by-side but you can't migrate data yet.
17
+ */
18
+ export declare function readV1(_payload: unknown, _oldKey: unknown): never;
19
+ //# sourceMappingURL=v1-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1-compat.d.ts","sourceRoot":"","sources":["../src/v1-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAKjE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Yoxallismus v1 backward-compatibility path.
3
+ *
4
+ * v1 was AES-256-GCM + ChaCha20-Poly1305 with Argon2id KDF, shipped
5
+ * embedded in @weave_protocol/hord. It was never published as a
6
+ * standalone package with a wire format spec.
7
+ *
8
+ * PLANNED FOR v0.2.0-beta:
9
+ * - Read-only decode path for Hord v1 encrypted payloads
10
+ * - Migration helper: readV1(payload, oldKey) → decrypt with v1,
11
+ * then re-encrypt with v2 keys
12
+ * - Zero-loss round-trip test suite against Hord v1 test vectors
13
+ *
14
+ * v0.1.0-beta.0 SHIPS WITH NO V1 COMPAT.
15
+ * If you're using Hord v1 encryption today, you can safely install
16
+ * yoxallismus v2 side-by-side but you can't migrate data yet.
17
+ */
18
+ export function readV1(_payload, _oldKey) {
19
+ throw new Error('[yoxallismus] v1 backward-compat is not yet implemented in v0.1.0-beta.0. ' +
20
+ 'Planned for v0.2.0. See THREAT_MODEL.md § Migration.');
21
+ }
22
+ //# sourceMappingURL=v1-compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1-compat.js","sourceRoot":"","sources":["../src/v1-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,UAAU,MAAM,CAAC,QAAiB,EAAE,OAAgB;IACxD,MAAM,IAAI,KAAK,CACb,4EAA4E;QAC1E,sDAAsD,CACzD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,59 @@
1
1
  {
2
2
  "name": "@weave_protocol/yoxallismus",
3
- "version": "0.0.1",
4
- "description": "STUB — this package is beta-only. Install @weave_protocol/yoxallismus@beta for the real thing.",
5
- "main": "index.js",
6
- "files": ["index.js", "README.md"],
7
- "author": "Trent Yoxall",
8
- "license": "Apache-2.0",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "EXPERIMENTAL post-quantum cryptographic composition layer for AI agents. NOT AUDITED. Use only for research and development. See THREAT_MODEL.md for scope.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "weave-yoxall": "dist/cli.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "THREAT_MODEL.md",
15
+ "SECURITY.md",
16
+ "SECURITY_ADVISORIES.md",
17
+ "SKILL.md"
18
+ ],
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "prepublishOnly": "npm run build"
28
+ },
9
29
  "repository": {
10
30
  "type": "git",
11
31
  "url": "git+https://github.com/Tyox-all/Weave_Protocol.git",
12
32
  "directory": "yoxallismus"
13
33
  },
14
- "keywords": ["post-quantum", "weave-protocol", "beta"]
34
+ "keywords": [
35
+ "post-quantum",
36
+ "cryptography",
37
+ "pq",
38
+ "kyber",
39
+ "ml-kem",
40
+ "hybrid-kem",
41
+ "aead",
42
+ "ratcheting",
43
+ "agent-security",
44
+ "weave-protocol",
45
+ "experimental"
46
+ ],
47
+ "author": "Trent Yoxall",
48
+ "license": "Apache-2.0",
49
+ "engines": {
50
+ "node": ">=18"
51
+ },
52
+ "dependencies": {
53
+ "@noble/post-quantum": "^0.4.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^20.0.0",
57
+ "typescript": "^5.3.0"
58
+ }
15
59
  }
package/index.js DELETED
@@ -1,27 +0,0 @@
1
- // STUB — @weave_protocol/yoxallismus 0.0.1
2
- // This is a placeholder. The real package is on the @beta tag.
3
-
4
- const RED = '\x1b[41m\x1b[1;37m';
5
- const RESET = '\x1b[0m';
6
- const msg = [
7
- '',
8
- RED + ' @weave_protocol/yoxallismus — install via @beta tag ' + RESET,
9
- '',
10
- ' This is the "latest" stub. The real package is a beta post-quantum',
11
- ' cryptographic library.',
12
- '',
13
- ' To install the real package:',
14
- '',
15
- ' npm install @weave_protocol/yoxallismus@beta',
16
- '',
17
- ' This stub exists because npm requires every package to have a "latest"',
18
- ' tag, and we do not want unaudited beta crypto pulled in by default.',
19
- '',
20
- ' Read before adopting:',
21
- ' https://github.com/Tyox-all/Weave_Protocol/blob/main/yoxallismus/README.md',
22
- ' https://github.com/Tyox-all/Weave_Protocol/blob/main/yoxallismus/THREAT_MODEL.md',
23
- ' https://github.com/Tyox-all/Weave_Protocol/blob/main/yoxallismus/SECURITY.md',
24
- '',
25
- ];
26
- for (const l of msg) console.error(l);
27
- throw new Error('Install @weave_protocol/yoxallismus@beta for the actual package.');