CN111736816B - Compiling and linking method and device and compiling and linking device - Google Patents

Compiling and linking method and device and compiling and linking device Download PDF

Info

Publication number
CN111736816B
CN111736816B CN202010699759.9A CN202010699759A CN111736816B CN 111736816 B CN111736816 B CN 111736816B CN 202010699759 A CN202010699759 A CN 202010699759A CN 111736816 B CN111736816 B CN 111736816B
Authority
CN
China
Prior art keywords
code
target
pseudo assembly
assembly code
programming language
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010699759.9A
Other languages
Chinese (zh)
Other versions
CN111736816A (en
Inventor
徐鹏
王一帆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huakong Tsingjiao Information Technology Beijing Co Ltd
Original Assignee
Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huakong Tsingjiao Information Technology Beijing Co Ltd filed Critical Huakong Tsingjiao Information Technology Beijing Co Ltd
Priority to CN202010699759.9A priority Critical patent/CN111736816B/en
Publication of CN111736816A publication Critical patent/CN111736816A/en
Application granted granted Critical
Publication of CN111736816B publication Critical patent/CN111736816B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a compiling and linking method and device and a compiling and linking device, which are used for compiling and linking ciphertext processing source codes, wherein the ciphertext processing source codes are realized based on a first programming language, and the ciphertext processing source codes comprise privacy operations realized by a second programming language in a dynamic library form. The method comprises the following steps: compiling the ciphertext processing source code and a core library for realizing the privacy operation according to the grammar rule and the custom language of the first programming language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language; and linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises the object information of all target called objects in the first pseudo assembly code. A cross-language execution environment is provided for the privacy operation.

Description

Compiling and linking method and device and compiling and linking device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a compiling and linking method and apparatus, and an apparatus for compiling and linking.
Background
The ciphertext processing system can realize data-related operations such as data cleaning, calculation, analysis, model training, storage, database query and the like based on the ciphertext of the data, does not expose the plaintext of the data in the operation process, and can protect the privacy and the safety of the data.
In general, a ciphertext processing system includes a front end for implementing a system framework for ciphertext processing and a back end for implementing ciphertext-based privacy computations. Because the processing efficiency of the ciphertext data is lower than that of the plaintext data, in order to improve the efficiency of the privacy computation, the backend is usually implemented by a language with higher relative execution efficiency, such as C/C + +, and the like, and thus the current ciphertext processing system has at least the following problems:
under the condition that the programming language adopted by the rear end of the cryptograph processing system is fixed, if the front end adopts a programming language matched with the rear end programming language, such as Python language, the system cannot support other programming languages, and in order to support other programming languages (such as R language or Java language and the like), other programming languages (such as R language or Java language and the like) have to be used for rewriting a set of system framework of the front end, so that the expansibility of the cryptograph processing system is low, and the redevelopment cost is high.
Disclosure of Invention
The embodiment of the application provides a compiling and linking method and device and a compiling and linking device, which can provide an execution environment for realizing cross-language and cross-platform private computation, so that a ciphertext processing system can support any programming language, the expandability of the system is enhanced, and the execution efficiency of codes can be improved.
In order to solve the above problem, an embodiment of the present application discloses a compiling and linking method, where the method is used for performing compiling and linking on ciphertext processing source codes, where the ciphertext processing source codes are implemented based on a first programming language, and the ciphertext processing source codes include a privacy operation implemented by a second programming language in a dynamic library form, and the method includes:
compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code.
On the other hand, the embodiment of the present application discloses a compiling and linking device, the device is used for compiling and linking ciphertext processing source codes, wherein the ciphertext processing source codes are implemented based on a first programming language, and the ciphertext processing source codes include privacy operations implemented by a second programming language in a dynamic library form, the device includes:
the compiling module is used for compiling the ciphertext processing source code and a core library for realizing the privacy operation according to the grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
and the linking module is used for linking all the function modules in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises the object information of all target called objects in the first pseudo assembly code, and the object information comprises the start line information of the target called objects in the second pseudo assembly code.
In yet another aspect, an embodiment of the present application discloses an apparatus for compiling link, where the apparatus is configured to compile link ciphertext processing source code, where the ciphertext processing source code is implemented based on a first programming language, and includes a privacy operation implemented in a second programming language in the form of a dynamic library, and the apparatus includes a memory, and one or more programs, where the one or more programs are stored in the memory, and configured to be executed by one or more processors, and include instructions for:
compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code.
In yet another aspect, embodiments of the present application disclose a machine-readable medium having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a compiled link method as described in one or more of the preceding.
According to the grammar rule and the custom language of the first programming language, the ciphertext processing source codes and the implementation of the core library of the privacy operation are compiled, the ciphertext processing source codes are converted into first pseudo assembly codes corresponding to the custom language, the core library is converted into second pseudo assembly codes corresponding to the custom language, the compiling process is independent of the first programming language of the front end, a cross-language and cross-platform execution environment is provided for the privacy operation, and the cost of secondary development is reduced.
In addition, in the embodiment of the application, based on a core library basic information table generated in the core library compiling process, each functional module in the first pseudo assembly code is linked to obtain the target file. The core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code. According to the core library basic information table, the implementation codes of the target called objects in the first pseudo assembly codes can be obtained, the pseudo assembly codes of the functional modules can be linked together, the implementation logic of the functional modules is provided, and a foundation is provided for a cross-platform execution environment.
Furthermore, in the embodiment of the application, the execution process of the bottom-layer executor is independent of the first programming language of the front end, so that a cross-language and cross-platform execution environment is provided for privacy operation, and the cost of secondary development is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a flow chart of the steps of one embodiment of a compilation linking method of the present application;
FIG. 2 is a flowchart illustrating the steps of one embodiment of a compiler-linker of the present application;
FIG. 3 is a block diagram of an apparatus 800 for compiling links according to the subject application;
fig. 4 is a schematic diagram of a server in some embodiments of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The general cryptograph processing system comprises a front end and a back end, wherein the front end is used for realizing a system framework for processing the cryptograph, and the back end is used for realizing data related operation based on the cryptograph. Because the ciphertext data processing efficiency is lower than that of plaintext data, in order to improve the ciphertext data processing efficiency, a language with higher relative execution efficiency, such as C/C + +, Rust, Go, and the like, is usually and fixedly adopted at the back end for implementation, and thus the current ciphertext processing system has at least the following problems:
under the condition that the programming language adopted by the rear end of the cryptograph processing system is fixed, if the front end adopts a programming language matched with the rear end programming language, such as Python language, the system cannot support other programming languages, and in order to support other programming languages (such as R language or Java language and the like), other programming languages (such as R language or Java language and the like) have to be used for rewriting a set of system framework of the front end, so that the expansibility of the cryptograph processing system is low, and the redevelopment cost is high.
The cryptograph processing platform (for example, a data transaction platform based on multi-party secure computation) is used for realizing secure fusion of multi-party data under the condition of ensuring that plaintext is not leaked, so that the data island problem is solved. If the front end of the cryptograph processing system running in the cryptograph processing platform only supports one fixed programming language, the application of the platform is definitely limited.
At present, in the fields of Machine Learning (ML), Deep Learning (DL), Artificial Intelligence (AI), and the like, frameworks of ML, DL, AI, and the like implemented by various programming languages appear in order to make it convenient for users to use trained models. Frameworks such as Tensorflow, Pythroch, Keras, MxNet, and caffe based on Python programming language; deeplearning4j based on the Java programming language; SVM light realized based on pure C language and Libsvm + + realized based on C + +; a Caret framework based on the R programming language, and the like. Of course, there are a number of other programming language implementations of frameworks for operations such as data storage, querying, etc., in addition to those described above. If the front end of a cryptograph processing system only supports one programming language, the realization of other programming languages cannot be supported, and the use scene of the platform is limited. If a set of front-end frameworks based on other programming languages (R or Java) are written, and simultaneously the running environments (R virtual machine and Java virtual machine) of other programming languages are used, the research and development cost is greatly increased.
In order to solve the above problems, the present application provides the following solutions.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a compiling and linking method according to the present application is shown, where the method is used for compiling and linking ciphertext processing source code, where the ciphertext processing source code is implemented based on a first programming language, and the ciphertext processing source code includes a privacy operation implemented in a second programming language in the form of a dynamic library, and the method may include the following steps:
step 101, compiling the ciphertext processing source code and a core library for realizing the privacy operation according to the grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language.
It should be noted that, in the embodiment of the present application, "first" and "second" in the first programming language and the second programming language are only used for distinguishing between the front-end framework and the back-end privacy operation of the ciphertext processing system, which may be implemented based on different programming languages, and do not indicate a specific programming language category. Likewise, the first pseudo assembly code and the second pseudo assembly code are used only to distinguish the ciphertext processing source code translated pseudo assembly code from the core library translated pseudo assembly code. It is to be understood that "first" and "second" in the first pseudo assembly code and the second pseudo assembly code and "first" and "second" in the first programming language and the second programming language do not represent a correspondence between the pseudo assembly code and the programming language.
102, linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code.
The method and the device can be used for compiling and linking ciphertext processing source codes compiled by different programming languages. The ciphertext processing source code may include a system framework based on a first programming language, and a privacy operation based on a second programming language, the privacy operation being included in the ciphertext processing source code in the form of a dynamic library.
The ciphertext processing source code refers to a program source code for the ciphertext processing system to perform data processing on ciphertext data. The ciphertext processing includes, but is not limited to: and data related operations such as cleaning, calculation, analysis, model training, storage, database query and the like of the data are realized based on the ciphertext. It should be noted that the embodiment of the present application does not limit the specific type of ciphertext processing. The ciphertext processing system may be implemented in different programming languages, and may perform privacy operations on ciphertext data based on a ciphertext data processing algorithm, for example, the ciphertext processing system may be a multi-party secure computing system.
The privacy operation refers to an operation performed on data based on a ciphertext, and the privacy operation may be implemented by a data processing algorithm based on the ciphertext, where the data processing algorithm may include algorithms such as data calculation, model training, database query, and the like. In the privacy operation process of the data, the data exists in a ciphertext mode, and the plaintext of the data cannot be exposed. Optionally, the privacy operations may include any one or more of: cipher text based computing operations, cipher text based model training, cipher text based database query operations, and the like.
For example, the privacy operations may include: and performing calculation operations such as addition, subtraction, multiplication, division, averaging and the like on the data ciphertext, performing comparison operation on the data ciphertext, performing model training and prediction such as machine learning and artificial intelligence by using the data ciphertext, performing database query operation on the data ciphertext, and the like.
It should be noted that the privacy operation may be implemented by invoking a ciphertext computing system, where the ciphertext computing system may be based on a multi-party secure computing protocol, data participating in the computation includes ciphertext data, and an intermediate result and a final computation result generated in the computation process are also ciphertext data. In the calculation process based on the ciphertext, the data plaintext is not exposed, and the privacy security of the data can be ensured.
The privacy operation may be used for data processing of ciphertext data. In some examples, the ciphertext data is a private data, and the technician stores a program containing a business logic for processing the private data in the task management platform in advance, wherein the business logic describes a processing process of the private data through a computer program language, and the processing process can contain one or more computing tasks. The business logic refers to a process that a technician performs data processing on private data by using one or more computing tasks and obtains the private data according to a natural law. For example, one business logic comprises: under the condition that the clear text of the credit rating values of the enterprises is not known, a group of enterprises which are already ranked according to the credit rating scores and another group of enterprises which are already ranked according to the credit rating scores are merged, and the merging process directly completes the ranking. Another business logic includes: under the condition that the repayment ability score plaintext of each user is not known, a group of users which are sequenced according to the repayment ability score and another group of users which are sequenced according to the repayment ability score are combined, and the sequence is directly completed in the combining process. The scheme of the application is suitable for any privacy operation scene based on the ciphertext.
The first programming language may be a model programming language, and the model programming language refers to a programming language for machine learning, deep learning, and artificial intelligence algorithm implementation. For example, the first programming language may include Python language, Java language, C language, R language, and the like. A framework of models such as machine learning, deep learning and artificial intelligence can be achieved based on the first programming language. For example, frames such as Tensorflow, Pythrch, Keras, MxNet, and caffe implemented based on Python language; a deepearning 4j framework implemented based on the Java language; an SVM light framework realized based on C language; a Libsvm + + framework realized based on a C + + language; a Caret framework implemented based on the R language, and the like.
The Python language is widely used in the fields of machine learning, artificial intelligence and the like due to the characteristics of simplicity, easiness in use, high development efficiency, cross-platform and the like. However, the Python language has its own disadvantage of being slow to run. In the privacy operation process based on the multi-party security computing protocol, at least two computing nodes are required to participate in computing, communication is required to be carried out between the at least two computing nodes, and the execution efficiency of the privacy operation is greatly influenced by multiple times of communication. Therefore, the privacy operation part of the embodiment of the application can be realized based on the C + + language, and compared with the Python language, the operation speed of the privacy operation can be greatly increased, and the processing efficiency of ciphertext processing can be further improved.
It should be noted that, for convenience of description, the first programming language is Python language, and the second programming language is C + + language in the embodiments of the present application. In practical applications, the embodiment of the present application does not limit the language types of the first programming language and the second programming language. For example, the first programming language may include: python language, Java language, C language, R language, etc. The second programming language may include: C/C + + language, Go language, Rust language, etc. The first and second programming languages may be different programming languages.
The method and the device for processing the ciphertext convert the ciphertext processing source codes realized by different first programming languages into the pseudo assembly codes of the user-defined language in a unified mode based on the ciphertext computing compiler. In addition, the embodiment of the application also realizes a ciphertext calculation linker which is used for linking the result obtained by compiling by the ciphertext calculation compiler to obtain the executable target file.
In an example of the embodiment of the present application, the following code list 1 shows a part of codes in ciphertext processing source codes of which the first programming language is Python.
Code list 1:
import sys
import os
import numpy as np
sys.path.append(os.getcwd() + '/privpy_lib')
import pnumpy as pnp
import privpy as pp
import psql as psq
from numpy import array as np
table = pnp.reshape(pp.ss("golda"), (10000,4))
colm0,colm1,colm2,colm3= table.trans()
conj0 = (colm3==5152)
conj1 = (colm2<=3948)
conj2 = (colm2>=3946)
conj3 = ( 1 - (1 - (colm0<20181031)) * (1 - (colm0==20181031)*(colm1<=95838463))))
conj4 = ( 1 - (1 - (colm0>20181031)) * (1 - ((colm0==20181031)*(colm1>=95327897))))
conjs0 =conj0*conj1*conj2*conj3*conj4
colm5= psq.sum(colm2,1)
colm5 = pp.farr([colm5])
pp.reveal(colm5, "a3")
the code list 1 is compiled through a ciphertext computing compiler, so that the code list 1 can be converted into a first pseudo assembly code corresponding to a custom language, as shown in a code list 2.
Code list 2:
----------------Line1----------------
Import sys None
----------------Line2----------------
Import os None
----------------Line3----------------
Import numpy np
----------------Line4----------------
CALL IR4-1 os.getcwd
Add IR4-2 IR4-1 '/privpy_lib'
CALL IR4-3 sys.path.append IR4-2
----------------Line5----------------
......
----------------Line9----------------
CALL IR9-1 pp.ss 'golda'
CALL IR9-2 pnp.reshape IR9-1 visit_Tuple
Assign table IR9-2
----------------Line10----------------
CALL IR10-1 table.trans
Assign visit_Tuple IR10-1
----------------Line12----------------
......
----------------Line18----------------
CALL IR18-1 psq.sum colm2 1
Assign colm5 IR18-1
----------------Line20----------------
CALL IR20-1 pp.farr None
Assign colm5 IR20-1
----------------Line21----------------
CALL IR21-1 pp.reveal colm5 'a3'
in code List 2, the behavior is annotated with a "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -. Ellipses between Line5 and Line9 and between Line12 and Line18 indicate the omission of part of the code.
In the embodiment of the application, the custom language may include a custom operation code, and the operation code is used to support a privacy operation in the ciphertext processing source code. The operation code may include comparison operations such as compare equal (Eq), compare equal to or less (LtE), compare equal to or more (GtE), compare less (Lt), compare greater (Gt). The operation code may further include an Add (Add), a subtract (Sub), a multiply (Mult), a divide (Div), an average (Avg), an ASSIGN operation (ASSIGN), a function CALL (CALL), and the like.
In code listing 2, lines of code beginning with the opcode "CALL" are used to represent pseudo assembly instructions that involve function CALLs. When the ciphertext computation virtual executor executes to the "CALL IR function name parameter name" instruction, it is not known how the called function is implemented. Therefore, in the embodiment of the application, each functional module in the code list 2 is linked through the ciphertext calculation linker, so that the executable target file is obtained. The ciphertext computation linker is used for linking together pseudo assembly code implementations of classes, functions and the like in a Python library generated by a compiler and providing implementation logic of the classes, functions and the like.
Through the ciphertext calculation compiler, a single file (ciphertext processing source code shown as a code list 1) and the core library of the privacy operation can be converted into a pseudo assembly code form of a custom language. The core library of the privacy operation includes a function library supported by a ciphertext computing system called by the privacy operation, such as a pnumpy library, a psql library, a pai library, and the like. Taking the pnumpy library as an example, all Python files under the directory of the pnumpy library can be converted into a pseudo assembly code form by a ciphertext calculation compiler. The core library refers to a Python implementation part at the bottom layer of the ciphertext computing system and a Python implementation part in an algorithm library of the ciphertext computing system.
After the compilation of the ciphertext computing compiler is completed, the ciphertext processing source code may be converted into a first pseudo assembly code corresponding to the custom language, and the core library may be converted into a second pseudo assembly code corresponding to the custom language.
Traversing each module of the compiled core library to generate a core library basic information table. The core library basic information table comprises information of all functions and classes in the core library. Therefore, the core library basic information table includes object information of all the target called objects in the first pseudo assembly code, and the object information includes start line information of the target called objects in the second pseudo assembly code. The target invoked object may include a library function in the ciphertext computing system invoked by the privacy operation, and custom functions and custom classes in the ciphertext computing system invoked by the privacy operation.
Referring to table 1, a specific illustration of a core library basic information table of the embodiment of the present application is shown.
TABLE 1
Args ClassName Distance FileName FuncName PackageName Start Stop
0 [‘x’] 26 math_function square pnumpy 2449 2475
287 [‘arr’, ‘newshape’, ‘order’] 16 Array_mainpulation reshape pnumpy 9 25
130 [‘varname’] 97 ss ss privpy 15 112
1 [‘self’] FixedArr 16 secret_fixed_point _next_ privpy 365 381
2 [‘self’, ‘index’, ‘value’] StringArr 15 secret_string _setitem_ privpy 117 132
3 [‘self’, ‘order’] FixedArr 51 secret_fixed_point dot privpy 986 1037
4 [‘a’, ‘b’, ‘rtol’, ‘atol’] 19 logic_function allclose pnumpy 307 326
5 [‘data’, ‘index’, ‘dtype’] 35 construction _homogenize ppandas 406 441
As shown in Table 1, information for each function or class in the core library that is compiled into pseudo assembly code is maintained in Table 1. Taking the reshape function in the pnumpy library as an example, by looking up the core library basic information table shown in table 1, it can be known that the pseudo assembly code in the file at line9 (i.e. line 10 of the code line, where the index of Python starts from 0 [ Start ]) and in the middle line 16 [ Distance ] of the ending [ Stop ] of line25 in pnumpy [ packageamname ] in the core library is the implementation code of the function. One parameter of this function is x [ Args ]. As can be seen from the basic information table of the core library shown in table 1, the function is an independent function, and is not a member function in a class, so there is no class information. While the dot function [ FuncName ] in the secret _ fixed _ point file [ FileName ] under the private [ packagemame ] package is a member function contained in the class fixdar [ ClassName ], and the pseudo-assembly code implementation of the function is a representation of the pseudo-assembly code of the middle 51 [ Distance ] line starting from line 986 to line 1037 ending [ Stop ].
Based on a core library basic information table generated in the compiling process, implementation codes corresponding to target called objects in the first pseudo assembly code can be recursively introduced into the first pseudo assembly code, so that each functional module in the first pseudo assembly code can be linked to obtain a target file.
In an optional embodiment of the present application, the step 102 of linking, based on a core library basic information table generated by the core library compiling process, each functional module in the first pseudo assembly code includes:
step S11, recursively introducing, based on the core library basic information table, an implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code, so as to obtain a introduced first pseudo assembly code;
step S12, scanning the introduced first pseudo assembly code, and marking the code category of each code line to obtain a marked code;
step S13, for the code line of the mark code whose code type is the first type, converting the code line into the object code which accords with the grammar rule of the first programming language;
and step S14, generating an interface function for the code line of which the code type is the second type in the mark codes.
Wherein the target called object refers to a called object that needs to be recursively introduced into the first pseudo assembly code. The target invoked object may include a library function in the ciphertext computing system invoked by the privacy operation, and custom functions and custom classes in the ciphertext computing system invoked by the privacy operation. In the pseudo assembly code, when a target called object is encountered, the implementation code of the target called object is obtained in a mode of searching a core library basic information table, and the implementation code is in the form of pseudo assembly code.
In an optional embodiment of the present application, the step S12, based on the core library basic information table, recursively introducing, into the first pseudo assembly code, implementation code corresponding to the target called object in the first pseudo assembly code, where the implementation code includes:
step S121, inquiring the object information of the target called object in the core library basic information table;
step S122, acquiring the start line information of the target called object in the second pseudo assembly code according to the object information of the target called object;
step S123, acquiring a realization code corresponding to the target called object according to the start line information of the target called object in the second pseudo assembly code;
step S124, recursively introducing the implementation code corresponding to the target called object to the position of the first pseudo assembly code where the target called object is called.
For convenience of description, the embodiment of the present application takes a reshape function in an array _ management. Referring to code listing 3, the pseudo assembly code for the reshape function is shown.
Code listing 3:
10 FunctionDef : START
11 name : reshape
12 args: arr newshape order
13 body:
14 CALL IR40-1 isinstance arr pp.IntArr
15 If IR40-1
16 Return
17 CALL IR41-2 np.reshape arr.value newshape order
18 CALL IR41-3 pp.IntArr IR41-2
19 Add IR41-4 IR41-3 0
20 CALL IR42-5 pp.farr arr
21 Assign tmp_arr IR42-5
22 Return
23 CALL IR43-6 np.reshape tmp_arr.value newshape order
24 CALL IR43-7 pp.FixedArr IR43-6
25 Add IR43-8 IR43-7 0
26 FunctionDef : STOP
as shown in code List 3, the name of the reshpe function (code line 11), the parameter args (code line 12), and the function body contents (code lines 14-25) are defined. Wherein, the code line 10 "function def: START" is the START mark of the function, and the code line 26 "function def: STOP" is the end mark of the function.
If the target called object in the first pseudo assembly code is a reshpe function, the object information of the target called object can be found through the core library basic information table shown in table 1, and the object information may include: directory name, file name, start line, end line, parameters, etc. According to the object information of the target called object, the start line information of the target called object in the second pseudo assembly code (such as the code list 3) can be acquired, further, according to the start line information of the target called object in the second pseudo assembly code, the implementation code corresponding to the target called object is acquired, and the implementation code corresponding to the target called object is recursively introduced to the position of the first pseudo assembly code where the target called object is called.
Optionally, the ciphertext computation linker of the embodiment of the present application includes a meta information extraction module, where the meta information extraction module is configured to generate a mapping relationship between a target called object and a pseudo assembly code of the target called object.
Specifically, the meta information extraction module performs the following steps by function def: START/FunctionDef: and the STOP is a starting mark of a function and the starting mark with ClassDef: START/ClassDef: STOP as a class, and mapping information is generated so as to conveniently and quickly obtain the implementation code of the target called object through the mapping information.
In one example, taking pnp. reshape function as an example, after the processing of the meta information extraction module, the following mapping information can be obtained. comp _ pnumpy/comp _ array _ management-resume [ 'arr', 'newscape' ] (16, 9, 25). The mapping information indicates that implementation code of the pnp _ resume () function is pseudo assembly code from 16 lines between lines 9-25 in a comp _ pnumpy/comp _ array _ management file, and parameters of the function include: 'arr' and 'newscape'.
In an optional embodiment of the present application, the target invoked object may include the target invoked object itself and invoked objects nested within the target invoked object.
In one example, a ciphertext processing source code, such as a file a, is converted into a first pseudo assembly code corresponding to a custom language after being compiled by a ciphertext computing compiler, such as a file B, a ciphertext computing linker links each function module in the file B, and assuming that a function func1 defined in a ciphertext computing system algorithm library is called in the file B, that is, func1 is a target called object, an implementation code of func1 is obtained based on a core library basic information table and is introduced to a position of calling func1 in the file B. Likewise, if func2 is called again inside func1, the implementation code of func2 is acquired based on the core library basic information table, and is introduced to the file B at the position of func1 where func2 is called. And so on.
The linking process of the embodiment of the present application may include the following four steps, which may be described as: recursive function calls, code class marking, object code generation, and interface function generation.
The recursive function call refers to that the ciphertext computing linker recursively calls all classes, functions and the like defined in a system library and an algorithm library of the ciphertext computing system, and implementation codes of the classes and the functions are recursively introduced into codes to be executed so as to expand operations related to all ciphertexts in the ciphertext computing virtual actuator.
The code type marking means that the ciphertext calculation linker scans pseudo assembly codes after recursive calling, and marks the code type of each code line to obtain a marked code. In this embodiment, two code categories may be marked, namely a first category (e.g., denoted as Python) and a second category (e.g., denoted as Asm), where the first category is used to indicate that the line of code is to be executed in a Python virtual machine, and the second category is used to indicate that the line of code is to be executed in a ciphertext computing virtual executor.
Object code generation refers to the process of converting lines of code marked "Python" into object code that satisfies the Python syntax and is executable in a Python virtual machine. After the pseudo assembly code generated by the cryptograph calculation compiler is marked by the code category, the code line marked as "Python" cannot be directly executed in a Python virtual machine because the syntax of the Python language is not satisfied, and therefore, conversion needs to be performed through the process of object code generation.
Interface function generation refers to the process of generating a code segment executable by the ciphertext computing virtual executor for the code line marked as "Asm". The interface function is used for transmitting parameter information for executing the privacy operation to a ciphertext computing virtual actuator and receiving a return result obtained by calling a bottom-layer actuator to execute the privacy operation by the ciphertext computing virtual actuator.
It should be noted that, in the embodiments of the present application, the first programming language is a Python language, and in a specific implementation, the first programming language may be any type of programming language. For example, if the first programming language is R language, the first class in the process of marking the code class may be R class, and the process of generating the object code may convert the code fragment marked as "R" class into the object code that satisfies the syntax of R language and can be executed in the R language virtual machine. Similarly, the second programming language may be any type of programming language.
In an alternative embodiment of the present application, the step S13 of scanning the imported first pseudo assembly code, and marking the code category of each code line includes:
scanning the introduced first pseudo assembly code, marking a first called object in the introduced first pseudo assembly code and a code line corresponding to a non-privacy operation as a first class, and marking a second called object in the introduced first pseudo assembly code and a code line corresponding to a privacy operation as a second class;
the first called object comprises a system function and a library function corresponding to the first programming language, and the second called object comprises a library function in the ciphertext computing system called by the privacy operation and a custom function and a custom class in the ciphertext computing system called by the privacy operation.
In this embodiment of the present application, the first called object may include a system extension library of Python and a function in a common extension library of Python. Functions in the system extension library of Python such as os.getcwd (), sys.path.apend (); functions in a common extended library of Python are np. The second called object comprises a library function in the ciphertext computing system called by the privacy operation, and a self-defining function and a self-defining class in the ciphertext computing system called by the privacy operation, for example, functions in an extended library supporting plaintext computing provided by the ciphertext computing system, such as pp.farr (), pnp.reshape (), psq.sum (), and the like.
As shown in the code list 3, there are different types of function calls, for example, the isinstance function in row 14 is a function in the system expansion library of Python, the np _ reshape function in row 17 is a function in the common expansion library of Python, and the pp.intear function (initialization function of class) in row 18, the pp.farr function in row 19, and the pp.fixedarr function (initialization function of class) in row 20 are all custom functions in the ciphertext computing system. That is, the functions called in the 14 th and 17 th rows are library functions corresponding to the first programming language, and belong to the first called object; and the three functions in the 18 th line, the 19 th line and the 20 th line are self-defined functions in the ciphertext computing system and belong to a second called object. Thus, the code in line 14 and 17 will be marked as a first class and will execute in a Python environment; while the code of lines 18, 19, and 20 will be labeled as a second category, will be executed by the ciphertext computation virtual executor invoking the underlying executor.
In addition, the code lines corresponding to the non-privacy operations are marked as a first category, and the code lines corresponding to the privacy operations are marked as a second category. The code lines corresponding to the non-private operations refer to code lines that are not relevant to the ciphertext computation. The code line corresponding to the privacy operation refers to a code line related to ciphertext calculation, and has a high coupling degree with the privacy operation, such as a code line of the privacy operation related to ciphertext addition, ciphertext comparison, ciphertext multiplication and the like.
According to the embodiment of the application, all codes related to privacy operation implementation are executed in the cryptograph computing virtual actuator as much as possible, and the switching times in the Python execution environment and the cryptograph computing virtual actuator environment are reduced, so that the code execution efficiency is improved.
Next, for a code line of which the code category is a first category in the mark-up code, converting the code line into object code which accords with the grammar rule of the first programming language; and generating an interface function exec _ code () for the code line of which the code category is the second category in the mark code.
In the embodiment of the present application, each exec _ code () interface function may contain 4 input parameters and one return value. Where the return value is the final output of a line of code labeled "Asm" or a set of codes labeled "Asm". Of the 4 input parameters, the first input parameter is a pseudo assembly code representation in a code line marked as "Asm", the second input parameter is a list of input symbol values corresponding to the pseudo assembly code, the third parameter is a list of input symbol names corresponding to the pseudo assembly code, and the fourth parameter is a list of output symbol names corresponding to the pseudo assembly code. Taking as an example the code line "Conj 1 = pp.exec _ code ([ 'Assign Conj1 IR13-1' ], [ IR13-1], [ 'IR13-1' ], [ 'Conj1' ])" in which the first input parameter of the interface function is: assign conj1 IR13-1, the second input parameter is: IR13-1, the third input parameter is: IR13-1, the fourth input parameter is Conj1, and the return value of the interface function is Conj 1. The interface function is used to perform a privacy operation by the ciphertext computing virtual executor, and assigns the result of the privacy operation to a variable Conj 1.
Optionally, the generating an interface function for a code line of which the code category is the second category in the markup code may include: and combining and generating an interface function corresponding to a plurality of continuous code lines with the code type of the second type.
In the case that a plurality of continuous code lines marked as "Asm" (second category) exist in the mark code, if an exec _ code () interface function is generated for each line, the code needs to jump frequently from the Python virtual machine environment to the ciphertext computing virtual executor environment during the execution process, which affects the execution efficiency. Therefore, the embodiment of the present application combines a plurality of consecutive code lines labeled "Asm" to generate an interface function. Therefore, continuous multi-line codes can be executed in the cryptograph computing virtual actuator and data transmission is carried out in the cryptograph computing virtual actuator, the process of repeatedly returning to the Python virtual machine environment is not needed, the number of times of switching back and forth between the two environments can be reduced, and the execution efficiency can be improved.
In an optional embodiment of the present application, after obtaining the target file in step 102, the method may further include:
inputting the target file into a first programming language executor to execute the target file through the first programming language executor, wherein the first programming language executor calls a corresponding bottom layer executor through a ciphertext computing virtual executor to execute a corresponding privacy operation when executing an interface function in the target file in the process of executing the target file.
In the embodiment of the application, the target file comprises target code which meets the grammar of the first programming language and can be executed in a first programming language executor, and an interface function which accords with the constraint of a ciphertext calculation executor and can be executed in the ciphertext calculation executor. The object code may be executed by an executor of a first programming language. The interface function can be used for transmitting input parameters to the bottom layer executor, executing the privacy operation realized by the interface function through the bottom layer executor, and assigning the calculation result of the privacy operation to the return value of the interface function.
In an alternative embodiment of the present application, the bottom layer actuator may include any one of: secret sharing based executors, homomorphic encryption based executors, trusted execution environment based executors.
In an embodiment of the present application, the bottom layer actuator includes any one of: an SS (Secret Sharing) based executor, an HE (Homomorphic Encryption) based executor, and a TEE (Trusted Execution Environment) based executor.
Optionally, in this embodiment of the present application, the ciphertext computation virtual executor may select a corresponding bottom layer executor according to the data obtaining manner of the privacy operation. The Data acquisition mode refers to a mode of acquiring Data from a DS (Data Server) to an ES (execution Server). For example, if the pp.ss () function is used in the process of acquiring data from the DS to the ES, the SS-based underlying executor is selected; selecting an HE-based bottom layer executor if a pp.he () function is used in the process of acquiring data from the DS to the ES; the TEE-based underlying executor is selected if the pp.tee () function is used in getting data from the DS to the ES.
In summary, according to the grammar rule and the custom language of the first programming language, the ciphertext processing source code and the core library for realizing the privacy operation are compiled, the ciphertext processing source code is converted into the first pseudo assembly code corresponding to the custom language, and the core library is converted into the second pseudo assembly code corresponding to the custom language, so that the compiling process is independent of the first programming language at the front end, a cross-language and cross-platform execution environment is provided for the privacy operation, and the cost of secondary development is reduced.
In addition, in the embodiment of the application, based on a core library basic information table generated in the core library compiling process, each functional module in the first pseudo assembly code is linked to obtain the target file. The core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code. According to the core library basic information table, the implementation codes of the target called objects in the first pseudo assembly codes can be obtained, the pseudo assembly codes of the functional modules can be linked together, the implementation logic of the functional modules is provided, and a foundation is provided for a cross-platform execution environment.
Furthermore, in the embodiment of the application, the execution process of the bottom-layer executor is independent of the first programming language of the front end, so that a cross-language and cross-platform execution environment is provided for privacy operation, and the cost of secondary development is reduced.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the embodiments of the application.
Device embodiment
Referring to fig. 2, a block diagram illustrating an embodiment of a compiling and linking apparatus according to the present application, where the apparatus is configured to perform compiling and linking on ciphertext processing source code, where the ciphertext processing source code is implemented based on a first programming language, and the ciphertext processing source code includes a privacy operation implemented by a second programming language in the form of a dynamic library, and the apparatus may specifically include:
a compiling module 201, configured to compile the ciphertext processing source code and a core library for implementing the privacy operation according to a grammar rule of the first programming language and a custom language, convert the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and convert the core library into a second pseudo assembly code corresponding to the custom language;
a linking module 202, configured to link each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process, so as to obtain a target file, where the core library basic information table includes object information of all target called objects in the first pseudo assembly code, and the object information includes start line information of the target called objects in the second pseudo assembly code.
Optionally, the link module 202 includes:
a recursive calling sub-module, configured to recursively introduce, based on the core library basic information table, an implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code, so as to obtain a first introduced pseudo assembly code;
the scanning and marking submodule is used for scanning the introduced first pseudo assembly code and marking the code category of each code line to obtain a marking code;
the code conversion sub-module is used for converting the code line of which the code category is the first category in the mark codes into the target codes which accord with the grammar rule of the first programming language;
and the interface generation submodule is used for generating an interface function for the code line of which the code category is the second category in the mark code.
Optionally, the recursive invocation submodule includes:
the query unit is used for querying the object information of the target called object in the core library basic information table;
a first obtaining unit, configured to obtain, according to object information of the target called object, start line information of the target called object in the second pseudo assembly code;
a second obtaining unit, configured to obtain, according to start line information of the target called object in the second pseudo assembly code, an implementation code corresponding to the target called object;
and the recursion unit is used for recursively introducing the implementation code corresponding to the target called object to the position of the first pseudo assembly code where the target called object is called.
Optionally, the target invoked object includes the target invoked object itself and an invoked object nested inside the target invoked object.
Optionally, the scan marking sub-module is specifically configured to scan the introduced first pseudo assembly code, mark a code line corresponding to a first called object and a non-privacy operation in the introduced first pseudo assembly code as a first category, and mark a code line corresponding to a second called object and a privacy operation in the introduced first pseudo assembly code as a second category;
the first called object comprises a system function and a library function corresponding to the first programming language, and the second called object comprises a library function in the ciphertext computing system called by the privacy operation and a custom function and a custom class in the ciphertext computing system called by the privacy operation.
Optionally, the apparatus further comprises:
and the execution module is used for inputting the target file into a first programming language executor so as to execute the target file through the first programming language executor, wherein in the process of executing the target file, when an interface function in the target file is executed, the first programming language executor calls a corresponding bottom layer executor through a ciphertext computing virtual executor to execute corresponding privacy operation.
Optionally, the bottom layer actuator comprises any one of: secret sharing based executors, homomorphic encryption based executors, trusted execution environment based executors.
In summary, according to the grammar rule and the custom language of the first programming language, the ciphertext processing source code and the core library for realizing the privacy operation are compiled, the ciphertext processing source code is converted into the first pseudo assembly code corresponding to the custom language, and the core library is converted into the second pseudo assembly code corresponding to the custom language, so that the compiling process is independent of the first programming language at the front end, a cross-language and cross-platform execution environment is provided for the privacy operation, and the cost of secondary development is reduced.
In addition, in the embodiment of the application, based on a core library basic information table generated in the core library compiling process, each functional module in the first pseudo assembly code is linked to obtain the target file. The core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code. According to the core library basic information table, the implementation codes of the target called objects in the first pseudo assembly codes can be obtained, the pseudo assembly codes of the functional modules can be linked together, the implementation logic of the functional modules is provided, and a foundation is provided for a cross-platform execution environment.
Furthermore, in the embodiment of the application, the execution process of the bottom-layer executor is independent of the first programming language of the front end, so that a cross-language and cross-platform execution environment is provided for privacy operation, and the cost of secondary development is reduced.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The embodiment of the application provides a device for compiling link, which is used for compiling link to ciphertext processing source code, wherein the ciphertext processing source code is implemented based on a first programming language, and the ciphertext processing source code includes a privacy operation implemented by a second programming language in a dynamic library form, the device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and are configured to be executed by the one or more processors, and the one or more programs include instructions for: compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language; linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code.
FIG. 3 is a block diagram illustrating an apparatus 800 for compiling links according to an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 3, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed state of the device 800, the relative positioning of the components, such as a display and keypad of the apparatus 800, the sensor assembly 814 may also detect a change in position of the apparatus 800 or a component of the apparatus 800, the presence or absence of user contact with the apparatus 800, orientation or acceleration/deceleration of the apparatus 800, and a change in temperature of the apparatus 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 4 is a schematic diagram of a server in some embodiments of the present application. The server 1900 may vary widely by configuration or performance and may include one or more Central Processing Units (CPUs) 1922 (e.g., one or more processors) and memory 1932, one or more storage media 1930 (e.g., one or more mass storage devices) storing applications 1942 or data 1944. Memory 1932 and storage medium 1930 can be, among other things, transient or persistent storage. The program stored in the storage medium 1930 may include one or more modules (not shown), each of which may include a series of instructions operating on a server. Still further, a central processor 1922 may be provided in communication with the storage medium 1930 to execute a series of instruction operations in the storage medium 1930 on the server 1900.
The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input-output interfaces 1958, one or more keyboards 1956, and/or one or more operating systems 1941, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
A non-transitory computer readable storage medium in which instructions, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform the compile link method shown in fig. 1.
A non-transitory computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor of an apparatus (server or terminal), enable the apparatus to perform a compilation linking method for compiling ciphertext processing source code, wherein the ciphertext processing source code is implemented based on a first programming language and includes privacy operations implemented in a second programming language in the form of a dynamic library, the method comprising: compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language; linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.
The compiling and linking method, the compiling and linking device and the device for compiling and linking provided by the application are introduced in detail, and specific examples are applied in the description to explain the principle and the implementation manner of the application, and the description of the above embodiments is only used for helping to understand the method and the core idea of the application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (19)

