@atlasauth/pca-mpc 0.0.0-stage → 0.2.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -2
  3. package/dist/beaver.d.ts +49 -0
  4. package/dist/beaver.js +72 -0
  5. package/dist/beaver.js.map +1 -0
  6. package/dist/compose.d.ts +21 -0
  7. package/dist/compose.js +33 -0
  8. package/dist/compose.js.map +1 -0
  9. package/dist/csprng.d.ts +46 -0
  10. package/dist/csprng.js +86 -0
  11. package/dist/csprng.js.map +1 -0
  12. package/dist/ec.d.ts +130 -0
  13. package/dist/ec.js +475 -0
  14. package/dist/ec.js.map +1 -0
  15. package/dist/endemic-ot.d.ts +209 -0
  16. package/dist/endemic-ot.js +405 -0
  17. package/dist/endemic-ot.js.map +1 -0
  18. package/dist/field.d.ts +34 -0
  19. package/dist/field.js +65 -0
  20. package/dist/field.js.map +1 -0
  21. package/dist/gf128.d.ts +23 -0
  22. package/dist/gf128.js +59 -0
  23. package/dist/gf128.js.map +1 -0
  24. package/dist/hybrid-ot.d.ts +153 -0
  25. package/dist/hybrid-ot.js +241 -0
  26. package/dist/hybrid-ot.js.map +1 -0
  27. package/dist/index.d.ts +29 -0
  28. package/dist/index.js +46 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/kem-ot.d.ts +292 -0
  31. package/dist/kem-ot.js +559 -0
  32. package/dist/kem-ot.js.map +1 -0
  33. package/dist/mascot.d.ts +189 -0
  34. package/dist/mascot.js +322 -0
  35. package/dist/mascot.js.map +1 -0
  36. package/dist/ot.d.ts +212 -0
  37. package/dist/ot.js +536 -0
  38. package/dist/ot.js.map +1 -0
  39. package/dist/party.d.ts +38 -0
  40. package/dist/party.js +40 -0
  41. package/dist/party.js.map +1 -0
  42. package/dist/runner.d.ts +56 -0
  43. package/dist/runner.js +97 -0
  44. package/dist/runner.js.map +1 -0
  45. package/dist/sharing.d.ts +40 -0
  46. package/dist/sharing.js +97 -0
  47. package/dist/sharing.js.map +1 -0
  48. package/dist/spdz-runner.d.ts +50 -0
  49. package/dist/spdz-runner.js +107 -0
  50. package/dist/spdz-runner.js.map +1 -0
  51. package/dist/spdz.d.ts +136 -0
  52. package/dist/spdz.js +243 -0
  53. package/dist/spdz.js.map +1 -0
  54. package/dist/thermometer.d.ts +22 -0
  55. package/dist/thermometer.js +41 -0
  56. package/dist/thermometer.js.map +1 -0
  57. package/package.json +58 -3
