Method for compiling high-level scripting language into block chain inherent scripting language

By introducing high-level scripting language primitives into blockchain transactions and using existing low-level opcode combinations to achieve advanced operations, the problem of restricted blockchain scripting language functions is solved, and more complex and general blockchain applications are realized.

CN119179488APending Publication Date: 2024-12-24NCHAIN HLDG LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411007158.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2017-07-07
Filing Date
2018-07-05
Publication Date
2024-12-24

AI Technical Summary

Technical Problem

The existing blockchain scripting language is limited when performing complex operations and cannot support control flow mechanisms such as loops and recursive jumps, resulting in limited functions and the inability to implement certain arithmetic operations such as multiplication and division, which limits blockchain technology. Applications and extensions.

Method used

By introducing high-level scripting language primitives into blockchain transactions, using existing low-level opcode combinations to implement advanced operational functions, such as multiplication and division, avoiding modification of scripting languages ​​or blockchain protocols, and providing more complex functional abstraction.

Benefits of technology

It realizes the execution of more diverse applications on the blockchain, simplifies programming, reduces errors, and improves the universality and functional strength of the blockchain system, making more technical applications possible.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179488A_ABST
    Figure CN119179488A_ABST
Patent Text Reader

Abstract

The present invention provides a method and a system that enable an additional function to be inserted into a blockchain script easily and in an efficient manner. According to one embodiment, the present invention provides a method implemented by a block chain, the method comprising the steps of: arranging multiple or a series of scripting language primitives to provide a function of a high-level scripting language primitive when executed, where the scripting language is associated with a block chain protocol; inserting the plurality of script language primitives into the script at least once; and inserting the script into the block chain transaction (Tx). The high-level scripting language primitives may perform, for example, arithmetic operations, such as multiplication or division. The scripting language primitive may be referred to as an opcode, word, or command, and is intrinsic to the scripting language. The script language may be Script.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with Chinese application number 2018800455874 (corresponding to PCT international application number PCT / IB2018 / 054970), application date July 5, 2018, and invention name “Method for compiling high-level scripting language into blockchain-native scripting language”. Technical Field

[0002] The present invention relates generally to distributed ledger technology, and more specifically to blockchain technology of variants of blockchain / cryptocurrency protocols. The present invention is particularly suitable for, but not limited to, controlling the manner in which scripts in arranged blockchain transactions (Tx) are executed, and thus controlling the manner in which control or ownership of digital resources is transferred via a blockchain network. Background Art

[0003] In this article, we use the term “blockchain” to cover all forms of computer-based electronic distributed ledger technology. These include consensus-based blockchains and transaction chain technologies, permissioned and permissionless ledgers, shared ledgers, sidechains, and their variants.

[0004] A blockchain is a peer-to-peer electronic ledger implemented as a decentralized, distributed computer-based system that consists of blocks, which in turn consist of transactions. Each transaction is a data structure that encodes the transfer of control of a digital asset between participants in the blockchain system and includes at least one input and at least one output. Each block contains a hash of the previous block, so that the blocks become linked together to create a permanent, unchangeable record of all transactions that have been written to the blockchain since its inception. Transactions contain small programs called scripts embedded in their inputs and outputs that specify how and by whom the outputs of the transaction can be accessed.

[0005] In order for a transaction to be written to the blockchain, it must be "validated". Network nodes work to ensure that each transaction is valid, and invalid transactions are rejected from the network. The software client installed on the node does this validation work for unspent transactions (UTXO) by executing its locking and unlocking scripts. If the execution of the locking and unlocking scripts evaluates to TRUE, then the transaction is valid and is written to the blockchain. Therefore, in order for a transaction to be written to the blockchain, the transaction must i) be validated by the first node that receives the transaction - if the transaction is validated, the node relays it to other nodes in the network; ii) be included in a new block built by the network nodes; iii) be added to the public ledger of past transactions.

[0006] It would be extremely advantageous if blockchain could be used to automate tasks and processes that are not limited to the cryptocurrency space, thereby expanding the applicability of the technology that blockchain enables. Such a solution would be able to leverage the benefits of blockchain (e.g., permanent, tamper-proof proof of record of events, distributed processing, etc.) while being more general in its application.

