Efficient MPC mixed protocol compiling method and compiler aiming at Java language

By combining the OPA Mixing compilation front-end and the ABY framework compilation back-end, efficient MPC hybrid protocol compilation in Java is achieved, addressing the shortcomings of existing compilers in protocol conversion overhead and efficiency, providing optimal protocol combination and automatic allocation in polynomial time, and improving the efficiency and flexibility of secure computing.

CN120780310APending Publication Date: 2025-10-14ZHEJIANG UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510853978.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-10-14

AI Technical Summary

Technical Problem

Existing MPC compilers have shortcomings in protocol conversion overhead and execution efficiency, and cannot meet the efficiency requirements of practical applications. Especially in specific scenarios such as privacy-preserving reasoning, traditional compilers cannot effectively utilize different types of secure multi-party computing protocols at the same time.

Method used

An efficient MPC hybrid protocol compiler for the Java language is designed. The OPA Mixing compiler front-end is used to parse Java programs into a static single assignment form. An integer programming solver is used to assign the optimal MPC protocol to each operation or module. Circuit evaluation is performed in conjunction with the ABY framework's compilation back-end, supporting flexible combinations of arithmetic, Boolean, and Yao's secret sharing protocols.

Benefits of technology

It achieves the globally optimal protocol combination within polynomial time, improves the automation and efficiency of protocol allocation, reduces protocol conversion overhead, supports multiple privacy protection and secure computing scenarios, and is easy to integrate into existing systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120780310A_ABST
    Figure CN120780310A_ABST
Patent Text Reader

Abstract

The invention provides an efficient and safe multi-party computing hybrid protocol compiler aiming at a Java language and a compiling method of the efficient and safe multi-party computing hybrid protocol compiler. The compiler comprises a compilation front end based on optimal protocol distribution mixing, an integer programming solver, a circuit converter and a compilation rear end based on an ABY framework; the compiling front end analyzes a program compiled by a Java language into a static single assignment (SSA) form, and converts the SSA form into an MPC-source; the integer programming solver is used for distributing an optimal MPC protocol for each operation or module in the MPC-source; the circuit converter is used for converting the MPC-source into an actual circuit framework constructed on the basis of ABY framework basic operation; and the compiling rear end evaluates the circuit by adopting a corresponding MPC protocol so as to obtain a target output of safe calculation. According to the method, multiple secure multi-party computing protocols are used in a mixed manner, and optimal protocol allocation is performed by adopting an integer programming method, so that the computing and communication overhead is effectively reduced, and the execution efficiency of secure computing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of computer security, and particularly relates to a secure multi-party computation (MPC) compiler technology. More particularly, the present application relates to an efficient MPC hybrid protocol compiler for Java language. BACKGROUND

[0002] Early MPC research focuses on the construction of basic protocols, such as Yao's garbled circuit protocol, GMW protocol and BGW protocol, etc. Yao's garbled circuit protocol exhibits unique advantages in two-party computing scenarios. It ensures the confidentiality of the computing process through a unique garbled truth table mechanism, but due to the large communication overhead, the efficiency is limited in practical applications. GMW protocol is designed based on the semi-honest model, and uses XOR operation to realize secret sharing, effectively reducing the computing and communication load. BGW protocol is aimed at arithmetic circuits, and uses Shamir secret sharing technology to build a multi-party computing framework, providing a solution for complex computing tasks.

[0003] In order to more conveniently convert high-level language source programs into circuit structures, MPC compilers have emerged. Early MPC compilers, such as: 1. MALKHID, NISAN N, PINKAS B, etc. in 2004 USENIX Security Conference published "Fairplay-Secure Two-Party Computation System", which proved the feasibility of a general MPC compiler; 2. DAMGARD (I), GEISLER (M), KREIGL (H), etc. in 2007 ACM Conference on Computer and Communications Security published "Sharing Decisions: Secure Multi-Party Computation and its Applications", which proposed a general MPC compiler based on the semi-honest model.

[0004] (DAMGARD (I), GEISLER (M), KREIGL (H), etc. in 2007 ACM Conference on Computer and Communications Security published "Sharing Decisions: Secure Multi-Party Computation and its Applications", which proposed a general MPC compiler based on the semi-honest model. ​M) et al. in 2009, "Asynchronous Multiparty Computation: Theory and Implementation", presented at the International Conference on Public Key Cryptography, further advanced the field; 3、BURKHART M, STRASSER M, MANY D et al. in 2010, "SEPIA: Privacy-Preserving Aggregation of Multi-Domain Network Events and Statistics", presented at the 19th USENIX Security Symposium (USENIX Security 10), among others, collectively demonstrating the feasibility of designing a general-purpose MPC compiler.

