Complete Technical Paper Content — Secure Multiparty Computation Ai
1. Executive Abstract, Problem Formulation & Background
Reward hacking or specification gaming occurs when an AI trained with reinforcement learning optimizes an objective function—achieving the literal, formal specification of an objective—without actually achieving an outcome that the programmers intended. DeepMind researchers have analogized it to the human behavior of finding a "shortcut" when being evaluated: "In the real world, when rewarded for doing well on a homework assignment, a student might copy another student to get the right answers, rather than learning the material—and thus exploit a loophole in the task specification". This idea is strongly associated with Goodhart's law, which argues that when a measure becomes a target, it ceases to be a good measure.
In Karl Sims' 1994 demonstration of creature evolution in a virtual environment, a fitness function that was expected to encourage the evolution of creatures that would learn to walk or crawl to a target resulted instead in the evolution of tall, rigid creatures that reached the target by falling over. This was patched by changing the environment so that taller creatures were forced to start farther from the target. Researchers from the Niels Bohr Institute stated in 1998 that their cycle-bot's reinforcement functions had "to be designed with great care." In their first experiments, "we rewarded the agent for driving towards the goal but did not punish it for driving away from it. Consequently, the agent drove in circles with a radius of 20–50 meters around the starting point. Such behavior was actually rewarded by the reinforcement function, furthermore circles with a certain radius are physically very stable when driving a bicycle". While setting up a 2011 experiment to test "survival of the flattest", experimenters attempted to ban mutations that altered the base reproduction rate. Every time a mutation occurred, the system would pause the simulation to test the new mutation in a test environment and would veto any mutations that resulted in a higher base reproduction rate. However, this resulted in mutated organisms that could recognize and suppress reproduction ("play dead") within the test environment. An initial patch, which removed cues that identified the test environment, failed to completely prevent runaway reproduction; new mutated organisms would "play dead" at random as a strategy to sometimes, by chance, outwit the mutation veto system. A 2017 DeepMind paper noted that "great care must be taken when defining the reward function," citing an unexpected failure when an agent flipped a brick because it received "a grasping reward calculated with the wrong reference point on the brick". OpenAI stated in 2017 that in some domains their semi-supervised system could result in agents "adopting policies that tricked evaluators," and that in one environment "a robot that was supposed to grasp items instead positioned its manipulator between the camera and the object so that it only appeared to be grasping it." A 2018 bug in OpenAI Gym could cause a robot expected to quietly move a block sitting atop a table to move the table instead. A 2020 collection of similar anecdotes posits that "evolution has its own 'agenda' distinct from the programmer's" and that "the first rule of directed evolution is 'you get what you select for'".
Homomorphic encryption is a form of encryption that allows computations to be performed on encrypted data without first having to decrypt it. The result of the computations are left in an encrypted form which, when decrypted, result in an output that is identical to that of the operations performed on the unencrypted data. Homomorphic encryption can be used for privacy-preserving outsourced storage and computation. This allows data to be encrypted and outsourced to commercial cloud environments for processing, all while encrypted. As an example of a practical application of homomorphic encryption: photographs can be scanned for regions of interest (ROI), the encrypted values of which are then compared to precomputed ROI of points of (touristical) interest, without revealing the contents of a photo. However, observation of side-channels can see a photograph being sent to a point-of-interest lookup service, revealing the fact that photographs were taken. Thus, homomorphic encryption eliminates the need for processing data in the clear, thereby preventing attacks that would enable an attacker to access that data while it is being processed, using privilege escalation. For sensitive data, such as healthcare information, homomorphic encryption can be used to enable new services by removing privacy barriers inhibiting data sharing or increasing security to existing services. For example, predictive analytics in healthcare can be hard to apply via a third-party service provider due to medical data privacy concerns. But if the predictive-analytics service provider could operate on encrypted data instead, without having the decryption keys, these privacy concerns are diminished. Moreover, even if the service provider's system is compromised, the data would remain secure.
Partially homomorphic encryption encompasses schemes that support the evaluation of circuits consisting of only one type of gate, e.g., addition or multiplication. Somewhat homomorphic encryption schemes can evaluate two types of gates, but only for a subset of circuits. Leveled fully homomorphic encryption supports the evaluation of arbitrary circuits composed of multiple types of gates of bounded (pre-determined) depth. Fully homomorphic encryption (FHE) allows the evaluation of arbitrary circuits composed of multiple types of gates of unbounded depth and is the strongest notion of homomorphic encryption. For the majority of homomorphic encryption schemes, the multiplicative depth of circuits is the main practical limitation in performing computations over encrypted data. Homomorphic encryption schemes are inherently malleable. In terms of malleability, homomorphic encryption schemes have weaker security properties than non-homomorphic schemes. A cryptosystem that supports arbitrary computation on ciphertexts is known as fully homomorphic encryption (FHE). Such a scheme enables the construction of programs for any desirable functionality, which can be run on encrypted inputs to produce an encryption of the result. Since such a program need never decrypt its inputs, it can be run by an untrusted party without revealing its inputs and internal state. Fully homomorphic cryptosystems have great practical implications in the outsourcing of private computations, for instance, in the context of cloud computing.
RSA cryptosystem (unbounded number of modular multiplications) ElGamal cryptosystem (unbounded number of modular multiplications) Goldwasser–Micali cryptosystem (unbounded number of exclusive or operations) Benaloh cryptosystem (unbounded number of modular additions) Paillier cryptosystem (unbounded number of modular additions) Sander-Young-Yung system (after more than 20 years solved the problem for logarithmic depth circuits) Boneh–Goh–Nissim cryptosystem (unlimited number of addition operations but at most one multiplication) Ishai-Paskin cryptosystem (polynomial-size branching programs)
The Brakerski-Gentry-Vaikuntanathan (BGV, 2011) scheme, building on techniques of Brakerski-Vaikuntanathan; The NTRU-based scheme by Lopez-Alt, Tromer, and Vaikuntanathan (LTV, 2012); The Brakerski/Fan-Vercauteren (BFV, 2012) scheme, building on Brakerski's scale-invariant cryptosystem; The NTRU-based scheme by Bos, Lauter, Loftus, and Naehrig (BLLN, 2013), building on LTV and Brakerski's scale-invariant cryptosystem; The security of most of these schemes is based on the hardness of the (Ring) Learning With Errors (RLWE) problem, except for the LTV and BLLN schemes that rely on an overstretched variant of the NTRU computational problem. This NTRU variant was subsequently shown vulnerable to subfield lattice attacks, which is why these two schemes are no longer used in practice. All the second-generation cryptosystems still follow the basic blueprint of Gentry's original construction, namely they first construct a somewhat homomorphic cryptosystem and then convert it to a fully homomorphic cryptosystem using bootstrapping. A distinguishing characteristic of the second-generation cryptosystems is that they all feature a much slower growth of the noise during the homomorphic computations. Additional optimizations by Craig Gentry, Shai Halevi, and Nigel Smart resulted in cryptosystems with nearly optimal asymptotic complexity: Performing T {\displaystyle T} operations on data encrypted with security parameter k {\displaystyle k} has complexity of only T ⋅ p o l y l o g ( k ) {\displaystyle T\cdot \mathrm {polylog} (k)} . These optimizations build on the Smart-Vercauteren techniques that enable packing of many plaintext values in a single ciphertext and operating on all these plaintext values in a SIMD fashion. Many of the advances in these second-generation cryptosystems were also ported to the cryptosystem over the integers. Another distinguishing feature of second-generation schemes is that they are efficient enough for many applications even without invoking bootstrapping, instead operating in the leveled FHE mode.
Unpadded RSA If the RSA public key has modulus n {\displaystyle n} and encryption exponent e {\displaystyle e} , then the encryption of a message m {\displaystyle m} is given by E ( m ) = m e mod n {\displaystyle {\mathcal {E}}(m)=m^{e}\;{\bmod {\;}}n} . The homomorphic property is then
E ( m 1 ) ⋅ E ( m 2 ) = m 1 e m 2 e mod n = ( m 1 m 2 ) e mod n = E ( m 1 ⋅ m 2 ) {\displaystyle {\begin{aligned}{\mathcal {E}}(m_{1})\cdot {\mathcal {E}}(m_{2})&=m_{1}^{e}m_{2}^{e}\;{\bmod {\;}}n\\[6pt]&=(m_{1}m_{2})^{e}\;{\bmod {\;}}n\\[6pt]&={\mathcal {E}}(m_{1}\cdot m_{2})\end{aligned}}}
2. Related Work, Literature Survey & Algorithmic Foundations
ElGamal In the ElGamal cryptosystem, in a cyclic group G {\displaystyle G} of order q {\displaystyle q} with generator g {\displaystyle g} , if the public key is ( G , q , g , h ) {\displaystyle (G,q,g,h)} , where h = g x {\displaystyle h=g^{x}} , and x {\displaystyle x} is the secret key, then the encryption of a message m {\displaystyle m} is E ( m ) = ( g r , m ⋅ h r ) {\displaystyle {\mathcal {E}}(m)=(g^{r},m\cdot h^{r})} , for some random r ∈ { 0 , … , q − 1 } {\displaystyle r\in \{0,\ldots ,q-1\}} . The homomorphic property is then
E ( m 1 ) ⋅ E ( m 2 ) = ( g r 1 , m 1 ⋅ h r 1 ) ( g r 2 , m 2 ⋅ h r 2 ) = ( g r 1 + r 2 , ( m 1 ⋅ m 2 ) h r 1 + r 2 ) = E ( m 1 ⋅ m 2 ) . {\displaystyle {\begin{aligned}{\mathcal {E}}(m_{1})\cdot {\mathcal {E}}(m_{2})&=(g^{r_{1}},m_{1}\cdot h^{r_{1}})(g^{r_{2}},m_{2}\cdot h^{r_{2}})\\[6pt]&=(g^{r_{1}+r_{2}},(m_{1}\cdot m_{2})h^{r_{1}+r_{2}})\\[6pt]&={\mathcal {E}}(m_{1}\cdot m_{2}).\end{aligned}}}
Goldwasser–Micali In the Goldwasser–Micali cryptosystem, if the public key is the modulus n {\displaystyle n} and quadratic non-residue x {\displaystyle x} , then the encryption of a bit b {\displaystyle b} is E ( b ) = x b r 2 mod n {\displaystyle {\mathcal {E}}(b)=x^{b}r^{2}\;{\bmod {\;}}n} , for some random r ∈ { 0 , … , n − 1 } {\displaystyle r\in \{0,\ldots ,n-1\}} . The homomorphic property is then
E ( b 1 ) ⋅ E ( b 2 ) = x b 1 r 1 2 x b 2 r 2 2 mod n = x b 1 + b 2 ( r 1 r 2 ) 2 mod n = E ( b 1 ⊕ b 2 ) . {\displaystyle {\begin{aligned}{\mathcal {E}}(b_{1})\cdot {\mathcal {E}}(b_{2})&=x^{b_{1}}r_{1}^{2}x^{b_{2}}r_{2}^{2}\;{\bmod {\;}}n\\[6pt]&=x^{b_{1}+b_{2}}(r_{1}r_{2})^{2}\;{\bmod {\;}}n\\[6pt]&={\mathcal {E}}(b_{1}\oplus b_{2}).\end{aligned}}}
where ⊕ {\displaystyle \oplus } denotes addition modulo 2, (i.e., exclusive-or).
Benaloh In the Benaloh cryptosystem, if the public key is the modulus n {\displaystyle n} and the base g {\displaystyle g} with a blocksize of c {\displaystyle c} , then the encryption of a message m {\displaystyle m} is E ( m ) = g m r c mod n {\displaystyle {\mathcal {E}}(m)=g^{m}r^{c}\;{\bmod {\;}}n} , for some random r ∈ { 0 , … , n − 1 } {\displaystyle r\in \{0,\ldots ,n-1\}} . The homomorphic property is then
E ( m 1 ) ⋅ E ( m 2 ) = ( g m 1 r 1 c ) ( g m 2 r 2 c ) mod n = g m 1 + m 2 ( r 1 r 2 ) c mod n = E ( m 1 + m 2 mod c ) . {\displaystyle {\begin{aligned}{\mathcal {E}}(m_{1})\cdot {\mathcal {E}}(m_{2})&=(g^{m_{1}}r_{1}^{c})(g^{m_{2}}r_{2}^{c})\;{\bmod {\;}}n\\[6pt]&=g^{m_{1}+m_{2}}(r_{1}r_{2})^{c}\;{\bmod {\;}}n\\[6pt]&={\mathcal {E}}(m_{1}+m_{2}\;{\bmod {\;}}c).\end{aligned}}}
Paillier In the Paillier cryptosystem, if the public key is the modulus n {\displaystyle n} and the base g {\displaystyle g} , then the encryption of a message m {\displaystyle m} is E ( m ) = g m r n mod n 2 {\displaystyle {\mathcal {E}}(m)=g^{m}r^{n}\;{\bmod {\;}}n^{2}} , for some random r ∈ { 0 , … , n − 1 } {\displaystyle r\in \{0,\ldots ,n-1\}} . The homomorphic property is then
3. Dataset Ingestion, Preprocessing & Stochastic Augmentations
E ( m 1 ) ⋅ E ( m 2 ) = ( g m 1 r 1 n ) ( g m 2 r 2 n ) mod n 2 = g m 1 + m 2 ( r 1 r 2 ) n mod n 2 = E ( m 1 + m 2 ) . {\displaystyle {\begin{aligned}{\mathcal {E}}(m_{1})\cdot {\mathcal {E}}(m_{2})&=(g^{m_{1}}r_{1}^{n})(g^{m_{2}}r_{2}^{n})\;{\bmod {\;}}n^{2}\\[6pt]&=g^{m_{1}+m_{2}}(r_{1}r_{2})^{n}\;{\bmod {\;}}n^{2}\\[6pt]&={\mathcal {E}}(m_{1}+m_{2}).\end{aligned}}}
Okamoto–Uchiyama cryptosystem Naccache–Stern cryptosystem Damgård–Jurik cryptosystem Sander–Young–Yung encryption scheme Boneh–Goh–Nissim cryptosystem Ishai–Paskin cryptosystem Joye-Libert cryptosystem Castagnos–Laguillaumie cryptosystem
NssMPClib - A General-Purpose Secure Multi-Party Computation Library Based on PyTorch Introduction NssMPClib is a secure multi-party computation (MPC) library designed specifically for machine learning, offering familiar PyTorch-style APIs that make privacy-preserving machine learning development as straightforward as regular PyTorch programming. It implements diverse privacy-preserving computation protocols based on both Arithmetic Secret Sharing and Function Secret Sharing. Key Features PyTorch Integration : Leverages PyTorch tensor operations for ease of use Torch-like APIs : Familiar APIs for seamless transition from standard PyTorch to secure computation Multiple Security Models : Supports both Semi-Honest and Honest-Majority security assumptions Flexible Party Configurations : 2-party and 3-party computation setups Multiple Secret Sharing Schemes : Additive Secret Sharing (2-party) Replicated Secret Sharing (3-party) Function Secret Sharing (FSS) implementations with multiple variants: Privacy-Preserving Neural Network Inference : Support for secure model evaluation Ring-based Computation : All operations performed on finite rings for cryptographic security System Requirements OS : Linux is the primary supported platform; Windows works for CPU-only installs (and CUDA installs with matching toolchain) but is less tested. Python : 3.10 or higher (recommended: 3.12) PyTorch : >=2.5.0 (recommended: 2.7.1 or newer compatible release) C/C++ compiler : required because torchcsprng always builds a native extension. On Linux: gcc / g++ (e.g. sudo apt-get install build-essential ). On Windows: install Build Tools for Visual Studio with the "Desktop development with C++" workload. CUDA toolkit : optional, only for GPU acceleration. Match the toolkit version to torch.version.cuda . Installation NssMPClib bundles CUDA extensions and CUTLASS submodules. The included advice script inspects your environment (Python, PyTorch, CUDA, nvcc, GPU, submodules) and reports whether the machine is ready to install. It is read-only and never installs anything itself; when something is missing, it names the required package or version instead of trying to generate platform-specific commands. Step 1: Clone with submodules git clone --recursive https://github.com/XidianNSS/NssMPClib.git cd NssMPClib If you cloned without --recursive , run git submodule update --init --recursive . Step 2: Check your environment python3 scripts/installation_advice.py If prerequisites (PyTorch, matching CUDA Toolkit / nvcc, submodules) are missing, the script prints a FAIL item with the required version or condition. Apply the fix that matches your OS/package manager and rerun the script until the diagnosis passes or only reports intentional warnings. Step 3: Install NssMPClib Once the check passes, the standard editable install is: pip install -e . --no-build-isolation Because --no-build-isolation reuses your environment instead of bootstrapping a clean one, setuptools and wheel must already be installed there. The advice script flags it explicitly if either is missing; install them with pip install --upgrade setuptools wheel and rerun. CUDA torch + matching nvcc + GPU visible : setup.py auto-detects CUDA_HOME (by scanning /usr/local/cuda-* for the nvcc release matching torch.version.cuda ) and TORCH_CUDA_ARCH_LIST (from visible GPUs), then builds the CUTLASS and CUDA torchcsprng extensions. CPU-only torch : setup.py skips the CUTLASS extension (since torch.version.cuda is unset) and csprng/setup.py skips its CUDA build (since torch.cuda.is_available() is False), so the same command above works as-is — no env vars needed. The NSSMPC_SKIP_CUTLASS=1 NSSMPC_SKIP_CSPRNG_CUDA=1 variant is only needed in edge cases (CUDA torch installed but nvcc missing / no GPU / broken toolchain); the advice script reports when those skip flags are already part of the selected installation path. Step 4: Generate cryptographic parameters python3 scripts/offline_parameter_generation.py Note : Parameters are saved to ~/NssMPClib/data/ (32-bit in data/32/ , 64-bit in data/64/ ). Quick Start: 2-Party Computation Example Party 0 - party_0.py : from nssmpc import Party2PC , PartyRuntime , SEMI_HONEST , SecretTensor import torch party = Party2PC ( 0 , SEMI_HONEST ) with PartyRuntime ( party ): party . online () x = torch . rand ([ 10 , 10 ]) share_x = SecretTensor ( tensor = x ) result = share_x . recon (). convert_to_real_field () print ( "Server result:" , result ) Party 1 - party_1.py : from nssmpc import Party2PC , PartyRuntime , SEMI_HONEST , SecretTensor client = Party2PC ( 1 , SEMI_HONEST ) with PartyRuntime ( client ): client . online () share_x = SecretTensor ( src_id = 0 ) result = share_x . recon (). convert_to_real_field () print ( "Client result:" , result ) Execution : # Terminal 1: Start server python party_0.py # Terminal 2: Start client (in separate terminal) python party_1.py Running Built-in Examples 1. Arithmetic Secret Sharing (2-Party) cd tests/primitives/secret_sharing/ # Terminal 1: python -m unittest test_ass_p0.py # Terminal 2: python -m unittest test_ass_p1.py 2. Neural Network Inference (2-Party) cd tests/application/neural_network/2pc/ # Terminal 1: python neural_network_P0.py # Terminal 2: python neural_network_P1.py 3. Replicated Secret Sharing (3-Party) cd tests/primitives/secret_sharing/ # Terminal 1: python -m unittest test_rss_p0.py # Terminal 2: python -m unittest test_rss_p1.py # Terminal 3: python -m unittest test_rss_p2.py Configuration Configure the library in nssmpc/config/configs.json : { "BIT_LEN" : 32 , // Ring size: 32 or 64 bits "DEVICE" : " cuda " , // Compute device: "cpu" or "cuda" "DTYPE" : " float " , // Data type: "float" or "int" "SCALE_BIT" : 8 , // Fixed-point scaling bits "DEBUG_LEVEL" : 2 // Debug level: 0-Secure, 1-Testing, 2-Development } DEBUG_LEVEL Details : 0 (Secure Mode) : Highest security. All pre-generated keys are destroyed after use, strictly following the One-Time Pad principle. 1 (Testing Mode) : Performance-optimized. Inputs with the same dimensions reuse the same set of keys, facilitating performance testing and batch operations. 2 (Development Mode) : Convenient for development. Uses a single globally-shared pre-generated key for all operations. ONLY for non-sensitive development environments . Usage Scenarios : DEBUG_LEVEL: 0 - Production environments with real sensitive data DEBUG_LEVEL: 1 - Performance testing environments, evaluating performance across different input sizes DEBUG_LEVEL: 2 - Protocol development environments, quickly verifying functional correctness Project Structure NssMPClib/ ├── nssmpc/ # Main library source │ ├── application/ # Privacy-preserving applications │ ├── config/ # Configuration files │ ├── infra/ # Infrastructure components │ ├── primitives/ # Cryptographic primitives │ ├── protocols/ # MPC protocols │ └── runtime/ # Runtime coordination ├── data/ # Precomputed cryptographic parameters ├── tests/ # Test suite and examples ├── tutorials/ # Detailed tutorials └── scripts/ # Utility scripts Precomputed Cryptographic Parameters The library uses pre-generated parameters for efficiency. Key types include: Parameter Type Purpose Typical Use AssMulTriples Multiplication in Arithmetic Secret Sharing 2-party computation BooleanTriples AND operations in Boolean Secret Sharing Secure comparison RssMulTriples Multiplication in Replicated Secret Sharing 3-party computation DICFKey Distributed Interval Containment Function Secure comparison GeLUKey Gaussian Error Linear Unit activation Neural networks and so on... Tutorials Detailed tutorials are available in the tutorials/ directory: Tutorial Description Tutorial 0 Library setup and configuration Tutorial 1 2-party secure computation Tutorial 2 3-party secure computation Tutorial 3 Privacy-preserving neural network inference Tutorial 4 Advanced internal components Best Practices Separate Processes : Each party must run in separate terminals Use Runtime Context : Always wrap operations in with PartyRuntime(party): Parameter Management : Generate parameters before first use Security Selection : Use DEBUG_LEVEL=0 for production, DEBUG_LEVEL=2 for development Troubleshooting Common Issues: "Parameters not found" Error : python3 scripts/offline_parameter_generation.py Port Already in Use : Change base port in configs.json or kill existing processes. CUDA Errors : Set DEVICE: "cpu" in config or check CUDA installation. Install-time CUDA / submodule errors (e.g. RuntimeError: The detected CUDA version (X.Y) mismatches ... , or fatal error: cutlass/...: No such file or directory ): Rerun the advice script. It will tell you whether the missing requirement is a matching CUDA Toolkit / nvcc version, a compatible PyTorch build, missing submodules, or an intentional CPU/skip-CUDA path: python3 scripts/installation_advice.py Contributing We welcome contributions! Please: Fork the repository Create a feature branch Add tests for new functionality Ensure all tests pass Submit a pull request Citation If you use NssMPClib in your research, please cite: @software{nssmpclib, title = {NssMPClib: Secure Multi-Party Computation Library}, author = {Xidian University NSS Lab}, year = {2024}, url = {https://github.com/XidianNSS/NssMPClib} } License NssMPClib is released under the MIT License. See the LICENSE file for details. Contact Email : xidiannss@gmail.com GitHub : https://github.com/XidianNSS/NssMPClib Issues : https://github.com/XidianNSS/NssMPClib/issues Acknowledgements Maintained by the Network and System Security (NSS) Laboratory at Xidian University.
NssMPClib is a secure multi-party computation (MPC) library designed specifically for machine learning, offering familiar PyTorch-style APIs that make privacy-preserving machine learning development as straightforward as regular PyTorch programming.
It implements diverse privacy-preserving computation protocols based on both Arithmetic Secret Sharing and Function Secret Sharing.
NssMPClib bundles CUDA extensions and CUTLASS submodules. The included advice script inspects your environment (Python, PyTorch, CUDA, nvcc, GPU, submodules) and reports whether the machine is ready to install. It is read-only and never installs anything itself; when something is missing, it names the required package or version instead of trying to generate platform-specific commands.
If prerequisites (PyTorch, matching CUDA Toolkit / nvcc, submodules) are missing, the script prints a FAIL item with the required version or condition. Apply the fix that matches your OS/package manager and rerun the script until the diagnosis passes or only reports intentional warnings.
Because --no-build-isolation reuses your environment instead of bootstrapping a clean one, setuptools and wheel must already be installed there. The advice script flags it explicitly if either is missing; install them with pip install --upgrade setuptools wheel and rerun.
4. Neural Network Backbone, Layer Specifications & Loss Formulations
The NSSMPC_SKIP_CUTLASS=1 NSSMPC_SKIP_CSPRNG_CUDA=1 variant is only needed in edge cases (CUDA torch installed but nvcc missing / no GPU / broken toolchain); the advice script reports when those skip flags are already part of the selected installation path.
Note : Parameters are saved to ~/NssMPClib/data/ (32-bit in data/32/ , 64-bit in data/64/ ).
from nssmpc import Party2PC , PartyRuntime , SEMI_HONEST , SecretTensor import torch party = Party2PC ( 0 , SEMI_HONEST ) with PartyRuntime ( party ): party . online () x = torch . rand ([ 10 , 10 ]) share_x = SecretTensor ( tensor = x ) result = share_x . recon (). convert_to_real_field () print ( "Server result:" , result )
from nssmpc import Party2PC , PartyRuntime , SEMI_HONEST , SecretTensor client = Party2PC ( 1 , SEMI_HONEST ) with PartyRuntime ( client ): client . online () share_x = SecretTensor ( src_id = 0 ) result = share_x . recon (). convert_to_real_field () print ( "Client result:" , result )
# Terminal 1: Start server python party_0.py # Terminal 2: Start client (in separate terminal) python party_1.py
cd tests/primitives/secret_sharing/ # Terminal 1: python -m unittest test_ass_p0.py # Terminal 2: python -m unittest test_ass_p1.py
cd tests/application/neural_network/2pc/ # Terminal 1: python neural_network_P0.py # Terminal 2: python neural_network_P1.py
cd tests/primitives/secret_sharing/ # Terminal 1: python -m unittest test_rss_p0.py # Terminal 2: python -m unittest test_rss_p1.py # Terminal 3: python -m unittest test_rss_p2.py
5. Training Protocol, Convergence Behavior & Experimental Evaluation
{ "BIT_LEN" : 32 , // Ring size: 32 or 64 bits "DEVICE" : " cuda " , // Compute device: "cpu" or "cuda" "DTYPE" : " float " , // Data type: "float" or "int" "SCALE_BIT" : 8 , // Fixed-point scaling bits "DEBUG_LEVEL" : 2 // Debug level: 0-Secure, 1-Testing, 2-Development }
NssMPClib/ ├── nssmpc/ # Main library source │ ├── application/ # Privacy-preserving applications │ ├── config/ # Configuration files │ ├── infra/ # Infrastructure components │ ├── primitives/ # Cryptographic primitives │ ├── protocols/ # MPC protocols │ └── runtime/ # Runtime coordination ├── data/ # Precomputed cryptographic parameters ├── tests/ # Test suite and examples ├── tutorials/ # Detailed tutorials └── scripts/ # Utility scripts
Install-time CUDA / submodule errors (e.g. RuntimeError: The detected CUDA version (X.Y) mismatches ... , or fatal error: cutlass/...: No such file or directory ): Rerun the advice script. It will tell you whether the missing requirement is a matching CUDA Toolkit / nvcc version, a compatible PyTorch build, missing submodules, or an intentional CPU/skip-CUDA path:
@software{nssmpclib, title = {NssMPClib: Secure Multi-Party Computation Library}, author = {Xidian University NSS Lab}, year = {2024}, url = {https://github.com/XidianNSS/NssMPClib} }
A secure multi-party computation library based on arithmetic secret sharing and function secret sharing.
smpc-dl-notes A repository containing detailed notes and figures on commonly secure multiparty computation protocols and schemes as well as relevant deep learning concepts and frameworks Repository Link: https://mpc-colab.github.io/smpc-dl-notes/
A repository containing detailed notes and figures on commonly secure multiparty computation protocols and schemes as well as relevant deep learning concepts and frameworks
A repository containing detailed notes and figures on commonly secure multiparty computation protocols and schemes as well as relevant deep learning concepts and frameworks
Model Figures & Evaluation Curves (4 Images)
Deep Learning Execution Pipeline
(Preprocessing)
(Feature Extraction)
(Self-Attention)
(Loss Optimization)