[0007] However, in order to increase the functionality of this technology, some of the technical limitations that currently exist need to be addressed. For example, in one or more protocols, programmers may not be able to use certain operators when writing programs in Script. Security-related concerns have led to the disabling of certain Script opcodes provided in the original version of the protocol. These include operators for performing certain arithmetic operations such as multiplication and division. Therefore, currently, in some protocols, there is no inherent mechanism for performing such operations in scripts, which leads to limitations on the functionality that script code can currently achieve. Any script containing disabled opcodes will fail and abort. This leads to limitations on the functionality of technologies implemented on such base blockchain protocols. Technical challenges arise when the desired implementation requires the use of functionality that is not provided in the base protocol. Changing the protocol may not always be desirable or feasible. At the same time, such blockchain platforms remain limited in functionality.

[0008] Therefore, while it is still desirable to maintain the security and integrity of blockchain scripting languages, there is also a need to provide a solution that provides script programmers with more programming capabilities and increases the versatility, usability, and applicability of the language. Such a solution will provide an improved blockchain network. This can bring many benefits, including but not limited to:

[0009] Makes it possible to automate complex blockchain-related transfers;

[0010] Control the flow of metadata recorded to the blockchain;

[0011] Expand the functionality and applications of blockchain-enabled technologies Summary of the invention

[0012] This article provides an example of such a solution.

[0013] According to the present invention, there is provided a system and / or method as defined in the accompanying claims.

[0014] Embodiments of the present invention may provide a method / system for blockchain implementation. The present invention may be a control method / system. It may be arranged to control the execution of a script embedded in a blockchain transaction (Tx), and / or whether an output is unlocked, and / or control the transfer of resources (e.g., a portion of a cryptocurrency) from one entity to another via a transaction.

[0015] The blockchain may be associated with a protocol and a scripting language. The scripting language may be a stack-based language. The scripting language may be limited in functionality in the sense that it may not allow complex control flow mechanisms such as loops and / or jump recursion.

[0016] Embodiments of the present invention may provide a mechanism for simulating or implementing the functionality of an operation in a blockchain script. The operation may be an operation that is not inherently supported by the scripting language associated with the blockchain protocol. It may be a disabled operation. It may be referred to as a high-level operation. It may be high-level relative to the vocabulary of the blockchain scripting language (opcode, command, instruction, or function). High-level operations may be operations that function at a level of abstraction that is removed from the language-inherent, primitive operations or opcodes. High-level operations may be arithmetic operations such as multiplication and division. The advantage of this is that the present invention can be used to conveniently write scripts containing the functionality without modifying the scripting language or blockchain protocol. Therefore, the present invention provides an improved blockchain system with more complex functionality, enabling more diverse applications to be executed on the blockchain, and enabling easier and faster programming of applications while reducing errors. Therefore, the result is a more versatile, powerful, and useful blockchain. This in turn makes it possible to build more blockchain-enabled technologies.

[0017] Additionally, or alternatively, the method may comprise the steps of:

[0018] Arranging a plurality of (blockchain) scripting language primitives to provide the functionality of a high-level scripting language primitive when executed; the scripting language may be associated with a blockchain protocol;

[0019] inserting multiple scripting language primitives into the script at least once; and / or

[0020] Insert the script into the blockchain transaction (Tx).

[0021] Additionally, or alternatively, the method according to the invention may comprise:

[0022] Storing a plurality of blockchain opcodes (primitives) that have been arranged and / or selected to perform the functions of a high-level scripting language operator;

[0023] Retrieve multiple opcodes from storage;

[0024] The plurality of opcodes are inserted into a script in a blockchain transaction.

[0025] Multiple opcodes may be described as a "block".

[0026] The method may include the steps of validating the transaction and / or submitting it to a blockchain network. It may include the step of executing the transaction.

[0027] Each of the plurality of scripting language primitives may also be referred to as a word, an opcode, a command, or a function. They may be referred to as "low-level primitives". For convenience, the term "opcode" will be used for "scripting language primitives". One, some, or all of the plurality of opcodes may be selected from the word set or instruction set of the scripting language. They may be intrinsic to the scripting language.

[0028] A high-level scripting language primitive may be a set or series of arranged opcodes. They may be deliberately arranged to provide the desired abstracted functionality. For ease of reference, they may be referred to as "high-level primitives". High-level primitives may perform arithmetic operations or data copying, logic or program (flow) control operations. They may produce a result that is retained in the computer's memory on a stack. High-level primitives may emulate or provide the functionality of opcodes that are not included in the language's native vocabulary or that have been disabled. High-level primitives may be "high-level" in the sense that they may be decomposed into more basic or fundamental operations that are native to the language and / or perform simpler operations in function. High-level primitives may be constructed at a more abstract level than opcodes to perform simple operations or produce results.

[0029] The scripting language may be a Script language. However, other languages ​​and protocols may fall within the scope of the present invention. The scripting language may be functionally limited. The term "non-Turing complete" may be used interchangeably with the term "functionally limited" herein. The language does not inherently support one or more control flow mechanisms, such as loops and / or recursive jumps, and in this sense, the language is functionally limited.

