@atlasauth/pca-mpc 0.3.0 → 0.4.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 (85) hide show
  1. package/README.md +81 -3
  2. package/dist/beaver.js +4 -0
  3. package/dist/beaver.js.map +1 -1
  4. package/dist/compose.d.ts +9 -2
  5. package/dist/compose.js +24 -1
  6. package/dist/compose.js.map +1 -1
  7. package/dist/ec.d.ts +6 -3
  8. package/dist/ec.js +27 -9
  9. package/dist/ec.js.map +1 -1
  10. package/dist/enc.d.ts +46 -0
  11. package/dist/enc.js +88 -0
  12. package/dist/enc.js.map +1 -0
  13. package/dist/endemic-ot.js +24 -1
  14. package/dist/endemic-ot.js.map +1 -1
  15. package/dist/hybrid-ot.js +3 -0
  16. package/dist/hybrid-ot.js.map +1 -1
  17. package/dist/kem-ot.js +2 -0
  18. package/dist/kem-ot.js.map +1 -1
  19. package/dist/mascot.d.ts +81 -30
  20. package/dist/mascot.js +232 -113
  21. package/dist/mascot.js.map +1 -1
  22. package/dist/net/certs.d.ts +14 -0
  23. package/dist/net/certs.js +30 -0
  24. package/dist/net/certs.js.map +1 -0
  25. package/dist/net/faults.d.ts +49 -0
  26. package/dist/net/faults.js +222 -0
  27. package/dist/net/faults.js.map +1 -0
  28. package/dist/net/forensics.d.ts +81 -0
  29. package/dist/net/forensics.js +181 -0
  30. package/dist/net/forensics.js.map +1 -0
  31. package/dist/net/gadget.d.ts +44 -0
  32. package/dist/net/gadget.js +102 -0
  33. package/dist/net/gadget.js.map +1 -0
  34. package/dist/net/index.d.ts +11 -0
  35. package/dist/net/index.js +28 -0
  36. package/dist/net/index.js.map +1 -0
  37. package/dist/net/launch-local.d.ts +53 -0
  38. package/dist/net/launch-local.js +190 -0
  39. package/dist/net/launch-local.js.map +1 -0
  40. package/dist/net/launch-support.d.ts +6 -0
  41. package/dist/net/launch-support.js +65 -0
  42. package/dist/net/launch-support.js.map +1 -0
  43. package/dist/net/mesh.d.ts +135 -0
  44. package/dist/net/mesh.js +491 -0
  45. package/dist/net/mesh.js.map +1 -0
  46. package/dist/net/offline-net.d.ts +58 -0
  47. package/dist/net/offline-net.js +485 -0
  48. package/dist/net/offline-net.js.map +1 -0
  49. package/dist/net/ot-net.d.ts +42 -0
  50. package/dist/net/ot-net.js +219 -0
  51. package/dist/net/ot-net.js.map +1 -0
  52. package/dist/net/pa.d.ts +65 -0
  53. package/dist/net/pa.js +118 -0
  54. package/dist/net/pa.js.map +1 -0
  55. package/dist/net/party-main.d.ts +48 -0
  56. package/dist/net/party-main.js +146 -0
  57. package/dist/net/party-main.js.map +1 -0
  58. package/dist/net/prep.d.ts +40 -0
  59. package/dist/net/prep.js +12 -0
  60. package/dist/net/prep.js.map +1 -0
  61. package/dist/net/protocol.d.ts +126 -0
  62. package/dist/net/protocol.js +655 -0
  63. package/dist/net/protocol.js.map +1 -0
  64. package/dist/net/wire.d.ts +89 -0
  65. package/dist/net/wire.js +242 -0
  66. package/dist/net/wire.js.map +1 -0
  67. package/dist/ot.d.ts +176 -17
  68. package/dist/ot.js +479 -252
  69. package/dist/ot.js.map +1 -1
  70. package/dist/otx.d.ts +76 -0
  71. package/dist/otx.js +238 -0
  72. package/dist/otx.js.map +1 -0
  73. package/dist/runner.d.ts +1 -1
  74. package/dist/runner.js +6 -1
  75. package/dist/runner.js.map +1 -1
  76. package/dist/sharing.d.ts +2 -0
  77. package/dist/sharing.js +7 -4
  78. package/dist/sharing.js.map +1 -1
  79. package/dist/spdz-runner.d.ts +20 -3
  80. package/dist/spdz-runner.js +21 -3
  81. package/dist/spdz-runner.js.map +1 -1
  82. package/dist/spdz.d.ts +96 -22
  83. package/dist/spdz.js +196 -47
  84. package/dist/spdz.js.map +1 -1
  85. package/package.json +15 -6