[0005] Typical hybrid protocol compilers include: 1、DEMMLER D, SCHNEIDER T, ZOHNER M in 2015, "ABY - A Framework for Efficient Mixed-Protocol Secure Two-Party Computation", presented at the Symposium on Network and Distributed System Security (NDSS), which supports flexible combinations of different protocols to optimize computational efficiency; 2、BISCHER N, DEMMLER D, KATZENBEISSER S et al. in 2018, "HyCC: Compilation of Hybrid Protocols for Practical Secure Computation", presented at the ACM Conference on Computer and Communications Security (CCS), which achieves efficient and automated deployment of hybrid protocols through compilation techniques; 3、RIAZIM S, WEINERT C, TKACHENKO O et al. in 2018, "Chameleon: A Hybrid Secure Computation Framework for Machine Learning Applications", presented at the ACM Asia Conference on Computer and Communications Security (ASIACCS), which supports the efficient and secure computation of machine learning algorithms.

[0006] ​(Chameleon:A Hybrid Secure Computation Framework for Machine LearningApplications), etc. The above hybrid compiler can use different protocols for different computing tasks, and some customized processing logic is made for the scene of its respective application.

[0007] However, the computing backend of the traditional MPC compiler usually only uses one secure multi-party computing protocol, and cannot use Yao's garbled circuit and arithmetic sharing protocols at the same time. The demand of actual computing tasks is complex and diverse, and different protocol types have their own advantages in computing types. Therefore, designing a hybrid protocol compiler that uses multiple protocols for secure evaluation at the same time has become a popular research topic. Although the existing MPC hybrid protocol compiler increases the overhead of protocol conversion, compared with the single protocol compiler, the performance of the hybrid protocol compiler is often better, but there is still room for improvement in protocol allocation strategy, cost model accuracy and optimization for specific application scenarios. In the specific scene of privacy-preserving inference, the execution efficiency is still much lower than that of clear computing, which cannot meet the efficiency requirements of actual applications. SUMMARY

[0008] The purpose of the present application is to provide an efficient MPC hybrid protocol compilation method and compiler for Java language, which can effectively reduce the overhead of protocol conversion, realize efficient circuit parallel computing, and greatly improve the efficiency of protocol allocation. By introducing a circuit converter, the operations and control flow structures in MPC-source code, i.e. linearized code (MPC-source), are mapped and compiled into Yao's garbled circuit, Boolean circuit and arithmetic circuit as a module for each function, which makes the logical circuit generated by the OPA Mixing-based compilation front-end directly applicable to the ABY framework-based compilation back-end, greatly facilitating the subsequent circuit evaluation process. The present application has wide versatility and can be applied to various privacy protection and secure computing scenarios, and is easy to integrate into existing system architecture, providing an efficient and reliable technical solution for users.

[0009] The technical scheme adopted by the present application is as follows: an efficient MPC hybrid protocol compiler for Java language, comprising: an OPA Mixing (optimal protocol allocation mixing) based compilation front-end for parsing a program written in Java language into a static single assignment (SSA) form, and converting the static single assignment (SSA) form into MPC-source, which is a linearized code representation containing all information required by MPC protocol;

[0010] The optimal protocol assignment (OPA) problem is solved by an integer programming solver, which assigns the optimal MPC protocol for each operation or module in the MPC-source according to a predefined cost model based on the cumulative operator overhead, and a circuit transformer transforms the MPC-source into a real circuit framework based on the ABY framework basic operations;

[0011] The ABY framework is a hybrid protocol framework that combines arithmetic secret sharing A, Boolean secret sharing B, and Yao's secret sharing Y.

[0012] The ABY framework-based compilation backend evaluates the circuit using the corresponding MPC protocol to obtain the target output of secure computation.

[0013] Preferably, the compilation front end parses the program written in Java language into static single assignment (SSA) form and converts the SSA form into MPC-source, including:

[0014] Syntax analysis is performed in the Java source code to build an abstract syntax tree (AST), so that each syntax structure is represented as a node in the tree, and the overall structure of the source code is composed of nodes, i.e. AST = {n1, n2, n3, …, n m};

[0015] Based on the construction of control flow graph (CFG), the AST obtained in step (2.1) is converted into CFG, so that each basic block (a series of sequentially executed statements) is represented as a node in CFG, and the edges between nodes represent the transfer of control flow, and the control flow structure of the program is composed of nodes and edges, i.e. CFG = {B1, B2, B3, …, B p};

[0016] Data flow analysis is performed, including live variable analysis and reachability definition analysis, to determine the lifetime and scope of each variable in the program, i.e. DFA = {d1, d2, d3, …, d q};

[0017] The CFG and data flow analysis results are converted into SSA form, so that each variable is assigned only once, and all control flow branches (such as if-else statements) are converted into φ nodes for merging values on different paths;

[0018] The variable definitions and control flow structures in SSA form are identified, and all conditional statements (e.g. if-else) are replaced by multiplexer (MUX) statements, while loop structures remain unchanged. In addition, all phi nodes are replaced by pseudo phi nodes (?) to represent variable updates in loops. The SSA code is further converted into MPC-source.

[0019] Preferably, the pseudo phi node is used in MPC-source to represent variable updates in loops. It gets the initial value from outside in the first iteration, and gets the value from the result of the previous iteration in the subsequent iterations. For the pseudo phi node x1 = (i == 0)? x0 : x2; represents if this is the first iteration, x1 takes the value of x0; otherwise, x1 takes the value of x2.