package/dist/kem-ot.js ADDED
@@ -0,0 +1,559 @@
1
+ "use strict";
2
+ /**
3
+ * Post-quantum base OT from ML-KEM — a 1-of-2 oblivious transfer whose hardness rests on Module-LWE
4
+ * (ML-KEM-768, FIPS 203) instead of the curve25519 discrete log. This is the end-game plan's P3
5
+ * ("KEM-based OT from ML-KEM") so the MPC base OT no longer has a classical, quantum-breakable root.
6
+ *
7
+ * ─── THE CONSTRUCTION (be precise and honest) ──────────────────────────────────────────────────────
8
+ * This is the folklore semi-honest 1-of-2 OT from a key-encapsulation mechanism — the "dual-public-key
9
+ * KEM-OT" (closely related to endemic/Masny–Rindal-style OT, but WITHOUT any oblivious-key derivation):
10
+ *
11
+ * RECEIVER, choice bit c, per transfer:
12
+ * • generates TWO *real* ML-KEM keypairs, (pk_c, sk_c) and (pk', sk');
13
+ * • places pk_c at wire index c and pk' at wire index 1−c, and sends the ordered pair (pk_0, pk_1);
14
+ * • KEEPS sk_c and DISCARDS the other secret sk' (this discard is the whole semi-honest assumption).
15
+ * SENDER, messages (m_0, m_1), per transfer:
16
+ * • encapsulates under each received key: (ct_b, ss_b) ← Encaps(pk_b) for b ∈ {0,1};
17
+ * • one-time-pads each message under a random-oracle key: E_b = m_b ⊕ H(b ‖ ss_b), and sends
18
+ * (ct_0, E_0), (ct_1, E_1).
19
+ * RECEIVER recovers ONLY m_c: ss_c ← Decaps(ct_c, sk_c); m_c = E_c ⊕ H(c ‖ ss_c).
20
+ * It cannot recover m_{1−c}: it discarded sk_{1−c}, so ss_{1−c} is hidden by ML-KEM IND-CCA security
21
+ * and H(1−c ‖ ss_{1−c}) is a pseudorandom pad.
22
+ *
23
+ * ─── WHY *THIS* CONSTRUCTION (soundness) ───────────────────────────────────────────────────────────
24
+ * A tempting alternative is an "oblivious public key": derive pk_{1−c} by HASHING some public value so
25
+ * the receiver provably cannot invert it. That is sound for group-based KEMs where a public key is a
26
+ * group element you can hash-to. It is NOT soundly implementable for ML-KEM with the primitive we have:
27
+ * an ML-KEM public key is a structured Module-LWE object (a matrix seed ρ plus t = A·s + e); a hash
28
+ * output is not a valid encapsulation target, and there is no black-box "hash → valid pk whose secret is
29
+ * unknown-to-everyone" for ML-KEM without a trusted setup or a specialised lattice gadget. Rolling one
30
+ * by hand would be exactly the hand-rolled lattice crypto this module forbids. So we use the two-real-
31
+ * keypairs/discard-one-secret variant, which is sound with `ml_kem768` as an opaque IND-CCA KEM.
32
+ *
33
+ * ─── SECURITY MODEL (exactly what is and is not achieved) ──────────────────────────────────────────
34
+ * • Receiver-choice privacy — UNCONDITIONAL, and holds even against a *malicious* sender. The wire
35
+ * message (pk_0, pk_1) is two i.i.d. honest ML-KEM public keys; the choice c only decides which
36
+ * secret the receiver keeps *locally*. The two orderings are therefore identically distributed, so
37
+ * the sender's view is independent of c with probability 1 (no assumption, no abort needed).
38
+ * • Sender privacy (receiver learns nothing about m_{1−c}) — SEMI-HONEST only, under ML-KEM IND-CCA
39
+ * security + H modelled as a random oracle. An honest-but-curious receiver discards sk_{1−c}; given
40
+ * only pk_{1−c} and ct_{1−c} it cannot distinguish ss_{1−c} from random (IND-CCA), so the pad hides
41
+ * m_{1−c}. A MALICIOUS receiver that *keeps both* secrets learns BOTH messages — this base OT does
42
+ * not stop that by itself.
43
+ * • POST-QUANTUM: both guarantees are PQ. Choice privacy is information-theoretic; sender privacy
44
+ * rests on Module-LWE (ML-KEM-768, NIST security level ~3) and a hash in the ROM — no classical
45
+ * discrete-log anywhere, which is the entire point of P3.
46
+ *
47
+ * ─── MALICIOUS-RECEIVER HARDENING (`kemBaseOtMal`, below) ──────────────────────────────────────────
48
+ * The semi-honest base OT above leaves two malicious-receiver surfaces. The committed variant
49
+ * `kemBaseOtMal` closes the one that CAN be closed from an opaque KEM, and documents — precisely,
50
+ * rather than faking a defence — the one that cannot:
51
+ *
52
+ * CLOSED (by an RO-commitment + session binding, mirroring the EC `baseOT`'s commit round):
53
+ * • ADAPTIVE / MALLEABLE / REPLAYED key material. The receiver first sends only a RO-commitment
54
+ * `com = H(rn ‖ pk_0 ‖ pk_1)` to its ordered public keys (and a receiver nonce `rn`); the sender
55
+ * replies with a fresh nonce `sn`; the parties set `sid = H(rn ‖ sn)`; only THEN does the receiver
56
+ * open `(pk_0, pk_1)` and the sender encapsulate, binding every pad to `(sid, com)`. The sender
57
+ * recomputes `com` from the opened keys and ABORTS on any mismatch. So the receiver must fix its
58
+ * keys BEFORE it learns `sn` (no adaptive/precomputed/related-key choice, no cross-session replay),
59
+ * and cannot open keys other than the ones it committed to — exactly the non-malleability the EC
60
+ * base OT gets from `R` being a single committed group element.
61
+ *
62
+ * NOT CLOSABLE from an OPAQUE ML-KEM, and WHY (an impossibility, not a shortcut):
63
+ * • A receiver that simply runs keygen TWICE and keeps BOTH secret keys learns both messages. To
64
+ * stop it the protocol would have to force one slot to a public key whose secret NOBODY knows
65
+ * (the Masny–Rindal "endemic OT" idea: `pk_{1−c}` derived in the public-key space from a random
66
+ * oracle / a common reference). That needs either (i) sampling / adding in ML-KEM's structured
67
+ * public-key space — reaching into the Module-LWE internals this module forbids (no hand-rolled
68
+ * lattice crypto), or (ii) a trusted setup / CRS. Crucially, the SAME decisional-Module-LWE
69
+ * indistinguishability that makes choice privacy hold (a real `pk` ≈ a uniform one) is what makes
70
+ * a cheating "both-keys-real" receiver UNDETECTABLE to the sender: it cannot tell a secretless
71
+ * slot from a real one. So this residue is intrinsic to the opaque primitive.
72
+ *
73
+ * ─── LIFTING THE RESIDUE (how this plugs into the stack) ───────────────────────────────────────────
74
+ * The residue is closed exactly where the EC stack closes its analogue: the KOS OT-extension (`ot.ts`).
75
+ * KOS runs the base OTs with ROLES INVERTED (the extension *sender* is the base *receiver*, holding the
76
+ * secret selector s) and adds the correlation check over sacrifice rows. A base receiver keeping both
77
+ * secrets maps to the extension *sender* learning the extension *receiver*'s seed pairs; the KOS
78
+ * consistency machinery + correlation-robust hash constrain that, raising the overall extension to
79
+ * malicious-with-abort against a cheating extension receiver — the attack IKNP is vulnerable to. So
80
+ * `kemBaseOtMal` is the right base layer: it hardens everything the opaque KEM allows (commitment /
81
+ * binding), and defers only the intrinsic residue to the layer that already handles it.
82
+ *
83
+ * No hand-rolled lattice crypto: all PQ operations go through `ml_kem768` (keygen/encapsulate/
84
+ * decapsulate) as a black box. Randomness follows the module policy — a CSPRNG (`secureOtRandom`) by
85
+ * default, a seeded deterministic stream ONLY when a test passes one.
86
+ */
87
+ Object.defineProperty(exports, "__esModule", { value: true });
88
+ exports.KEM_OT_SECRET_BYTES = exports.KemBaseOtAbort = void 0;
89
+ exports.kemOtPad = kemOtPad;
90
+ exports.kemBaseOtReceive = kemBaseOtReceive;
91
+ exports.kemBaseOtSend = kemBaseOtSend;
92
+ exports.kemBaseOtOpen = kemBaseOtOpen;
93
+ exports.kemBaseOT = kemBaseOT;
94
+ exports.withKemBaseOt = withKemBaseOt;
95
+ exports.kemBaseOtMalCommit = kemBaseOtMalCommit;
96
+ exports.kemBaseOtMalSenderNonce = kemBaseOtMalSenderNonce;
97
+ exports.kemBaseOtMalOpen = kemBaseOtMalOpen;
98
+ exports.kemBaseOtMalSend = kemBaseOtMalSend;
99
+ exports.kemBaseOtMalRecover = kemBaseOtMalRecover;
100
+ exports.kemBaseOtMal = kemBaseOtMal;
101
+ exports.withKemBaseOtMal = withKemBaseOtMal;
102
+ exports.kemBaseOtMalRandomSend = kemBaseOtMalRandomSend;
103
+ exports.kemBaseOtMalRandomRecover = kemBaseOtMalRandomRecover;
104
+ exports.kemBaseOtMalRandom = kemBaseOtMalRandom;
105
+ const node_crypto_1 = require("node:crypto");
106
+ const ml_kem_js_1 = require("@noble/post-quantum/ml-kem.js");
107
+ const csprng_1 = require("./csprng");
108
+ /** Bytes of fresh randomness fed to ML-KEM keygen (d ‖ z, FIPS 203). */
109
+ const KEYGEN_SEED_BYTES = 64;
110
+ /** Bytes of fresh randomness fed to ML-KEM encapsulation (the message m, FIPS 203). */
111
+ const ENCAPS_MSG_BYTES = ml_kem_js_1.ml_kem768.msgLen; // 32
112
+ const TAG_KEMOT = new TextEncoder().encode('atlas-pca-mpc/kem-ot-pad');
113
+ function sha256(...chunks) {
114
+ const h = (0, node_crypto_1.createHash)('sha256');
115
+ for (const c of chunks)
116
+ h.update(c);
117
+ return new Uint8Array(h.digest());
118
+ }
119
+ function u32(x) {
120
+ const b = new Uint8Array(4);
121
+ b[0] = (x >>> 24) & 0xff;
122
+ b[1] = (x >>> 16) & 0xff;
123
+ b[2] = (x >>> 8) & 0xff;
124
+ b[3] = x & 0xff;
125
+ return b;
126
+ }
127
+ /** XOR two equal-length byte arrays into a fresh array. */
128
+ function xorBytes(a, b) {
129
+ if (a.length !== b.length)
130
+ throw new Error('kem-ot: XOR length mismatch');
131
+ const out = new Uint8Array(a.length);
132
+ for (let i = 0; i < a.length; i++)
133
+ out[i] = a[i] ^ b[i];
134
+ return out;
135
+ }
136
+ /**
137
+ * The random-oracle pad for one slot: `H(TAG ‖ i ‖ b ‖ sharedSecret)` expanded (SHA-256 counter mode)
138
+ * to exactly `len` bytes. `i` binds the transfer index and `b` the slot, so the two pads of one transfer
139
+ * — and the pads across transfers — are domain-separated.
140
+ */
141
+ function kemOtPad(index, slot, sharedSecret, len) {
142
+ const out = new Uint8Array(len);
143
+ let produced = 0;
144
+ let ctr = 0;
145
+ while (produced < len) {
146
+ const block = sha256(TAG_KEMOT, u32(index), Uint8Array.of(slot & 1), u32(ctr), sharedSecret);
147
+ for (let k = 0; k < block.length && produced < len; k++)
148
+ out[produced++] = block[k];
149
+ ctr++;
150
+ }
151
+ return out;
152
+ }
153
+ /**
154
+ * RECEIVER round 1: for each choice bit, generate two real ML-KEM keypairs, send both public keys
155
+ * (chosen one at wire index `c`), and retain only the chosen secret key. Returns the wire message AND
156
+ * the retained receiver state.
157
+ */
158
+ function kemBaseOtReceive(choices, rng = (0, csprng_1.secureOtRandom)()) {
159
+ const publicKeys = [];
160
+ const secretKeys = [];
161
+ const retainedChoices = [];
162
+ for (let i = 0; i < choices.length; i++) {
163
+ const c = choices[i] & 1;
164
+ const chosen = ml_kem_js_1.ml_kem768.keygen(rng.bytes(KEYGEN_SEED_BYTES));
165
+ const other = ml_kem_js_1.ml_kem768.keygen(rng.bytes(KEYGEN_SEED_BYTES));
166
+ // Place the chosen public key at wire index c; the other at 1−c. The order is the only thing the
167
+ // sender sees, and both keys are i.i.d. honest keygen outputs, so it reveals nothing about c.
168
+ const pk0 = c === 0 ? chosen.publicKey : other.publicKey;
169
+ const pk1 = c === 0 ? other.publicKey : chosen.publicKey;
170
+ publicKeys.push([pk0, pk1]);
171
+ // Keep only the chosen secret; `other.secretKey` is deliberately dropped (never stored).
172
+ secretKeys.push(chosen.secretKey);
173
+ retainedChoices.push(c);
174
+ }
175
+ return { message: { publicKeys }, state: { choices: retainedChoices, secretKeys } };
176
+ }
177
+ /**
178
+ * SENDER round: encapsulate under each received public key and one-time-pad each message under
179
+ * `H(slot ‖ sharedSecret)`. `messages[i] = [m_0, m_1]`; the two messages of one transfer must be equal
180
+ * length (padding is derived to that length). Returns the sender wire message.
181
+ */
182
+ function kemBaseOtSend(messages, receiverMessage, rng = (0, csprng_1.secureOtRandom)()) {
183
+ const { publicKeys } = receiverMessage;
184
+ if (messages.length !== publicKeys.length) {
185
+ throw new Error('kemBaseOtSend: messages/publicKeys length mismatch');
186
+ }
187
+ const ciphertexts = [];
188
+ const encrypted = [];
189
+ for (let i = 0; i < messages.length; i++) {
190
+ const [m0, m1] = messages[i];
191
+ if (m0.length !== m1.length) {
192
+ throw new Error(`kemBaseOtSend (index ${i}): the two messages must be equal length`);
193
+ }
194
+ const [pk0, pk1] = publicKeys[i];
195
+ // ml_kem768.encapsulate derandomised with fresh bytes so a seeded test stays reproducible.
196
+ const e0 = ml_kem_js_1.ml_kem768.encapsulate(pk0, rng.bytes(ENCAPS_MSG_BYTES));
197
+ const e1 = ml_kem_js_1.ml_kem768.encapsulate(pk1, rng.bytes(ENCAPS_MSG_BYTES));
198
+ ciphertexts.push([e0.cipherText, e1.cipherText]);
199
+ encrypted.push([
200
+ xorBytes(m0, kemOtPad(i, 0, e0.sharedSecret, m0.length)),
201
+ xorBytes(m1, kemOtPad(i, 1, e1.sharedSecret, m1.length)),
202
+ ]);
203
+ }
204
+ return { ciphertexts, encrypted };
205
+ }
206
+ /**
207
+ * RECEIVER recovery: decapsulate ONLY the chosen ciphertext with the retained secret key and unmask the
208
+ * chosen message. The receiver never touches the non-chosen slot (it has no secret for it). Returns
209
+ * `received[i] = m_{i, choices[i]}`.
210
+ */
211
+ function kemBaseOtOpen(state, senderMessage) {
212
+ const { choices, secretKeys } = state;
213
+ const { ciphertexts, encrypted } = senderMessage;
214
+ if (ciphertexts.length !== choices.length || encrypted.length !== choices.length) {
215
+ throw new Error('kemBaseOtOpen: transcript/state length mismatch');
216
+ }
217
+ const received = [];
218
+ for (let i = 0; i < choices.length; i++) {
219
+ const c = choices[i] & 1;
220
+ const ss = ml_kem_js_1.ml_kem768.decapsulate(ciphertexts[i][c], secretKeys[i]);
221
+ const e = encrypted[i][c];
222
+ received.push(xorBytes(e, kemOtPad(i, c, ss, e.length)));
223
+ }
224
+ return received;
225
+ }
226
+ /**
227
+ * In-process combined simulator (both parties in one call), matching the shape of `baseOT` in `ot.ts`:
228
+ * run `count = choices.length` KEM base OTs and return the receiver's recovered messages plus the full
229
+ * transcript. This is the drop-in the KOS extension consumes (see `OtChannel`'s `baseOtFn` option).
230
+ */
231
+ function kemBaseOT(messages, choices, rng = (0, csprng_1.secureOtRandom)()) {
232
+ if (messages.length !== choices.length) {
233
+ throw new Error('kemBaseOT: messages/choices length mismatch');
234
+ }
235
+ const { message: receiverMessage, state } = kemBaseOtReceive(choices, rng);
236
+ const senderMessage = kemBaseOtSend(messages, receiverMessage, rng);
237
+ const received = kemBaseOtOpen(state, senderMessage);
238
+ return {
239
+ received,
240
+ transcript: {
241
+ publicKeys: receiverMessage.publicKeys,
242
+ ciphertexts: senderMessage.ciphertexts,
243
+ encrypted: senderMessage.encrypted,
244
+ },
245
+ };
246
+ }
247
+ /**
248
+ * Wire the ML-KEM base OT into the existing KOS OT-extension: returns the constructor option bag for
249
+ * `OtChannel` that makes it run its κ setup base OTs over `kemBaseOT` (post-quantum) instead of the
250
+ * classical EC Chou–Orlandi `baseOT`. Everything above the base OT (the IKNP matrix, the KOS correlation
251
+ * check, the correlation-robust hash) is unchanged.
252
+ *
253
+ * const ch = new OtChannel(secureOtRandom(), withKemBaseOt());
254
+ */
255
+ function withKemBaseOt() {
256
+ return { baseOtFn: kemBaseOT };
257
+ }
258
+ // ===================================================================================================
259
+ // MALICIOUS-RECEIVER HARDENING: the committed, session-bound KEM base OT (`kemBaseOtMal`).
260
+ //
261
+ // See the module header for the exact security model. In one line: an RO-commitment to the ordered
262
+ // public keys + a two-nonce session id bind the receiver's key material (commit-BEFORE the sender's
263
+ // nonce, open AFTER), and the sender aborts if the opened keys do not match the commitment — closing
264
+ // the adaptive / malleable / replay surfaces. The intrinsic "keep both secrets" residue is deferred to
265
+ // the KOS extension, as the header and tests document.
266
+ // ===================================================================================================
267
+ const TAG_KEMOT_COMMIT = new TextEncoder().encode('atlas-pca-mpc/kem-ot-commit');
268
+ const TAG_KEMOT_SID = new TextEncoder().encode('atlas-pca-mpc/kem-ot-sid');
269
+ const TAG_KEMOT_MALPAD = new TextEncoder().encode('atlas-pca-mpc/kem-ot-mal-pad');
270
+ /** Bytes of a protocol nonce (receiver `rn`, sender `sn`). */
271
+ const NONCE_BYTES = 32;
272
+ /** Raised when the committed KEM base OT aborts: a cheating receiver (opened keys ≠ commitment) is caught. */
273
+ class KemBaseOtAbort extends Error {
274
+ constructor(message) {
275
+ super(message);
276
+ this.name = 'KemBaseOtAbort';
277
+ }
278
+ }
279
+ exports.KemBaseOtAbort = KemBaseOtAbort;
280
+ /** The RO-commitment to one transfer's ordered public keys, bound to the receiver nonce `rn`. */
281
+ function kemMalCommit(rn, index, pk0, pk1) {
282
+ return sha256(TAG_KEMOT_COMMIT, rn, u32(index), pk0, pk1);
283
+ }
284
+ /** The session id `sid = H(TAG ‖ rn ‖ sn)` — both parties' nonces, so neither alone fixes it. */
285
+ function kemMalSid(rn, sn) {
286
+ return sha256(TAG_KEMOT_SID, rn, sn);
287
+ }
288
+ /**
289
+ * The malicious-variant RO pad: `H(TAG ‖ sid ‖ com ‖ i ‖ slot ‖ ss)` expanded to `len` bytes. Binding
290
+ * the pad to `(sid, com)` ties the sender's encryption to the exact committed keys and this session, so
291
+ * a receiver that opens different keys (or replays another session) cannot unmask the message.
292
+ */
293
+ function kemOtMalPad(sid, com, index, slot, sharedSecret, len) {
294
+ const out = new Uint8Array(len);
295
+ let produced = 0;
296
+ let ctr = 0;
297
+ while (produced < len) {
298
+ const block = sha256(TAG_KEMOT_MALPAD, sid, com, u32(index), Uint8Array.of(slot & 1), u32(ctr), sharedSecret);
299
+ for (let k = 0; k < block.length && produced < len; k++)
300
+ out[produced++] = block[k];
301
+ ctr++;
302
+ }
303
+ return out;
304
+ }
305
+ /**
306
+ * RECEIVER round 1: generate the keypairs (keeping only the chosen secret), draw a nonce `rn`, and send
307
+ * only the COMMITMENTS to the ordered public keys. Returns the round-1 wire message plus the retained
308
+ * state (which holds the not-yet-revealed public keys for the round-3 opening).
309
+ */
310
+ function kemBaseOtMalCommit(choices, rng = (0, csprng_1.secureOtRandom)()) {
311
+ const rn = rng.bytes(NONCE_BYTES);
312
+ const publicKeys = [];
313
+ const secretKeys = [];
314
+ const retainedChoices = [];
315
+ const commitments = [];
316
+ for (let i = 0; i < choices.length; i++) {
317
+ const c = choices[i] & 1;
318
+ const chosen = ml_kem_js_1.ml_kem768.keygen(rng.bytes(KEYGEN_SEED_BYTES));
319
+ const other = ml_kem_js_1.ml_kem768.keygen(rng.bytes(KEYGEN_SEED_BYTES));
320
+ const pk0 = c === 0 ? chosen.publicKey : other.publicKey;
321
+ const pk1 = c === 0 ? other.publicKey : chosen.publicKey;
322
+ publicKeys.push([pk0, pk1]);
323
+ secretKeys.push(chosen.secretKey);
324
+ retainedChoices.push(c);
325
+ commitments.push(kemMalCommit(rn, i, pk0, pk1));
326
+ }
327
+ return {
328
+ message: { rn, commitments },
329
+ state: { choices: retainedChoices, secretKeys, publicKeys, rn },
330
+ };
331
+ }
332
+ /** SENDER round 2: draw the sender nonce `sn` completing the session id. */
333
+ function kemBaseOtMalSenderNonce(rng = (0, csprng_1.secureOtRandom)()) {
334
+ return { sn: rng.bytes(NONCE_BYTES) };
335
+ }
336
+ /** RECEIVER round 3: open the committed public keys (the sender will re-check them against `com`). */
337
+ function kemBaseOtMalOpen(state) {
338
+ return { publicKeys: state.publicKeys.map(([a, b]) => [a, b]) };
339
+ }
340
+ /**
341
+ * SENDER round 4: VERIFY the opened keys against the round-1 commitments (ABORT on mismatch), then
342
+ * encapsulate under each and one-time-pad each message with a `(sid, com)`-bound pad.
343
+ */
344
+ function kemBaseOtMalSend(messages, commit, senderNonce, opening, rng = (0, csprng_1.secureOtRandom)()) {
345
+ const { rn, commitments } = commit;
346
+ const { publicKeys } = opening;
347
+ if (messages.length !== publicKeys.length || commitments.length !== publicKeys.length) {
348
+ throw new Error('kemBaseOtMalSend: messages/commitments/publicKeys length mismatch');
349
+ }
350
+ const sid = kemMalSid(rn, senderNonce.sn);
351
+ const ciphertexts = [];
352
+ const encrypted = [];
353
+ for (let i = 0; i < messages.length; i++) {
354
+ const [m0, m1] = messages[i];
355
+ if (m0.length !== m1.length) {
356
+ throw new Error(`kemBaseOtMalSend (index ${i}): the two messages must be equal length`);
357
+ }
358
+ const [pk0, pk1] = publicKeys[i];
359
+ // The binding check: the opened keys MUST reproduce the round-1 commitment, else a cheating
360
+ // receiver swapped/adapted its keys after learning the sender nonce → ABORT.
361
+ const com = kemMalCommit(rn, i, pk0, pk1);
362
+ if (!constTimeEqual(com, commitments[i])) {
363
+ throw new KemBaseOtAbort(`kem base OT (index ${i}): opened public keys do not match the receiver's commitment; aborting`);
364
+ }
365
+ const e0 = ml_kem_js_1.ml_kem768.encapsulate(pk0, rng.bytes(ENCAPS_MSG_BYTES));
366
+ const e1 = ml_kem_js_1.ml_kem768.encapsulate(pk1, rng.bytes(ENCAPS_MSG_BYTES));
367
+ ciphertexts.push([e0.cipherText, e1.cipherText]);
368
+ encrypted.push([
369
+ xorBytes(m0, kemOtMalPad(sid, com, i, 0, e0.sharedSecret, m0.length)),
370
+ xorBytes(m1, kemOtMalPad(sid, com, i, 1, e1.sharedSecret, m1.length)),
371
+ ]);
372
+ }
373
+ return { ciphertexts, encrypted };
374
+ }
375
+ /**
376
+ * RECEIVER round 5: decapsulate ONLY the chosen ciphertext and unmask with the `(sid, com)`-bound pad.
377
+ */
378
+ function kemBaseOtMalRecover(state, senderNonce, senderMessage, tamper) {
379
+ const { choices, secretKeys, publicKeys, rn } = state;
380
+ const { ciphertexts, encrypted } = senderMessage;
381
+ if (ciphertexts.length !== choices.length || encrypted.length !== choices.length) {
382
+ throw new Error('kemBaseOtMalRecover: transcript/state length mismatch');
383
+ }
384
+ let sid = kemMalSid(rn, senderNonce.sn);
385
+ if (tamper?.tamperReceiverSid)
386
+ sid = tamper.tamperReceiverSid(sid);
387
+ const received = [];
388
+ for (let i = 0; i < choices.length; i++) {
389
+ const c = choices[i] & 1;
390
+ const [pk0, pk1] = publicKeys[i];
391
+ const com = kemMalCommit(rn, i, pk0, pk1);
392
+ const ss = ml_kem_js_1.ml_kem768.decapsulate(ciphertexts[i][c], secretKeys[i]);
393
+ const e = encrypted[i][c];
394
+ received.push(xorBytes(e, kemOtMalPad(sid, com, i, c, ss, e.length)));
395
+ }
396
+ return received;
397
+ }
398
+ /** Constant-time byte-equality (both the commitment check and length check in one place). */
399
+ function constTimeEqual(a, b) {
400
+ if (a.length !== b.length)
401
+ return false;
402
+ let diff = 0;
403
+ for (let i = 0; i < a.length; i++)
404
+ diff |= a[i] ^ b[i];
405
+ return diff === 0;
406
+ }
407
+ /**
408
+ * In-process combined simulator for the MALICIOUS-HARDENED committed KEM base OT, matching the shape of
409
+ * `kemBaseOT` so it is a drop-in for `OtChannel`'s `baseOtFn` (`withKemBaseOtMal`). Runs all five
410
+ * rounds; a cheating receiver (opened keys ≠ commitment) makes the sender throw `KemBaseOtAbort`. The
411
+ * `tamper` hook injects malicious-receiver behaviour for tests.
412
+ */
413
+ function kemBaseOtMal(messages, choices, rng = (0, csprng_1.secureOtRandom)(), tamper) {
414
+ if (messages.length !== choices.length) {
415
+ throw new Error('kemBaseOtMal: messages/choices length mismatch');
416
+ }
417
+ const { message: commit, state } = kemBaseOtMalCommit(choices, rng);
418
+ const senderNonce = kemBaseOtMalSenderNonce(rng);
419
+ const opening = kemBaseOtMalOpen(state);
420
+ // A malicious receiver may open keys OTHER than those it committed to (test-injected).
421
+ if (tamper?.tamperOpenedKeys)
422
+ tamper.tamperOpenedKeys(opening.publicKeys);
423
+ const senderMessage = kemBaseOtMalSend(messages, commit, senderNonce, opening, rng);
424
+ const received = kemBaseOtMalRecover(state, senderNonce, senderMessage, tamper);
425
+ return {
426
+ received,
427
+ transcript: {
428
+ rn: commit.rn,
429
+ commitments: commit.commitments,
430
+ sn: senderNonce.sn,
431
+ publicKeys: opening.publicKeys,
432
+ ciphertexts: senderMessage.ciphertexts,
433
+ encrypted: senderMessage.encrypted,
434
+ },
435
+ };
436
+ }
437
+ /**
438
+ * Wire the MALICIOUS-HARDENED committed ML-KEM base OT into the KOS OT-extension — the recommended
439
+ * post-quantum base. Like `withKemBaseOt`, but the κ setup base OTs run the committed/session-bound
440
+ * protocol (and abort on a cheating receiver). Everything above the base OT is unchanged.
441
+ *
442
+ * const ch = new OtChannel(secureOtRandom(), withKemBaseOtMal());
443
+ */
444
+ function withKemBaseOtMal() {
445
+ return { baseOtFn: (m, c, r) => kemBaseOtMal(m, c, r) };
446
+ }
447
+ // ===================================================================================================
448
+ // COMMITTED KEM *RANDOM* OT (`kemBaseOtMalRandom`) — the random-OT face of the hardened protocol.
449
+ //
450
+ // The chosen-message `kemBaseOtMal` above one-time-pads the sender's messages internally and never
451
+ // surfaces the raw KEM shared secrets. A hybrid OT COMBINER (`hybrid-ot.ts`) needs those per-slot
452
+ // shared secrets so it can fold them with a second base OT's secrets. This variant runs the EXACT SAME
453
+ // five-round committed/session-bound protocol — same `rn`/`sn`/`sid`, same RO-commitment to the ordered
454
+ // public keys, same ABORT on an opened-key / commitment mismatch — but instead of padding messages it
455
+ // returns, per transfer, a session-bound shared secret PER SLOT:
456
+ //
457
+ // ss_slot = H(TAG ‖ sid ‖ com ‖ i ‖ slot ‖ Decaps/Encaps shared secret).
458
+ //
459
+ // The SENDER derives BOTH (`senderSecrets[i] = [ss_0, ss_1]`); the honest RECEIVER derives only the
460
+ // chosen one (`recvSecrets[i] = ss_{choices[i]}`), because it kept only `sk_{choices[i]}`. Binding each
461
+ // secret to `(sid, com)` makes it non-transferable across sessions / across different opened keys —
462
+ // identical to how `kemOtMalPad` binds the chosen-message pad. The intrinsic "keep both secrets"
463
+ // residue is UNCHANGED from the chosen-message variant (an opaque IND-CCA KEM cannot stop it; see the
464
+ // module header) — closing it is exactly the job the hybrid combiner delegates to the EC base OT.
465
+ // ===================================================================================================
466
+ const TAG_KEMOT_MALSECRET = new TextEncoder().encode('atlas-pca-mpc/kem-ot-mal-secret');
467
+ /** Byte length of a derived committed-KEM random-OT shared secret. */
468
+ exports.KEM_OT_SECRET_BYTES = 32;
469
+ /**
470
+ * The session-bound per-slot shared secret `H(TAG ‖ sid ‖ com ‖ i ‖ slot ‖ ss)` (32 bytes). Binding to
471
+ * `(sid, com)` ties it to the committed keys and this exact session — the random-OT analogue of
472
+ * `kemOtMalPad`.
473
+ */
474
+ function kemOtMalSecret(sid, com, index, slot, sharedSecret) {
475
+ return sha256(TAG_KEMOT_MALSECRET, sid, com, u32(index), Uint8Array.of(slot & 1), sharedSecret).slice(0, exports.KEM_OT_SECRET_BYTES);
476
+ }
477
+ /**
478
+ * SENDER round 4 (RANDOM variant): VERIFY the opened keys against the round-1 commitments (ABORT on
479
+ * mismatch), encapsulate under each, and derive BOTH per-slot session-bound shared secrets. No messages
480
+ * are padded — the two secrets per transfer ARE the random output.
481
+ */
482
+ function kemBaseOtMalRandomSend(commit, senderNonce, opening, rng = (0, csprng_1.secureOtRandom)()) {
483
+ const { rn, commitments } = commit;
484
+ const { publicKeys } = opening;
485
+ if (commitments.length !== publicKeys.length) {
486
+ throw new Error('kemBaseOtMalRandomSend: commitments/publicKeys length mismatch');
487
+ }
488
+ const sid = kemMalSid(rn, senderNonce.sn);
489
+ const ciphertexts = [];
490
+ const senderSecrets = [];
491
+ for (let i = 0; i < publicKeys.length; i++) {
492
+ const [pk0, pk1] = publicKeys[i];
493
+ // Same binding check as the chosen-message variant: opened keys MUST reproduce the commitment.
494
+ const com = kemMalCommit(rn, i, pk0, pk1);
495
+ if (!constTimeEqual(com, commitments[i])) {
496
+ throw new KemBaseOtAbort(`kem base OT (index ${i}): opened public keys do not match the receiver's commitment; aborting`);
497
+ }
498
+ const e0 = ml_kem_js_1.ml_kem768.encapsulate(pk0, rng.bytes(ENCAPS_MSG_BYTES));
499
+ const e1 = ml_kem_js_1.ml_kem768.encapsulate(pk1, rng.bytes(ENCAPS_MSG_BYTES));
500
+ ciphertexts.push([e0.cipherText, e1.cipherText]);
501
+ senderSecrets.push([
502
+ kemOtMalSecret(sid, com, i, 0, e0.sharedSecret),
503
+ kemOtMalSecret(sid, com, i, 1, e1.sharedSecret),
504
+ ]);
505
+ }
506
+ return { ciphertexts, senderSecrets };
507
+ }
508
+ /**
509
+ * RECEIVER round 5 (RANDOM variant): decapsulate ONLY the chosen ciphertext and derive the chosen
510
+ * session-bound shared secret. The receiver never touches the non-chosen slot (it kept no secret for it).
511
+ */
512
+ function kemBaseOtMalRandomRecover(state, senderNonce, senderMessage, tamper) {
513
+ const { choices, secretKeys, publicKeys, rn } = state;
514
+ const { ciphertexts } = senderMessage;
515
+ if (ciphertexts.length !== choices.length) {
516
+ throw new Error('kemBaseOtMalRandomRecover: transcript/state length mismatch');
517
+ }
518
+ let sid = kemMalSid(rn, senderNonce.sn);
519
+ if (tamper?.tamperReceiverSid)
520
+ sid = tamper.tamperReceiverSid(sid);
521
+ const recvSecrets = [];
522
+ for (let i = 0; i < choices.length; i++) {
523
+ const c = choices[i] & 1;
524
+ const [pk0, pk1] = publicKeys[i];
525
+ const com = kemMalCommit(rn, i, pk0, pk1);
526
+ const ss = ml_kem_js_1.ml_kem768.decapsulate(ciphertexts[i][c], secretKeys[i]);
527
+ recvSecrets.push(kemOtMalSecret(sid, com, i, c, ss));
528
+ }
529
+ return recvSecrets;
530
+ }
531
+ /**
532
+ * In-process combined simulator for the committed KEM RANDOM OT. Runs the same five rounds as
533
+ * `kemBaseOtMal` (commit → sender nonce → open → verify+encapsulate → recover) but outputs per-slot
534
+ * shared secrets instead of padded messages. A cheating receiver (opened keys ≠ commitment) makes the
535
+ * sender throw `KemBaseOtAbort`. The `tamper` hook injects malicious-receiver behaviour for tests.
536
+ */
537
+ function kemBaseOtMalRandom(choices, rng = (0, csprng_1.secureOtRandom)(), tamper) {
538
+ const { message: commit, state } = kemBaseOtMalCommit(choices, rng);
539
+ const senderNonce = kemBaseOtMalSenderNonce(rng);
540
+ const opening = kemBaseOtMalOpen(state);
541
+ // A malicious receiver may open keys OTHER than those it committed to (test-injected).
542
+ if (tamper?.tamperOpenedKeys)
543
+ tamper.tamperOpenedKeys(opening.publicKeys);
544
+ const senderMessage = kemBaseOtMalRandomSend(commit, senderNonce, opening, rng);
545
+ const recvSecrets = kemBaseOtMalRandomRecover(state, senderNonce, senderMessage, tamper);
546
+ return {
547
+ senderSecrets: senderMessage.senderSecrets,
548
+ recvSecrets,
549
+ sid: kemMalSid(commit.rn, senderNonce.sn),
550
+ transcript: {
551
+ rn: commit.rn,
552
+ commitments: commit.commitments,
553
+ sn: senderNonce.sn,
554
+ publicKeys: opening.publicKeys,
555
+ ciphertexts: senderMessage.ciphertexts,
556
+ },
557
+ };
558
+ }
559
+ //# sourceMappingURL=kem-ot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kem-ot.js","sourceRoot":"","sources":["../src/kem-ot.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;;;AA0CH,4BAUC;AA+CD,4CAqBC;AAOD,sCA2BC;AAOD,sCAiBC;AAOD,8BAmBC;AAUD,sCAEC;AAqID,gDAwBC;AAGD,0DAEC;AAGD,4CAEC;AAMD,4CAsCC;AAKD,kDAuBC;AAgBD,oCA2BC;AASD,4CAEC;AA2ED,wDAgCC;AAMD,8DAsBC;AAQD,gDAwBC;AAlqBD,6CAAyC;AACzC,6DAA0D;AAC1D,qCAA0C;AAG1C,wEAAwE;AACxE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,uFAAuF;AACvF,MAAM,gBAAgB,GAAG,qBAAS,CAAC,MAAM,CAAC,CAAC,KAAK;AAEhD,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAEvE,SAAS,MAAM,CAAC,GAAG,MAAoB;IACrC,MAAM,CAAC,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,GAAG,CAAC,CAAS;IACpB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