1. A compilation linking method, wherein the method is used for performing compilation linking on ciphertext processing source code, and wherein the ciphertext processing source code is implemented based on a first programming language and includes privacy operations implemented in a second programming language in the form of a dynamic library, the method comprising:
compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code;
the user-defined language comprises a user-defined operation code, and the operation code is used for supporting privacy operation in the ciphertext processing source code;
the step of linking each functional module in the first pseudo assembly code based on the core library basic information table generated in the core library compiling process comprises the following steps:
recursively introducing an implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code based on the core library basic information table to obtain a introduced first pseudo assembly code;
scanning the introduced first pseudo assembly code, and marking the code category of each code line to obtain a marked code;
for the code line of which the code category is a first category in the mark codes, converting the code line into target codes which accord with the grammar rule of the first programming language;
and generating an interface function for the code line of which the code category is the second category in the mark codes.
2. The method according to claim 1, wherein the recursively introducing, based on the core library basic information table, implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code comprises:
inquiring the object information of the target called object in the core library basic information table;
acquiring the start line information of the target called object in the second pseudo assembly code according to the object information of the target called object;
acquiring an implementation code corresponding to the target called object according to the start line information of the target called object in the second pseudo assembly code;
and recursively introducing the implementation code corresponding to the target called object to the position of the first pseudo assembly code where the target called object is called.
3. The method of claim 1, wherein the target invoked object comprises the target invoked object itself and invoked objects nested within the target invoked object.
4. The method of claim 1, wherein scanning the imported first pseudo assembly code to mark a code class of each code line comprises:
scanning the introduced first pseudo assembly code, marking a first called object in the introduced first pseudo assembly code and a code line corresponding to a non-privacy operation as a first class, and marking a second called object in the introduced first pseudo assembly code and a code line corresponding to a privacy operation as a second class;
the first called object comprises a system function and a library function corresponding to the first programming language, and the second called object comprises a library function in the ciphertext computing system called by the privacy operation and a custom function and a custom class in the ciphertext computing system called by the privacy operation.
5. The method of any of claims 1 to 4, wherein after obtaining the target document, the method further comprises:
inputting the target file into a first programming language executor to execute the target file through the first programming language executor, wherein the first programming language executor calls a corresponding bottom layer executor through a ciphertext computing virtual executor to execute a corresponding privacy operation when executing an interface function in the target file in the process of executing the target file.
6. The method of claim 5, wherein the bottom layer actuator comprises any one of: secret sharing based executors, homomorphic encryption based executors, trusted execution environment based executors.
7. A compile-linking apparatus, configured to perform compile-linking on ciphertext processing source code, where the ciphertext processing source code is implemented based on a first programming language and includes a privacy operation implemented in a second programming language in the form of a dynamic library, the apparatus comprising:
the compiling module is used for compiling the ciphertext processing source code and a core library for realizing the privacy operation according to the grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
a linking module, configured to link each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, where the core library basic information table includes object information of all target called objects in the first pseudo assembly code, and the object information includes start line information of the target called objects in the second pseudo assembly code;
the user-defined language comprises a user-defined operation code, and the operation code is used for supporting privacy operation in the ciphertext processing source code;
the link module includes:
a recursive calling sub-module, configured to recursively introduce, based on the core library basic information table, an implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code, so as to obtain a first introduced pseudo assembly code;
the scanning and marking submodule is used for scanning the introduced first pseudo assembly code and marking the code category of each code line to obtain a marking code;
the code conversion sub-module is used for converting the code line of which the code category is the first category in the mark codes into the target codes which accord with the grammar rule of the first programming language;
and the interface generation submodule is used for generating an interface function for the code line of which the code category is the second category in the mark code.
8. The apparatus of claim 7, wherein said recursive invocation submodule comprises:
the query unit is used for querying the object information of the target called object in the core library basic information table;
a first obtaining unit, configured to obtain, according to object information of the target called object, start line information of the target called object in the second pseudo assembly code;
a second obtaining unit, configured to obtain, according to start line information of the target called object in the second pseudo assembly code, an implementation code corresponding to the target called object;
and the recursion unit is used for recursively introducing the implementation code corresponding to the target called object to the position of the first pseudo assembly code where the target called object is called.
9. The apparatus of claim 7, wherein the target invoked object comprises the target invoked object itself and an invoked object nested within the target invoked object.
10. The apparatus according to claim 7, wherein the scan marking sub-module is specifically configured to scan the imported first pseudo assembly code, mark code lines corresponding to a first called object and a non-private operation in the imported first pseudo assembly code as a first category, and mark code lines corresponding to a second called object and a private operation in the imported first pseudo assembly code as a second category;
the first called object comprises a system function and a library function corresponding to the first programming language, and the second called object comprises a library function in the ciphertext computing system called by the privacy operation and a custom function and a custom class in the ciphertext computing system called by the privacy operation.
11. The apparatus of any one of claims 7 to 10, further comprising:
and the execution module is used for inputting the target file into a first programming language executor so as to execute the target file through the first programming language executor, wherein in the process of executing the target file, when an interface function in the target file is executed, the first programming language executor calls a corresponding bottom layer executor through a ciphertext computing virtual executor to execute corresponding privacy operation.
12. The apparatus of claim 11, wherein the bottom layer actuator comprises any one of: secret sharing based executors, homomorphic encryption based executors, trusted execution environment based executors.
13. An apparatus for compile linking, wherein the apparatus is configured to compile linking ciphertext processing source code, wherein the ciphertext processing source code is implemented based on a first programming language and includes privacy operations implemented in a second programming language in the form of a dynamic library, the apparatus comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors to perform the one or more programs including instructions for:
compiling the ciphertext processing source code and a core library for realizing the privacy operation according to a grammar rule of the first programming language and a custom language, converting the ciphertext processing source code into a first pseudo assembly code corresponding to the custom language, and converting the core library into a second pseudo assembly code corresponding to the custom language;
linking each function module in the first pseudo assembly code based on a core library basic information table generated in the core library compiling process to obtain a target file, wherein the core library basic information table comprises object information of all target called objects in the first pseudo assembly code, and the object information comprises start line information of the target called objects in the second pseudo assembly code;
the user-defined language comprises a user-defined operation code, and the operation code is used for supporting privacy operation in the ciphertext processing source code;
the step of linking each functional module in the first pseudo assembly code based on the core library basic information table generated in the core library compiling process comprises the following steps:
recursively introducing an implementation code corresponding to a target called object in the first pseudo assembly code into the first pseudo assembly code based on the core library basic information table to obtain a introduced first pseudo assembly code;
scanning the introduced first pseudo assembly code, and marking the code category of each code line to obtain a marked code;
for the code line of which the code category is a first category in the mark codes, converting the code line into target codes which accord with the grammar rule of the first programming language;
and generating an interface function for the code line of which the code category is the second category in the mark codes.
14. The apparatus according to claim 13, wherein the recursively introducing, into the first pseudo assembly code, implementation code corresponding to the target called object in the first pseudo assembly code based on the core library basic information table includes:
inquiring the object information of the target called object in the core library basic information table;
acquiring the start line information of the target called object in the second pseudo assembly code according to the object information of the target called object;
acquiring an implementation code corresponding to the target called object according to the start line information of the target called object in the second pseudo assembly code;
and recursively introducing the implementation code corresponding to the target called object to the position of the first pseudo assembly code where the target called object is called.
15. The apparatus of claim 13, wherein the target invoked object comprises the target invoked object itself and an invoked object nested within the target invoked object.
16. The apparatus of claim 13, wherein the scanning the imported first pseudo assembly code to mark a code class of each code line comprises:
scanning the introduced first pseudo assembly code, marking a first called object in the introduced first pseudo assembly code and a code line corresponding to a non-privacy operation as a first class, and marking a second called object in the introduced first pseudo assembly code and a code line corresponding to a privacy operation as a second class;
the first called object comprises a system function and a library function corresponding to the first programming language, and the second called object comprises a library function in the ciphertext computing system called by the privacy operation and a custom function and a custom class in the ciphertext computing system called by the privacy operation.
17. The apparatus of any of claims 13 to 16, wherein the apparatus is further configured to execute the one or more programs by the one or more processors includes instructions for:
inputting the target file into a first programming language executor to execute the target file through the first programming language executor, wherein the first programming language executor calls a corresponding bottom layer executor through a ciphertext computing virtual executor to execute a corresponding privacy operation when executing an interface function in the target file in the process of executing the target file.
18. The apparatus of claim 17, wherein the bottom layer actuator comprises any one of: secret sharing based executors, homomorphic encryption based executors, trusted execution environment based executors.
19. A machine-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform the method of compiling a link according to any of claims 1 to 6.
CN202010699759.9A 2020-07-20 2020-07-20 Compiling and linking method and device and compiling and linking device Active CN111736816B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010699759.9A CN111736816B (en) 2020-07-20 2020-07-20 Compiling and linking method and device and compiling and linking device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010699759.9A CN111736816B (en) 2020-07-20 2020-07-20 Compiling and linking method and device and compiling and linking device