[0020] Preferably, the multiplexer (MUX) is a common MPC operation that selects different values according to conditions. Res = MUX(x, y, cnd) represents if the value of cnd is true, Res takes the value of x; otherwise, Res takes the value of y.

[0021] Preferably, the MPC-source supports MPC protocols of arithmetic secret sharing, Boolean secret sharing, and Yao's secret sharing.

[0022] Solve the optimal protocol assignment (OPA) problem using an integer programming solver, and assign the optimal MPC protocol to each operation or module in the MPC-source according to the predefined cost model, which is:

[0023] Identify each operation or module in the MPC-source as a decision variable in the integer programming problem, and define the execution cost and protocol conversion cost for each decision variable according to the predefined cost model;

[0024] Construct an integer programming model whose goal is to minimize the sum of the execution cost and protocol conversion cost of all decision variables, and the integer programming model includes:

[0025] Run the integer programming solver to solve the optimal MPC protocol assignment scheme for each operation or module according to the cost model and constraints, and output the optimal protocol assignment result, i.e. the optimal MPC protocol assigned to each operation or module, as well as the corresponding execution cost and protocol conversion cost.

[0026] Preferably, the input of the ABY framework-based post-compiled backend depends on the circuit converter, which includes:

[0027] The operation and control flow structures in the MPC-source code are mapped and compiled into Yao's garbled circuit, Boolean circuit and arithmetic circuit as a module for each function, corresponding to arithmetic sharing, Boolean sharing and Yao's sharing three protocol types respectively;

[0028] The logic circuit conversion generates a circuit configuration file suitable for the ABY framework.

[0029] Preferably, the ABY framework-based compilation backend evaluates the circuit using the corresponding MPC protocol, including:

[0030] Receive the actual circuit framework constructed based on the ABY framework basic operation by the circuit converter;

[0031] According to the optimal protocol allocation result output by the integer programming solver, select the corresponding MPC protocol to evaluate each operation or module in the circuit framework;

[0032] Process the control flow in the circuit, perform circuit evaluation, and output the target output of secure computation;

[0033] During the evaluation process, for operations or modules that need to cross protocol modules, perform the corresponding sharing conversion operation to ensure compatibility and security between different protocols.

[0034] Preferably, the integer programming solver includes: receiving a pre-defined cost model based on the accumulation of underlying operator overhead and operation or module information in MPC-source; Construct the objective function, which aims to minimize the sum of the execution cost and protocol conversion cost of all operations or modules; For each operation or module, set the constraint condition to ensure that it can only be assigned to one MPC protocol, and for operations or modules that need to be converted, add additional constraint conditions to ensure the feasibility and correctness of the conversion, and apply linear or integer programming techniques to solve the optimal protocol allocation problem.

[0035] Preferably, the compiler also includes an optimization module for improving the execution efficiency of the MPC-source code and reducing the computational complexity, specifically including:

[0036] Analyze the MPC-source code to identify redundant or non-optimal operation and control flow structures; Apply code optimization techniques such as loop optimization, branch elimination and expression simplification; Adjust the operation order and execution strategy to fully utilize the SIMD parallel computing of the ABY framework-based compilation backend and reduce communication overhead.

[0037] The application is based on the OPA Mixing of the front-end of the compiler, which parses the program written by the user in Java language into a static single assignment (SSA) form, identifies the variable definition and control flow structure in the SSA form, all conditional statements (such as if-else) are replaced with a multiplexer (MUX) statement, and the loop structure remains unchanged. In addition, all phi nodes are replaced with pseudo phi nodes (:) to represent the variable update in the loop, and the SSA code is further converted into MPC-source. The optimal protocol allocation (OPA) problem is solved by using an integer programming solver, and according to the pre-defined cost model based on the cumulative overhead of the underlying operator, the optimal MPC protocol is allocated to each operation or module in the MPC-source. The circuit converter maps and compiles the operations and control flow structures in the MPC-source code into Yao's garbled circuit, Boolean circuit and arithmetic circuit as a module for each function, corresponding to arithmetic sharing, Boolean sharing and Yao's sharing of three protocol types. The logic circuit conversion generates a circuit configuration file suitable for the ABY framework. The post-compiled backend based on the ABY framework evaluates the circuit using the corresponding MPC protocol to obtain the target output of the secure calculation.

[0038] The application has the following beneficial effects:

[0039] 1. Polynomial time solution: through linear programming relaxation to prove the existence of integer solution, to ensure that the global optimal protocol combination is found in polynomial time, which is more efficient and accurate than the exhaustive method (exponential complexity) or heuristic algorithm (local optimum) of HyCC.