@@ -10,7 +10,11 @@
10
10
  * silent wrong answer. (Malicious-with-abort, dishonest-majority.)
11
11
  *
12
12
  * Offline phase (two interchangeable sources, same tiny interface):
13
- * - DEFAULT: a trusted dealer produces the authenticated triples / input sharings and knows α.
13
+ * - DEFAULT, labelled `'trusted-dealer'` in the result: a trusted dealer produces the authenticated
14
+ * triples / input sharings and knows the MAC keys. A dealer that hands out a wrong triple (c ≠ a·b) is
15
+ * now DETECTED: every delivered triple is certified by the sacrifice check with `SACRIFICE_PARTNERS`
16
+ * independent partners (spdz.ts `sacrificeVerify`) and a bad one aborts. The dealer is still trusted for
17
+ * PRIVACY (it knows every share and key).
14
18
  * - NO-DEALER: pass `cfg.offline` (a `NoDealerOffline` from `mascot.ts`) and the triples, input
15
19
  * sharings and the distributed MAC key all come from real oblivious transfer — no dealer, and α
16
20
  * is never reconstructed. Either way the ONLINE phase here is the same maliciously-secure protocol.
@@ -19,9 +23,11 @@
19
23
  Object.defineProperty(exports, "__esModule", { value: true });
20
24
  exports.composeSecureMalicious = composeSecureMalicious;
21
25
  const field_1 = require("./field");
26
+ const csprng_1 = require("./csprng");
22
27
  const spdz_1 = require("./spdz");
23
28
  const thermometer_1 = require("./thermometer");
24
29
  const party_1 = require("./party");
30
+ const compose_1 = require("./compose");
25
31
  const T_M = 3;