[0030] The method may further include the step of selecting one, some or all of the plurality of scripting language primitives from a vocabulary or instruction set of the scripting language.

[0031] The method may further include the step of saving and / or storing the plurality of scripting language primitives in or on a computer-based storage resource. The computer-based storage resource may be a non-volatile computer memory. The method may further include the step of retrieving the plurality of scripting language primitives from the computer-based storage resource prior to inserting them into the script.

[0032] The script can be an unlocking script, a locking script, or a redeem script.

[0033] Scripts are inserted into blockchain transactions (Tx) in association with the inputs or outputs of the blockchain transaction.

[0034] The method may further include the steps of receiving an input or signal from a source and using the input or signal to control a number of times the plurality of scripting language primitives are inserted into the script.

[0035] The method may further include the step of submitting the transaction to the blockchain network.

[0036] Multiple scripting language primitives are inserted into template scripts and / or template transactions (Tx). Templates can be incomplete versions of scripts / transactions.

[0037] The present invention also provides a computer-implemented system. The system can be arranged to perform any embodiment of the above method. Any features described with respect to one or more aspects of the present invention may also be applicable to any other aspects. Any features described with respect to the method may also be applicable to the corresponding system, and vice versa.

[0038] The present invention also provides a system, comprising:

[0039] Processor; and

[0040] A memory comprising executable instructions that, as a result of execution by the processor, cause the system to perform any embodiment of the computer-implemented method described herein.

[0041] The present invention also provides a non-transitory computer-readable storage medium having executable instructions stored thereon, which, as a result of execution by a processor of a computer system, causes the computer system to perform at least an embodiment of the computer-implemented method described herein. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] These and other aspects of the invention will become apparent from and will be elucidated with reference to the embodiments described herein. Embodiments of the invention will now be described by way of example only with reference to the accompanying drawings, in which:

[0043] Figure 1 It is shown how transactions can be linked together on a blockchain to transfer control of ownership of a cryptocurrency, as is known in the prior art.

[0044] Figure 2 Control transactions suitable for use in accordance with embodiments of the present invention and relating to exemplary use cases are shown.

[0045] Figure 3 An example network associated with a blockchain is shown. DETAILED DESCRIPTION

[0046] The present invention provides an improved mechanism for implementing the functionality of high-level operations in blockchain scripts, even if the scripting language of the blockchain's associated protocol does not provide inherent opcodes for high-level operations or has been disabled. The present invention utilizes a series of existing low-level opcodes of the language and combines them in a creative way to implement the desired functionality. Selected combinations of primitive opcodes are selected and / or arranged to provide the desired high-level functionality. For convenience and ease of reference, the selected combination of inherent opcodes may be referred to as "high-level operators". Therefore, the term "high-level" may be used to indicate that an operation can be decomposed into more basic or fundamental operations, preferably the more basic or fundamental operations are inherent to the scripting language. Multiple opcodes or block opcodes are associated with tags or identifiers for ease of reference, use or invocation.

[0047] The code portions that make up the high-level operators may be predefined or preselected. In this context, "pre" may refer to before the final use or application in which the code portion is ultimately placed. Additionally or alternatively, it may refer to before execution or run time. The code portion (or "block") is stored on a computer-based resource such as a non-volatile memory. When a script is needed for a specific purpose, the stored operator can be accessed, copied and inserted into the script at one or more selected locations to provide the desired control and functionality when executed. The script into which the high-level operator is inserted may be a template accessible from storage. Thus, functionally complex blockchain transactions can be generated in a convenient and fast manner, thereby saving programming time, effort and reducing the likelihood of coding errors. By reducing the likelihood of errors, the present invention provides a mechanism for ensuring the quality of the code used for blockchain transactions. This in turn reduces the number of script (and transaction) failures at runtime. In this sense, the present invention provides a more efficient and error-reducing solution to execute transactions on the blockchain and to perform transfers from one party to another through the output of one transaction to the input of a second transaction.

[0048] At runtime, one or more signals or inputs may be received from a source, and the input(s) may be used to influence or control the number of times a high-level operator is used in a script. In some embodiments, the input(s) are received from a sensor(s). Thus, a script may be generated such that a result is calculated in response to certain external or environmental factors.

[0049] Another advantage is that the design, implementation, or deployment of existing scripting languages ​​does not need to be modified or changed in any way; functionality of disabled or unimplemented primitive operators can be easily provided without breaking the blockchain protocol in its current form.

