@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 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,IAAI,EACJ,aAAa,EACb,WAAW,EACX,SAAS,GACV,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,YAAY,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AAYpB,OAAO,EACL,gBAAgB,EAAE,kBAAkB,EACpC,kBAAkB,EAAE,oBAAoB,EACxC,gBAAgB,EAAE,kBAAkB,EACpC,mBAAmB,EAAE,qBAAqB,EAC3C,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErG;;;GAGG;AACH,qBAAa,QAAQ;IACnB,uCAAuC;IACvC,MAAM,CAAC,eAAe,IAAI,aAAa;IAIvC,oDAAoD;IACpD,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,aAAa,GAAG,eAAe;IAItD;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAE,UAAU,EACrB,cAAc,CAAC,EAAE,UAAU,GAC1B;QAAE,UAAU,EAAE,gBAAgB,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE;IAO9D,gDAAgD;IAChD,MAAM,CAAC,WAAW,CAChB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,gBAAgB,EAC5B,OAAO,EAAE,gBAAgB,GACxB,UAAU;IAMb,2DAA2D;IAC3D,MAAM,CAAC,gBAAgB,0BAAoB;IAC3C,MAAM,CAAC,kBAAkB,4BAAsB;IAC/C,MAAM,CAAC,kBAAkB,4BAAsB;IAC/C,MAAM,CAAC,oBAAoB,8BAAwB;IACnD,MAAM,CAAC,gBAAgB,0BAAoB;IAC3C,MAAM,CAAC,kBAAkB,4BAAsB;IAC/C,MAAM,CAAC,mBAAmB,6BAAuB;IACjD,MAAM,CAAC,qBAAqB,+BAAyB;CACtD"}
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @weave_protocol/yoxallismus — EXPERIMENTAL post-quantum
3
+ * cryptographic composition layer for AI agents.
4
+ *
5
+ * ⚠️ NOT AUDITED. Beta software. See THREAT_MODEL.md and SECURITY.md
6
+ * before use. Do not use for regulated, medical, financial, or
7
+ * legal data.
8
+ */
9
+ import { showBetaBanner } from './labels.js';
10
+ // Show the beta warning banner on first import (silenceable via env var)
11
+ showBetaBanner();
12
+ // ─── Public API ─────────────────────────────────────────────────
13
+ // Labels & status metadata
14
+ export { STATUS } from './labels.js';
15
+ // KEM
16
+ export { generateHybridKeypair, encapsulate, decapsulate, publicKeyOf, } from './kem.js';
17
+ // AEAD
18
+ export { aeadEncrypt, aeadDecrypt, aeadEncryptWithNonce, KEY_LEN, NONCE_LEN, TAG_LEN, } from './aead.js';
19
+ // KDF
20
+ export { hkdf, deriveAeadKey, deriveNonce, HKDF_HASH, } from './kdf.js';
21
+ // Ratchet
22
+ export { initRatchet, ratchetEncrypt, ratchetDecrypt, } from './ratchet.js';
23
+ // Serialization
24
+ export { serializePublicKey, deserializePublicKey, serializeKeypair, deserializeKeypair, serializeCiphertext, deserializeCiphertext, serializePayload, deserializePayload, } from './serialize.js';
25
+ // v1 compat (throws — not implemented in v0.1.0-beta.0)
26
+ export { readV1 } from './v1-compat.js';
27
+ // ─── High-level facade ──────────────────────────────────────────
28
+ import { generateHybridKeypair, encapsulate, decapsulate, publicKeyOf, } from './kem.js';
29
+ import { aeadEncrypt, aeadDecrypt } from './aead.js';
30
+ import { deriveAeadKey } from './kdf.js';
31
+ import { serializeKeypair, deserializeKeypair, serializePublicKey, deserializePublicKey, serializePayload, deserializePayload, serializeCiphertext, deserializeCiphertext, } from './serialize.js';
32
+ /**
33
+ * The high-level "just encrypt this for that person" facade.
34
+ * Under the hood: hybrid KEM → HKDF → AES-256-GCM.
35
+ */
36
+ export class PQCipher {
37
+ /** Generate a fresh hybrid keypair. */
38
+ static generateKeypair() {
39
+ return generateHybridKeypair();
40
+ }
41
+ /** Get the public half of a keypair for sharing. */
42
+ static publicKeyOf(kp) {
43
+ return publicKeyOf(kp);
44
+ }
45
+ /**
46
+ * Encrypt a message to a recipient's public key.
47
+ * Returns a bundle: { ciphertext (KEM), payload (AEAD) }.
48
+ * Sender does not need their own keypair for this (KEM is sender-anonymous).
49
+ */
50
+ static encryptTo(recipientPub, plaintext, associatedData) {
51
+ const kem = encapsulate(recipientPub);
52
+ const aeadKey = deriveAeadKey(kem.sharedSecret, 'weave-yoxall v0.1 pqcipher-encrypt');
53
+ const payload = aeadEncrypt(aeadKey, plaintext, associatedData);
54
+ return { ciphertext: kem.ciphertext, payload };
55
+ }
56
+ /** Decrypt a message received from a sender. */
57
+ static decryptFrom(recipientPriv, ciphertext, payload) {
58
+ const sharedSecret = decapsulate(recipientPriv, ciphertext);
59
+ const aeadKey = deriveAeadKey(sharedSecret, 'weave-yoxall v0.1 pqcipher-encrypt');
60
+ return aeadDecrypt(aeadKey, payload);
61
+ }
62
+ /** All serialization helpers exposed as static methods. */
63
+ static serializeKeypair = serializeKeypair;
64
+ static deserializeKeypair = deserializeKeypair;
65
+ static serializePublicKey = serializePublicKey;
66
+ static deserializePublicKey = deserializePublicKey;
67
+ static serializePayload = serializePayload;
68
+ static deserializePayload = deserializePayload;
69
+ static serializeCiphertext = serializeCiphertext;
70
+ static deserializeCiphertext = deserializeCiphertext;
71
+ }
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAU,MAAM,aAAa,CAAC;AAErD,yEAAyE;AACzE,cAAc,EAAE,CAAC;AAEjB,mEAAmE;AAEnE,2BAA2B;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM;AACN,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,UAAU,CAAC;AAElB,OAAO;AACP,OAAO,EACL,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;AAEnB,MAAM;AACN,OAAO,EACL,IAAI,EACJ,aAAa,EACb,WAAW,EACX,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,UAAU;AACV,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,gBAAgB;AAChB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,wDAAwD;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAg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CAAC,CAAC;IACvC,CAAC;IAED,2DAA2D;IAC3D,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,MAAM,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,MAAM,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,MAAM,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,MAAM,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,MAAM,CAAC,qBAAqB,GAAG,qBAAqB,CAAC"}
package/dist/kdf.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * HKDF (HMAC-based Key Derivation Function) wrapper.
3
+ *
4
+ * Uses Node's built-in HKDF via crypto.hkdfSync. SHA-256 chosen for v0.1
5
+ * because it's ubiquitous and fast; the reduced quantum strength (~128
6
+ * bits via Grover) is adequate for the beta scope.
7
+ *
8
+ * DESIGN NOTES:
9
+ * - We use HKDF-Extract-then-Expand as a single hkdfSync call
10
+ * - Salt SHOULD be a random per-session value when combining independent
11
+ * shared secrets (as in PQ-hybrid KEM combination)
12
+ * - Info SHOULD be an application-context string ("weave-yoxall v0.1
13
+ * kem-combine", "chain-key-advance", etc.) — this domain-separates
14
+ * derived keys so a leak in one context doesn't cross-contaminate
15
+ */
16
+ export declare const HKDF_HASH = "sha256";
17
+ export declare const HKDF_OUTPUT_LEN = 32;
18
+ /**
19
+ * Derive `length` bytes of keying material from an input keying material,
20
+ * salt, and info context string.
21
+ */
22
+ export declare function hkdf(inputKeyMaterial: Uint8Array, salt: Uint8Array, info: string | Uint8Array, length?: number): Uint8Array;
23
+ /**
24
+ * Derive a 32-byte AEAD key from a shared secret and a context info string.
25
+ * Convenience wrapper — most callers want this.
26
+ */
27
+ export declare function deriveAeadKey(sharedSecret: Uint8Array, info: string, salt?: Uint8Array): Uint8Array;
28
+ /**
29
+ * Derive a 12-byte AEAD nonce deterministically from a chain key + counter.
30
+ * This is what the ratchet uses to avoid random-nonce reuse across sessions.
31
+ */
32
+ export declare function deriveNonce(chainKey: Uint8Array, counter: number): Uint8Array;
33
+ //# sourceMappingURL=kdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../src/kdf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;GAGG;AACH,wBAAgB,IAAI,CAClB,gBAAgB,EAAE,UAAU,EAC5B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,MAAM,GAAE,MAAwB,GAC/B,UAAU,CAUZ;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAEnG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAK7E"}
package/dist/kdf.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * HKDF (HMAC-based Key Derivation Function) wrapper.
3
+ *
4
+ * Uses Node's built-in HKDF via crypto.hkdfSync. SHA-256 chosen for v0.1
5
+ * because it's ubiquitous and fast; the reduced quantum strength (~128
6
+ * bits via Grover) is adequate for the beta scope.
7
+ *
8
+ * DESIGN NOTES:
9
+ * - We use HKDF-Extract-then-Expand as a single hkdfSync call
10
+ * - Salt SHOULD be a random per-session value when combining independent
11
+ * shared secrets (as in PQ-hybrid KEM combination)
12
+ * - Info SHOULD be an application-context string ("weave-yoxall v0.1
13
+ * kem-combine", "chain-key-advance", etc.) — this domain-separates
14
+ * derived keys so a leak in one context doesn't cross-contaminate
15
+ */
16
+ import { hkdfSync } from 'node:crypto';
17
+ export const HKDF_HASH = 'sha256';
18
+ export const HKDF_OUTPUT_LEN = 32;
19
+ /**
20
+ * Derive `length` bytes of keying material from an input keying material,
21
+ * salt, and info context string.
22
+ */
23
+ export function hkdf(inputKeyMaterial, salt, info, length = HKDF_OUTPUT_LEN) {
24
+ const infoBytes = typeof info === 'string' ? new TextEncoder().encode(info) : info;
25
+ const derived = hkdfSync(HKDF_HASH, Buffer.from(inputKeyMaterial), Buffer.from(salt), Buffer.from(infoBytes), length);
26
+ return new Uint8Array(derived);
27
+ }
28
+ /**
29
+ * Derive a 32-byte AEAD key from a shared secret and a context info string.
30
+ * Convenience wrapper — most callers want this.
31
+ */
32
+ export function deriveAeadKey(sharedSecret, info, salt) {
33
+ return hkdf(sharedSecret, salt || new Uint8Array(32), info, 32);
34
+ }
35
+ /**
36
+ * Derive a 12-byte AEAD nonce deterministically from a chain key + counter.
37
+ * This is what the ratchet uses to avoid random-nonce reuse across sessions.
38
+ */
39
+ export function deriveNonce(chainKey, counter) {
40
+ const counterBytes = new Uint8Array(8);
41
+ const dv = new DataView(counterBytes.buffer);
42
+ dv.setBigUint64(0, BigInt(counter), false);
43
+ return hkdf(chainKey, counterBytes, 'weave-yoxall v0.1 nonce-derive', 12);
44
+ }
45
+ //# sourceMappingURL=kdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kdf.js","sourceRoot":"","sources":["../src/kdf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,IAAI,CAClB,gBAA4B,EAC5B,IAAgB,EAChB,IAAyB,EACzB,SAAiB,eAAe;IAEhC,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnF,MAAM,OAAO,GAAG,QAAQ,CACtB,SAAS,EACT,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EACjB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EACtB,MAAM,CACP,CAAC;IACF,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,YAAwB,EAAE,IAAY,EAAE,IAAiB;IACrF,OAAO,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,QAAoB,EAAE,OAAe;IAC/D,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7C,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,gCAAgC,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC"}
package/dist/kem.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * PQ-hybrid Key Encapsulation Mechanism.
3
+ *
4
+ * Combines X25519 (classical elliptic-curve KEM) with ML-KEM-768
5
+ * (post-quantum lattice KEM, NIST FIPS 203) via HKDF-SHA-256.
6
+ *
7
+ * The security guarantee: an attacker must break BOTH primitives to
8
+ * recover the shared secret. If Shor's algorithm arrives and breaks
9
+ * X25519, the ML-KEM component keeps the secret confidential. If a
10
+ * classical or quantum attack on ML-KEM emerges, X25519 keeps the
11
+ * secret confidential.
12
+ *
13
+ * This is the same construction Signal ships as PQXDH and Cloudflare
14
+ * ships as X25519Kyber768Draft00 in TLS 1.3. The design pattern is
15
+ * well-established; the primitives are NIST-standardized.
16
+ *
17
+ * WIRE FORMAT (v0.1.0-beta.0, subject to change before v0.2):
18
+ * Public key: [X25519 32B][ML-KEM-768 pub 1184B] = 1216 bytes
19
+ * Private key: [X25519 32B][ML-KEM-768 priv 2400B] = 2432 bytes
20
+ * Ciphertext: [X25519 eph pub 32B][ML-KEM-768 ct 1088B] = 1120 bytes
21
+ * Shared sec: 32 bytes (HKDF-combined)
22
+ */
23
+ import type { HybridKeypair, HybridPublicKey, EncapsulationResult, HybridCiphertext } from './types.js';
24
+ /**
25
+ * Generate a fresh hybrid keypair. Both halves are generated with
26
+ * independent randomness from Node's crypto RNG.
27
+ */
28
+ export declare function generateHybridKeypair(): HybridKeypair;
29
+ /**
30
+ * Encapsulate a shared secret to the recipient's hybrid public key.
31
+ *
32
+ * Returns:
33
+ * - sharedSecret: 32 bytes that both parties will hold
34
+ * - ciphertext: the hybrid KEM output that recipient decapsulates
35
+ */
36
+ export declare function encapsulate(recipientPub: HybridPublicKey): EncapsulationResult;
37
+ /**
38
+ * Decapsulate a shared secret from a ciphertext using the recipient's
39
+ * private key. Both halves must succeed; either failure means the
40
+ * derived shared secret will not match the sender's.
41
+ *
42
+ * ML-KEM has "implicit rejection" — a malformed ML-KEM ciphertext
43
+ * doesn't throw, it silently returns garbage. That's a feature (it
44
+ * prevents timing attacks) but means the caller MUST verify the
45
+ * shared secret was correct out-of-band (typically via AEAD auth-tag
46
+ * verification on subsequent messages).
47
+ */
48
+ export declare function decapsulate(recipientPriv: HybridKeypair, ct: HybridCiphertext): Uint8Array;
49
+ export declare function publicKeyOf(kp: HybridKeypair): HybridPublicKey;
50
+ //# sourceMappingURL=kem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kem.d.ts","sourceRoot":"","sources":["../src/kem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOxG;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,aAAa,CAoBrD;AAID;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,eAAe,GAAG,mBAAmB,CAyC9E;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE,EAAE,gBAAgB,GAAG,UAAU,CAyB1F;AAID,wBAAgB,WAAW,CAAC,EAAE,EAAE,aAAa,GAAG,eAAe,CAK9D"}
package/dist/kem.js ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * PQ-hybrid Key Encapsulation Mechanism.
3
+ *
4
+ * Combines X25519 (classical elliptic-curve KEM) with ML-KEM-768
5
+ * (post-quantum lattice KEM, NIST FIPS 203) via HKDF-SHA-256.
6
+ *
7
+ * The security guarantee: an attacker must break BOTH primitives to
8
+ * recover the shared secret. If Shor's algorithm arrives and breaks
9
+ * X25519, the ML-KEM component keeps the secret confidential. If a
10
+ * classical or quantum attack on ML-KEM emerges, X25519 keeps the
11
+ * secret confidential.
12
+ *
13
+ * This is the same construction Signal ships as PQXDH and Cloudflare
14
+ * ships as X25519Kyber768Draft00 in TLS 1.3. The design pattern is
15
+ * well-established; the primitives are NIST-standardized.
16
+ *
17
+ * WIRE FORMAT (v0.1.0-beta.0, subject to change before v0.2):
18
+ * Public key: [X25519 32B][ML-KEM-768 pub 1184B] = 1216 bytes
19
+ * Private key: [X25519 32B][ML-KEM-768 priv 2400B] = 2432 bytes
20
+ * Ciphertext: [X25519 eph pub 32B][ML-KEM-768 ct 1088B] = 1120 bytes
21
+ * Shared sec: 32 bytes (HKDF-combined)
22
+ */
23
+ import { generateKeyPairSync, createPrivateKey, createPublicKey, diffieHellman, randomBytes } from 'node:crypto';
24
+ import { ml_kem768 } from '@noble/post-quantum/ml-kem';
25
+ import { hkdf } from './kdf.js';
26
+ const HYBRID_COMBINE_INFO = 'weave-yoxall v0.1 pq-hybrid-combine';
27
+ // ─── Key generation ─────────────────────────────────────────────
28
+ /**
29
+ * Generate a fresh hybrid keypair. Both halves are generated with
30
+ * independent randomness from Node's crypto RNG.
31
+ */
32
+ export function generateHybridKeypair() {
33
+ // X25519 half via Node crypto — request DER SPKI/PKCS8 export
34
+ const x = generateKeyPairSync('x25519', {
35
+ publicKeyEncoding: { type: 'spki', format: 'der' },
36
+ privateKeyEncoding: { type: 'pkcs8', format: 'der' },
37
+ });
38
+ // Extract raw 32-byte keys from DER (Node returns wrapped SPKI/PKCS8)
39
+ const x25519PublicKey = extractX25519RawFromSpki(x.publicKey);
40
+ const x25519PrivateKey = extractX25519RawFromPkcs8(x.privateKey);
41
+ // ML-KEM-768 half via noble
42
+ const mlkemSeed = randomBytes(64);
43
+ const mlkemKeys = ml_kem768.keygen(mlkemSeed);
44
+ return {
45
+ x25519PublicKey,
46
+ x25519PrivateKey,
47
+ mlkemPublicKey: mlkemKeys.publicKey,
48
+ mlkemPrivateKey: mlkemKeys.secretKey,
49
+ };
50
+ }
51
+ // ─── Encapsulation (sender side) ────────────────────────────────
52
+ /**
53
+ * Encapsulate a shared secret to the recipient's hybrid public key.
54
+ *
55
+ * Returns:
56
+ * - sharedSecret: 32 bytes that both parties will hold
57
+ * - ciphertext: the hybrid KEM output that recipient decapsulates
58
+ */
59
+ export function encapsulate(recipientPub) {
60
+ // X25519: generate ephemeral, compute shared secret
61
+ const ephemeral = generateKeyPairSync('x25519', {
62
+ publicKeyEncoding: { type: 'spki', format: 'der' },
63
+ privateKeyEncoding: { type: 'pkcs8', format: 'der' },
64
+ });
65
+ const ephemeralPubRaw = extractX25519RawFromSpki(ephemeral.publicKey);
66
+ const ephemeralPrivObj = createPrivateKey({
67
+ key: ephemeral.privateKey,
68
+ format: 'der',
69
+ type: 'pkcs8',
70
+ });
71
+ const recipientX25519PubObj = createPublicKey({
72
+ key: wrapX25519RawAsSpki(recipientPub.x25519PublicKey),
73
+ format: 'der',
74
+ type: 'spki',
75
+ });
76
+ const x25519SharedSecret = new Uint8Array(diffieHellman({
77
+ privateKey: ephemeralPrivObj,
78
+ publicKey: recipientX25519PubObj,
79
+ }));
80
+ // ML-KEM: encapsulate to recipient's ML-KEM public key
81
+ const mlkemResult = ml_kem768.encapsulate(recipientPub.mlkemPublicKey);
82
+ const mlkemSharedSecret = mlkemResult.sharedSecret;
83
+ const mlkemCiphertext = mlkemResult.cipherText;
84
+ // Combine via HKDF: salt = both public parts, ikm = concatenated secrets
85
+ const salt = concatBytes(recipientPub.x25519PublicKey, recipientPub.mlkemPublicKey);
86
+ const ikm = concatBytes(x25519SharedSecret, mlkemSharedSecret);
87
+ const sharedSecret = hkdf(ikm, salt, HYBRID_COMBINE_INFO, 32);
88
+ return {
89
+ sharedSecret,
90
+ ciphertext: {
91
+ x25519EphemeralPublicKey: ephemeralPubRaw,
92
+ mlkemCiphertext,
93
+ },
94
+ };
95
+ }
96
+ // ─── Decapsulation (recipient side) ─────────────────────────────
97
+ /**
98
+ * Decapsulate a shared secret from a ciphertext using the recipient's
99
+ * private key. Both halves must succeed; either failure means the
100
+ * derived shared secret will not match the sender's.
101
+ *
102
+ * ML-KEM has "implicit rejection" — a malformed ML-KEM ciphertext
103
+ * doesn't throw, it silently returns garbage. That's a feature (it
104
+ * prevents timing attacks) but means the caller MUST verify the
105
+ * shared secret was correct out-of-band (typically via AEAD auth-tag
106
+ * verification on subsequent messages).
107
+ */
108
+ export function decapsulate(recipientPriv, ct) {
109
+ // X25519: compute shared secret with ephemeral public + own private
110
+ const recipientPrivObj = createPrivateKey({
111
+ key: wrapX25519RawAsPkcs8(recipientPriv.x25519PrivateKey),
112
+ format: 'der',
113
+ type: 'pkcs8',
114
+ });
115
+ const ephemeralPubObj = createPublicKey({
116
+ key: wrapX25519RawAsSpki(ct.x25519EphemeralPublicKey),
117
+ format: 'der',
118
+ type: 'spki',
119
+ });
120
+ const x25519SharedSecret = new Uint8Array(diffieHellman({
121
+ privateKey: recipientPrivObj,
122
+ publicKey: ephemeralPubObj,
123
+ }));
124
+ // ML-KEM: decapsulate
125
+ const mlkemSharedSecret = ml_kem768.decapsulate(ct.mlkemCiphertext, recipientPriv.mlkemPrivateKey);
126
+ // Combine — same salt/info as encapsulate
127
+ const salt = concatBytes(recipientPriv.x25519PublicKey, recipientPriv.mlkemPublicKey);
128
+ const ikm = concatBytes(x25519SharedSecret, mlkemSharedSecret);
129
+ return hkdf(ikm, salt, HYBRID_COMBINE_INFO, 32);
130
+ }
131
+ // ─── Public-key extraction ──────────────────────────────────────
132
+ export function publicKeyOf(kp) {
133
+ return {
134
+ x25519PublicKey: kp.x25519PublicKey,
135
+ mlkemPublicKey: kp.mlkemPublicKey,
136
+ };
137
+ }
138
+ // ─── Helpers ────────────────────────────────────────────────────
139
+ function concatBytes(a, b) {
140
+ const out = new Uint8Array(a.length + b.length);
141
+ out.set(a, 0);
142
+ out.set(b, a.length);
143
+ return out;
144
+ }
145
+ // X25519 SPKI DER header (12 bytes) + 32-byte raw key
146
+ const X25519_SPKI_HEADER = Uint8Array.from([
147
+ 0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x03, 0x21, 0x00,
148
+ ]);
149
+ // X25519 PKCS8 DER header (16 bytes) + 32-byte raw key
150
+ const X25519_PKCS8_HEADER = Uint8Array.from([
151
+ 0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x04, 0x22, 0x04, 0x20,
152
+ ]);
153
+ function extractX25519RawFromSpki(der) {
154
+ // DER format: [header 12 bytes][raw 32 bytes]
155
+ return new Uint8Array(der.slice(der.length - 32));
156
+ }
157
+ function extractX25519RawFromPkcs8(der) {
158
+ // DER format: [header 16 bytes][raw 32 bytes]
159
+ return new Uint8Array(der.slice(der.length - 32));
160
+ }
161
+ function wrapX25519RawAsSpki(raw) {
162
+ return Buffer.concat([Buffer.from(X25519_SPKI_HEADER), Buffer.from(raw)]);
163
+ }
164
+ function wrapX25519RawAsPkcs8(raw) {
165
+ return Buffer.concat([Buffer.from(X25519_PKCS8_HEADER), Buffer.from(raw)]);
166
+ }
167
+ //# sourceMappingURL=kem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kem.js","sourceRoot":"","sources":["../src/kem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AAElE,mEAAmE;AAEnE;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,8DAA8D;IAC9D,MAAM,CAAC,GAAG,mBAAmB,CAAC,QAAQ,EAAE;QACtC,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAClD,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;KACrD,CAAC,CAAC;IACH,sEAAsE;IACtE,MAAM,eAAe,GAAG,wBAAwB,CAAC,CAAC,CAAC,SAA8B,CAAC,CAAC;IACnF,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,CAAC,CAAC,UAA+B,CAAC,CAAC;IAEtF,4BAA4B;IAC5B,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAE9C,OAAO;QACL,eAAe;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,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAe;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAe;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ⚠️ EXPERIMENTAL — NOT AUDITED ⚠️
3
+ *
4
+ * @weave_protocol/yoxallismus is a beta post-quantum cryptographic
5
+ * composition layer. It has NOT undergone external cryptographic audit.
6
+ *
7
+ * DO NOT USE for:
8
+ * - Regulated data (HIPAA, PCI-DSS, SOC2-audited storage)
9
+ * - Medical records
10
+ * - Financial records
11
+ * - Legal evidence
12
+ * - Anything where a cryptographic failure causes real-world harm
13
+ *
14
+ * DO USE for:
15
+ * - Research on post-quantum agent architectures
16
+ * - Experimentation with PQ-hybrid primitives
17
+ * - Development against future PQ-cryptographic patterns
18
+ * - Learning post-quantum cryptography by example
19
+ *
20
+ * See THREAT_MODEL.md for the full list of what this library defends
21
+ * against, what it doesn't, and what its known limitations are.
22
+ *
23
+ * See SECURITY.md for the bug bounty program.
24
+ */
25
+ /**
26
+ * Print the beta warning banner to stderr on first import.
27
+ * Silenceable via env var. Called once per Node process.
28
+ */
29
+ export declare function showBetaBanner(): void;
30
+ /**
31
+ * Machine-readable metadata about the library's status.
32
+ * Consumed by CLI, by import-time banner, and by test harness.
33
+ */
34
+ export declare const STATUS: {
35
+ readonly version: "0.1.0-beta.0";
36
+ readonly audited: false;
37
+ readonly auditPlanned: false;
38
+ readonly status: "experimental";
39
+ readonly productionReady: false;
40
+ readonly scopeForUse: readonly ["research", "experimentation", "development", "learning post-quantum patterns"];
41
+ readonly scopeForNonUse: readonly ["regulated data (HIPAA, PCI-DSS, SOC2)", "medical records", "financial records", "legal evidence", "production security-critical systems"];
42
+ readonly primitivesUsed: {
43
+ readonly kem: readonly ["X25519 (classical)", "ML-KEM-768 (post-quantum, NIST FIPS 203)"];
44
+ readonly aead: readonly ["AES-256-GCM (Node crypto)"];
45
+ readonly kdf: readonly ["HKDF-SHA-256 (Node crypto)"];
46
+ readonly ratchet: readonly ["symmetric ratchet only in v0.1; DH double-ratchet planned v0.2"];
47
+ };
48
+ readonly knownLimitations: readonly ["no threshold encryption yet", "no zero-knowledge proofs yet", "no verifiable delay functions yet", "no cascade cipher yet", "no FHE integration yet", "no Yoxallismus v1 backward-compat shim yet", "no formal audit performed", "no quantum RNG integration yet"];
49
+ };
50
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAkBH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAmCT,CAAC"}
package/dist/labels.js ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * ⚠️ EXPERIMENTAL — NOT AUDITED ⚠️
3
+ *
4
+ * @weave_protocol/yoxallismus is a beta post-quantum cryptographic
5
+ * composition layer. It has NOT undergone external cryptographic audit.
6
+ *
7
+ * DO NOT USE for:
8
+ * - Regulated data (HIPAA, PCI-DSS, SOC2-audited storage)
9
+ * - Medical records
10
+ * - Financial records
11
+ * - Legal evidence
12
+ * - Anything where a cryptographic failure causes real-world harm
13
+ *
14
+ * DO USE for:
15
+ * - Research on post-quantum agent architectures
16
+ * - Experimentation with PQ-hybrid primitives
17
+ * - Development against future PQ-cryptographic patterns
18
+ * - Learning post-quantum cryptography by example
19
+ *
20
+ * See THREAT_MODEL.md for the full list of what this library defends
21
+ * against, what it doesn't, and what its known limitations are.
22
+ *
23
+ * See SECURITY.md for the bug bounty program.
24
+ */
25
+ const BANNER = [
26
+ '',
27
+ ' ⚠️ \x1b[41m\x1b[1;37m EXPERIMENTAL — NOT AUDITED \x1b[0m',
28
+ '',
29
+ ' @weave_protocol/yoxallismus is a beta post-quantum cryptographic',
30
+ ' composition layer. It has not undergone external cryptographic audit.',
31
+ '',
32
+ ' Do NOT use for regulated, medical, financial, or legal data.',
33
+ '',
34
+ ' See THREAT_MODEL.md and SECURITY.md before adopting.',
35
+ ' Silence this banner with: YOXALL_SILENCE_BETA_WARNING=1',
36
+ '',
37
+ ];
38
+ let bannerShown = false;
39
+ /**
40
+ * Print the beta warning banner to stderr on first import.
41
+ * Silenceable via env var. Called once per Node process.
42
+ */
43
+ export function showBetaBanner() {
44
+ if (bannerShown)
45
+ return;
46
+ bannerShown = true;
47
+ if (process.env.YOXALL_SILENCE_BETA_WARNING === '1')
48
+ return;
49
+ for (const line of BANNER)
50
+ process.stderr.write(line + '\n');
51
+ }
52
+ /**
53
+ * Machine-readable metadata about the library's status.
54
+ * Consumed by CLI, by import-time banner, and by test harness.
55
+ */
56
+ export const STATUS = {
57
+ version: '0.1.0-beta.0',
58
+ audited: false,
59
+ auditPlanned: false,
60
+ status: 'experimental',
61
+ productionReady: false,
62
+ scopeForUse: [
63
+ 'research',
64
+ 'experimentation',
65
+ 'development',
66
+ 'learning post-quantum patterns',
67
+ ],
68
+ scopeForNonUse: [
69
+ 'regulated data (HIPAA, PCI-DSS, SOC2)',
70
+ 'medical records',
71
+ 'financial records',
72
+ 'legal evidence',
73
+ 'production security-critical systems',
74
+ ],
75
+ primitivesUsed: {
76
+ kem: ['X25519 (classical)', 'ML-KEM-768 (post-quantum, NIST FIPS 203)'],
77
+ aead: ['AES-256-GCM (Node crypto)'],
78
+ kdf: ['HKDF-SHA-256 (Node crypto)'],
79
+ ratchet: ['symmetric ratchet only in v0.1; DH double-ratchet planned v0.2'],
80
+ },
81
+ knownLimitations: [
82
+ 'no threshold encryption yet',
83
+ 'no zero-knowledge proofs yet',
84
+ 'no verifiable delay functions yet',
85
+ 'no cascade cipher yet',
86
+ 'no FHE integration yet',
87
+ 'no Yoxallismus v1 backward-compat shim yet',
88
+ 'no formal audit performed',
89
+ 'no quantum RNG integration yet',
90
+ ],
91
+ };
92
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.js","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,GAAG;IACb,EAAE;IACF,6DAA6D;IAC7D,EAAE;IACF,oEAAoE;IACpE,yEAAyE;IACzE,EAAE;IACF,gEAAgE;IAChE,EAAE;IACF,wDAAwD;IACxD,2DAA2D;IAC3D,EAAE;CACH,CAAC;AAEF,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,WAAW;QAAE,OAAO;IACxB,WAAW,GAAG,IAAI,CAAC;IACnB,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG;QAAE,OAAO;IAC5D,KAAK,MAAM,IAAI,IAAI,MAAM;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;IACnB,MAAM,EAAE,cAAc;IACtB,eAAe,EAAE,KAAK;IACtB,WAAW,EAAE;QACX,UAAU;QACV,iBAAiB;QACjB,aAAa;QACb,gCAAgC;KACjC;IACD,cAAc,EAAE;QACd,uCAAuC;QACvC,iBAAiB;QACjB,mBAAmB;QACnB,gBAAgB;QAChB,sCAAsC;KACvC;IACD,cAAc,EAAE;QACd,GAAG,EAAE,CAAC,oBAAoB,EAAE,0CAA0C,CAAC;QACvE,IAAI,EAAE,CAAC,2BAA2B,CAAC;QACnC,GAAG,EAAE,CAAC,4BAA4B,CAAC;QACnC,OAAO,EAAE,CAAC,gEAAgE,CAAC;KAC5E;IACD,gBAAgB,EAAE;QAChB,6BAA6B;QAC7B,8BAA8B;QAC9B,mCAAmC;QACnC,uBAAuB;QACvB,wBAAwB;QACxB,4CAA4C;QAC5C,2BAA2B;QAC3B,gCAAgC;KACjC;CACO,CAAC"}
@@ -0,0 +1,38 @@
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 type { RatchetSession, EncryptedPayload } from './types.js';
23
+ /**
24
+ * Initialize a ratchet session from an initial 32-byte shared secret
25
+ * (typically the output of a hybrid KEM decapsulation).
26
+ */
27
+ export declare function initRatchet(sharedSecret: Uint8Array): RatchetSession;
28
+ /**
29
+ * Encrypt a message, advancing the ratchet by one step.
30
+ * Mutates the session in place.
31
+ */
32
+ export declare function ratchetEncrypt(session: RatchetSession, plaintext: Uint8Array, associatedData?: Uint8Array): EncryptedPayload;
33
+ /**
34
+ * Decrypt a message, advancing the ratchet by one step.
35
+ * Both sides must process messages in the same order for chain keys to match.
36
+ */
37
+ export declare function ratchetDecrypt(session: RatchetSession, payload: EncryptedPayload, associatedData?: Uint8Array): Uint8Array;
38
+ //# sourceMappingURL=ratchet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ratchet.d.ts","sourceRoot":"","sources":["../src/ratchet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOnE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,UAAU,GAAG,cAAc,CAYpE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,cAAc,CAAC,EAAE,UAAU,GAC1B,gBAAgB,CAclB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,UAAU,GAC1B,UAAU,CAgBZ"}