26
32
  /**
27
33
  * Compose stakeholder decision vectors under MALICIOUS-secure MPC. Returns the composed decision only
@@ -33,7 +39,9 @@ function composeSecureMalicious(vectors, cfg = {}) {
33
39
  if (n === 0)
34
40
  throw new Error('composeSecureMalicious: no parties (fail closed)');
35
41
  const Q = cfg.Q ?? party_1.DEFAULT_Q;
36
- const rng = new field_1.FieldRng(cfg.seed);
42
+ (0, compose_1.assertDecisionVectors)(vectors, Q);
43
+ // No seed => cryptographically secure randomness (see runner.ts); a seed is for reproducible tests only.
44
+ const rng = cfg.seed === undefined ? new csprng_1.SecureFieldRng() : new field_1.FieldRng(cfg.seed);
37
45
  // --- Offline: MAC key + authenticated input sharings + triples ---
38
46
  // Either a NO-DEALER provider (OT-based, mascot.ts) or the trusted dealer, behind one interface.
39
47
  const offline = cfg.offline;
@@ -43,7 +51,15 @@ function composeSecureMalicious(vectors, cfg = {}) {
43
51
  const ctx = offline ? offline.macContext : (0, spdz_1.setupMac)(n, rng);
44
52
  const engine = new spdz_1.SpdzEngine(ctx, cfg.deviations ?? []);
45
53
  let mults = 0;
46
- const nextTriple = () => (offline ? offline.genAuthTriple() : (0, spdz_1.genAuthTriple)(ctx, rng));
54
+ const verify = cfg.dealer?.verifyTriples ?? true;
55
+ const nextTriple = () => {
56
+ if (offline)
57
+ return offline.genAuthTriple();
58
+ if (!verify)
59
+ return cfg.dealer?.fault ? (0, spdz_1.genTripleWithPartners)(ctx, rng, 1, cfg.dealer.fault).keep : (0, spdz_1.genAuthTriple)(ctx, rng);
60
+ const dealt = (0, spdz_1.genTripleWithPartners)(ctx, rng, cfg.dealer?.partners ?? spdz_1.SACRIFICE_PARTNERS, cfg.dealer?.fault);
61
+ return (0, spdz_1.sacrificeVerify)([dealt], ctx, rng)[0];
62
+ };
47
63
  const shareBit = (bit, owner) => offline ? offline.authInput(BigInt(bit), owner) : (0, spdz_1.authShare)(BigInt(bit), ctx, rng);
48
64
  // Secure AND over authenticated bits = product.
49
65
  const andBits = (bits) => {
@@ -98,6 +114,8 @@ function composeSecureMalicious(vectors, cfg = {}) {
98
114
  Q,
99
115
  opens: engine.openCount,
100
116
  multiplications: mults,
117
+ offlineMode: offline ? 'no-dealer' : 'trusted-dealer',
118
+ triplesVerified: offline ? true : verify,
101
119
  macChecked: true,
102
120
  };
103
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spdz-runner.js","sourceRoot":"","sources":["../src/spdz-runner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAqDH,wDAmFC;AAtID,mCAAmC;AACnC,iCAYgB;AAEhB,+CAAqE;AACrE,mCAAyD;AA4BzD,MAAM,GAAG,GAAG,CAAC,CAAC;AAEd;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,OAAsC,EACtC,MAA0B,EAAE;IAE5B,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IACzB,IAAI,CAAC,K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AAC,CAAC,CAAc,CAAC;AAClD,CAAC"}
package/dist/spdz.d.ts CHANGED
@@ -19,11 +19,13 @@
19
19
  *
20
20
  * Security upgrade: semi-honest → **malicious-with-abort, dishonest-majority** (secure against up to
21
21
  * N−1 actively-corrupted parties; privacy and MAC-forgery-resistance both hold at the N−1 threshold).
22
- * The MAC is information-theoretic: forging a MAC on a wrong value succeeds with probability ≤ 2/p
23
- * (here ≈ 2^−60), independent of the adversary's computing power.
22
+ * The MAC is information-theoretic, independent of the adversary's computing power. ONE key over the 61-bit
23
+ * field is only ≈ 2^−60 sound, so every value carries `MAC_KEYS = 2` MACs under INDEPENDENT global keys, each
24
+ * with its own challenge vector, all checked in the same batched check: the forgery probability is
25
+ * ≤ (2/p)^2 ≈ 2^−120 (proof: docs/pca/security/pca-mpc-spdz-soundness.md; `macSoundnessBits`).
24
26
  *
25
27
  * OFFLINE-PHASE BOUNDARY (honest, see docs §7): the authenticated triples / input sharings below are
26
- * produced by a TRUSTED DEALER that honestly knows `α`. That keeps the *online* phase — openings,
28
+ * produced by a TRUSTED DEALER that honestly knows the MAC keys. That keeps the *online* phase — openings,
27
29
  * MAC updates, and the MAC-check — the real, maliciously-secure thing, with the dealer as the one
28
30
  * explicit trust assumption. A no-dealer offline phase (MASCOT/Overdrive: OT- or HE-based authenticated
29
31
  * triple generation, itself maliciously secure, with a distributed `α` nobody ever reconstructs) is
@@ -32,20 +34,30 @@
32
34
  * via `node:crypto`), modelling the commit-then-open round that defeats a rushing adversary.
33
35
  */
34
36
  import { FieldRng } from './field';
