@weave_protocol/yoxallismus 0.0.1 → 0.2.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.
- package/README.md +236 -16
- package/SECURITY.md +110 -0
- package/SECURITY_ADVISORIES.md +86 -0
- package/SKILL.md +52 -0
- package/THREAT_MODEL.md +187 -0
- package/WIRE_FORMAT.md +102 -0
- package/dist/aead.d.ts +44 -0
- package/dist/aead.d.ts.map +1 -0
- package/dist/aead.js +96 -0
- package/dist/aead.js.map +1 -0
- package/dist/cascade.d.ts +31 -0
- package/dist/cascade.d.ts.map +1 -0
- package/dist/cascade.js +74 -0
- package/dist/cascade.js.map +1 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +501 -0
- package/dist/cli.js.map +1 -0
- package/dist/double-ratchet.d.ts +106 -0
- package/dist/double-ratchet.d.ts.map +1 -0
- package/dist/double-ratchet.js +238 -0
- package/dist/double-ratchet.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -0
- package/dist/kdf.d.ts +33 -0
- package/dist/kdf.d.ts.map +1 -0
- package/dist/kdf.js +45 -0
- package/dist/kdf.js.map +1 -0
- package/dist/kem.d.ts +79 -0
- package/dist/kem.d.ts.map +1 -0
- package/dist/kem.js +220 -0
- package/dist/kem.js.map +1 -0
- package/dist/labels.d.ts +51 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +93 -0
- package/dist/labels.js.map +1 -0
- package/dist/ratchet.d.ts +38 -0
- package/dist/ratchet.d.ts.map +1 -0
- package/dist/ratchet.js +91 -0
- package/dist/ratchet.js.map +1 -0
- package/dist/sealed.d.ts +33 -0
- package/dist/sealed.d.ts.map +1 -0
- package/dist/sealed.js +40 -0
- package/dist/sealed.js.map +1 -0
- package/dist/serialize.d.ts +20 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +97 -0
- package/dist/serialize.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/v1-compat.d.ts +37 -0
- package/dist/v1-compat.d.ts.map +1 -0
- package/dist/v1-compat.js +58 -0
- package/dist/v1-compat.js.map +1 -0
- package/dist/wire.d.ts +21 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +114 -0
- package/dist/wire.js.map +1 -0
- package/package.json +53 -7
- package/index.js +0 -27
package/dist/kem.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
* COMBINERS
|
|
18
|
+
* v2 (default, wire format yoxall/2):
|
|
19
|
+
* ss = HKDF-SHA-256(ikm = ss_mlkem || ss_x25519 || eph_x25519_pub || recip_x25519_pub,
|
|
20
|
+
* salt = 32 zero bytes, info = "weave-yoxall/2 kem-combine")
|
|
21
|
+
* Same shape as X-Wing: binding the X25519 ephemeral and recipient
|
|
22
|
+
* public keys means the combined secret is IND-CCA even if only the
|
|
23
|
+
* X25519 half is relied on. ML-KEM is already IND-CCA, so its
|
|
24
|
+
* ciphertext doesn't need to be hashed in.
|
|
25
|
+
* v1 (legacy, v0.1.0-beta.0): HKDF over ss_x25519 || ss_mlkem, salted
|
|
26
|
+
* with the recipient public keys, without the ephemeral key. Kept
|
|
27
|
+
* only so data from v0.1 can still be decrypted (YOXALL-2026-002).
|
|
28
|
+
*
|
|
29
|
+
* WIRE FORMAT (byte sizes, unchanged since v0.1):
|
|
30
|
+
* Public key: [X25519 32B][ML-KEM-768 pub 1184B] = 1216 bytes
|
|
31
|
+
* Private key: [X25519 32B][ML-KEM-768 priv 2400B] = 2432 bytes
|
|
32
|
+
* Ciphertext: [X25519 eph pub 32B][ML-KEM-768 ct 1088B] = 1120 bytes
|
|
33
|
+
* Shared sec: 32 bytes (HKDF-combined)
|
|
34
|
+
*/
|
|
35
|
+
import { generateKeyPairSync, createPrivateKey, createPublicKey, diffieHellman, randomBytes } from 'node:crypto';
|
|
36
|
+
import { ml_kem768 } from '@noble/post-quantum/ml-kem';
|
|
37
|
+
import { hkdf } from './kdf.js';
|
|
38
|
+
const HYBRID_COMBINE_INFO_V1 = 'weave-yoxall v0.1 pq-hybrid-combine';
|
|
39
|
+
const HYBRID_COMBINE_INFO_V2 = 'weave-yoxall/2 kem-combine';
|
|
40
|
+
function combine(version, x25519Shared, mlkemShared, ephemeralPub, recipient) {
|
|
41
|
+
if (version === 1) {
|
|
42
|
+
const salt = concatBytes(recipient.x25519PublicKey, recipient.mlkemPublicKey);
|
|
43
|
+
return hkdf(concatBytes(x25519Shared, mlkemShared), salt, HYBRID_COMBINE_INFO_V1, 32);
|
|
44
|
+
}
|
|
45
|
+
const ikm = concatAll(mlkemShared, x25519Shared, ephemeralPub, recipient.x25519PublicKey);
|
|
46
|
+
return hkdf(ikm, new Uint8Array(32), HYBRID_COMBINE_INFO_V2, 32);
|
|
47
|
+
}
|
|
48
|
+
// ─── Key generation ─────────────────────────────────────────────
|
|
49
|
+
/**
|
|
50
|
+
* Generate a fresh hybrid keypair. Both halves are generated with
|
|
51
|
+
* independent randomness from Node's crypto RNG.
|
|
52
|
+
*/
|
|
53
|
+
export function generateHybridKeypair() {
|
|
54
|
+
// X25519 half via Node crypto — request DER SPKI/PKCS8 export
|
|
55
|
+
const x = generateKeyPairSync('x25519', {
|
|
56
|
+
publicKeyEncoding: { type: 'spki', format: 'der' },
|
|
57
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'der' },
|
|
58
|
+
});
|
|
59
|
+
// Extract raw 32-byte keys from DER (Node returns wrapped SPKI/PKCS8)
|
|
60
|
+
const x25519PublicKey = extractX25519RawFromSpki(x.publicKey);
|
|
61
|
+
const x25519PrivateKey = extractX25519RawFromPkcs8(x.privateKey);
|
|
62
|
+
// ML-KEM-768 half via noble
|
|
63
|
+
const mlkemSeed = randomBytes(64);
|
|
64
|
+
const mlkemKeys = ml_kem768.keygen(mlkemSeed);
|
|
65
|
+
return {
|
|
66
|
+
x25519PublicKey,
|
|
67
|
+
x25519PrivateKey,
|
|
68
|
+
mlkemPublicKey: mlkemKeys.publicKey,
|
|
69
|
+
mlkemPrivateKey: mlkemKeys.secretKey,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// ─── Encapsulation (sender side) ────────────────────────────────
|
|
73
|
+
/**
|
|
74
|
+
* Encapsulate a shared secret to the recipient's hybrid public key.
|
|
75
|
+
*
|
|
76
|
+
* Returns:
|
|
77
|
+
* - sharedSecret: 32 bytes that both parties will hold
|
|
78
|
+
* - ciphertext: the hybrid KEM output that recipient decapsulates
|
|
79
|
+
*/
|
|
80
|
+
export function encapsulate(recipientPub, version = 2) {
|
|
81
|
+
return encapsulateWith(recipientPub, version, randomBytes(32), randomBytes(32));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Deterministic encapsulation from caller-supplied randomness. Used for
|
|
85
|
+
* known-answer test vectors only — NEVER call with non-random inputs in
|
|
86
|
+
* real use. Not exported from the package index.
|
|
87
|
+
*/
|
|
88
|
+
export function encapsulateWith(recipientPub, version, x25519EphemeralPrivate, mlkemRandomness) {
|
|
89
|
+
// X25519: ephemeral keypair from the supplied private scalar
|
|
90
|
+
const ephemeralPrivObj = createPrivateKey({
|
|
91
|
+
key: wrapX25519RawAsPkcs8(x25519EphemeralPrivate),
|
|
92
|
+
format: 'der',
|
|
93
|
+
type: 'pkcs8',
|
|
94
|
+
});
|
|
95
|
+
const ephemeralPubRaw = extractX25519RawFromSpki(createPublicKey(ephemeralPrivObj).export({ type: 'spki', format: 'der' }));
|
|
96
|
+
const recipientX25519PubObj = createPublicKey({
|
|
97
|
+
key: wrapX25519RawAsSpki(recipientPub.x25519PublicKey),
|
|
98
|
+
format: 'der',
|
|
99
|
+
type: 'spki',
|
|
100
|
+
});
|
|
101
|
+
const x25519SharedSecret = new Uint8Array(diffieHellman({
|
|
102
|
+
privateKey: ephemeralPrivObj,
|
|
103
|
+
publicKey: recipientX25519PubObj,
|
|
104
|
+
}));
|
|
105
|
+
// ML-KEM: encapsulate to recipient's ML-KEM public key
|
|
106
|
+
const mlkemResult = ml_kem768.encapsulate(recipientPub.mlkemPublicKey, mlkemRandomness);
|
|
107
|
+
const mlkemSharedSecret = mlkemResult.sharedSecret;
|
|
108
|
+
const mlkemCiphertext = mlkemResult.cipherText;
|
|
109
|
+
const sharedSecret = combine(version, x25519SharedSecret, mlkemSharedSecret, ephemeralPubRaw, recipientPub);
|
|
110
|
+
return {
|
|
111
|
+
sharedSecret,
|
|
112
|
+
ciphertext: {
|
|
113
|
+
x25519EphemeralPublicKey: ephemeralPubRaw,
|
|
114
|
+
mlkemCiphertext,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ─── Decapsulation (recipient side) ─────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Decapsulate a shared secret from a ciphertext using the recipient's
|
|
121
|
+
* private key. Both halves must succeed; either failure means the
|
|
122
|
+
* derived shared secret will not match the sender's.
|
|
123
|
+
*
|
|
124
|
+
* ML-KEM has "implicit rejection" — a malformed ML-KEM ciphertext
|
|
125
|
+
* doesn't throw, it silently returns garbage. That's a feature (it
|
|
126
|
+
* prevents timing attacks) but means the caller MUST verify the
|
|
127
|
+
* shared secret was correct out-of-band (typically via AEAD auth-tag
|
|
128
|
+
* verification on subsequent messages).
|
|
129
|
+
*/
|
|
130
|
+
export function decapsulate(recipientPriv, ct, version = 2) {
|
|
131
|
+
// X25519: compute shared secret with ephemeral public + own private
|
|
132
|
+
const recipientPrivObj = createPrivateKey({
|
|
133
|
+
key: wrapX25519RawAsPkcs8(recipientPriv.x25519PrivateKey),
|
|
134
|
+
format: 'der',
|
|
135
|
+
type: 'pkcs8',
|
|
136
|
+
});
|
|
137
|
+
const ephemeralPubObj = createPublicKey({
|
|
138
|
+
key: wrapX25519RawAsSpki(ct.x25519EphemeralPublicKey),
|
|
139
|
+
format: 'der',
|
|
140
|
+
type: 'spki',
|
|
141
|
+
});
|
|
142
|
+
const x25519SharedSecret = new Uint8Array(diffieHellman({
|
|
143
|
+
privateKey: recipientPrivObj,
|
|
144
|
+
publicKey: ephemeralPubObj,
|
|
145
|
+
}));
|
|
146
|
+
// ML-KEM: decapsulate
|
|
147
|
+
const mlkemSharedSecret = ml_kem768.decapsulate(ct.mlkemCiphertext, recipientPriv.mlkemPrivateKey);
|
|
148
|
+
return combine(version, x25519SharedSecret, mlkemSharedSecret, ct.x25519EphemeralPublicKey, recipientPriv);
|
|
149
|
+
}
|
|
150
|
+
// ─── Public-key extraction ──────────────────────────────────────
|
|
151
|
+
export function publicKeyOf(kp) {
|
|
152
|
+
return {
|
|
153
|
+
x25519PublicKey: kp.x25519PublicKey,
|
|
154
|
+
mlkemPublicKey: kp.mlkemPublicKey,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// ─── Helpers ────────────────────────────────────────────────────
|
|
158
|
+
/** Deterministic keypair from seeds — known-answer test vectors only. */
|
|
159
|
+
export function keypairFromSeeds(x25519Private, mlkemSeed) {
|
|
160
|
+
const priv = createPrivateKey({ key: wrapX25519RawAsPkcs8(x25519Private), format: 'der', type: 'pkcs8' });
|
|
161
|
+
const x25519PublicKey = extractX25519RawFromSpki(createPublicKey(priv).export({ type: 'spki', format: 'der' }));
|
|
162
|
+
const ml = ml_kem768.keygen(mlkemSeed);
|
|
163
|
+
return { x25519PublicKey, x25519PrivateKey: new Uint8Array(x25519Private), mlkemPublicKey: ml.publicKey, mlkemPrivateKey: ml.secretKey };
|
|
164
|
+
}
|
|
165
|
+
/** Raw X25519 Diffie-Hellman on 32-byte keys (used by the double ratchet). */
|
|
166
|
+
export function x25519(privateKey, publicKey) {
|
|
167
|
+
return new Uint8Array(diffieHellman({
|
|
168
|
+
privateKey: createPrivateKey({ key: wrapX25519RawAsPkcs8(privateKey), format: 'der', type: 'pkcs8' }),
|
|
169
|
+
publicKey: createPublicKey({ key: wrapX25519RawAsSpki(publicKey), format: 'der', type: 'spki' }),
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
/** Fresh raw X25519 keypair (used by the double ratchet). */
|
|
173
|
+
export function generateX25519() {
|
|
174
|
+
const k = generateKeyPairSync('x25519', {
|
|
175
|
+
publicKeyEncoding: { type: 'spki', format: 'der' },
|
|
176
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'der' },
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
publicKey: extractX25519RawFromSpki(k.publicKey),
|
|
180
|
+
privateKey: extractX25519RawFromPkcs8(k.privateKey),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function concatAll(...parts) {
|
|
184
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
185
|
+
let off = 0;
|
|
186
|
+
for (const p of parts) {
|
|
187
|
+
out.set(p, off);
|
|
188
|
+
off += p.length;
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
function concatBytes(a, b) {
|
|
193
|
+
const out = new Uint8Array(a.length + b.length);
|
|
194
|
+
out.set(a, 0);
|
|
195
|
+
out.set(b, a.length);
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
// X25519 SPKI DER header (12 bytes) + 32-byte raw key
|
|
199
|
+
const X25519_SPKI_HEADER = Uint8Array.from([
|
|
200
|
+
0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x03, 0x21, 0x00,
|
|
201
|
+
]);
|
|
202
|
+
// X25519 PKCS8 DER header (16 bytes) + 32-byte raw key
|
|
203
|
+
const X25519_PKCS8_HEADER = Uint8Array.from([
|
|
204
|
+
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x04, 0x22, 0x04, 0x20,
|
|
205
|
+
]);
|
|
206
|
+
function extractX25519RawFromSpki(der) {
|
|
207
|
+
// DER format: [header 12 bytes][raw 32 bytes]
|
|
208
|
+
return new Uint8Array(der.slice(der.length - 32));
|
|
209
|
+
}
|
|
210
|
+
function extractX25519RawFromPkcs8(der) {
|
|
211
|
+
// DER format: [header 16 bytes][raw 32 bytes]
|
|
212
|
+
return new Uint8Array(der.slice(der.length - 32));
|
|
213
|
+
}
|
|
214
|
+
function wrapX25519RawAsSpki(raw) {
|
|
215
|
+
return Buffer.concat([Buffer.from(X25519_SPKI_HEADER), Buffer.from(raw)]);
|
|
216
|
+
}
|
|
217
|
+
function wrapX25519RawAsPkcs8(raw) {
|
|
218
|
+
return Buffer.concat([Buffer.from(X25519_PKCS8_HEADER), Buffer.from(raw)]);
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=kem.js.map
|
package/dist/kem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kem.js","sourceRoot":"","sources":["../src/kem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EA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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.2.0-beta.0";
|
|
36
|
+
readonly wireFormat: "yoxall/2 (locked through 1.0)";
|
|
37
|
+
readonly audited: false;
|
|
38
|
+
readonly auditPlanned: false;
|
|
39
|
+
readonly status: "experimental";
|
|
40
|
+
readonly productionReady: false;
|
|
41
|
+
readonly scopeForUse: readonly ["research", "experimentation", "development", "learning post-quantum patterns"];
|
|
42
|
+
readonly scopeForNonUse: readonly ["regulated data (HIPAA, PCI-DSS, SOC2)", "medical records", "financial records", "legal evidence", "production security-critical systems"];
|
|
43
|
+
readonly primitivesUsed: {
|
|
44
|
+
readonly kem: readonly ["X25519 (classical)", "ML-KEM-768 (post-quantum, NIST FIPS 203)", "X-Wing-style v2 combiner"];
|
|
45
|
+
readonly aead: readonly ["AES-256-GCM (Node crypto)", "cascade: AES-256-GCM inside ChaCha20-Poly1305 (Node crypto)"];
|
|
46
|
+
readonly kdf: readonly ["HKDF-SHA-256 (Node crypto)", "HMAC-SHA-256 chain keys"];
|
|
47
|
+
readonly ratchet: readonly ["Signal Double Ratchet over X25519, seeded by the hybrid KEM"];
|
|
48
|
+
};
|
|
49
|
+
readonly knownLimitations: readonly ["no threshold encryption yet", "no zero-knowledge proofs yet", "no verifiable delay functions yet", "double-ratchet DH steps are classical X25519 (PQ only at session start)", "no FHE integration yet", "Yoxallismus v1 (Hord) payloads cannot be decrypted (detector only; YOXALL-2026-003)", "no formal audit performed", "no quantum RNG integration yet"];
|
|
50
|
+
};
|
|
51
|
+
//# 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;;;;;;;;;;;;;;;;CAoCT,CAAC"}
|
package/dist/labels.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
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.2.0-beta.0',
|
|
58
|
+
wireFormat: 'yoxall/2 (locked through 1.0)',
|
|
59
|
+
audited: false,
|
|
60
|
+
auditPlanned: false,
|
|
61
|
+
status: 'experimental',
|
|
62
|
+
productionReady: false,
|
|
63
|
+
scopeForUse: [
|
|
64
|
+
'research',
|
|
65
|
+
'experimentation',
|
|
66
|
+
'development',
|
|
67
|
+
'learning post-quantum patterns',
|
|
68
|
+
],
|
|
69
|
+
scopeForNonUse: [
|
|
70
|
+
'regulated data (HIPAA, PCI-DSS, SOC2)',
|
|
71
|
+
'medical records',
|
|
72
|
+
'financial records',
|
|
73
|
+
'legal evidence',
|
|
74
|
+
'production security-critical systems',
|
|
75
|
+
],
|
|
76
|
+
primitivesUsed: {
|
|
77
|
+
kem: ['X25519 (classical)', 'ML-KEM-768 (post-quantum, NIST FIPS 203)', 'X-Wing-style v2 combiner'],
|
|
78
|
+
aead: ['AES-256-GCM (Node crypto)', 'cascade: AES-256-GCM inside ChaCha20-Poly1305 (Node crypto)'],
|
|
79
|
+
kdf: ['HKDF-SHA-256 (Node crypto)', 'HMAC-SHA-256 chain keys'],
|
|
80
|
+
ratchet: ['Signal Double Ratchet over X25519, seeded by the hybrid KEM'],
|
|
81
|
+
},
|
|
82
|
+
knownLimitations: [
|
|
83
|
+
'no threshold encryption yet',
|
|
84
|
+
'no zero-knowledge proofs yet',
|
|
85
|
+
'no verifiable delay functions yet',
|
|
86
|
+
'double-ratchet DH steps are classical X25519 (PQ only at session start)',
|
|
87
|
+
'no FHE integration yet',
|
|
88
|
+
'Yoxallismus v1 (Hord) payloads cannot be decrypted (detector only; YOXALL-2026-003)',
|
|
89
|
+
'no formal audit performed',
|
|
90
|
+
'no quantum RNG integration yet',
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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;QACrF,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"}
|
package/dist/ratchet.js
ADDED
|
@@ -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;
|
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AAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;IACxE,MAAM,KAAK,GAAG,CAAC,SAAS,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"}
|
package/dist/sealed.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sealed boxes (wire format yoxall/2): encrypt to a recipient's hybrid
|
|
3
|
+
* public key, sender-anonymous, one shot.
|
|
4
|
+
*
|
|
5
|
+
* ss = hybrid KEM (v2 combiner) to the recipient
|
|
6
|
+
* key = HKDF(ss, salt = 32 zero bytes, info = "weave-yoxall/2 seal <mode>")
|
|
7
|
+
* body = AES-256-GCM(key, random nonce, pt, aad) mode "aes-256-gcm"
|
|
8
|
+
* | cascadeEncrypt(key, pt, aad) mode "cascade"
|
|
9
|
+
*
|
|
10
|
+
* The caller passes the expected AAD to open(): it is never carried in
|
|
11
|
+
* the message, so a recipient can't be tricked into accepting a message
|
|
12
|
+
* bound to some other context.
|
|
13
|
+
*/
|
|
14
|
+
import type { HybridCiphertext, HybridKeypair, HybridPublicKey } from './types.js';
|
|
15
|
+
export type SealMode = 'aes-256-gcm' | 'cascade';
|
|
16
|
+
export interface SealedMessage {
|
|
17
|
+
version: 2;
|
|
18
|
+
mode: SealMode;
|
|
19
|
+
kem: HybridCiphertext;
|
|
20
|
+
nonce: Uint8Array;
|
|
21
|
+
ciphertext: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export interface SealOptions {
|
|
24
|
+
/** Associated data bound to the message; must be passed identically to open(). */
|
|
25
|
+
aad?: Uint8Array;
|
|
26
|
+
/** "cascade" layers AES-256-GCM inside ChaCha20-Poly1305. Default "aes-256-gcm". */
|
|
27
|
+
mode?: SealMode;
|
|
28
|
+
}
|
|
29
|
+
export declare function seal(recipient: HybridPublicKey, plaintext: Uint8Array, opts?: SealOptions): SealedMessage;
|
|
30
|
+
export declare function open(recipient: HybridKeypair, msg: SealedMessage, opts?: {
|
|
31
|
+
aad?: Uint8Array;
|
|
32
|
+
}): Uint8Array;
|
|
33
|
+
//# sourceMappingURL=sealed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed.d.ts","sourceRoot":"","sources":["../src/sealed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMnF,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,gBAAgB,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,oFAAoF;IACpF,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAID,wBAAgB,IAAI,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,GAAE,WAAgB,GAAG,aAAa,CAO7G;AAED,wBAAgB,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,UAAU,CAAA;CAAO,GAAG,UAAU,CAS9G"}
|
package/dist/sealed.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sealed boxes (wire format yoxall/2): encrypt to a recipient's hybrid
|
|
3
|
+
* public key, sender-anonymous, one shot.
|
|
4
|
+
*
|
|
5
|
+
* ss = hybrid KEM (v2 combiner) to the recipient
|
|
6
|
+
* key = HKDF(ss, salt = 32 zero bytes, info = "weave-yoxall/2 seal <mode>")
|
|
7
|
+
* body = AES-256-GCM(key, random nonce, pt, aad) mode "aes-256-gcm"
|
|
8
|
+
* | cascadeEncrypt(key, pt, aad) mode "cascade"
|
|
9
|
+
*
|
|
10
|
+
* The caller passes the expected AAD to open(): it is never carried in
|
|
11
|
+
* the message, so a recipient can't be tricked into accepting a message
|
|
12
|
+
* bound to some other context.
|
|
13
|
+
*/
|
|
14
|
+
import { encapsulate, decapsulate } from './kem.js';
|
|
15
|
+
import { hkdf } from './kdf.js';
|
|
16
|
+
import { aeadEncrypt, aeadDecrypt } from './aead.js';
|
|
17
|
+
import { cascadeEncrypt, cascadeDecrypt } from './cascade.js';
|
|
18
|
+
const keyFor = (ss, mode) => hkdf(ss, new Uint8Array(32), `weave-yoxall/2 seal ${mode}`, 32);
|
|
19
|
+
export function seal(recipient, plaintext, opts = {}) {
|
|
20
|
+
const mode = opts.mode ?? 'aes-256-gcm';
|
|
21
|
+
if (mode !== 'aes-256-gcm' && mode !== 'cascade')
|
|
22
|
+
throw new Error(`seal: unknown mode "${mode}"`);
|
|
23
|
+
const kem = encapsulate(recipient, 2);
|
|
24
|
+
const key = keyFor(kem.sharedSecret, mode);
|
|
25
|
+
const body = mode === 'cascade' ? cascadeEncrypt(key, plaintext, opts.aad) : aeadEncrypt(key, plaintext, opts.aad);
|
|
26
|
+
return { version: 2, mode, kem: kem.ciphertext, nonce: body.nonce, ciphertext: body.ciphertext };
|
|
27
|
+
}
|
|
28
|
+
export function open(recipient, msg, opts = {}) {
|
|
29
|
+
if (msg.version !== 2)
|
|
30
|
+
throw new Error(`open: unsupported sealed-message version ${msg.version}`);
|
|
31
|
+
const ss = decapsulate(recipient, msg.kem, 2);
|
|
32
|
+
const key = keyFor(ss, msg.mode);
|
|
33
|
+
if (msg.mode === 'cascade')
|
|
34
|
+
return cascadeDecrypt(key, { nonce: msg.nonce, ciphertext: msg.ciphertext }, opts.aad);
|
|
35
|
+
if (msg.mode === 'aes-256-gcm') {
|
|
36
|
+
return aeadDecrypt(key, { nonce: msg.nonce, ciphertext: msg.ciphertext, ...(opts.aad ? { associatedData: opts.aad } : {}) });
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`open: unknown mode "${msg.mode}"`);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=sealed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed.js","sourceRoot":"","sources":["../src/sealed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmB9D,MAAM,MAAM,GAAG,CAAC,EAAc,EAAE,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,uBAAuB,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAEnH,MAAM,UAAU,IAAI,CAAC,SAA0B,EAAE,SAAqB,EAAE,OAAoB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,IAAI,CAAC,GAAG,CAAC,CAAC;IACnH,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC/H,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAwB,GAAqB,CAAC,IAAI,GAAG,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy wire format yoxall/0.1.0-beta.0 (keys, KEM ciphertexts, payloads).
|
|
3
|
+
*
|
|
4
|
+
* Key envelopes are unchanged in yoxall/2. The KEM-ciphertext and payload
|
|
5
|
+
* envelopes are kept so v0.1 data stays readable; new data uses the
|
|
6
|
+
* locked yoxall/2 envelopes in wire.ts (spec: WIRE_FORMAT.md).
|
|
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"}
|