Publications (2)

Publication Number Publication Date
CN111736816A CN111736816A (en) 2020-10-02
CN111736816B true CN111736816B (en) 2020-11-24

Family

ID=72655172

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010699759.9A Active CN111736816B (en) 2020-07-20 2020-07-20 Compiling and linking method and device and compiling and linking device

Country Status (1)

Country Link
CN (1) CN111736816B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302150B (en) * 2022-09-08 2024-02-13 科东(广州)软件科技有限公司 Hypervisor self-starting program generation method and operating system starting method
CN117234590B (en) * 2023-08-02 2024-03-29 北京握奇数据股份有限公司 Instruction set generation method, device, medium and equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4118456B2 (en) * 1999-06-29 2008-07-16 株式会社東芝 Program language processing system, code optimization method, and machine-readable storage medium
CN102880452A (en) * 2012-02-01 2013-01-16 日照市国软软件有限公司 Programming language capable of cross-language reusing
CN105653260A (en) * 2015-12-22 2016-06-08 中软信息系统工程有限公司 Multi-CPU framework-supporting application software development and operation service system
CN109918074B (en) * 2017-12-08 2022-09-27 中标软件有限公司 Compiling link optimization method
CN111158646A (en) * 2019-12-17 2020-05-15 广西交通设计集团有限公司 SQL lightweight persistent layer framework and configuration method