35
- /** The global SPDZ MAC key, additively shared. `alpha` is known to the DEALER only (and to tests). */
36
- export interface MacContext {
37
- n: number;
38
- /** α_i: party i's share of the MAC key. Σ α_i = α. No single party may learn α. */
37
+ /** One global SPDZ MAC key, additively shared. */
38
+ export interface MacKey {
39
+ /** α_i: party i's share of this key. Σ α_i = α. No single party may learn α. */
39
40
  alphaShares: bigint[];
40
- /** The global MAC key α. For dealer preprocessing + test inspection ONLY; never held by one party. */
41
+ /** The key α. For dealer preprocessing + test inspection ONLY; never held by one party. */
41
42
  alpha: bigint;
42
43
  }
43
- /** An authenticated secret-shared value: value shares summing to x, MAC shares summing to α·x. */
44
+ /**
45
+ * The global SPDZ MAC keys, additively shared. Key 0 is `alphaShares`/`alpha`; `extraKeys` are further
46
+ * INDEPENDENT keys (the statistical-security amplification: each is an independent 2/p test).
47
+ */
48
+ export interface MacContext extends MacKey {
49
+ n: number;
50
+ /** Independent keys 1..k-1. Every authenticated value carries one MAC per key. */
51
+ extraKeys: MacKey[];
52
+ }
53
+ /** An authenticated secret-shared value: value shares summing to x, MAC shares summing to α·x (per key). */
44
54
  export interface AuthSV {
45
55
  /** value shares x_i (Σ = x). */
46
56
  value: bigint[];
47
- /** MAC shares γ_i (Σ = α·x). */
57
+ /** MAC shares γ_i under key 0 (Σ = α·x). */
48
58
  mac: bigint[];
59
+ /** MAC shares under keys 1..k-1 (`extraMac[l-1]` sums to `extraKeys[l-1].alpha · x`). */
60
+ extraMac: bigint[][];
49
61
  }
50
62
  /** An authenticated Beaver triple: ⟦a⟧, ⟦b⟧, ⟦c⟧ with c = a·b, every component MAC'd. */
51
63
  export interface AuthTriple {
@@ -53,34 +65,80 @@ export interface AuthTriple {
53
65
  b: AuthSV;
54
66
  c: AuthSV;
55
67
  }
68
+ /** Number of independent MAC keys the trusted-dealer / no-dealer setups create by default. */
69
+ export declare const MAC_KEYS = 2;
70
+ /** The statistical security the MAC-check must provide, in bits. `SpdzEngine` refuses a weaker context. */
71
+ export declare const MIN_MAC_SOUNDNESS_BITS = 100;
72
+ /** All keys of a context, key 0 first. */
73
+ export declare function macKeys(ctx: MacContext): MacKey[];
74
+ /**
75
+ * Soundness (as -log2 of the forgery probability) of the batched MAC-check over a field of `fieldBits`
76
+ * bits (default: this field) with `keys` independent keys: per key the failure probability is ≤ 2/p
77
+ * (1/p for guessing the key, 1/p for a random combination hitting a non-zero residual), and the keys and
78
+ * challenge vectors are independent, so the total is ≤ (2/p)^keys. Returns `keys · (log2 p − 1)`.
79
+ */
80
+ export declare function macSoundnessBits(keys: number, p?: bigint): number;
56
81
  /** Raised when the SPDZ MAC-check detects an inconsistent opening/MAC: the protocol ABORTS, no output. */
57
82
  export declare class MacCheckAbort extends Error {
58
83
  constructor(message: string);
59
84
  }
60
- /** Dealer preprocessing: sample the global MAC key α and additively share it across n parties. */
61
- export declare function setupMac(n: number, rng: FieldRng): MacContext;
62
- /** Authenticated sharing of `secret` (dealer-side): value shares sum to x, MAC shares sum to α·x. */
85
+ /** Dealer preprocessing: sample `keys` independent global MAC keys and additively share each across n parties. */
86
+ export declare function setupMac(n: number, rng: FieldRng, keys?: number): MacContext;
87
+ /** Authenticated sharing of `secret` (dealer-side): value shares sum to x, MAC shares sum to α·x per key. */
63
88
  export declare function authShare(secret: bigint, ctx: MacContext, rng: FieldRng): AuthSV;
64
89
  /** Authenticated sharing of a PUBLIC constant c: value = shareConstant(c), MAC = share of α·c (via α_i·c). */
65
90
  export declare function authConstant(c: bigint, ctx: MacContext): AuthSV;
66
- /** ⟦x⟧ + ⟦y⟧ (local; MAC shares add, preserving Σγ = α·(x+y)). */
91
+ /** ⟦x⟧ + ⟦y⟧ (local; MAC shares add, preserving Σγ = α·(x+y) under every key). */
67
92
  export declare function addAuth(x: AuthSV, y: AuthSV): AuthSV;
68
93
  /** ⟦x⟧ − ⟦y⟧ (local). */
69
94
  export declare function subAuth(x: AuthSV, y: AuthSV): AuthSV;
70
95
  /** −⟦x⟧ (local). */
71
96
  export declare function negAuth(x: AuthSV): AuthSV;
72
- /** ⟦x⟧ · c for a PUBLIC scalar c (local): both value and MAC shares scale by c. */
97
+ /** ⟦x⟧ · c for a PUBLIC scalar c (local): value and every MAC share scale by c. */
73
98
  export declare function scaleAuth(x: AuthSV, c: bigint): AuthSV;
74
99
  /**
75
100
  * ⟦x⟧ + c for a PUBLIC constant c (local). The SPDZ public-constant rule: add c to ONE party's value
76
- * share, and add α_i·c to EVERY party's MAC share (each party holds α_i), so Σγ becomes α·x + α·c =
77
- * α·(x+c). This is what lets affine gates stay authenticated without any interaction.
101
+ * share, and add α_i·c to EVERY party's MAC share under EVERY key (each party holds its α_i), so Σγ becomes
102
+ * α·x + α·c = α·(x+c). This is what lets affine gates stay authenticated without any interaction.
78
103
  */
79
104
  export declare function addPublicAuth(x: AuthSV, c: bigint, ctx: MacContext): AuthSV;
80
105
  /** Logical NOT of an authenticated bit b: ⟦1 − b⟧ (local). */
81
106
  export declare function notBitAuth(b: AuthSV, ctx: MacContext): AuthSV;
82
107
  /** Dealer preprocessing: one authenticated triple (a, b, c=a·b), every component MAC'd. */
83
108
  export declare function genAuthTriple(ctx: MacContext, rng: FieldRng): AuthTriple;
109
+ /**
110
+ * Number of independent sacrifice partners per delivered triple. The sacrifice of one partner passes a
111
+ * triple with c ≠ a·b with probability ≤ 1/p (the random challenge must hit one value); `r` independent
112
+ * partners (each with its own challenge) give ≤ p^-r, so 2 partners ≈ 2^-122 > the 2^-100 floor.
113
+ */
114
+ export declare const SACRIFICE_PARTNERS = 2;
115
+ /** A triple to be delivered plus its sacrifice partners; every partner shares `keep.b` (same sharing). */
116
+ export interface TripleWithPartners {
117
+ keep: AuthTriple;
118
+ partners: AuthTriple[];
119
+ }
120
+ /**
121
+ * TEST-ONLY fault of a LYING trusted dealer: the dealer authenticates a wrong product, so the triple is
122
+ * internally MAC-consistent (the MACs are computed on the wrong c) - exactly the lie MACs alone cannot
123
+ * detect. `keepCDelta` makes the delivered triple's c = a·b + delta; `partnerCDelta[r]` does the same to
124
+ * sacrifice partner r.
125
+ */
126
+ export interface DealerFault {
127
+ keepCDelta?: bigint;
128
+ partnerCDelta?: Array<bigint | undefined>;
129
+ }
130
+ /** Trusted-dealer preprocessing of one triple together with its sacrifice partners (all sharing b). */
131
+ export declare function genTripleWithPartners(ctx: MacContext, rng: FieldRng, partners?: number, fault?: DealerFault): TripleWithPartners;
132
+ /**
133
+ * The MASCOT/SPDZ **sacrifice** check on a batch. For every kept triple (a,b,c) and each partner (â,b,ĉ)
134
+ * it draws a public random challenge e ≠ 0, opens ρ = e·a − â, forms ⟦τ⟧ = e·⟦c⟧ − ⟦ĉ⟧ − ρ·⟦b⟧ and opens
135
+ * it. If both triples are correct, τ = e·(c − ab) − (ĉ − âb) = 0; if c = ab + δ with δ ≠ 0, τ = e·δ − δ̂ is
136
+ * non-zero except for one value of e (prob 1/p), and independent partners multiply the failure
137
+ * probabilities. A lie in either opening is caught by the single batched MAC-check (all keys). Throws
138
+ * `MacCheckAbort` on any failure and emits NOTHING; otherwise returns the certified kept triples.
139
+ * The partners are consumed and must never be reused.
140
+ */
141
+ export declare function sacrificeVerify(batch: ReadonlyArray<TripleWithPartners>, ctx: MacContext, rng: FieldRng, deviations?: Deviation[]): AuthTriple[];
84
142
  /** A party's broadcast deviation in the ONLINE phase — the knob that lets tests model an active cheater. */
85
143
  export interface Deviation {
86
144
  /** 0-based index of the `open()` call to corrupt. */
@@ -91,7 +149,23 @@ export interface Deviation {
91
149
  valueDelta?: bigint;
92
150
  /** delta added to that party's MAC share carried into the MAC-check for that open (a forged MAC). */
93
151
  macDelta?: bigint;
152
+ /** which MAC key `macDelta` applies to (0 = key 0, default). */
153
+ macKey?: number;
154
+ }
155
+ /** One partial opening as it reaches the MAC-check: the public value and the MAC shares per key per party. */
156
+ export interface OpenedValue {
157
+ value: bigint;
158
+ /** macShares[key][party] */
159
+ macShares: bigint[][];
160
+ label: string;
94
161
  }
162
+ /**
163
+ * The arithmetic core of the batched SPDZ MAC-check, over an ARBITRARY prime modulus `p` so the very same
164
+ * code can be exercised on a deliberately tiny field (the soundness experiment in the tests). For each key
165
+ * l, with its own challenge vector r^(l): a^(l) = Σ_j r_j^(l)·v_j, and party i's residual share is
166
+ * σ_i^(l) = Σ_j r_j^(l)·γ_ij^(l) − α_i^(l)·a^(l). Returns σ[key][party]; honest data gives Σ_i σ_i^(l) = 0 for every l.
167
+ */
168
+ export declare function macResiduals(p: bigint, alphaShares: bigint[][], opened: ReadonlyArray<Pick<OpenedValue, 'value' | 'macShares'>>, challenges: bigint[][]): bigint[][];
95
169
  /**
96
170
  * The SPDZ online engine: performs partial openings (broadcast value shares, sum to the public value,
97
171
  * RETAIN the MAC shares for a single batched MAC-check at the end) and the MAC-check itself. A list of
@@ -114,11 +188,11 @@ export declare class SpdzEngine {
114
188
  */
115
189
  open(x: AuthSV, label?: string): bigint;
116
190
  /**
117
- * SPDZ MAC-check over every partial-open so far. Draws public random coefficients r_j (a secure
118
- * coin-flip in the real protocol; a seeded RNG here, documented), forms the public combination
119
- * a = Σ r_j·a_j and each party's residual share σ_i = (Σ r_j·γ_i(a_j)) − α_i·a, then runs
120
- * commit-then-open on the σ_i and checks Σ σ_i = 0. Honest runs give exactly 0; ANY inconsistent
121
- * opened value or forged MAC makes it non-zero with probability ≥ 1 − 2/p, and we ABORT.
191
+ * SPDZ MAC-check over every partial-open so far. For EACH key draws an independent public challenge
192
+ * vector (a secure coin-flip in the real protocol; the supplied RNG here), forms the residual shares
193
+ * (`macResiduals`), then runs commit-then-open on every σ and checks Σ σ = 0 for every key. Honest runs
194
+ * give exactly 0; ANY inconsistent opened value or forged MAC makes some key's sum non-zero with
195
+ * probability ≥ 1 − (2/p)^k, and we ABORT.
122
196
  *
123
197
  * The commit-then-open (SHA-256 binding commitment) models the round that stops a *rushing*
124
198
  * adversary from choosing its σ_i after seeing the others — it must commit before any are revealed.