SPDZCoder: Combining Expert Knowledge with LLMs for Generating Privacy-Computing Code
Privacy computing receives increasing attention but writing privacy computing code remains challenging for developers due to limited library functions, necessitating function implementation from scratch, and data-obliviousness requirement, contradicting intuitive thinking and usual practices of programmers. Automating the generation of privacy computing code with large language models (LLMs) can streamline development effort and lower the barrier to using privacy computing frameworks since LLMs exhibit strong capabilities in coding tasks. However, existing LLMs still encounter challenges in code translation for privacy-preserving computation—such as translating Python to MP-SPDZ—due to the scarcity of MP-SPDZ data required for effective pre-training or fine-tuning. Moreover, the lack of benchmark further hinders the evaluation of translation quality. To address the limitations, this work proposes SPDZCoder, a training-free framework that combines LLMs with expert knowledge for generating privacy computing code. Specifically, SPDZCoder employs a rigorous procedure for collecting high-quality expert knowledge to represent the semantic-expressing differences between Python and MP-SPDZ, and derives transformation rules for translating Python to MP-SPDZ based on these knowledge. Then, SPDZCoder progressively converts Python code into MP-SPDZ code using transformation rules in a three-stage pipeline. To evaluate SPDZCoder, we manually constructed a benchmark dataset, SPDZEval, which comprises six data splits, each representing a distinct class of challenging tasks in MP-SPDZ implementation. Extensive experiments demonstrate that SPDZCoder achieves superior performance, significantly surpassing baselines in pass@1 and pass@2. Specifically, SPDZCoder with GPT-4 as its backbone attains overall correctness values of \\(85.94\\%\\) and \\(92.01\\%\\) in pass@1 and pass@2, respectively, whereas the best-performing baseline achieves only \\(63.58\\%\\) and \\(76.36\\%\\) , respectively.
Authors
- Xiaoning Dong
- Wei Xu (ORCID: https://orcid.org/0000-0002-9271-0223)
- Yanlin Wang (ORCID: https://orcid.org/0000-0001-7761-7269)
- Jia Li (ORCID: https://orcid.org/0000-0002-5579-8852)
- Ling Huang (ORCID: https://orcid.org/0000-0003-1562-1371)
- Peilin Xin (ORCID: https://orcid.org/0009-0000-9645-4215)
Institutions
- Sun Yat-sen University (CN)
- ShangHai JiAi Genetics & IVF Institute (CN)
- Nuctech (China) (CN)
- Tsinghua University (CN)
Publication Details
- Journal
- ACM Transactions on Software Engineering and Methodology
- Published
- 2026-09-18
- DOI
- https://doi.org/10.1145/3845985
- Primary Topic
- Advanced Malware Detection Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00