[0050] Thereafter, we present a solution according to embodiments of the present invention that allows for emulation of advanced multiplication and division operators. These embodiments consist of script-based sequences of operations that provide the desired functionality and behavior of the operator. The operator provides a mechanism for controlling how programs implemented by the blockchain will be executed. Since these programs are embedded into the inputs and outputs of blockchain transactions (Tx), they provide a mechanism to influence and control how transactions are executed, thereby transferring control of cryptocurrency ownership from one party to another.

[0051] Example - Multiplication:

[0052] In this implementation, we provide a mechanism for multiplication in blockchain scripts. This exploits the knowledge that multiplication is about making X and Y the values ​​you wish to multiply. When written in the grammar of the Script language, the multiplication operator becomes:

[0053]

[0054]

[0055] The result of performing the above operation is that the product is left in the Alt stack.

[0056]

[0057] In the code above, the purpose of the opening segment is to swap operands when necessary to ensure that fewer additions need to be performed, for example 2×3 will require fewer additions, as well as 3×2. This reduces the amount of work and makes the entire code more efficient in terms of time and computation. The "swap" segment is:

[0058]

[0059] The purpose of the following code is to provide a counter mechanism:

[0060] OP_1OP_ROT OP_DUP OP_TOALTSTACK OP_TOALTSTACK

[0061] OP_2DUP OP_EQUAL

[0062] The value of the counter can be used to control the number of additions performed.

[0063] In the example above, the code shown in the dashed box is the code used to perform the addition. The addition is repeated, as shown in the subsequent dashed boxes, but the content is not repeated for simplicity and readability. The OP_EQUAL operation at the end of the addition code is used to check whether the addition has been performed a sufficient number of times.

[0064] The code shown in the double-line box serves to "clean up" the stack and return the result.

[0065] Worked Example - Multiplication

[0066] To further illustrate the technique, we now provide a working example using two operands, 2 and 3. In the following example, the state of the Main and Alt stacks is shown. The left column is the Main stack and the right column is the Alt stack.

[0067] OP_2OP_3

[0068] OP_2DUP OP_GREATERTHAN

[0069] This leaves the stack in the following state (note: duplication is not shown here for simplicity):

[0070]

[0071] If the top stack item is false, then the "body" of the code is executed using:

[0072]

[0073] Use the OP_ROT operation to rotate the first 3 items to the left.

[0074]

[0075]

[0076] Example - Division:

[0077] In the second example, division is implemented instead of multiplication, using the knowledge that division can be performed by repeated subtraction. A script-based sequence of operations is provided that emulates the behavior of the division operator. Let X and Y be the values ​​that we wish to divide. The division operator, when written in the syntax of the Script language, becomes:

[0078]

[0079]

[0080] The output of the above, left on the Alt stack, is:

[0081]

[0082] Worked Example - Division In this working example, we divide 11 by 3.

[0083]

[0084]

[0085] Second Working Example - Division

[0086] In this second working example, it is shown how the scheme handles the case of division by zero, which can be a source of coding errors in computational implementations due to the inability of finite machines to represent infinity. In this example, the division of 3 by 0 is shown step by step.

[0087]

[0088] Third Working Example - Division

[0089] In this third working example, 0 divided by 3 is shown step by step.

[0090]

[0091] Example use case: blockchain-enabled control systems

[0092] The present invention provides a technique for implementing high-level operations in blockchain scripts, even if the language of the protocol does not include low-level opcodes for this purpose. This provides a highly general arrangement for implementing schemes on blockchain platforms.

[0093] To illustrate this, let’s now consider a system that combines multiple inputs to regulate the behavior of other devices. For example, suppose two sensors provide the following inputs:

[0094] (i) Number of liquid containers on the ship's deck n

[0095] (ii) The weight of the container. Assume that the weight of the container ww is exactly the same.

[0096] In this simple example, the device is a cargo ship, which can have two states:

[0097] (i) the cargo remains at the terminal (status 1); and

[0098] (ii) The cargo leaves the port (state 2). Initially, the system is in state 1.

[0099] Define the threshold condition W t The total weight W carried on the deck of the cargo ship controls its behavior

[0100] If W>W t , the system is in state 2.

[0101] Figure 2The control transaction (Tx) submitted to the blockchain is shown. The op_code Pro_MULT represents a high-level arithmetic operation (×) as described above. The sensor provides the values ​​n and w to the unlocking script. Therefore, the corresponding unlocking script that needs to be submitted to the locking script is:

[0102] <n> <w><Signature of Sensor 1><Signature of Sensor 2> < / w> < / n>