Also Published As

Publication number Publication date
CN111736816A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
CN111258590B (en) Code execution method and device for code execution
CN111142876B (en) Compiling processing method and device and compiling processing device
CN109032606B (en) Native application compiling method and device and terminal
US11520995B2 (en) Systems and methods for dynamically expanding natural language processing agent capacity
CN110365751B (en) Service processing method, device and equipment of gateway system
CN111736816B (en) Compiling and linking method and device and compiling and linking device
CN107423106B (en) Method and apparatus for supporting multi-frame syntax
CN114168111B (en) Method, device, product and storage medium for realizing componentized route
CN112187862A (en) Task processing method and device for task processing
CN113076108B (en) Code execution method and device for code execution
CN110704030A (en) Interface configuration information generation method and device, electronic equipment and storage medium
CN111221613B (en) Program calling method and device and storage medium
CN111767058A (en) Program compiling method and device, electronic equipment and storage medium
CN111736852B (en) Compiling and linking method and device and compiling and linking device
CN111274556A (en) Code obfuscation method, device and storage medium
CN107832058B (en) Data processing method and device
CN112287380B (en) Data processing method and device and data processing device
CN115202623A (en) Service capability using method, device and equipment
CN110989987B (en) Portal webpage generation method and device, client, server and storage medium
CN112486617A (en) Ciphertext data processing architecture, method, device and machine readable medium
CN110209591A (en) Picture searching method, apparatus, electronic equipment and storage medium
CN116361838B (en) Data processing method, device and system and readable storage medium
CN112003788B (en) Data request sending method, device, equipment and medium
CN114721913B (en) Method and device for generating data flow graph
CN114020694B (en) Header file address acquisition method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant