How nemoyuan2008/md-ml works
Project type and purpose
• MD-ML is a C++20 research library implementing “MD-ML: Super Fast Privacy-Preserving Machine Learning for Malicious Security with a Dishonest Majority.”
• It provides a two-phase secure computation framework (offline preprocessing + online circuit evaluation) for neural-network inference and other linear/algebraic computations.
File structure
• Top-level: CMakeLists.txt, README.md, LICENSE, dummy.cpp
• src/
• utils/ → general helpers (Timer, tensor, linear_algebra, rand, IO)
• share/ → data representations (Spdz2kShare, Mod2PowN, IsSpdz2kShare)
• networking/ → Party class, handles peer-to-peer I/O and synchronization
• protocols/ → Gate abstractions (AddGate, MultiplyGate, Conv2DGate, Circuit, Input/Output Gate, etc.)
• fake-offline/→ simulation of offline preprocessing (FakeCircuit, FakeParty, FakeGate variants)
• experiments/ → concrete benchmarks and demos (dot-product, AlexNet on ImageNet), each with its own CMakeLists and party-0/party-1 executables
Insights from the README
• Build scripts orchestrate static library/executable creation for both the core library and the experiments.
Components
1. Application Layer (experiments/ executables)
2. Protocol Engine (src/protocols: Gate, Circuit, PartyWithFakeOffline)
3. Offline Preprocessing Module (src/fake-offline: FakeParty, FakeCircuit, FakeGate implementations)
4. Communication Layer (src/networking: Party class, sockets or TCP channels)
5. Share Abstraction (src/share: Spdz2kShare, Mod2PowN)
6. Utility Library (src/utils: Timer, tensor, linear algebra)
• Application → Protocol Engine: constructs circuit(s) and invokes Circuit::run()
• Protocol Engine → Offline Module: requests preprocessed triples/truncations via FakeParty API
• Protocol Engine ↔ Communication Layer: exchanges share-messages between parties in both phases
• Protocol Engine ↔ Share Abstraction: creates/manipulates Spdz2kShare objects for every gate operation
• All layers → Utility Library: for timing, random number generation, tensor ops
c. Architectural patterns & principles:
• Layered architecture (Utils → Share → Protocol → Application)
• Strategy/Plugin pattern for Gate implementations and for swapping real vs. fake offline preprocessing
• Peer-to-peer network topology for N parties (dishonest-majority setting)
• Circuit abstraction separating control flow from cryptographic primitives
d. Key technologies/frameworks:
• C++20 modules and templates for gate/share abstractions
• CMake for cross-platform build orchestration
• Boost.Asio (via Boost.System) or raw sockets for networking
• Eigen for local linear-algebra (conv2D, tensor manipulations)
Don’t overthink—capture every logical component and its dependencies.
• How CMake orchestrates building static libs and executables.