@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
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The offline material one party holds when the online phase starts, whichever way it was produced:
3
+ * dealt by a TRUSTED DEALER over the mesh (`protocol.ts` `runDealer`) or generated by the parties themselves
4
+ * from oblivious transfer with NO dealer (`offline-net.ts`).
5
+ */
6
+ import type { AW, PA } from './pa';
7
+ import type { Disclosure } from './forensics';
8
+ /** Number of sharings per delivered triple: a, b, c, then (a-hat, c-hat) for each sacrifice partner. */
9
+ export declare const sharingsPerTriple: (partners: number) => number;
10
+ export interface Prep {
11
+ /** Where this material came from. A `trusted-dealer` knows every share and key. */
12
+ mode: 'trusted-dealer' | 'no-dealer';
13
+ /** Whether the shares carry pairwise tags (identifiable abort). Only the trusted-dealer mode provides them. */
14
+ tagged: boolean;
15
+ /** My pairwise verification key Δ (0n when untagged). */
16
+ delta: bigint;
17
+ /** My share of each global MAC key, pairwise-authenticated. */
18
+ alpha: PA[];
19
+ /** Triples with their sacrifice partners: `triples[t] = [a, b, c, a-hat_1, c-hat_1, ...]` (partners share b). */
20
+ triples: AW[][];
21
+ /**
22
+ * trusted-dealer: the authenticated random MASKS r for each (owner, chain), `inputs[owner*C + c]`; the owner
23
+ * broadcasts x - r. no-dealer: the authenticated INPUT bits themselves, same indexing.
24
+ */
25
+ inputs: AW[];
26
+ /** My own plaintext side of `inputs`: the masks r (trusted-dealer) or my input bits (no-dealer), one per chain. */
27
+ myPlain: bigint[];
28
+ /** no-dealer only: an authenticated random mask for the input-consistency check. */
29
+ checkMask?: AW;
30
+ /** no-dealer only: the OT transcript of the triple products, for attributing a failed sacrifice (`forensics.ts`). */
31
+ forensics?: {
32
+ gadget: bigint[];
33
+ /** Choice bits per product item (the encoded width). */
34
+ rows: number;
35
+ /** Product slots per triple: the product and one per sacrifice partner. */
36
+ slots: number;
37
+ /** My disclosure for triple `t` (the triple is discarded when this is used). */
38
+ disclose: (t: number) => Disclosure;
39
+ };
40
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * The offline material one party holds when the online phase starts, whichever way it was produced:
4
+ * dealt by a TRUSTED DEALER over the mesh (`protocol.ts` `runDealer`) or generated by the parties themselves
5
+ * from oblivious transfer with NO dealer (`offline-net.ts`).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.sharingsPerTriple = void 0;
9
+ /** Number of sharings per delivered triple: a, b, c, then (a-hat, c-hat) for each sacrifice partner. */
10
+ const sharingsPerTriple = (partners) => 3 + 2 * partners;
11
+ exports.sharingsPerTriple = sharingsPerTriple;
12
+ //# sourceMappingURL=prep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prep.js","sourceRoot":"","sources":["../../src/net/prep.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAKH,wGAAwG;AACjG,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;AAAnE,QAAA,iBAAiB,qBAAkD"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The DISTRIBUTED malicious-with-abort (SPDZ-style) composition protocol (research prototype).
3
+ *
4
+ * Same circuit and semantics as `composeSecureMalicious` (allow = AND, t = MAX, r = MAX via
5
+ * thermometers; authenticated Beaver multiplication; batched MAC-check before any output), but each
6
+ * party is its OWN process holding ONLY its own shares, and every opening is a real message over the
7
+ * TLS mesh (`mesh.ts`). Rounds (n parties, C = 1 + 3 + Q independent chains, k = MAC_KEYS global keys):
8
+ *
9
+ * prep dealer -> party : [TRUSTED-DEALER mode] key shares, sacrificed-triple material, input masks, pairwise tags
10
+ * (or, in NO-DEALER mode, the OT-based offline phase of `offline-net.ts` runs here instead)
11
+ * coin1-* all-to-all : commit/open of a random seed -> public challenges for the triple sacrifice
12
+ * sac-rho all-to-all : value shares of rho = e*a - a-hat for every triple and sacrifice partner
13
+ * sac-tau all-to-all : value shares of tau = e*c - c-hat - rho*b; every tau must be 0
14
+ * inputs all-to-all : [dealer mode] owner broadcasts x - r (r is the owner's dealer-given mask)
15
+ * in-check all-to-all : [no-dealer mode] opening of a masked random combination of the inputs
16
+ * mul0.. all-to-all : value shares of d = x-a, e = y-b for all C chains at once (n-1 rounds)
17
+ * out all-to-all : value shares of the C output bits
18
+ * <rd>.t all-to-all : [dealer mode] after every opening, the pairwise tags: each receiver verifies
19
+ * the sender's opened shares IMMEDIATELY and blames the sender if one fails
20
+ * coin-c/o all-to-all : commit/open of a random seed -> public MAC-check challenges
21
+ * sig-c/o all-to-all : commit/open of each party's MAC residual shares (one per key); sums must be 0
22
+ * digest all-to-all : hash of the whole broadcast transcript; any disagreement aborts
23
+ * blame all-to-all : [only after a failed MAC-check, dealer mode] every party opens its combined MAC
24
+ * shares and key shares with their pairwise tags; each verifier checks them and
25
+ * names the party whose data is inconsistent (or the dealer, if none is)
26
+ *
27
+ * No output is decoded until the MAC-check and the transcript echo pass. Everything else (timeouts,
28
+ * malformed/duplicate/out-of-order frames, disconnects, aborts) is handled by the mesh.
29
+ *
30
+ * OFFLINE MODES (the result names which one ran): `trusted-dealer` - a separate process that knows every
31
+ * share and key (it can break privacy and integrity if it colludes; but a dealer that gives a WRONG triple is
32
+ * detected by the sacrifice, and a dealer that deals inconsistent MACs is named by the blame round); and
33
+ * `no-dealer` - the parties derive the MAC keys, triples, authenticated inputs and pairwise tags themselves
34
+ * from OT.
35
+ *
36
+ * IDENTIFIABLE ABORT: in BOTH modes every share is pairwise-authenticated (`pa.ts`; dealt by the dealer, or
37
+ * generated by the parties from OT in `offline-net.ts`), so a party that lies about a share, a tag, a MAC share
38
+ * or a residual in the ONLINE phase is named by the honest verifiers with first-hand evidence. What stays
39
+ * unnamed: in no-dealer mode, a wrong OT operand in the offline triple products (the sacrifice detects the bad
40
+ * triple but its tags are consistent with it) - named only for n = 2, where the peer is the only possible
41
+ * culprit; and a verifier's accusation is evidence for the accuser only, never proof for a third party.
42
+ * Network-level misbehaviour (framing, commitments, timeouts) is attributed in both modes.
43
+ *
44
+ * HONEST LIMITS: there is no security proof for this implementation; the echo-broadcast is a hash exchange, not
45
+ * a Byzantine agreement protocol; the trusted dealer is trusted for privacy.
46
+ */
47
+ import { type DealerFault } from '../spdz';
48
+ import type { ComposedDecision } from '../compose';
49
+ import type { DecisionVector } from '../party';
50
+ import type { Mesh } from './mesh';
51
+ export declare const T_M = 3;
52
+ /** Thrown by the test-only `silent` behaviour; the host process then idles with its sockets open. */
53
+ export declare class SilentParty extends Error {
54
+ constructor();
55
+ }
56
+ /** Number of independent circuit chains (= output bits = input bits per owner). */
57
+ export declare const chainCount: (Q: number) => number;
58
+ /** Test-only protocol-level misbehaviour for a (malicious) party. Never set in production. */
59
+ export interface Behavior {
60
+ kind: 'open-lie' | 'mac-lie' | 'bad-tag' | 'sigma-lie' | 'offline-lie' | 'ot-u-lie' | 'ot-proof-lie' | 'equivocate' | 'bad-coin-open' | 'bad-sigma-open' | 'short-array' | 'noncanonical' | 'crash' | 'silent';
61
+ round?: string;
62
+ }
63
+ export interface RoundStat {
64
+ rd: string;
65
+ ms: number;
66
+ bytesOut: number;
67
+ bytesIn: number;
68
+ }
69
+ export interface PartyResult {
70
+ id: number;
71
+ n: number;
72
+ Q: number;
73
+ composed: ComposedDecision;
74
+ rounds: RoundStat[];
75
+ transcriptDigest: string;
76
+ wallMs: number;
77
+ multiplications: number;
78
+ opens: number;
79
+ /** Where the preprocessing came from. */
80
+ offlineMode: 'trusted-dealer' | 'no-dealer';
81
+ /** Independent global MAC keys checked (statistical soundness ~ (2/p)^keys). */
82
+ macKeys: number;
83
+ /** Triples certified by the sacrifice check (each with `sacrificePartners` independent partners). */
84
+ sacrificedTriples: number;
85
+ sacrificePartners: number;
86
+ /** Whether aborts in this run were identifiable by pairwise tags. */
87
+ identifiableAbort: boolean;
88
+ }
89
+ export interface DealerConfig {
90
+ n: number;
91
+ Q?: number;
92
+ mesh: Mesh;
93
+ /** Deterministic stream for reproducible tests; omit in real runs (CSPRNG). */
94
+ seed?: bigint;
95
+ /** TEST ONLY: a LYING dealer that authenticates a wrong product c = a*b + delta. */
96
+ fault?: DealerFault;
97
+ /** TEST ONLY: a dealer that deals party 0 a MAC share of input mask number `macFaultAtInput` that does not match its value. */
98
+ macFaultAtInput?: number;
99
+ }
100
+ /**
101
+ * The TRUSTED DEALER role: samples the MAC keys, the verification keys, sacrifice-certified authenticated
102
+ * triples and authenticated input masks, and ships each party only its own slice. It never sees any party's
103
+ * input bit (inputs are masked by r and the masked value is broadcast only among parties), but it knows every
104
+ * key and share, so it can break privacy/integrity if it colludes with parties. That is the stated trust
105
+ * assumption of this mode. A dealer that deals a wrong triple is caught by the parties' sacrifice check.
106
+ */
107
+ export declare function runDealer(cfg: DealerConfig): Promise<void>;
108
+ export interface PartyConfig {
109
+ id: number;
110
+ n: number;
111
+ Q?: number;
112
+ input: DecisionVector;
113
+ mesh: Mesh;
114
+ /** Node id of the dealer (default n). */
115
+ dealerId?: number;
116
+ /** Which offline phase to run (default `trusted-dealer`). */
117
+ offline?: 'trusted-dealer' | 'no-dealer';
118
+ /** TEST ONLY: refused unless `unsafeTestHooks` is `true`. */
119
+ behavior?: Behavior;
120
+ /** Explicit opt-in for `behavior`. Leave unset in production. */
121
+ unsafeTestHooks?: boolean;
122
+ sessionId: string;
123
+ /** Deadline (ms) every party has to commit to and open its forensic disclosure; shared by all parties (default 30 s). */
124
+ forensicDeadlineMs?: number;
125
+ }
126
+ export declare function runParty(cfg: PartyConfig): Promise<PartyResult>;