[0040] 2. Fine-grained allocation: support independent protocol allocation for each operation / module (such as arithmetic sharing for multiplication and Yao's sharing for comparison), which is more automated than manual protocol allocation in the ABY framework.

[0041] 3. Cost model fusion: combine the protocol conversion cost data of the ABY framework to dynamically calculate the overhead of different protocol combinations, ensuring that the allocation strategy is close to the actual running environment.

[0042] 4. SSA form simplification: through SSA to eliminate variable ambiguity, each variable is uniquely assigned, reducing redundant calculation and improving the efficiency of integer programming.

[0043] 5. Protocol independence: support arithmetic, Boolean and Yao's three protocols, which can be flexibly replaced by other protocols (such as MPC protocol extension), which is more expandable than the fixed protocol combination of the ABY framework. BRIEF DESCRIPTION OF DRAWINGS

[0044] Figure 1 is a simplified system architecture diagram of the efficient MPC hybrid protocol compiler for Java language provided by the application.

[0045] Figure 2 This is a flow chart of an efficient MPC hybrid protocol compiler for Java language according to the present invention. DETAILED DESCRIPTION

[0046] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be noted that the following examples are intended to facilitate understanding of the present invention and do not have any limiting effect on the present invention.

[0047] The following combination Figure 1 and Figure 2 The compiler of the present invention is described in detail as follows:

[0048] The present invention provides an efficient MPC hybrid protocol compiler for Java language, such as Figure 1 As shown, the simplified system architecture of the compiler of the present invention includes a Java source code input module 1, an MPC hybrid protocol compilation processing core 2, and a security calculation result storage module 3. Among them, the Java source code input module 1 serves as the starting point of the compilation process and is used to store and provide the Java program code written by the user. The MPC hybrid protocol compilation processing core 2 integrates the compilation front end based on OPA Mixing (Optimal Protocol Allocation Mixing), an integer programming solver, a circuit converter, and an ABY framework compilation back end. The security calculation result storage module 3 is used to store the target output of the security calculation after processing by the MPC hybrid protocol compiler.

[0049] like Figure 2 As shown, the OPA Mixing-based compilation front-end of the present invention parses user programs written in Java into static single assignment (SSA) form, identifies variable definitions and control flow structures within the SSA form, and replaces all conditional statements (such as if-else) with multiplexer (MUX) statements, while retaining the loop structure. Furthermore, all φ nodes are replaced with pseudo-φ nodes (?:) to represent variable updates within loops, further converting the SSA code into MPC-source. An integer programming solver is used to solve the optimal protocol assignment (OPA) problem. Based on a predefined cost model based on the accumulation of underlying operator overhead, the optimal MPC protocol is assigned to each operation or module in the MPC-source. The circuit converter maps the operations and control flow structures in the MPC-source code into Yao's garbled circuits, Boolean circuits, and arithmetic circuits, with each function as a module. These circuits correspond to the three protocol types: arithmetic sharing, Boolean sharing, and Yao's sharing, respectively. The logic circuits are converted to generate circuit configuration files suitable for the ABY framework. The ABY-based compilation back-end evaluates the circuits using the corresponding MPC protocols to obtain the target output for secure computation.

[0050] By designing the circuit converter as a standardized interface, the application seamlessly connects the OPA Mixing-based Java-specific compilation front-end with the ABY framework-based efficient protocol evaluation back-end, building a cross-language collaborative MPC protocol compilation system. Through the static single assignment (SSA) form conversion and intermediate representation optimization of the front-end for Java code, combined with the parallelization evaluation capabilities of the back-end for arithmetic, Boolean, and Yao's shared protocols, the system realizes a significant improvement in the compilation efficiency of MPC protocols in the Java language environment, with performance indicators approaching the level of professional MPC compilers in the C / C++ language environment.

[0051] Embodiment 1

[0052] In order to better describe the specific application examples of the application, the following specific descriptions are given for detailed application scenarios:

[0053] Suppose there are two participants, Alice and Bob, each holding a private integer. Alice holds the integer x, and Bob holds the integer y. They want to jointly calculate the result of x 2 +y 2 >100 without revealing their respective private integers. To achieve this goal, we will use the efficient MPC mixing protocol compilation method for the Java language of the application to compile and execute the corresponding Java code.

[0054] A simple Java program is used to describe the above scenario.

[0055]

[0056] The Java code is parsed line by line, and various syntax elements are identified and converted into a tree-like AST. Each syntax structure is a node in the tree, and the relationship between nodes reflects the hierarchy and logic of the code. First, the compiler starts parsing from the outermost CompilationUnit of the code and identifies the class SecureComparison. Then, enter the class and find the main method, recording its parameters args. In the method body, identify the declaration and assignment of each variable, and finally the output statement.

[0057]

[0058]

[0059] The AST is then converted into a CFG, where each node represents a basic block, which is a sequence of statements executed in order. Edges between nodes represent control flow transitions, reflecting the program's execution order. The program starts at entry block B1, where x and y are initialized. Control then flows to B2, where the squares of x and y are computed. Next, the sum of the squares is computed in B3. In B4, a comparison operation is performed, resulting in a comparison value. Finally, control reaches B5, which outputs the final result.

[0060]

[0061]

[0062] Subsequent live variable analysis and reachability definition analysis are performed to determine the lifetime and scope of each variable in the program. Live variable analysis helps the compiler understand which variables are live in a certain basic block, meaning their values may be used in subsequent computations. For example, in B1, x and y are assigned values, which are used in the subsequent square computations, so they are live variables. Reachability definition analysis is used to determine in which basic blocks a variable's definition is reachable. For instance, the definition of x is in B1 and is reachable in the square computation in B2. Through these analyses, the compiler can better manage variable usage, avoiding unnecessary computations and storage, and improving code execution efficiency.

[0063]

[0064] The CFG and data flow analysis results are converted into SSA form, where each variable is assigned a value only once, and control flow branches are handled with φ nodes. In SSA form, each variable has a unique identifier, such as x_0, y_0, etc. This avoids repeated assignments of variables, making code analysis and optimization simpler. For example, x may be assigned multiple times in the original code, but in SSA form, each assignment generates a new variable version. Additionally, since the program has no explicit control flow branches, φ nodes are not used. SSA form provides a clear variable usage and assignment relationship for subsequent MPC-source generation.

[0065]

[0066] The compiler front-end converts the SSA code into MPC-source, replacing conditional statements with multi-plexer (MUX) statements and φ nodes with pseudo-φ nodes. MPC-source is a linearized representation of the code that contains all the information required for the MPC protocol. In this example, it is first specified that the input data comes from Alice and Bob, respectively. Then the square sum is computed. For the comparison operation sum_0 > 100, a multi-plexer MUX is used to represent it. If sum_0 > 100 is true, result_0 takes the value 1, otherwise it takes the value 0. Finally, the comparison result is outputted.

[0067]

[0068]

[0069] The integer programming solver identifies each operation in the MPC-source as a decision variable. According to the predefined cost model, for arithmetic operations such as multiplication and addition, the overhead of the arithmetic secret sharing protocol is low; for comparison operations, the overhead of Yao's secret sharing protocol is low. The cost of protocol conversion is also considered, as conversion between different protocols can incur additional overhead. The execution cost and protocol conversion cost are defined for each decision variable to facilitate the construction of an integer programming model for optimal protocol assignment later.

[0070]

[0071] The objective of the integer programming model is to minimize the sum of the execution cost and protocol conversion cost of all operations. By setting constraints, it is ensured that each operation can only be assigned to one MPC protocol, and for operations that require protocol conversion, the constraint of conversion cost is met. This guarantees that the overall cost is optimized in the use and conversion of different protocols.

[0072]

[0073]

[0074] Running the integer programming solver, the optimal MPC protocol assignment scheme for each operation is obtained according to the cost model and constraints. In this example, multiplication and addition operations are assigned to the arithmetic secret sharing protocol, and comparison operations are assigned to Yao's secret sharing protocol, taking into account the cost of protocol conversion. Finally, the protocol assignment, execution cost, and total execution cost of each operation are outputted, providing a protocol basis for subsequent circuit conversion.

[0075]

[0076] The circuit converter divides the MPC-source code into modules by function, mainly the main function module here. According to the optimal protocol allocation result, each operation is mapped to the corresponding hybrid protocol circuit. The arithmetic operation is mapped to the arithmetic circuit, and the comparison operation is mapped to the Yao circuit. In this way, the abstract code operation can be converted into a specific circuit implementation, and preparations are made for subsequent circuit evaluation.

[0077]

[0078] The logic circuit is converted into a circuit configuration file suitable for the ABY framework. In the configuration file, detailed information about each operation in the corresponding hybrid protocol circuit is described, including the protocol used, the input and output. For example, the x_0*x_0 operation uses the arithmetic secret sharing protocol, the input is x_0, and the output is xSquared_0. Through this configuration file, the ABY framework compilation backend can accurately evaluate the circuit.

[0079]

[0080]

[0081] The ABY framework compilation backend first receives the ABY framework configuration file generated by the circuit converter to build the actual circuit framework. Then, according to the optimal protocol allocation result, the corresponding MPC protocol is selected to evaluate each operation in the circuit. For arithmetic operations, the arithmetic secret sharing protocol is used; for comparison operations, the Yao secret sharing protocol is used. During the evaluation process, the control flow of the circuit needs to be handled to ensure that the operations are executed in order. For operations that need to cross protocols, perform the corresponding sharing conversion operation to ensure compatibility and security between different protocols. Finally, the result of the secure calculation is output, achieving the goal of secure calculation without revealing private data.

[0082] Embodiment 2

[0083] In order to better describe the specific application examples of the present application, the following specific description is made according to the detailed application scenarios:

[0084] Suppose there are three parties involved: Alice, Bob, and Charlie, who want to jointly calculate the secure cumulative sum, where each party holds a private integer and needs to be added to the shared variable in a loop. They hope to jointly calculate the cumulative sum result without revealing their respective private integers. In order to achieve this goal, we will use the efficient MPC hybrid protocol compilation method for the Java language to compile and execute the corresponding Java code.

[0085] A simple Java program is used to describe the above scenario.

[0086]

[0087]

[0088] The compiler parses the Java code line by line, identifying various syntax elements and converting them into an AST in a tree structure. Each syntax structure is a node in the tree, and the relationships between nodes represent the hierarchy and logic of the code. The compiler starts from the outermost CompilationUnit, identifies the class SecureLoop and its main method and argument args. In the method body, it identifies the variable declarations (a, b, c, sum), the for loop statement (including initialization, condition, increment, and loop body), and the output statement in turn.

[0089]

[0090] The AST is then converted into a CFG, where each node represents a basic block, which is a sequence of statements that are executed in order. Each basic block is represented as a node in the control flow graph (CFG), and the edges between nodes represent the control flow transitions, reflecting the execution order of the program. The program starts at the entry block B1, where a, b, c, and sum are initialized. Then it enters B2 for the for loop initialization. In B3, the condition is checked, and if it is true, it enters B4, executes the loop body (including increment and accumulation operations), and returns to B3. If the condition is false, it enters B5 to output the result.

[0091]

[0092]

[0093] Subsequently, live variable analysis and reachability definition analysis are performed to determine the lifetime and scope of each variable in the program. Live variable analysis helps the compiler understand which variables are active in a certain basic block, i.e., which variables will be used later in the program. For example, in B1, a, b, c, and sum are defined and will be used later, so they are active variables. Reachability definition analysis specifies which basic blocks a variable definition is valid in. For example, a is defined in B1 and can be used in the subsequent loop-related basic blocks B2, B3, and B4.

[0094]

[0095] CFG and dataflow analysis results are converted into SSA form, where each variable is assigned only once and control flow branches are handled with phi nodes. In SSA form, a unique identifier is added to each variable (e.g., a_0, b_0, etc.) to avoid repeated assignments, which simplifies code analysis and optimization. For conditional statements within loops, a pseudo-phi node logic is used to handle variable updates (e.g., the update of sum). This form simplifies code analysis and optimization, providing a clear variable relationship for subsequent MPC-source generation.

[0096]

[0097]

[0098] The compilation front-end converts the SSA code into MPC-source, replacing conditional statements with multiplexer (MUX) statements and phi nodes with pseudo-phi nodes. MPC-source is a linearized code representation that contains all the information required for MPC protocols. MPC-source explicitly specifies the input data sources (from Alice, Bob, and Charlie, respectively) and initializes sum. In loop calculations, MUX operations are used to implement conditional judgment logic (i.e., selecting different accumulation methods based on the value of i). Finally, the secure computation result is output.

[0099]

[0100] Each operation in MPC-source is identified as a decision variable. Based on the cost model, arithmetic operations are suitable for arithmetic secret sharing protocols, conditional judgments are suitable for Boolean secret sharing protocols, and comparison operations are suitable for Yao's secret sharing protocols. Considering the protocol conversion cost, the execution cost and protocol conversion cost of each decision variable are defined to construct an integer programming model for optimal protocol allocation. After MPC-source generation, by defining decision variables (e.g., a_0, b_0, and loop accumulation operations) and constraint conditions (each operation can only be assigned to one protocol), the optimal protocol allocation is solved in polynomial time, avoiding the exponential complexity of the exhaustive method. The compilation front-end proves that the integer programming problem can be solved in polynomial time by the total unimodularity of the linear constraint matrix. Total unimodularity (TU) refers to the fact that if the constraint matrix of an integer programming problem is a total unimodular matrix, the optimal solution of its linear programming relaxation must be an integer solution, thus avoiding the NP-hard integer programming solution problem. The protocol allocation problem is converted into a binary decision variable x op,proto (proto represents whether the operation op is assigned to the protocol proto), a linear objective function and linear constraint conditions are constructed to ensure that the matrix satisfies the TU property.

[0101]

[0102] The integer programming model aims to minimize the sum of all operation execution costs and protocol conversion costs. By setting constraints, it is ensured that each operation is assigned only one MPC protocol, and the protocol conversion meets the cost and feasibility requirements, thereby achieving the overall cost optimization in different protocol usage and conversion.

[0103]

[0104]

[0105] An integer programming solver is run to obtain the optimal MPC protocol assignment scheme for each operation according to the predefined cost model and constraints. In this example, the input and initialization operation is assigned an arithmetic secret sharing protocol, the addition operation in the loop uses the arithmetic secret sharing protocol, the conditional judgment uses the Boolean secret sharing protocol, the comparison operation uses the Yao's secret sharing protocol, and the protocol conversion cost is considered. Finally, the protocol assignment, execution cost, and total execution cost are output, providing the basis for protocol conversion. In the embodiment, each operation (such as addition, conditional judgment, and comparison) is independently assigned a protocol, rather than uniformly assigned to the entire module. By linearizing and splitting the MPC-source, each atomic operation (addition, conditional judgment, and comparison) is treated as an independent decision unit, enabling fine-grained protocol assignment at the operation level. The arithmetic operation (sum = sum +...) is assigned an arithmetic secret sharing (A protocol), the conditional judgment (i == 0) is assigned a Boolean secret sharing (B protocol), and the final comparison (sum > 100) is assigned a Yao's sharing (Y protocol). Unlike the manual protocol labeling in the ABY framework (such as aby::ArithmeticCircuit), the present invention automatically assigns protocols through an integer programming solver. The automatic assignment process is as follows: the compiler extracts all atomic operations from the AST of the Java code and fills in the measured costs in the ABY framework paper (such as A protocol addition overhead 8, Y protocol comparison overhead 7, and B protocol MUX overhead 6) for each operation; the solver outputs the optimal solution according to the single protocol assignment constraints (each operation can only choose one protocol) and the conversion cost constraints. This process does not require human intervention and supports dynamic expansion (such as adding new protocols only requires updating the cost matrix).

[0106]

[0107] In the dynamic environment parameter injection mechanism, the increase of network delay in the wide area network scenario will significantly affect the protocol conversion cost (such as A→B, B→A, A→Y, Y→A conversion costs increase from 10 / 15 / 20 / 25 to 20 / 30 / 30 / 40), at this time the conditional judgment operation still maintains the allocation due to the low cost advantage of B protocol native support (B protocol 6 vs A protocol 12), but the protocol selection of the input operation will be re-decided due to the surge of conversion cost - if the input selects A protocol, it needs to bear 3 times of A→B conversion from input to conditional judgment (20x3), the total cost (17+43+60=120) is higher than the total cost when the input selects B protocol (B protocol input execution cost 6x3+initialization B protocol cost 3=21, addition uses B protocol execution cost 15x3, conditional judgment and comparison cost 6x2+10=22, total cost 21+45+22=88), so the solver will prefer to select B protocol input to avoid high conversion overhead. At the same time, when Charlie's CPU performance is weak (A protocol execution cost from 5→12), the A protocol cost (12) of its input operation c is significantly higher than the B protocol (6), the decision variable x_(c,B) is set to 1, at this time the addition operation sum+c needs to bear additional B→A conversion cost 15 because the input c is B protocol, the solver will balance between the A protocol execution advantage (8) of the arithmetic operation and the conversion cost, if the total cost after conversion (8+15=23) is still lower than the B protocol addition cost 15, then keep the A protocol allocation, otherwise adjust to B protocol to balance the device load, finally realize the environmental adaptability optimization of protocol allocation through dynamic correction of cost parameters.

[0108] The MPC-source is divided into modules according to functions (mainly the main function module). According to the optimal protocol allocation result, each operation is mapped to the corresponding hybrid protocol circuit. The input, initialization and addition operations are mapped to the arithmetic circuit, the MUX conditional judgment is mapped to the Boolean circuit, and the comparison operation is mapped to the Yao circuit, realizing the conversion from code operation to specific circuit and preparing for circuit evaluation.

[0109]

[0110] The logic circuit is converted into a circuit configuration file suitable for the ABY framework. The file describes the information of each operation in the corresponding hybrid protocol circuit in detail, including protocol type, input source and output result. For example, the a_0 operation uses the arithmetic secret sharing protocol, the input comes from Alice, and the output is a_0 itself. Through the configuration file, the ABY framework compilation backend can accurately evaluate the circuit.

[0111]

[0112]

[0113] The ABY framework compiler backend receives the ABY framework configuration file generated by the circuit converter, and constructs an actual circuit framework. According to the optimal protocol allocation result, each operation of the MPC protocol evaluation circuit is selected. The circuit control flow (especially the loop structure) is handled well to ensure that the operations are executed in sequence. Shared conversion operations are performed on cross-protocol operations to ensure protocol compatibility and security. Finally, the secure calculation result is output, realizing the secure addition and calculation of three parties without leaking the private integer.

[0114]

[0115] The embodiments described herein are merely some preferred embodiments and features, and any person skilled in the art can make some modifications and changes according to the essence described herein, and these modifications and changes are also considered to belong to the scope of the present application and the scope limited by the independent claims and the dependent claims.

Claims

1. An efficient MPC hybrid protocol compilation method for Java language, characterized in that: The following steps are involved: Step S1: Parse the program written in Java language into a static single assignment (SSA) form, and convert the static single assignment (SSA) form into a linearized code (MPC-source), wherein the linearized code (MPC-source) contains all information required by the MPC protocol; Step S2: Construct an integer programming model, identify each operation or module in the MPC-source as a decision variable in the integer programming model, and define the execution cost and protocol conversion cost for each decision variable based on a predefined cost model; construct the integer programming model with the goal of minimizing the sum of the execution cost and protocol conversion cost of all decision variables; run the integer programming solver to solve the optimal MPC protocol allocation scheme for each operation or module based on the cost model and constraints, and output the optimal protocol allocation result; Step S3: According to the optimal MPC protocol allocation result, the linearized code (MPC-source) is mapped to the corresponding protocol circuit through the circuit converter, and converted into a circuit configuration file suitable for the ABY framework, where the ABY framework is a hybrid protocol framework that combines arithmetic secret sharing (A), Boolean secret sharing (B), and Yao secret sharing (Y); Step S4: According to the optimal MPC protocol allocation result, each operation or module in the circuit framework based on the ABY framework generated by the corresponding MPC protocol evaluation step S3 is selected, and the security calculation result is finally output.

2. The efficient MPC hybrid protocol compilation method for Java language according to claim 1, characterized in that The step S1 specifically includes: S1.1: Perform syntax analysis on the Java source code to construct an abstract syntax tree (AST). Each syntax structure is represented as a node in the tree. The relationships between the nodes reflect the hierarchy and logic of the code, and the nodes constitute the overall structure of the source code. S1.2: Based on the construction of the control flow graph (CFG), the AST obtained in step S1.1 is converted into the CFG, so that each basic block is represented as a node in the control flow graph. The edges between nodes represent the transfer of control flow. The nodes and edges constitute the control flow structure of the program. The basic block is a series of statements executed sequentially. S1.3: Perform data flow analysis, including active variable analysis and reachable definition analysis, to determine the lifecycle and scope of each variable in the program; S1.4: Convert the control flow graph (CFG) and data flow analysis results obtained in the above steps into SSA form, so that each variable is assigned only once and all control flow branches are converted into φ nodes for merging values ​​on different paths. S1.5: Identify variable definitions and control flow structures in SSA form. All conditional statements are replaced with multiplexer (MUX) statements, while the loop structure remains unchanged. In addition, all φ nodes are replaced with pseudo-φ nodes to represent variable updates in the loop.

3. The efficient MPC hybrid protocol compilation method for Java language according to claim 2, characterized in that: The pseudo φ node is used in the MPC-source to indicate variable updates in a loop. Initial values ​​are obtained externally in the first iteration, and values ​​are obtained from the results of the previous iteration in subsequent iterations. For the pseudo φ node x1 = (i == 0) ? x0: x2, if this is the first iteration, x1 takes the value of x0; otherwise, x1 takes the value of x2.

4. The efficient MPC hybrid protocol compilation method for Java language according to claim 2, characterized in that The multiplexer (MUX) is a common MPC operation used to select different values ​​according to conditions; Res=MUX(x, y, cnd) means that if the value of cnd is true, Res takes the value of x; otherwise, Res takes the value of y.

5. The method according to any one of claims 1 to 4, characterized in that In step S2, an integer programming model is constructed, the goal of which is to minimize the sum of the execution cost and the protocol conversion cost of all decision variables. When constructing the integer programming model, minimizing the sum of the execution cost and the protocol conversion cost of all decision variables can be achieved by constructing the following objective function: Suppose the operation set is O={o1,o2,…,o n } (such as input, addition, conditional judgment, comparison and other operations), the protocol set is P = {A, B, Y} (arithmetic secret sharing, Boolean secret sharing, Yao secret sharing); introduce the binary decision variable x o,p , where x o,p =1 means that operation o is assigned to protocol p, otherwise it is 0; the execution cost of operation o selecting protocol p is recorded as The protocol conversion cost is recorded as The objective function is formalized as: This function minimizes the overall cost by accumulating the execution cost and conversion cost of all operations selecting different protocols.

6. The efficient MPC hybrid protocol compilation method for Java language according to claim 1, characterized in that: In step S3, the linearized code (MPC-source) is mapped to the corresponding hybrid protocol circuit through the circuit converter and converted into a circuit configuration file suitable for the ABY framework. Specifically, the operations and control flow structures in the linearized code (MPC-source) are mapped and compiled into Yao's garbled circuits, Boolean circuits, and arithmetic circuits with each function as a module, corresponding to the three protocol types of arithmetic sharing, Boolean sharing, and Yao's sharing respectively; then the circuit configuration file suitable for the ABY framework is generated.

7. The efficient MPC hybrid protocol compilation method for Java language according to claim 1, characterized in that In step S4, during the evaluation process, each operation or module in the evaluation circuit framework performs corresponding shared conversion operations for operations or modules that need to cross protocol modules to ensure compatibility and security between different protocols.

8. A compiler for implementing the method according to any one of claims 1 to 4 or 6 to 7, characterized in that: include: It consists of a compilation front-end based on optimal protocol allocation, an integer programming solver, a circuit converter, and a compilation back-end based on the ABY framework. The compilation front-end parses programs written in Java into static single assignment (SSA) form and converts the SSA form into MPC-source; the integer programming solver assigns the optimal MPC protocol to each operation or module in the MPC-source; the circuit converter transforms the MPC-source into an actual circuit framework built based on the basic operations of the ABY framework; the compilation back-end uses the corresponding MPC protocol to evaluate the circuit to obtain the target output of secure calculation.

9. The compiler according to claim 5, wherein: include: It consists of a compilation front-end based on optimal protocol allocation, an integer programming solver, a circuit converter, and a compilation back-end based on the ABY framework. The compilation front-end parses programs written in Java into static single assignment (SSA) form and converts the SSA form into MPC-source; the integer programming solver assigns the optimal MPC protocol to each operation or module in the MPC-source; the circuit converter transforms the MPC-source into an actual circuit framework built based on the basic operations of the ABY framework; the compilation back-end uses the corresponding MPC protocol to evaluate the circuit to obtain the target output of secure calculation.

10. The compiler according to claim 8, wherein The compiler also includes an optimization module to improve the execution efficiency and reduce the computational complexity of MPC-source code. Specifically, it analyzes the MPC-source code to identify redundant or suboptimal operations and control flow structures; applies code optimization techniques such as loop optimization, branch elimination, and expression simplification; and adjusts the operation order and execution strategy to fully utilize the ABY-based compilation backend SIMD parallel computing and reduce communication overhead.