Script execution method and apparatus involving multi-party secure computation
By delaying the execution of the MPC operator in multi-party secure computation and generating an optimized execution graph, the problem of low execution efficiency of the MPC operator is solved, achieving more efficient computational performance and parallelism.
Patent Information
- Application Number
- CN202211735937.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In existing multi-party secure computation, the execution method of the MPC operator lacks optimization space, resulting in low computational efficiency.
By generating MPC operators and adding them to the operator cache list, execution is delayed, an optimized execution graph is generated, and code optimization is performed to improve execution efficiency.
It improves the execution performance and efficiency of multi-party secure computation, optimizes the execution path and code of the MPC operator, reduces the execution depth, and increases parallelism.
Smart Images

Figure CN115987508B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] One or more embodiments of the present specification relate to multi-party secure computation, and in particular to a method and apparatus for execution of a script involving multi-party secure computation. BACKGROUND
[0002] In the Internet big data scenario, various platforms have accumulated a large amount of data. For example, an electronic payment platform has transaction flow data of merchants, an e-commerce platform stores sales data of merchants, and a bank institution has lending data of merchants. In order to increase the value of data, there is a demand for multiple platforms to jointly process data. For example, the above electronic payment platform, e-commerce platform and bank institution intend to jointly perform machine learning to train a merchant classification model.
[0003] However, the data stored by each party often involves user privacy data. At present, the industry pays more and more attention to data security and personal privacy, and recently domestic has closely introduced a number of data protection related policies and regulations. Therefore, protecting the privacy and security of each party in the process of joint data processing has become a focus. For this purpose, the concept of privacy computing is proposed, which is used to realize joint processing of data without revealing the original data, so that data is available but not visible. In privacy computing, multi-party secure computation (MPC) has no special requirements for hardware and does not affect the accuracy of the result, so it is widely used in various privacy computing scenarios.
[0004] Therefore, it is desirable to have an improved solution that can improve the execution performance of MPC computation. SUMMARY
[0005] One or more embodiments of the present specification describe a script execution method and apparatus involving multi-party secure computation, which can optimize mpc operator computation in a user script to execute mpc computation formula in a more efficient way, and improve mpc computation efficiency and execution performance.
[0006] According to a first aspect, a script execution method involving multi-party secure computation is provided, comprising:
[0007] Obtaining a user script, which includes a plurality of computation formulas involving multi-party secure computation (MPC);
[0008] According to the computation formula, an mpc operator corresponding to the computation formula is generated, and the mpc operator is added to an operator cache list;
[0009] In response to a preset trigger condition, an mpc operator sequence contained in the operator cache list is read;
[0010] determine an optimized execution code of the sequence of mpc operators according to the dependency relationship between the operators;
[0011] execute the sequence of mpc operators according to the optimized execution code.
[0012] In one embodiment, the process of generating mpc operators specifically comprises: in a script reloading phase, determining a target mpc operator corresponding to an arbitrary target computation formula, and modifying the target computation formula to a generation operation of generating the target mpc operator; and executing the generation operation in the reloading script to generate the target mpc operator.
[0013] In one specific embodiment, the preset trigger condition comprises that the operator cache list is full.
[0014] In another embodiment, the preset trigger condition comprises reading a preset type of operation statement in the user script, the preset type comprising one of the following: outputting a current operation result, and exiting.
[0015] According to one embodiment, the process of determining an optimized execution code of the sequence of mpc operators specifically comprises: generating a target execution graph reflecting an execution path of the sequence of mpc operators according to the dependency relationship between the operators; the target execution graph comprises a plurality of levels, each level comprising parallel operations of mpc operators that do not have a dependency relationship with each other; and determining the optimized execution code according to the target execution graph.
[0016] In one embodiment of the above-mentioned embodiment, the process of generating a target execution graph reflecting an execution path of the sequence of mpc operators specifically comprises: generating a first original execution graph according to the direct dependency relationship between the operators in the sequence of mpc operators; and performing path optimization on the first execution graph using a plurality of optimization strategies to obtain a second execution graph as the target execution graph; wherein the number of levels of the second execution graph is less than that of the first execution graph.
[0017] Further, in one example, the plurality of optimization strategies can comprise an optimization strategy for multiple executions of the same operator.
[0018] In one embodiment of the above-mentioned embodiment, the process of determining an optimized execution code according to the target execution graph specifically comprises: determining a target execution code corresponding to the target execution graph; and performing code optimization on the target execution code to obtain the optimized execution code.
[0019] Further, in one example, the code optimization comprises at least one of the following: repeated code elimination, and useless code elimination.
[0020] In one example, after executing the sequence of mpc operators according to the optimized execution code, the operator cache list is emptied.
[0021] According to a second aspect, a script execution apparatus involving multi-party secure computation is provided, comprising:
[0022] A script obtaining unit is configured to obtain a user script, which comprises a plurality of calculation formulas involving multi-party secure computation (mpc);
[0023] An operator adding unit is configured to generate corresponding mpc operators according to the calculation formulas, and add the mpc operators into an operator cache list;
[0024] A sequence reading unit is configured to read a sequence of mpc operators contained in the operator cache list in response to a preset trigger condition;
[0025] An optimization unit is configured to determine an optimized execution code of the sequence of mpc operators according to a dependency relationship between the operators;
[0026] An execution unit is configured to execute the sequence of mpc operators according to the optimized execution code.
[0027] According to a third aspect, a computer readable storage medium is provided, which stores a computer program, and when the computer program is executed in a computer, the computer is caused to execute the method of the first aspect.
[0028] According to a fourth aspect, a computing device is provided, which comprises a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method of the first aspect is implemented.
[0029] In the embodiments of the present specification, a scheme of delaying the execution of mpc operators is proposed, and an operator cache list is provided to store the mpc operators.
[0030] A range of operator execution contexts is provided, thereby providing space and possibility for the optimization of execution manners. Based on the context provided by the operator cache list, the execution manner of operators can be optimized within a certain execution window, thereby improving the efficiency of mpc calculation. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained based on these drawings without paying creative labor.
[0032] Ordinary skilled in the art can also obtain other drawings based on these drawings without paying creative labor.
[0033] Figure 1 An example of a user script is shown;
[0034] Figure 2 An example of script code for a user script overload by a conventional interpreter is shown; Figure 1
[0035] Figure 3 An example of a conceptual diagram of script optimized execution is shown according to an embodiment;
[0036] Figure 4 A flowchart of a script execution method is shown according to an embodiment;
[0037] Figure 5 An example of an overloaded script after a user script is overloaded according to an embodiment is shown; Figure 1
[0038] An example of a generated operator list is shown; Figure 6
[0039] An example of operator cache list contents is shown; Figure 7
[0040] An example of a DAG execution graph for an operator sequence is shown; Figure 8
[0041] An example of an optimized DAG execution graph is shown; Figure 9
[0042] A structural diagram of a script execution apparatus is shown according to an embodiment. Figure 10 DETAILED DESCRIPTION
[0043] 0The solutions provided in the present specification are described below with reference to the accompanying drawings.
[0044] As described previously, multi-party secure computation (MPC) is a commonly used privacy computation method and is applied in various privacy computation scenarios. In practice, to perform specific secure computation, a user generally uses a high-level script language (such as Python) to write a user script, in which the calculation process of MPC computation is defined. An interpreter of the script language translates the user script into mpc operators and executes them in sequence.
[0045] Compared with the mode of compiling and then executing the whole user script, the script language interpreter has the feature of interpreting and then immediately executing a script fragment. That is, the interpreter reads a script fragment (which can be a line), translates it into target operation code, and then immediately executes the target operation code, and then reads the next script fragment. Therefore, the mpc related operations defined by the user in the high-level language script are all immediately executed. Due to the immediate execution feature, the operator execution layer does not have the possibility of optimization based on context. This requires the user to pay special attention to the writing when writing the script, because the common writing in the ordinary script (such as Python) is not efficient when executed by MPC.
[0046] Figure 1 An example of a user script is shown. In Figure 1 , since data a comes from Alice and data b comes from Bob, and the script contains operations on data a and data b, this user script involves multi-party secure computation mpc.
[0047] Figure 2 The script code reloaded by the conventional interpreter for the user script of Figure 1 is shown. Since data a and b belong to two parties respectively, the operations on a and b, including addition and multiplication, are all operation operations implemented by mpc. Therefore, in the reloaded stage of the script, the interpreter directly modifies the addition in the script to mpc addition operator mpc_add, and modifies the multiplication to mpc multiplication operator mpc_mul, to obtain the script code shown in Figure 2 .
[0048] In the interpretation execution, Figure 2 , the script code is executed immediately in sequence. Specifically, after the mpc addition operator in statement 1 is executed to obtain x, the mpc multiplication operator in statement 2 is executed to obtain y, and then each loop in the loop statement is executed in sequence.
[0049] From the above example, it can be seen directly that due to the immediate execution and serial execution feature of the conventional interpreter, the execution mode and execution order of each mpc operator strictly depend on the mode and order described by the user in the script, and there is no optimization space. The calculation process defined by the user in the script according to the general execution logic and the conventional writing is not an efficient way for the calculation efficiency of mpc operators.
[0050] In view of this, in the embodiments of the present specification, a scheme for optimizing the execution of a script involving multi-party secure computation is proposed. Figure 3 A conceptual diagram of script optimization execution according to an embodiment is shown. As Figure 3As shown, instead of the conventional interpreter's immediate execution of MPC operators, this embodiment continuously generates MPC operators based on user scripts, but does not execute them immediately. Instead, the generated MPC operators are added to an operator cache list. In response to the operator cache list being full (or other triggering conditions), a sequence of MPC operators is read from the list, and an optimized execution graph is generated for this operator sequence. This execution... Figure 1 Generally, it takes the form of a directed acyclic graph (DAG). Therefore, DAG will be used to refer to the execution graph of the operator in many places below. Then, according to the optimized DAG, the operator sequence is executed. After this, the operator cache list is cleared, and MPC operators are continued to be stored in it.
[0051] pass Figure 3 As shown in the diagram, in the embodiments of this specification, an operator cache list is used to delay the execution of MPC operators. The operator cache list can provide a certain range of operator execution context, thereby providing space and possibilities for optimizing the execution path. Based on the context provided by the operator cache list, the operator execution method can be optimized within a certain execution window, improving the efficiency of MPC computation.
[0052] The following examples illustrate the specific implementation process of the above technical concepts.
[0053] Figure 4 A flowchart illustrating a script execution method according to one embodiment is shown. This method is executed by a script interpreter, which can be deployed in any device, equipment, platform, or cluster of devices with computing and processing capabilities. Figure 4 As shown, the method includes the following steps.
[0054] In step 41, the user script is obtained, which includes several computational formulas involving multi-party secure computation (MPC). (Continuing with...) Figure 1 Taking the script shown as an example, since data a comes from Alice and data b comes from Bob, and the script contains calculation formulas for data a and data b, this user script involves multi-party secure computation (MPC). The calculation formulas for data a and data b (including direct calculations and further calculations based on the calculation results) are calculation formulas involving MPC.
[0055] In step 42, the corresponding MPC operator is generated according to the calculation formula in the user script, and the MPC operator is added to the operator cache list.
[0056] Those skilled in the art will understand that for user scripts written in high-level scripting languages, script overloading can be performed before they are translated into executable code and executed, in which some functions / methods or their operations are rewritten or modified. For example, Figure 2The above describes a typical overloaded process, where addition is modified to the MPC addition operator `mpc_add`, and multiplication is modified to the MPC multiplication operator `mpc_mul`. Each operator corresponds to an operation function.
[0057] Unlike the conventional overload process modification method, in this embodiment, instead of modifying the calculation formula to the corresponding MPC operator, it modifies it to the generation operation of generating the MPC operator. Specifically, during the script overload stage, for any target calculation formula involving multi-party data, the corresponding target MPC operator is determined according to its operation method, and the target calculation formula is modified to generate the generation operation of the target MPC operator.
[0058] In a specific example, `emit` represents the operation function for the generation operation, whose input parameters include the generated operator and the operator's input. For instance, for the calculation x = a + b in the user script, since it involves addition operations between multiple data, the corresponding MPC operator can be determined to be the MPC addition operator `mpc_add`. Therefore, in this step, the calculation is modified into a generation operation that generates this MPC addition operator:
[0059] x = emit(“mpc_add”, a, b)
[0060] Thus, according to one embodiment, Figure 1 The reloaded script after the user script is reloaded is as follows: Figure 5 As shown. Comparison Figure 5 and Figure 2 visible, Figure 5 The overloaded script changes the direct MPC operator operation to an emit operation. This emit operation only generates the MPC operator and does not execute the MPC operator immediately.
[0061] By execution Figure 5 The overloaded script shown can generate Figure 6 The list of operators is shown. It can be understood that, since a loop (for i in range(10)) is defined in the original script, the operation to generate the MPC multiplication operator will be executed 10 times. Figure 6 The list of operators contains 10 consecutive mpc_mul(x,y) operators.
[0062] It can be appreciated that different numbers of operators can be generated depending on the complexity of the original script, whether there are loops, the number of loops, and so on. In practical applications, the list of generated operators can be long, and even the memory cannot fully accommodate it, in the case of a fully expanded loop. Therefore, in an embodiment, the interpretation executor can generate mpc operators and add them to the operator cache list at the same time; after a batch of operators in the operator cache list are executed, the next batch of operators is generated and added.
[0063] The size of the operator cache list can be set as needed with reference to various factors, such as the memory size, the complexity of the script, the preferred application range of the subsequent optimization strategy, and so on. For example, assuming that the size of the operator cache list is 5, that is, 5 mpc operators can be stored. Then, the generated operators shown in Figure 6 are added to the operator cache list in turn, and the contents of the operator cache list shown in Figure 7 are obtained. As shown in Figure 7 , the operator cache list contains the first 5 operators in Figure 6 .
[0064] Next, in step 43, in response to a preset trigger condition, the sequence of mpc operators contained in the operator cache list is read.
[0065] Typically, the above-mentioned preset trigger condition includes that the operator cache list is full. For example, as shown in Figure 7 , the operator cache list with a capacity of 5 is full after storing 5 mpc operators, at which time the mpc operators contained therein can be read in turn to form a sequence of mpc operators.
[0066] In an embodiment, the above-mentioned preset trigger condition can also include reading a predetermined type of operation statement in the user script, such as the following operation statements: outputting the current operation result, exiting, and so on. For example, when the reveal(x) statement requesting to output the current operation result is read, the sequence of mpc operators stored therein is read regardless of whether the operator cache list is full at this time. According to the characteristics of different script languages, the operation statement corresponding to the above-mentioned trigger condition can also have other types, such as jump, interruption, encounter with a plug-in, or other custom statements that make the operator cache list output its contents in some languages. Once such a statement is read, the currently stored mpc operators are read from the operator cache list to obtain a sequence of mpc operators.
[0067] Thus, in step 44, the optimized execution code of the mpc operator sequence is determined according to the dependency relationship between the operators. It can be understood that the mpc operator sequence read from the operator cache list often contains multiple operators, which can form a context of operator optimization. Based on the context, various optimization strategies and optimization methods can be used to determine the optimized execution path of the mpc operator sequence and obtain its optimized execution code.
[0068] In order to obtain the optimized execution code, in an embodiment, the execution path of the mpc operator is optimized first to obtain a target execution graph, and then the optimized execution code is obtained based on the target execution graph. The target execution graph can be in the form of a directed acyclic graph (DAG) and is used to indicate the execution path of the mpc operator sequence. The generated target execution graph can include several levels, and each level includes parallel operations of mpc operators that do not have a dependency relationship with each other.
[0069] In an embodiment, the DAG execution graph can be generated as the above-mentioned target execution graph according to the direct dependency relationship between the operators in the mpc operator sequence read from the operator cache list.
[0070] For example, for the mpc operator sequence in the operator cache list of Figure 7 , the direct dependency relationship between the operators can be analyzed as follows: the mpc addition operator for calculating x and the mpc multiplication operator for calculating y do not have a dependency relationship with each other; the mpc multiplication operators for calculating x in the subsequent steps all depend on the previously calculated x and y. According to the above dependency relationship, by placing the mpc operators that do not depend on each other in the same layer for parallel computation, the DAG execution graph shown in Figure 8 can be obtained. In the DAG graph in Figure 8 , it can be seen that the secure addition operation of applying the mpc_add operator based on data a and b and the secure multiplication operation of applying the mpc_mul operator are in the same level and are executed in parallel. Compared with the conventional execution mode of sequentially and serially executing the operators, the execution efficiency is improved.
[0071] In an embodiment, the DAG execution graph generated according to the direct dependency relationship between the operators as described above is used as an initial first execution graph, and based on the first execution graph, further optimization is performed using several optimization strategies to obtain a second execution graph, so that the number of levels of the second execution graph is less than that of the first execution graph. Thus, the optimized second execution graph is used as the final target execution graph.
[0072] It can be understood that in the prior art, in the scenario of local operation, there are various optimization strategies for increasing parallelism and improving computing efficiency. For example, for the case of executing the same operator multiple times, there are certain optimization strategies in the prior art. Specifically, if the addition operation (addition operator) is executed multiple times, the optimization strategy can convert it into a multiplication operation. If the multiplication operation is executed multiple times, that is, the power operation is performed, the optimization strategy can split and combine the power operation. For example, when the local operation wants to calculate a 8 , instead of multiplying a by 7, it is split into the following calculation: first calculate a 2 , multiply two a 2 s to get a 4 , and then multiply two a 4 s to get a 8 . In this way, only 3 multiplication operations are required. For example, in the case of alternately executing some operators in a loop, there are also corresponding optimization strategies. In the case where the operation involves multiple parameters, the optimization strategy often also considers the dependency relationship between the parameters. These optimization strategies can come from various optimization scenarios, for example, compiler optimization during compilation, CPU optimization during execution, etc. The optimization strategies in the above various scenarios can be used to optimize the execution path in applicable cases.
[0073] Continue the previous example. For the DAG graph shown in Figure 8 , the mpc multiplication operator based on y that is performed multiple times can be optimized using, for example, the optimization strategy for the power operation, to obtain the DAG graph shown in Figure 9 .
[0074] In Figure 9 , it can be seen that the operators in the first level do not change relative to Figure 8 . However, in the second level, t1 and t2 are calculated in parallel, where t1 is obtained by applying the mpc_mul operator to x and y, that is, t1 = mpc_mul(x, y), and t2 is obtained by applying the mpc_mul operator to y itself, that is, t2 = mpc_mul(y, y). The operators for calculating t1 and t2 are independent of each other.
[0075] It should be noted here that since y is obtained based on two-party data a and b, y itself still belongs to multi-party data. For example, in the case of mpc operation based on secret sharing, each party obtains a shard of the result through mpc operation. Subsequent operations still need to be performed jointly by multiple parties based on their respective shards. Therefore, the calculation of y*y still needs to use the mpc operator mpc_mul, rather than local calculation.
[0076] Based on t1 and t2 obtained in the second level as described above, in the third level, mpc multiplication operators are applied to t1 and t2, and x is obtained. The x thus obtained is the same as Figure 8 The mpc multiplication is applied to y three times in series in the middle, and the result is the same. However, the number of levels, or the depth, of the execution graph is reduced by one compared with Figure 8 Thus, the optimized execution graph has a higher parallelism and a higher execution efficiency. Therefore, the optimized execution graph can be used as a target execution graph to indicate the execution path of the operators.
[0077] Then, the optimized execution code can be determined based on the target execution graph. Specifically, the underlying code of each mpc operator can be obtained. As described above, an mpc operator can be considered as a function, and the underlying code of the function is the executable code that implements the specific operation process of the function. For a specific mpc operator, the underlying code is a piece of executable code that is developed in advance and is used to implement the multi-party secure computation defined in the mpc operator based on specific cryptographic primitives (such as secret sharing and oblivious transfer OT) and privacy computing protocols. Further, the underlying code corresponding to each mpc operator can be combined according to the execution path (including the operation order between operators and input and output) indicated by the target execution graph to obtain the target execution code as the optimized execution code of the mpc operator sequence.
[0078] In an embodiment, the target execution code can be code-optimized to obtain the optimized execution code. The process of code optimization can include eliminating duplicate code / common code, eliminating useless code, and the like. The duplicate code can be caused by multiple executions of the same operator, and some code actually does not need to be executed multiple times, so it can be eliminated for optimization. The useless code, also known as dead code, is code that is not actually used in the execution process. Code optimization can also include other conventional optimization methods, which are not enumerated here and are not limited.
[0079] In the above embodiments, the process of determining the optimized execution code of the mpc operator sequence involves execution path optimization and code optimization. In alternative embodiments, only the execution path optimization can be performed, or only the code optimization can be performed, or more optimization in other aspects can also be performed. It should be understood that the core of the above process is to provide an optimized context space for scripts involving mpc computation through the operator cache list, which provides a basis and possibility for optimized execution, rather than the specific optimization algorithm and optimization strategy. The embodiments of the present specification do not limit the specific optimization method based on the context space.
[0080] At step 45, the sequence of mpc operators is executed according to the optimized execution code based on the execution of various optimizations to obtain the optimized execution code. Thus, the mpc computation involved in the user script is executed in an optimized manner. The optimized manner can be different from the execution order and execution path originally written in the user script and more efficient than the original execution order and execution path.
[0081] After the current sequence of mpc operators is executed, the operator cache list can be emptied and the generated mpc operators can be continuously added to the operator cache list. For example, after the sequence of mpc operators in the operator cache list shown in Figure 7 is executed and the operator cache list is emptied, the next five mpc operators mpc_mul(x, y) in Figure 6 are continuously added to the operator cache list, and steps 43 to 45 are executed again. The above process can be repeatedly executed until all mpc operators in the user script are executed.
[0082] In this way, during the script execution process shown in Figure 4 , the mpc operators are executed in a delayed manner, and a certain range of operator execution contexts is provided through the operator cache list, thereby providing space and possibility for optimization of the execution manner. Based on the context provided by the operator cache list, the execution manner of the operators can be optimized within a certain execution window, thereby improving the efficiency of mpc computation.
[0083] According to another aspect, an embodiment of a script execution device for a multi-party secure computation script is provided. Figure 10 A structural schematic diagram of a script execution device according to an embodiment is shown, which can be integrated into a script interpretation executor, which can be deployed in any device, platform or device cluster with data storage, computing and processing capabilities. As shown in Figure 10 , the script execution device 100 includes:
[0084] A script acquisition unit 101 configured to acquire a user script including a plurality of computation formulas involving multi-party secure computation (mpc);
[0085] An operator adding unit 102 configured to generate corresponding mpc operators according to the computation formulas and add the mpc operators to an operator cache list;
[0086] A sequence reading unit 103 configured to read a sequence of mpc operators included in the operator cache list in response to a preset trigger condition;
[0087] An optimization unit 104 configured to determine an optimized execution code of the sequence of mpc operators according to a dependency relationship between the operators;
[0088] The execution unit 105 is configured to execute the sequence of mpc operators according to the optimized execution code.
[0089] According to an embodiment, the operator adding unit 102 is specifically configured to:
[0090] In the script reloading phase, a target mpc operator corresponding to an arbitrary target computation formula is determined, and the target computation formula is modified to generate a generation operation of the target mpc operator;
[0091] The generation operation in the reloading script is executed to generate the target mpc operator.
[0092] In an embodiment, the preset trigger condition includes that the operator cache list is full. In another embodiment, the preset trigger condition includes that a preset type of operation statement in the user script is read, and the preset type includes one of the following: outputting the current operation result, and exiting.
[0093] According to an embodiment, the optimization unit 104 further includes (not shown in the figure):
[0094] The execution graph generation module is configured to generate a target execution graph reflecting an execution path of the sequence of mpc operators according to a dependency relationship between the operators; the target execution graph includes a plurality of levels, and each level includes parallel operation of mpc operators that do not have a dependency relationship with each other;
[0095] The code determination module is configured to determine the optimized execution code according to the target execution graph.
[0096] In an embodiment of the above embodiment, the execution graph generation module is specifically configured to: generate a first original execution graph according to a direct dependency relationship between each operator in the sequence of mpc operators; and perform path optimization on the first execution graph using a plurality of optimization strategies to obtain a second execution graph as the target execution graph; wherein the number of levels of the second execution graph is less than that of the first execution graph.
[0097] Further, in an example, the plurality of optimization strategies can include an optimization strategy for multiple executions of the same operator.
[0098] In an embodiment of the above embodiment, the code determination module is specifically configured to: determine a target execution code corresponding to the target execution graph; and perform code optimization on the target execution code to obtain the optimized execution code.
[0099] Further, in an example, the code optimization can include at least one of the following: repeated code elimination, and useless code elimination.
[0100] In one embodiment, the apparatus 100 described above can further comprise a cache clearing unit (not shown in the figure) configured to clear the operator cache list after the execution unit 105 executes the sequence of mpc operators.
[0101] By the script execution apparatus described above, the mpc operators are executed with delay, and a certain range of operator execution contexts are provided through the operator cache list, thereby providing space for optimization of the execution manner. Based on the contexts provided by the operator cache list, the operator execution manner can be optimized within a certain execution window, thereby improving the efficiency of mpc computation.
[0102] According to another aspect, embodiments further provide a computer readable storage medium having stored thereon a computer program which, when executed in a computer, cause the computer to perform the method described above. Figure 4
[0103] According to yet another aspect, embodiments further provide a computing device comprising a memory and a processor, the memory having stored thereon executable code that, when executed by the processor, realizes the method described above. Figure 4
[0104] Those skilled in the art should be aware that, in one or more examples described above, the functions described above of the present application can be realized by hardware, software, firmware or any combination thereof. When realized by software, these functions can be stored in a computer readable medium or transmitted as one or more instructions or codes on a computer readable medium.
[0105] The above detailed description sets forth the purposes, technical solutions and beneficial effects of the present application. It should be understood that the above detailed description is merely a specific embodiment of the present application, and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solutions of the present application shall be included in the protection scope of the present application.
Claims
1. A script execution method involving multi-party secure computation, the method being executed by a script interpreter; comprising: Obtain the user script, which includes several computation formulas involving multi-party secure computation (mpc). During the script reloading phase, the target MPC operator corresponding to any target computation formula is determined, and the target computation formula is modified to generate the target MPC operator. Execute the generation operation in the overloaded script to generate the target MPC operator and add the MPC operator to the operator cache list; In response to a preset trigger condition, the sequence of MPC operators contained in the operator cache list is read; Based on the dependencies between operators, the optimized execution code for the MPC operator sequence is determined; The MPC operator sequence is executed according to the optimized execution code.
2. The method according to claim 1, wherein, The preset triggering condition includes: the operator cache list is full.
3. The method according to claim 1, wherein, The preset triggering conditions include: reading an operation statement of a preset type in the user script, wherein the preset type includes one of the following: outputting the current calculation result, or exiting.
4. The method according to claim 1, wherein, The optimized execution code for the MPC operator sequence is determined, including: Based on the dependencies between operators, a target execution graph is generated that reflects the execution path of the MPC operator sequence; the target execution graph includes several levels, and each level includes parallel operations of MPC operators that are independent of each other; The optimized execution code is determined based on the target execution graph.
5. The method according to claim 4, generating a target execution graph reflecting the execution path of the MPC operator sequence, comprising: Based on the direct dependencies between operators in the MPC operator sequence, the original first execution graph is generated; Using several optimization strategies, the first execution graph is path optimized to obtain a second execution graph as the target execution graph; wherein the number of levels in the second execution graph is less than that in the first execution graph.
6. The method according to claim 5, wherein, The optimization strategies include: Optimization strategies for executing the same operator multiple times.
7. The method according to claim 4, wherein, Based on the target execution graph, the optimized execution code is determined, including: Determine the target execution code corresponding to the target execution graph; The target executable code is optimized to obtain the optimized executable code.
8. The method according to claim 7, wherein the code optimization includes at least one of the following: duplicate code elimination, useless code elimination.
9. The method according to claim 1, further comprising: Clear the operator cache list.
10. A script execution apparatus involving multi-party secure computation, the apparatus being executed by a script interpreter; comprising: The script acquisition unit is configured to acquire user scripts, including several calculation formulas involving multi-party secure computation (mpc). The operator adding unit is configured to, during the script reloading phase, determine the target MPC operator corresponding to any target computation formula, modify the target computation formula to generate the target MPC operator, execute the generation operation in the reloaded script, generate the target MPC operator, and add the MPC operator to the operator cache list; The sequence reading unit is configured to read the MPC operator sequence contained in the operator cache list in response to a preset trigger condition; The optimization unit is configured to determine the optimized execution code of the MPC operator sequence based on the dependencies between operators; The execution unit is configured to execute the MPC operator sequence according to the optimized execution code.
11. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-9.
12. A computing device, comprising a memory and a processor, characterized in that, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-9.
Citation Information
Patent Citations
Data processing method and device and electronic equipment
CN113206830A
Task execution method and device in multi-party security computing
CN113849806A