Generation method, operation method and device of digital currency hard wallet application program
The instruction set of the digital currency hard wallet application is replaced and protected through custom mapping tables and encryption technology, which solves the security problem of Java Applet applications being easily decompiled during the distribution and storage process, and achieves effective protection of applications. Protect.
Patent Information
- Application Number
- CN202310269817.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2024-09-20
AI Technical Summary
Digital currency Java Applet applications are easily decompiled during distribution and storage, leading to security risks.
Use a custom mapping table to forward-replace the instruction set in the application source code, encrypt the mapping table, generate ciphertext, and package it into a hard wallet application file to ensure that it is run through key decryption in the security chip.
The security of the application is improved, the original code is difficult to recover through reverse analysis, the business logic is protected, and the security of the digital currency hard wallet application is enhanced.
Smart Images

Figure CN118673475A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of digital currency technology, and in particular to a method for generating, a method for operating, and a device for a digital currency hard wallet application. Background Art
[0002] Digital currency uses the Java Applet application running in the security chip to realize the hard wallet function. In the usual process, Java Applet is generally imported into the security chip in the user terminal through online distribution. The basic process of importing is: the programmer writes the Java Applet source code based on the Java language, and then compiles it into an executable Cap file (Java Applet application), and the Applet application is then distributed to the security chip through the TSM system.
[0003] Since Java files are very easy to be decompiled, Java Applet applications may have risks in multiple links. First, during the distribution process, digital currency Applet applications may be hijacked and leaked in the link; second, when digital currency Applet applications are sent to security chips, attackers may export firmware from the security chips. The leaked Java Applet files can be decompiled and other methods can be used to discover relevant important business logic. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and device for generating a digital currency hard wallet application to solve the technical problem that the application is easily decompiled.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating a digital currency hard wallet application is provided, comprising:
[0006] Get the source code of the digital currency hard wallet application;
[0007] Based on a custom mapping table, the instruction set in the source code of the digital currency hard wallet application is positively replaced, thereby generating an intermediate file of the digital currency hard wallet application; wherein the mapping table includes the instruction set before the replacement and the instruction set after the replacement;
[0008] Encrypting the mapping table using a key to generate a mapping table ciphertext;
[0009] The digital currency hard wallet application intermediate file and the mapping table ciphertext are packaged into a digital currency hard wallet application file.
[0010] Optionally, based on a custom mapping table, the instruction set in the source code of the digital currency hard wallet application is positively replaced to generate a digital currency hard wallet application intermediate file, including:
[0011] Compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file;
[0012] Based on a custom mapping table, the class files in the bytecode file of the digital currency hard wallet application are parsed and forward replaced by instruction sets, thereby generating a digital currency hard wallet application intermediate file; wherein the instruction set is an opcode instruction set.
[0013] Optionally, packaging the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file includes:
[0014] The digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file; wherein the JavaRuntime class library is used to decrypt the mapping table ciphertext and reversely replace the instruction set in the security chip.
[0015] Optionally, the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file, including:
[0016] Packing the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format;
[0017] The digital currency hard wallet application file in the Jar file format is converted into a digital currency hard wallet application file in the Cap file format.
[0018] Optionally, after packaging the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file, the method further includes:
[0019] Distribute the digital currency hard wallet application file to the security chip.
[0020] Optionally, after distributing the digital currency hard wallet application file to the security chip, the method further includes:
[0021] When the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server.
[0022] Optionally, the method further comprises:
[0023] The key is imported into the security chip by production line presetting.
[0024] In addition, according to another aspect of an embodiment of the present invention, a method for running a digital currency hard wallet application is provided, comprising:
[0025] Decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and mapping table ciphertext;
[0026] Decrypting the mapping table ciphertext using the key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement;
[0027] Based on the mapping table, reversely replace the instruction set in the digital currency hard wallet application intermediate file, thereby generating a digital currency hard wallet application instruction file;
[0028] Execute the digital currency hard wallet application instruction file.
[0029] In addition, according to another aspect of an embodiment of the present invention, a device for generating a digital currency hard wallet application is provided, comprising:
[0030] Obtaining module, used to obtain the source code of the digital currency hard wallet application;
[0031] A forward replacement module, used to perform forward replacement on the instruction set in the source code of the digital currency hard wallet application based on a custom mapping table, thereby generating an intermediate file of the digital currency hard wallet application; wherein the mapping table includes the instruction set before replacement and the instruction set after replacement;
[0032] An encryption module, used to encrypt the mapping table using a key to generate a mapping table ciphertext;
[0033] The packaging module is used to package the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file.
[0034] Optionally, the forward replacement module is further used for:
[0035] Compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file;
[0036] Based on a custom mapping table, the class files in the bytecode file of the digital currency hard wallet application are parsed and forward replaced by instruction sets, thereby generating a digital currency hard wallet application intermediate file; wherein the instruction set is an opcode instruction set.
[0037] Optionally, the packaging module is further used for:
[0038] The digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file; wherein the JavaRuntime class library is used to decrypt the mapping table ciphertext and reversely replace the instruction set in the security chip.
[0039] Optionally, the packaging module is further used for:
[0040] Packing the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format;
[0041] The digital currency hard wallet application file in the Jar file format is converted into a digital currency hard wallet application file in the Cap file format.
[0042] Optionally, the device further comprises:
[0043] A distribution module is used to distribute the digital currency hard wallet application file to the security chip.
[0044] Optionally, the distribution module is further used for:
[0045] When the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server.
[0046] Optionally, the key is imported into the security chip by production line presetting.
[0047] In addition, according to another aspect of an embodiment of the present invention, a running device for a digital currency hard wallet application is provided, comprising:
[0048] A decompression module is used to decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and the mapping table ciphertext;
[0049] A decryption module, used to decrypt the mapping table ciphertext using a key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement;
[0050] A reverse replacement module, used to reversely replace the instruction set in the digital currency hard wallet application intermediate file based on the mapping table, thereby generating a digital currency hard wallet application instruction file;
[0051] An execution module is used to execute the digital currency hard wallet application instruction file.
[0052] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:
[0053] one or more processors;
[0054] a storage device for storing one or more programs,
[0055] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0056] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0057] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0058] One embodiment of the above invention has the following advantages or beneficial effects: because the instruction set in the source code of the digital currency hard wallet application is positively replaced based on a custom mapping table, and the mapping table is encrypted with a key, the technical problem of the application being easily decompiled in the prior art is overcome. The embodiment of the present invention uses a custom mapping table to positively replace the instruction set in the source code and encrypts the mapping table for protection. When the attacker performs a reverse attack analysis on the protected digital currency hard wallet application file, since the instruction set in the source code has been replaced by a custom instruction set that is extremely difficult to crack, and the key is stored in the security chip, even if the attacker obtains the digital currency hard wallet application, it is difficult to read the chaotic code, difficult to restore the original code, and difficult to understand the business logic, thereby achieving the purpose of protecting the digital currency hard wallet application.
[0059] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0061] Figure 1 is a schematic diagram of the main process of a method for generating a digital currency hard wallet application according to an embodiment of the present invention;
[0062] Figure 2 It is a schematic diagram of the replacement relationship between the customized Java virtual machine instruction set OPcode (listed above) and the conventional Java virtual machine instruction set OPcode (listed below) according to an embodiment of the present invention;
[0063] Figure 3 It is a schematic diagram of the main process of a method for generating a digital currency hard wallet application according to a reference embodiment of the present invention;
[0064] Figure 4 It is a schematic diagram of the main process of a method for generating a digital currency hard wallet application according to another reference embodiment of the present invention;
[0065] Figure 5 is a schematic diagram of the main process of the method for running a digital currency hard wallet application according to an embodiment of the present invention;
[0066] Figure 6 It is a schematic diagram of the main process of the operation method of the digital currency hard wallet application according to a reference embodiment of the present invention;
[0067] Figure 7 is a schematic diagram of main modules of a device for generating a digital currency hard wallet application according to an embodiment of the present invention;
[0068] Figure 8 is a schematic diagram of main modules of a running device for a digital currency hard wallet application according to an embodiment of the present invention;
[0069] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0070] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0071] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0072] Java application code protection has always been a major security issue. Currently, Java programs running on terminals such as PCs and mobile phones are generally protected by reinforcement, obfuscation, and conversion from Java to C language. The high-performance processors that PCs and mobile phones rely on are sufficient to support the performance and efficiency consumption brought by complex code protection schemes. However, compared with the CPUs on terminals such as PCs and mobile phones, the processing power of security chips is extremely low, and the memory and storage are extremely small, making it difficult to implement and support the operation of complex software protection technologies. At the same time, the Cap file of Java Applet is a special file format and cannot be directly protected. More importantly, since Java Applet is usually stored in the security chip after being issued and relies on hardware security isolation protection, various application parties generally believe that its risk window is relatively small, and basically no software protection is performed on Java Applet.
[0073] Figure 1 Schematic diagram of the main process of the method for generating a digital currency hard wallet application according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for generating the digital currency hard wallet application may include:
[0074] Step 101, obtain the digital currency hard wallet application source code.
[0075] First, the programmer writes the digital currency hard wallet application (Java Applet) source code based on the Java language and packages it into a digital currency hard wallet application source code file in the Jar file format. Specifically, the digital currency hard wallet application source code can be obtained through the interface component.
[0076] Step 102, based on the customized mapping table, forward replace the instruction set in the source code of the digital currency hard wallet application, so as to generate an intermediate file of the digital currency hard wallet application; wherein the mapping table includes the instruction set before replacement and the instruction set after replacement.
[0077] Before step 102, it is necessary to customize the mapping table first, and the mapping table includes the instruction set before replacement and the instruction set after replacement, and the two are in a mapping relationship. In step 102, the instruction set in the source code of the digital currency hard wallet application can be positively replaced based on the pre-customized mapping table, so as to generate the digital currency hard wallet application intermediate file. In other words, the instruction set in the source code of the digital currency hard wallet application is the instruction set before replacement in the mapping table, and the instruction set in the intermediate file of the digital currency hard wallet application is the instruction set after replacement in the mapping table.
[0078] Optionally, step 102 may include: compiling the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file; based on a custom mapping table, performing instruction set parsing and forward replacement on the class file in the digital currency hard wallet application bytecode file, thereby generating a digital currency hard wallet application intermediate file; wherein the instruction set is an opcode instruction set. Since the digital currency hard wallet application source code is written in Java, it is necessary to first use a Java compiler to compile it into a digital currency hard wallet application bytecode file, and then parse the class file (class file) in the digital currency hard wallet application bytecode file, and based on a custom mapping table, forward replace the opcode (OPCode) instruction set in the class file, thereby generating a digital currency hard wallet application intermediate file. In an embodiment of the present invention, the instruction set is an opcode instruction set, i.e., OPCode,
[0079] Bytecode file: Bytecode is an intermediate code, which is more abstract than machine code and needs to be translated by a translator to become an intermediate code of machine code. Bytecode is a binary code (file) in an intermediate state (intermediate code). The bytecode file is in class format and mainly contains the Java virtual machine instruction set and symbol table as well as some other auxiliary information, among which the main part of the Java virtual machine instruction set is the operation code (OPCode).
[0080] The Java virtual machine instruction set consists of an operation code (OPCode) of one byte length, which represents a specific operation meaning, followed by zero or more operands (OPerand) representing the parameters required for this operation. Many instructions in the Java virtual machine do not contain operands, but only one OPCode. Therefore, the main part of the Java virtual machine instruction set is OPCode. When the Java application is started and run, the Java virtual machine needs to parse the bytecode (mainly the OPCode instruction set), convert it into machine-readable machine code and run it in the system. In the whole process, the most critical thing is to protect the OPCode instruction set.
[0081] Machine code is data that can be directly interpreted by the computer's CPU (computers only recognize 0 and 1). Generally speaking, machine code is the code that a computer can directly execute and execute the fastest.
[0082] The Java virtual machine currently has 204 opcodes, each of which represents a certain function. For example, 0x04 represents pushing the int constant value 1 onto the stack, and 0x62 represents adding the two float values at the top of the stack and pushing the result onto the stack. Each opcode has a mnemonic, for example, the mnemonic of 0x62 is fadd, the mnemonic of 0x04 is iconst_1, and the mnemonic of 0x00 is nop, which means no operation. As shown in the following table:
[0083]
[0084]
[0085] The embodiment of the present invention customizes the OPcode of the Java virtual machine instruction set, establishes a replacement relationship between the customized Java virtual machine instruction set OPcode (i.e., the operation code after replacement) and the conventional Java virtual machine instruction set OPcode (i.e., the operation code before replacement), and encrypts and protects the replacement relationship.
[0086] like Figure 2 As shown, the custom Opcode 0x00 corresponds to the conventional Opcode 0x02, and the custom Opcode 0x02 corresponds to the conventional Opcode 0x0F. That is, when the protected digital currency hard wallet application executes instruction sets 0x00 and 0x02, it does not represent the functions "no operation" and "int type constant value -1 push" represented by the conventional Opcode, but the two functions "int type constant value -1 push" and "double type constant value 1 push".
[0087] Since there are 204 Opcodes, the maximum number of mappings between custom Opcodes and regular Opcodes is: 204*203*202*201*…*2*1=n!, a large number of 385 digits, which is difficult to crack by brute force. Therefore, even if the application is leaked, it is difficult for attackers to steal the processing logic by decompiling it.
[0088] It should be pointed out that some of the 204 opcodes can be customized and replaced, or all of the 204 opcodes can be customized and replaced. The more customized opcodes are, the more difficult it will be to decompile.
[0089] Step 103: encrypt the mapping table using a key to generate a mapping table ciphertext.
[0090] In order to ensure that the application file will not be decompiled, the mapping table needs to be encrypted to generate a mapping table ciphertext. Optionally, a symmetric encryption algorithm can be used to encrypt the mapping table to increase the speed of encryption and decryption.
[0091] Step 104, packaging the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file.
[0092] In this step, the digital currency hard wallet application intermediate file and the mapping table ciphertext are packaged into a digital currency hard wallet application file, and the digital currency hard wallet application file can be sent to the security chip for installation.
[0093] Optionally, step 104 may include: packaging the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file; wherein the JavaRuntime class library is used to decrypt the mapping table ciphertext and reversely replace the instruction set in the security chip. In order to facilitate the running of the digital currency hard wallet application in the security chip, the JavaRuntime class library in Java can also be packaged in the digital currency hard wallet application file. Then, when the digital currency hard wallet application runs in the security chip, the JavaRuntime class library decrypts the mapping table ciphertext and reversely replaces the instruction set, so that the digital currency hard wallet application can run normally.
[0094] Optionally, packaging the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file includes: packaging the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format; converting the digital currency hard wallet application file in the Jar file format into a digital currency hard wallet application file in a Cap file format. In an embodiment of the present invention, firstly, the digital currency hard wallet application intermediate file (such as a Class file), the mapping table ciphertext and the JavaRuntime class library in Java are packaged into a digital currency hard wallet application file in a Jar file format, and then the digital currency hard wallet application file in a Jar file format is converted into an executable Cap file, i.e., a digital currency hard wallet application file (Java Applet application) in a Cap file format.
[0095] Jar file: generally a file package compressed from multiple Class files and related files. Cap file: target file generated by the Java Applet application smart card Java virtual machine. Applet application is an application on the smart card, which is written in Java programming language and can be run in JavaCard Runtime Environment (JCRE).
[0096] Optionally, after step 104, the process further includes: distributing the digital currency hard wallet application file to the security chip. After packaging, the digital currency hard wallet application file is distributed to the security chip so that the digital currency hard wallet application can run in the security chip.
[0097] Optionally, after distributing the digital currency hard wallet application file to the security chip, it also includes: when the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server. In order to decrypt the mapping table ciphertext in the security chip, it is necessary to send the key to the security chip in a secure manner. One way is to send the key to the security chip through the server when the digital currency hard wallet application is initialized in the security chip to ensure the security of the key.
[0098] Optionally, the method further includes: importing the key into the security chip by means of production line presetting. In order to decrypt the mapping table ciphertext in the security chip, it is necessary to use a secure method to send the key to the security chip. One way is to import the key into the security chip by means of production line presetting when producing the security chip to ensure the security of the key.
[0099] During the development phase, the embodiment of the present invention uses a set of customized instruction sets to replace the original conventional instruction sets to form a mapping table, and then performs forward replacement of the instruction sets in the source code based on the mapping table. At the same time, the mapping table is encrypted, and the key is sent to the security chip of the user terminal in a secure manner.
[0100] According to the various embodiments described above, it can be seen that the embodiment of the present invention solves the technical problem that the application is easily decompiled in the prior art by forward replacing the instruction set in the source code of the digital currency hard wallet application based on a custom mapping table and encrypting the mapping table with a key. The embodiment of the present invention forward replaces the instruction set in the source code through a custom mapping table and encrypts the mapping table for protection. When the attacker performs a reverse attack analysis on the protected digital currency hard wallet application file, since the instruction set in the source code has been replaced by a custom instruction set that is extremely difficult to crack, and the key is stored in the security chip, even if the attacker obtains the digital currency hard wallet application, it is difficult to read the chaotic code, difficult to restore the original code, and difficult to understand the business logic, thereby achieving the purpose of protecting the digital currency hard wallet application.
[0101] Figure 3 Schematic diagram of the main process of a method for generating a digital currency hard wallet application according to a reference embodiment of the present invention. As another embodiment of the present invention, Figure 3 As shown, the method for generating the digital currency hard wallet application may include:
[0102] Step 301: Customize a mapping table, where the mapping table includes an operation code instruction set before replacement and an operation code instruction set after replacement.
[0103] Step 302, compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file.
[0104] Step 303, based on the custom mapping table, the class files in the digital currency hard wallet application bytecode file are subjected to instruction set parsing and forward replacement, thereby generating a digital currency hard wallet application intermediate file.
[0105] Step 304: Use a key to encrypt the mapping table to generate a mapping table ciphertext.
[0106] Step 305: Package the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format.
[0107] Step 306: convert the digital currency hard wallet application file in the Jar file format into the digital currency hard wallet application file in the Cap file format.
[0108] Step 307, distribute the digital currency hard wallet application file to the security chip.
[0109] Step 308, when the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server.
[0110] In addition, the specific implementation content of the method for generating a digital currency hard wallet application in a reference embodiment of the present invention has been described in detail in the method for generating a digital currency hard wallet application described above, so the repeated content will not be described here.
[0111] Figure 4 is a schematic diagram of the main process of a method for generating a digital currency hard wallet application according to another reference embodiment of the present invention. As another embodiment of the present invention, Figure 4 As shown, the method for generating the digital currency hard wallet application may include:
[0112] Step 401 : Customize a mapping table, wherein the mapping table includes an operation code instruction set before replacement and an operation code instruction set after replacement.
[0113] Step 402, compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file.
[0114] Step 403, based on the custom mapping table, the class files in the digital currency hard wallet application bytecode file are subjected to instruction set parsing and forward replacement, thereby generating a digital currency hard wallet application intermediate file.
[0115] Step 404: encrypt the mapping table using a key to generate a mapping table ciphertext.
[0116] Step 405: import the key into the security chip by production line presetting.
[0117] Step 406: Package the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format.
[0118] Step 407: convert the digital currency hard wallet application file in the Jar file format into the digital currency hard wallet application file in the Cap file format.
[0119] Step 408: Distribute the digital currency hard wallet application file to the security chip.
[0120] It should be noted that step 405 may be executed after the security chip is manufactured, and the specific execution order is not limited. The embodiment of the present invention only shows step 405 exemplarily.
[0121] In addition, the specific implementation content of the method for generating a digital currency hard wallet application in another reference embodiment of the present invention has been described in detail in the method for generating a digital currency hard wallet application described above, so the repeated content will not be described here.
[0122] Figure 5 is a schematic diagram of the main process of the operation method of the digital currency hard wallet application according to an embodiment of the present invention. As another embodiment of the present invention, Figure 5 As shown, the method for running the digital currency hard wallet application may include:
[0123] Step 501, decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and mapping table ciphertext.
[0124] When the digital currency hard wallet application is in operation, the virtual machine in the security chip decompresses the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and mapping table ciphertext.
[0125] Step 502: Decrypt the mapping table ciphertext using the key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement.
[0126] The mapping table ciphertext is decrypted using the key sent to the security chip or the key preset in the security chip to obtain the mapping table. Specifically, when the virtual machine parses the instruction set in the intermediate file of the digital currency hard wallet application, it first decrypts the mapping table of the custom Java virtual machine instruction set (OPcode operation code) and the conventional Java virtual machine instruction set (OPcode operation code).
[0127] Step 503: Based on the mapping table, reversely replace the instruction set in the digital currency hard wallet application intermediate file, thereby generating a digital currency hard wallet application instruction file;
[0128] Step 504, executing the digital currency hard wallet application instruction file.
[0129] The virtual machine maps the customized Java virtual machine instruction set to the corresponding conventional Java virtual machine instruction set one by one according to the mapping table, and executes the conventional Java virtual machine instruction set operation.
[0130] Since the JavaRuntime class library is also packaged in the digital currency hard wallet application file, the JavaRuntime class library can be called to execute steps 502 and 503. Figure 6As shown, during the running phase, the digital currency hard wallet application first loads the class file, then initializes Linking, and then parses and executes the instruction set. In the process of parsing and executing the instruction set, the JavaRuntime class library is called, and the mapping table ciphertext is decrypted by the JavaRuntime class library to obtain the mapping table. Then, based on the mapping table, the instruction set in the intermediate file of the digital currency hard wallet application is reverse replaced. The JavaRuntime class library outputs the reverse-replaced instruction set, which is the conventional Java virtual machine instruction set. The virtual machine executes the conventional Java virtual machine instruction set, so that the digital currency program can run normally.
[0131] The embodiment of the present invention performs positive replacement of the instruction set in the source code through a custom mapping table and encrypts the mapping table for protection. When an attacker performs a reverse attack analysis on the protected digital currency hard wallet application file, since the instruction set in the source code has been replaced by a custom instruction set that is extremely difficult to crack, and the key is stored in the security chip, even if the attacker obtains the digital currency hard wallet application, it is difficult for the attacker to read the chaotic code, restore the original code, and understand the business logic, thereby achieving the purpose of protecting the digital currency hard wallet application.
[0132] Figure 7 Schematic diagram of the main modules of the device for generating a digital currency hard wallet application according to an embodiment of the present invention. Figure 7 As shown, the generating device 700 of the digital currency hard wallet application includes an acquisition module 701, a forward replacement module 702, an encryption module 703 and a packaging module 704; wherein, the acquisition module 701 is used to obtain the source code of the digital currency hard wallet application; the forward replacement module 702 is used to forward replace the instruction set in the source code of the digital currency hard wallet application based on a custom mapping table, so as to generate a digital currency hard wallet application intermediate file; wherein, the mapping table includes the instruction set before replacement and the instruction set after replacement; the encryption module 703 is used to encrypt the mapping table with a key to generate a mapping table ciphertext; the packaging module 704 is used to package the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file.
[0133] Optionally, the forward replacement module 702 is further configured to:
[0134] Compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file;
[0135] Based on a custom mapping table, the class files in the bytecode file of the digital currency hard wallet application are parsed and forward replaced by instruction sets, thereby generating a digital currency hard wallet application intermediate file; wherein the instruction set is an opcode instruction set.
[0136] Optionally, the packaging module 704 is further configured to:
[0137] The digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file; wherein the JavaRuntime class library is used to decrypt the mapping table ciphertext and reversely replace the instruction set in the security chip.
[0138] Optionally, the packaging module 704 is further configured to:
[0139] Packing the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format;
[0140] The digital currency hard wallet application file in the Jar file format is converted into a digital currency hard wallet application file in the Cap file format.
[0141] Optionally, the device further comprises:
[0142] A distribution module is used to distribute the digital currency hard wallet application file to the security chip.
[0143] Optionally, the distribution module is further used for:
[0144] When the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server.
[0145] Optionally, the key is imported into the security chip by production line presetting.
[0146] It should be noted that the specific implementation content of the device for generating the digital currency hard wallet application of the present invention has been described in detail in the method for generating the digital currency hard wallet application described above, so the repeated content will not be described here.
[0147] Figure 8 Schematic diagram of the main modules of the running device of the digital currency hard wallet application according to an embodiment of the present invention. Figure 8As shown, the running device 800 of the digital currency hard wallet application includes a decompression module 801, a decryption module 802, a reverse replacement module 803 and an execution module 804; wherein the decompression module 801 is used to decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and the mapping table ciphertext; the decryption module 802 is used to decrypt the mapping table ciphertext using the key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement; the reverse replacement module 803 is used to reversely replace the instruction set in the digital currency hard wallet application intermediate file based on the mapping table, thereby generating a digital currency hard wallet application instruction file; the execution module 804 is used to execute the digital currency hard wallet application instruction file.
[0148] It should be noted that the specific implementation content of the running device of the digital currency hard wallet application described in the present invention has been described in detail in the method for generating the digital currency hard wallet application described above, so the repeated content will not be described here.
[0149] Fig. 9 An exemplary system architecture 900 is shown to which a method for generating a digital currency hard wallet application or an apparatus for generating a digital currency hard wallet application according to an embodiment of the present invention may be applied.
[0150] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0151] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0152] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0153] The server 905 may be a server that provides various services, such as a backend management server (for example only) that provides support for shopping websites browsed by users using the terminal devices 901, 902, and 903. The backend management server may analyze and process the received data such as the item information query request, and feed back the processing results to the terminal device.
[0154] It should be noted that the method for generating a digital currency hard wallet application provided in the embodiment of the present invention is generally executed by the server 905 , and accordingly, the generating device of the digital currency hard wallet application is generally set in the server 905 .
[0155] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0156] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0157] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0158] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0159] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.
[0160] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0161] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0162] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module, a forward replacement module, an encryption module and a packaging module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0163] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a decompression module, a decryption module, a reverse replacement module and an execution module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0164] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: obtaining the source code of the digital currency hard wallet application; based on a custom mapping table, forward replacing the instruction set in the source code of the digital currency hard wallet application, thereby generating a digital currency hard wallet application intermediate file; wherein the mapping table includes the instruction set before replacement and the instruction set after replacement; encrypting the mapping table with a key to generate a mapping table ciphertext; packaging the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file.
[0165] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device implements the following method: decompressing the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and the mapping table ciphertext; using the key in the security chip to decrypt the mapping table ciphertext to generate a mapping table; wherein the mapping table includes the instruction set before replacement and the instruction set after replacement; based on the mapping table, the instruction set in the digital currency hard wallet application intermediate file is reversely replaced to generate a digital currency hard wallet application instruction file; executing the digital currency hard wallet application instruction file.
[0166] As another aspect, an embodiment of the present invention further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method described in any of the above embodiments is implemented.
[0167] According to the technical solution of the embodiment of the present invention, because a custom mapping table is used to positively replace the instruction set in the source code of the digital currency hard wallet application, and a key is used to encrypt the mapping table, the technical problem of the application being easily decompiled in the prior art is overcome. The embodiment of the present invention uses a custom mapping table to positively replace the instruction set in the source code and encrypts the mapping table for protection. When an attacker performs a reverse attack analysis on the protected digital currency hard wallet application file, since a custom instruction set with extremely high cracking difficulty has been used to replace the instruction set in the source code, and the key is stored in the security chip, even if the attacker obtains the digital currency hard wallet application, it is difficult to read the chaotic code, difficult to restore the original code, and difficult to understand the business logic, thereby achieving the purpose of protecting the digital currency hard wallet application.
[0168] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for generating a digital currency hard wallet application, It is characterized in that include: Get the source code of the digital currency hard wallet application; Based on a custom mapping table, the instruction set in the source code of the digital currency hard wallet application is positively replaced, thereby generating an intermediate file of the digital currency hard wallet application; wherein the mapping table includes the instruction set before the replacement and the instruction set after the replacement; Encrypting the mapping table using a key to generate a mapping table ciphertext; The digital currency hard wallet application intermediate file and the mapping table ciphertext are packaged into a digital currency hard wallet application file.
2. The method according to claim 1, It is characterized in that Based on the custom mapping table, the instruction set in the source code of the digital currency hard wallet application is positively replaced to generate a digital currency hard wallet application intermediate file, including: Compile the digital currency hard wallet application source code into a digital currency hard wallet application bytecode file; Based on a custom mapping table, the class files in the bytecode file of the digital currency hard wallet application are parsed and forward replaced by instruction sets, thereby generating a digital currency hard wallet application intermediate file; wherein the instruction set is an opcode instruction set.
3. The method according to claim 1, It is characterized in that Packing the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file includes: The digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file; wherein the JavaRuntime class library is used to decrypt the mapping table ciphertext and reversely replace the instruction set in the security chip.
4. The method according to claim 3, It is characterized in that The digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library are packaged into a digital currency hard wallet application file, including: Packing the digital currency hard wallet application intermediate file, the mapping table ciphertext and the JavaRuntime class library into a digital currency hard wallet application file in a Jar file format; The digital currency hard wallet application file in the Jar file format is converted into a digital currency hard wallet application file in the Cap file format.
5. The method according to claim 1, It is characterized in that After packaging the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file, the method further includes: Distribute the digital currency hard wallet application file to the security chip.
6. The method according to claim 5, It is characterized in that After distributing the digital currency hard wallet application file to the security chip, the method further includes: When the digital currency hard wallet application is initialized in the security chip, the key is sent to the security chip through the server.
7. The method according to claim 1, It is characterized in that Also includes: The key is imported into the security chip by production line presetting.
8. A method for operating a digital currency hard wallet application, It is characterized in that include: Decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and mapping table ciphertext; Decrypting the mapping table ciphertext using the key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement; Based on the mapping table, reversely replace the instruction set in the digital currency hard wallet application intermediate file, thereby generating a digital currency hard wallet application instruction file; Execute the digital currency hard wallet application instruction file.
9. A device for generating a digital currency hard wallet application, It is characterized in that include: Obtaining module, used to obtain the source code of the digital currency hard wallet application; A forward replacement module, used to perform forward replacement on the instruction set in the source code of the digital currency hard wallet application based on a custom mapping table, thereby generating an intermediate file of the digital currency hard wallet application; wherein the mapping table includes the instruction set before replacement and the instruction set after replacement; An encryption module, used to encrypt the mapping table using a key to generate a mapping table ciphertext; The packaging module is used to package the digital currency hard wallet application intermediate file and the mapping table ciphertext into a digital currency hard wallet application file.
10. A device for running a digital currency hard wallet application, It is characterized in that include: A decompression module is used to decompress the digital currency hard wallet application file to obtain the digital currency hard wallet application intermediate file and the mapping table ciphertext; A decryption module, used to decrypt the mapping table ciphertext using a key in the security chip to generate a mapping table; wherein the mapping table includes an instruction set before replacement and an instruction set after replacement; A reverse replacement module, used to reversely replace the instruction set in the digital currency hard wallet application intermediate file based on the mapping table, thereby generating a digital currency hard wallet application instruction file; An execution module is used to execute the digital currency hard wallet application instruction file.
11. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
12. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
13. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method and device to preprocess application installation files and server
CN108089880A
Application program source code protection method and device, computer device and storage medium
CN110619219A
Instruction encryption method and device and encrypted instruction decryption method and device
CN111639358A
Application execution method and related device
CN113918285A
Cited By
Cryptocurrency wallet hacking systems and methods
TWI919580B