[0103] Blockchain Network

[0104] Reference now Figure 3 , which shows in block diagram form an exemplary network associated with a blockchain, which may be referred to herein as a blockchain network 100 and may be used to implement the present invention. The blockchain network 100 is a peer-to-peer open member network that anyone can join without invitation or consent from other members. Distributed electronic devices running an instance of a blockchain protocol (under which the blockchain network 100 operates) may participate in the blockchain network 100. Such distributed electronic devices may be referred to as nodes 102. The blockchain protocol may be, for example, a cryptocurrency.

[0105] The electronic devices that run the blockchain protocol and form the nodes 102 of the blockchain network 100 may be various types of devices, including, for example, computers (e.g., desktop computers, laptop computers, tablet computers), servers, mobile devices such as smart phones, wearable computers such as smart watches, or other electronic devices.

[0106] The nodes 102 of the blockchain network 100 are coupled to each other using suitable communication technologies, which may include wired and wireless communication technologies. In many cases, the blockchain network 100 is implemented at least in part on the Internet, and some nodes 102 may be located in geographically dispersed locations.

[0107] Nodes 102 maintain a global ledger of all transactions on the blockchain, which is divided into blocks, and each block contains a hash of the previous block in the chain. The global ledger is a distributed ledger, and each node 102 can store a complete copy or a partial copy of the global ledger. Transactions of nodes 102 that affect the global ledger are verified by other nodes 102, thereby maintaining the validity of the global ledger. The details of implementing and operating a blockchain network are understood by those skilled in the art.

[0108] Each transaction generally has one or more inputs and one or more outputs. Scripts embedded in the inputs and outputs specify how and by whom the outputs of the transaction are accessed. The output of a transaction may be an address to which the value is transferred as a result of the transaction. The value is then associated with the output address as an unspent transaction output (UTXO). Subsequent transactions may then refer to the address as an input, thereby consuming or dispersing the value.

[0109] Nodes 102 can perform many different functions from network routing to wallet services to maintain a robust and secure, decentralized public ledger. A "full node" contains a complete and up-to-date copy of the blockchain, and can therefore verify any transaction (consumed or unconsumed) on the public ledger. A "lightweight node" (or SPV) maintains a subset of the blockchain and can verify transactions using "simple payment verification" technology. Lightweight nodes only download the headers of the blocks, not the transactions within each block. These nodes therefore rely on peer nodes to verify their transactions. A "mining node" can be a full node or a lightweight node, responsible for verifying transactions and creating new blocks on the blockchain. A "wallet node" is typically a lightweight node that handles the wallet service for the user. Nodes 102 communicate with each other using a connection-oriented protocol, such as TCP / IP (Transmission Control Protocol).

[0110] It should be noted that the above embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design many alternative embodiments without departing from the scope of the invention as defined by the appended claims. In the claims, any reference signs in brackets shall not be construed as limiting the claims. The words "comprising, comprise" and the like do not exclude the presence of elements or steps in addition to those listed in any claim or in the entire specification. In this specification, "comprises" means "includes or consists of", and "comprising" means "including or consisting of". The singular reference of an element does not exclude the plural reference of the element, and vice versa. The present invention may be implemented by hardware comprising several different elements and by a suitably programmed computer. In a device claim enumerating several means, several of these means may be implemented by one and the same item of hardware. The fact that certain measures are recited in mutually different dependent claims does not mean that a combination of these measures cannot be used to advantage.

Claims

1. A computer-implemented method comprising the following steps: storing a plurality of blockchain primitives that have been arranged and / or selected to perform the functionality of a high-level scripting language operator; retrieving the plurality of blockchain primitives from storage; The plurality of blockchain primitives are inserted into a script of a blockchain transaction.

2. The method according to claim 1, wherein the method further comprises: Verifying the transaction and / or submitting the transaction to the blockchain network.

3. The method according to claim 2, wherein the method further comprises: Execute the transaction.

4. The method of any one of the preceding claims, wherein each of the plurality of blockchain primitives is selected from a vocabulary or instruction set of a scripting language.

5. The method of claim 4, wherein the blockchain primitives are native to the scripting language.

6. The method of claim 4 or 5, wherein the scripting language is limited in functionality.

7. A computer-readable storage medium comprising computer-executable instructions, which when executed configure a processor to perform the method of any one of claims 1 to 6.

8. An electronic device comprising: Interface device; a processor, coupled to the interface device; A memory is coupled to the processor, wherein computer executable instructions are stored in the memory, and when the computer executable instructions are executed, the processor is configured to perform the method according to any one of claims 1 to 6.