Inscript functions in blockchain transactions

By redefining the OP_RETURN opcode to read and output specific portions of the lock script, the method enables more complex script executions within blockchain transactions, addressing the limitations of existing protocols.

JP7654567B2Active Publication Date: 2025-04-01NCHAIN LICENSING AG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2021569440
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-05-24
Filing Date
2020-04-22
Publication Date
2025-04-01
Estimated Expiration
2040-04-22

AI Technical Summary

Technical Problem

Existing blockchain protocols face limitations in executing complex scripts due to the restrictive functionality of opcodes like OP_RETURN, which can terminate script execution and override transactions, leading to a loss of functionality.

Method used

The method involves redefining the functionality of OP_RETURN to allow it to read a data element from the stack and output a portion of the lock script following an instance of OP_CODESEPARATOR, enabling in-script loops and more flexible execution of lock scripts.

Benefits of technology

This approach enhances the capability of blockchain transactions to execute complex functions, such as loops, within the script, thereby improving the functionality and versatility of blockchain protocols.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007654567000010
    Figure 0007654567000010
  • Figure 0007654567000011
    Figure 0007654567000011
  • Figure 0007654567000012
    Figure 0007654567000012
Patent Text Reader

Abstract

A method for executing a blockchain transaction. The transaction includes at least one output that includes a lock script, the lock script including an instance of a first opcode and one or more instances of a second opcode. Each instance of the second opcode separates a portion of the lock script. Invoking an instance of the first opcode reads a first data element from at least one stack, the first data element being generated during execution of the lock script by an unlock script of a different transaction. A first portion of the lock script is output following an instance of the second opcode that corresponds to the first data element.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present disclosure relates to using blockchain transactions to implement in-script composite functions. For example, a composite function may be used to generate a loop within a transaction's script. [Background technology]

[0002] Blockchain refers to a form of distributed data structure in which a duplicate copy of the blockchain is maintained at each of multiple nodes in a peer-to-peer (P2P) network. A blockchain contains a chain of blocks of data, with each block containing one or more transactions. Each transaction may point to the previous transaction in the sequence. Transactions can be submitted to the network for inclusion in a new block. New blocks are generated by a process known as "mining." "Mining" involves each of multiple mining nodes competing to perform a "proof-of-work," i.e., solving a cryptographic puzzle based on a pool of pending transactions waiting to be included in a block.

[0003] Traditionally, transactions in a blockchain are used to transfer digital assets, i.e. data that acts as a store of value. However, blockchains can also be used to stack additional functionality on top of the blockchain. For example, blockchain protocols may allow additional user data to be stored in the output of a transaction. Modern blockchains increase the maximum amount of data that can be stored in a single transaction, allowing more complex data to be incorporated. For example, this can be used to store electronic documents, or audio or video data, in the blockchain.

[0004] Each node in the network can have any one, two, or all three roles: forwarding, mining, and storage. Forwarding nodes propagate transactions through the nodes of the network. Mining nodes mine transactions into blocks. Storage nodes each store their own copies of the mined blocks of the blockchain. To have a transaction recorded in the blockchain, a party sends the transaction to one of the nodes of the network to be propagated. Mining nodes that receive a transaction may compete to mine the transaction into a new block. Each node is configured to respect the same node protocol, which includes one or more conditions for a transaction to be valid. Invalid transactions are not propagated or mined into blocks. Assuming the transaction is verified and thereby accepted into the blockchain, the transaction (including any user data) thus remains stored in each node of the P2P network as an immutable public record.

[0005] Miners who successfully solve the proof-of-work puzzle to generate an updated block are typically rewarded with a new transaction, called a "generation transaction," that generates a new amount of the digital asset. Proof-of-work incentivizes miners not to cheat the system by including double-spending transactions in their blocks, because it requires a huge amount of computational resources to mine a block, and because blocks containing double-spending attempts may not be accepted by other nodes.

[0006] In an “output-based” model (sometimes called a UTXO-based model), the data structure of a given transaction includes one or more inputs and one or more outputs. Any spendable output includes an element, sometimes called a UTXO (for “unspent transaction output”), that specifies an amount of digital assets. The output may further include a locking script that specifies a condition for redeeming the output. Each input includes a pointer to such an output in a prior transaction and may further include an unlocking script for unlocking the pointed-to output’s locking script. Thus, when considering a pair of transactions, we refer to them as a first transaction and a second transaction (or “target” transaction). The first transaction includes at least one output that includes a locking script that specifies an amount of digital assets and defines one or more conditions for unlocking the output. The second target transaction includes at least one input that includes a pointer to an output of the first transaction and an unlocking script for unlocking the output of the first transaction.

[0007] In such a model, when the second target transaction is sent to the P2P network to be propagated and recorded in the blockchain, one of the conditions for validity applied at each node is that the unlock script meets all of one or more conditions defined in the lock script of the first transaction, and another is that the output of the first transaction has not yet been redeemed by another previous valid transaction. Any node that finds the target transaction invalid according to any of these conditions will not propagate it or mine it into a block for recording in the blockchain.

[0008] An alternative type of transaction model is the account-based model, where each transaction transfers by referencing absolute account balances, rather than defining the amount to be transferred by referencing back to the UTXO of the preceding transaction in the past sequence of transactions. The current state of all accounts is stored and constantly updated by miners separate from the blockchain.

[0009] Blockchain protocols may use a scripting language for transactions. A script is essentially a list of elements, which may be data or instructions. Instructions are referenced in the document as script words, opcodes, commands, or functions. Opcodes (short for operation code) perform a given operation on the data in the script.

[0010] One blockchain scripting language is a dual stack implementation based on Forth with arbitrary loop function execution. Forth uses a dual stack with a main stack, the data stack, and an additional stack, the return stack. Summary of the Invention

[0011] One such opcode is OP_RETURN. In the original blockchain protocol, the purpose of OP_RETURN was to terminate the execution of a script. It does not invalidate the transaction that contains the script. However, this results in a fraud attack when OP_RETURN is included in the input script of a transaction. Specifically, the input script of a transaction that contains OP_RETURN may be used to unlock the output script of a previous transaction. Therefore, in the existing blockchain protocol, the protocol was modified to allow the storage of data on the blockchain such that the opcode OP_RETURN represents a provably unspent transaction output. In the existing protocol, the OP_RETURN opcode is used to terminate the execution of a script and invalidate the transaction at the same time. However, this results in a loss of functionality in the blockchain, since a transaction with OP_RETURN in its input script will not result in a "TRUE" (or valid) execution when executed with an unlock script.

[0012] Another opcode is OP_CODESEPARATOR (OCS). OCS is an opcode that is "visible" to the opcode OP_CHECKSIG, which means that OP_CHECKSIG can determine where in the script the next OCS is located. For completeness, OP_CHECKSIG usually checks the signature against all the data in the script after the last OCS has been executed.

[0013] According to one aspect disclosed herein, a computer-implemented method for executing a transaction on a blockchain, the transaction including at least one output including a locking script, the locking script including an instance of a first opcode and one or more instances of a second opcode, each instance of the second opcode separating a portion of the locking script, the method comprising: reading a first data element from at least one stack upon invoking an instance of the first opcode, the first data element being generated during execution of the lock script by an unlock script of a different transaction; outputting a first portion of the locking script following an instance of the second opcode corresponding to the first data element; A method is provided that includes:

[0014] Here, the first opcode has visibility of the second opcode, allowing portions of the lock script to be selected, i.e., the portion of the script that is located after a particular instance of the second opcode can be identified and output, e.g., to be executed. This can be used to enable in-script looping, such as by jumping from one portion of the lock script to another.

[0015] The first opcode may be an OP_RETURN opcode. Here, the functionality of OP_RETURN is redefined. Its purpose is no longer to terminate the execution of the script and invalidate the transaction. Instead, OP_RETURN receives an identifier or instance of a second opcode and outputs the script following that instance of the second opcode. In some examples, instead of executing the script from end to end, OP_RETURN can be used to jump forward or backward to another part of the script. For example, some parts of the script may be executed more than once, some parts of the script may not be executed at all, or they may be executed in a different order.

[0016] The second opcode may be an OP_CODESEPARATOR (OCS) opcode. The OCS is placed between parts of a script, effectively separating those parts. OP_RETURN may locate an instance of the OCS in the script in order to output the script following that particular instance.

[0017] For simplicity, the first opcode is hereinafter referred to as "OP_RETURN" or the "termination opcode" and the second opcode is hereinafter referred to as "OP_CODESEPARATOR" or the "separation opcode". However, the present disclosure is not limited to opcodes with these particular labels. More generally, although embodiments are described in terms of OP_RETURN of a blockchain scripting language, the same teachings can be implemented with any opcode that, when invoked by a script engine (e.g., a script interpreter), reads a first data element from a stack and outputs a portion of the script following an instance of a second opcode that corresponds to the data element. Similarly, although embodiments are described in terms of OP_CODESEPARATOR, the same teachings can be implemented with any opcode that separates portions of the script that appear to be the first opcode.

[0018] References to a first and a second instance of a first opcode should be interpreted as instances of the same type of opcode. Similarly, references to a first and a second instance of a second opcode should be interpreted as instances of the same type of opcode, where the first and second opcodes are different kinds of opcodes. [Brief description of the drawings]

[0019] To aid in the understanding of embodiments of the present disclosure and to show how such embodiments may be put into effect, reference is made, by way of example only, to the accompanying drawings in which: [Figure 1] FIG. 1 is a schematic block diagram of a system for implementing a blockchain. [Diagram 2]1 illustrates diagrammatically some examples of transactions that may be recorded on a blockchain. [Diagram 3] FIG. 2 is a schematic block diagram of node software for executing transactions. [Figure 4] 13 is an example of loop unpacking from an inscripted composite function of the Euclidean algorithm for inputs a=105 and b=28. [Figure 5A] For input,7,G,, here is an example of inscript elliptic curve point multiplication. [Figure 5B] 5A is a continuation of FIG. 5A and is an example of inscripted elliptic curve point multiplication for input,7,G. [Figure 5C] 5B is a continuation of FIG. 5B , and is an example of inscripted elliptic curve point multiplication for input,7,G. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0020] FIG. 1 illustrates an exemplary system 100 for implementing a blockchain 150. The system 100 includes a packet-switched network 101, which is typically a wide area internetwork such as the Internet. The packet-switched network 101 includes a number of nodes 104 arranged to form a peer-to-peer (P2P) overlay network 106 within the packet-switched network 101. Each node 104 includes a peer computing device with different nodes 104 belonging to different peers. Each node 104 includes a processing device including one or more processors, e.g., one or more central processing units (CPUs), accelerator processors, application specific processors, and / or field programmable gate arrays (FPGAs). Each node also includes a memory, i.e., a computer-readable storage device in the form of one or more non-transitory computer-readable media. The memory may include one or more memory units using one or more memory media, e.g., magnetic media such as hard disks, electronic media such as solid-state drives (SSDs), flash memory or EEPROMs, and / or optical media such as optical disk drives.

[0021] Blockchain 150 refers to a chain of blocks 151 of data, with a respective copy of the blockchain 150 maintained at each of multiple nodes in a peer-to-peer (P2P) network 160. Each block 151 in the chain includes one or more transactions 152, where transaction in this context refers to a type of data structure. The nature of the data structure depends on the type of transaction protocol used as part of the transaction model or scheme. A given blockchain typically uses one particular transaction protocol throughout. In one common type of transaction protocol, the data structure of each transaction 152 includes at least one input and at least one output. Each output specifies an amount that represents the quantity of a digital asset belonging to a user for which that output is cryptographically locked (requiring that user's 103 signature to be unlocked and thereby redeemed or used). Each input points back to the output of a preceding transaction 152, thereby linking the transactions.

[0022] At least some of the nodes 104 assume the role of forwarding nodes 104F, which forward and thereby propagate transactions 152. At least some of the nodes 104 assume the role of miners 104M, which mine blocks 151. At least some of the nodes 104 assume the role of storage nodes 104S (also called "full-copy" nodes), with each node storing a respective copy of the same blockchain 150 in its respective memory. Each miner node 104M also maintains a pool 154 of transactions 152 waiting to be mined into blocks 151. A given node 104 may be a forwarding node 104, a miner 104M, a storage node 104S, or any combination of two or all of these.

[0023] For a given current transaction 152j, the input (or each of them) includes a pointer that references the output of a previous transaction 152i in the sequence of transactions, specifying that this output is redeemed or "spent" in the current transaction 152j. In general, the previous transaction can be any transaction in the pool 154 or any block 151. The previous transaction 152i does not necessarily have to exist when the current transaction 152j is created or sent to the network 106, but the previous transaction 152i must exist and be verified in order for the current transaction to be concluded. Thus, "preceding" in this specification refers to something that precedes in a logical sequence linked by a pointer, and not necessarily to a time of creation or transmission in the chronological order. Thus, it does not necessarily exclude transactions 152i, 152j from being created or sent out of order (see the discussion of orphan transactions below). A preceding transaction 152i may equally be referred to as an antecedent or predecessor transaction.

[0024] The input of the current transaction 152j also includes the signature of the user 103a to whom the output of the previous transaction 152i is locked. The output of the current transaction 152j can also be cryptographically locked to the new user 103b. Thus, the current transaction 152j can transfer an amount defined in the input of the previous transaction 152i to the new user 103b defined in the output of the current transaction 152j. In some cases, a transaction 152 may have multiple outputs and split the input amount among multiple users (one of which is the original user to make the change). In some cases, a transaction may have multiple inputs and combine amounts from multiple outputs of one or more previous transactions and redistribute them into one or more outputs of the current transaction.

[0025] This is sometimes called an "output-based" transaction protocol, and sometimes also called an "unspent transaction output (UTXO) type protocol" (where the outputs are called UTXOs). A user's total balance is not defined by one number stored in the blockchain, instead, the user needs a special "wallet" application 105 to collate the values ​​of all of the user's UTXOs, which are distributed across many different transactions 152 in the blockchain 151.

[0026] As part of the account-based transaction model, another type of transaction protocol is sometimes called an "account-based" protocol. In the account-based case, each transaction transfers by referencing an absolute account balance, rather than defining the amount to be transferred by referencing back to the UTXO of a preceding transaction in the past sequence of transactions. The current state of every account is stored and constantly updated by miners separate from the blockchain. In such a system, transactions are ordered using the successive transaction records (so-called "positions") of the accounts. This value is signed by the senders as part of their cryptographic signature and hashed as part of the transaction reference calculation. In addition, an optional data field can also sign the transaction. This data field may point back to a previous transaction, for example if a previous transaction ID is included in the data field.

[0027] In both types of transaction protocols, when a user 103 wants to execute a new transaction 152j, he sends the new transaction from his computer terminal 102 to one of the nodes 104 of the P2P network 106 (currently usually a server or a data center, but in principle it could be another user terminal). This node 104 checks whether the transaction is valid according to a node protocol applied to each node 104. The details of the node protocol correspond to the type of transaction protocol used in the blockchain 150 in question and together form an overall transaction model. The node protocol typically requires the nodes 104 to check that the cryptographic signature in the new transaction 152j matches an expected signature, which depends on the previous transaction 152i in the ordered sequence of transactions 152. In the output-based case, this may include checking that the cryptographic signature of the user included in the input of the new transaction 152j matches a condition defined in the output of the previous transaction 152j that the new transaction consumes, which typically includes at least checking that the cryptographic signature in the input of the new transaction 152j unlocks the output of the previous transaction 152i to which the input of the new transaction points. In some transaction protocols, the condition may be defined, at least in part, by custom script included in the input and / or output. Alternatively, it may be fixed solely in the node protocol, or by a combination of these. In any case, if the new transaction 152j is valid, the current node forwards the new transaction to one or more other nodes of the nodes 104 in the P2P network 106. At least some of these nodes 104 also act as forwarding nodes 104F, applying the same tests according to the same node protocol, and forwarding the new transaction 152j to one or more further nodes 104, etc.In this manner, the new transaction is propagated throughout the network of nodes 104.

[0028] In an output-based model, the definition of whether a given output (e.g., UTXO) is spent is whether it has already been validly redeemed by an input of another onward transaction 152j according to the node protocol. Another condition for a transaction to be valid is that the output of the preceding transaction 152i that it attempts to spend or redeem has not yet been consumed / redeemed by another valid transaction. Again, if not valid, the transaction 152j is not propagated or recorded in the blockchain. This prevents double-spending, where a payer attempts to spend the same transaction output multiple times. On the other hand, an account-based model prevents double-spending by maintaining an account balance. Again, because of the defined order of transactions, the account balance has a single defined state at a time.

[0029] In addition to validating, at least some of the nodes 104M compete to be the first to create a block of transactions in a process called mining, which is backed by a "proof of work." At the mining nodes 104M, new transactions are added to a pool of valid transactions that have not yet appeared in a block. Miners then compete to assemble a new valid block 151 of transactions 152 from the pool of transactions 154 by attempting to solve a cryptographic puzzle. This typically involves searching for a "nonce" value such that when the nonce is concatenated with the pool of transactions 154 and hashed, the output of the hash satisfies a predefined condition. For example, the predefined condition may be that the output of the hash has a predefined number of leading zeros. A property of a hash function is that it has an output that is unpredictable with respect to the input. This search can therefore only be performed by brute force and therefore consumes a significant amount of processing resources at each node 104M trying to solve the puzzle.

[0030] The first miner node 104M to solve the puzzle announces this to the network 106 and provides its solution as a proof. This solution can be easily checked by other nodes 104 in the network (it is easy to verify that the hash output satisfies the condition given the solution for the hash). The pool 154 of transactions for which the winner solved the puzzle is recorded as a new block 151 in the blockchain 150 by at least some of the nodes 104 acting as storage nodes 104S, based on checking the winner's published solution at each node. The new block 151n is also assigned a block pointer 155, which points to the previously created block 151n-1 in the chain. The proof-of-work helps to reduce the risk of double spending, since it takes a lot of effort to create a new block 151, and blocks containing double spending are likely to be rejected by other nodes 104, thus providing an incentive for mining nodes 104M not to include double spending in their blocks. Once created, blocks 151 cannot be altered because they are known and maintained at each storage node 104Si in the P2P network 106 according to the same protocol, and block pointers 155 impose an order on blocks 151. This provides an immutable public ledger of transactions, as transactions 152 are recorded in ordered blocks at each storage node 104S in the P2P network 106.

[0031] Note that different miners 104M, who are constantly competing to solve the puzzle, may be solving the puzzle based on different snapshots of the unmined transaction pool 154 at any given time, depending on when they started looking for a solution. Whoever solves the puzzle first defines the transactions 152 to be included in the next new block 151n, and the current unmined transaction pool 154 is updated. Miners 104M then continue to compete to produce blocks from the newly defined unsolved pool 154. There is also a protocol to resolve possible "forks", which are cases when two miners 104M solve the puzzle within a very short time of each other and inconsistent views of the blockchain propagate. In essence, whenever a branch of a fork grows, the longest one becomes the final blockchain 150.

[0032] In most blockchains, the winning miner 104M is automatically rewarded with a special type of new transaction that creates a new amount of digital assets out of nothing (a normal transaction transfers an amount of digital assets from one user to another). Thus, the winning node is said to have "mined" an amount of digital assets. This special type of transaction is sometimes called a "generation" transaction; it automatically forms part of a new block 151n. This reward incentivizes miners 104M to participate in proof-of-work competitions. Often, normal (non-generation) transactions specify an additional transaction fee in one of their outputs to further reward the winning miner 104M who generated the block 151n that contains the transaction.

[0033] Due to the computational resources involved in mining, typically at least each of the miner nodes 104M takes the form of a server including one or more physical server units, or an entire data center. Each transfer node 104M and / or storage node 104S may also take the form of a server or a data center. However, in principle, any given node 104 may include a user terminal or a group of user terminals networked together.

[0034] The memory of each node 104 stores software configured to run on the processing unit of the node 104 to perform one or more respective roles and process transactions 152 according to the node protocol. It will be appreciated that any operation attributable to a node 104 may be performed by software executing on the processing unit of the respective computing device. The node software may be implemented in one or more applications at the application layer, or a lower layer such as the operating system layer or protocol layer, or any combination thereof. Additionally, the term "blockchain" as used herein is a general term referring to a general type of technology and is not limited to any particular proprietary blockchain, protocol, or service.

[0035] Also connected to the network 101 are computing devices 102 of each of a number of parties 103 acting as consumer users. These act as payers and payees in transactions, but do not necessarily participate in mining or propagating transactions on behalf of other parties. They do not necessarily execute the mining protocol. Two parties 103 and their respective devices 102 are shown for illustrative purposes: a first party 103a and its respective computing device 102a, and a second party 103b and its respective computing device 102b. It will be understood that many more such parties 103 and their respective computing devices 102 may exist and participate in the system, but for convenience they are not shown. Each party 103 may be an individual or an organization. Purely by way of example, the first party 103a will be referred to herein as Alice, and the second party 103b will be referred to as Bob, but it will be understood that this is not limiting and that any reference herein to Alice or Bob may be substituted with "first party" and "second party", respectively.

[0036] The computing equipment 102 of each party 103 comprises a respective processing device comprising one or more processors, for example one or more CPUs, GPUs, other accelerator processors, application specific processors, and / or FPGAs. The computing equipment 102 of each party 103 further comprises a memory, i.e. a computer readable storage device in the form of a non-transitory computer readable medium or media. This memory may include one or more memory units using, for example, a magnetic medium such as a hard disk, an electronic medium such as a SSD, a flash memory or an EEPROM, and / or an optical medium such as an optical disk drive. The memory on the computing equipment 102 of each party 103 stores software including a respective instance of at least one client application 105 arranged to operate on the processing device. It will be understood that any operation belonging to a given node 104 may be performed by using software executed on the processing device of the respective computing equipment 102. The computing equipment 102 of each party 103 comprises at least one user terminal, for example a desktop or laptop computer, a tablet, a smartphone, or a wearable device such as a smart watch. The computing device 102 of a given party 103 may also include one or more other networked resources, such as cloud computing resources, accessed via a user terminal.

[0037] The client application 105 may be initially provided to the computing equipment 102 of any given party 103 on one or more suitable computer readable storage media, for example downloaded from a server, or on a removable storage device such as a removable SSD, a flash memory key, a removable EEPROM, a removable magnetic disk drive, a magnetic floppy disk or tape, an optical disk, for example a CD or DVD ROM, or a removable optical drive.

[0038] The client application 105 has at least a "wallet" functionality, which has two main functions. One of these is to allow each user party 103 to create, sign and send transactions 152 that are propagated throughout the network of nodes 104 and thereby included in the blockchain 150. The other is to report to each party the amount of digital assets that it currently owns. In an output-based system, this second function involves reconciling the amount defined in the outputs of the various transactions 152 scattered throughout the blockchain 150 that belong to that party.

[0039] NOTE: Although various client functions are sometimes described as being integrated into a given client application 105, this is not necessarily limiting; instead, any client functionality described herein may be implemented in two or more different suites of applications, interfacing, for example, via an API, or one plugging into the other. More generally, client functions may be implemented at the application layer, or at a lower layer such as an operating system, or any combination of these. The following is described in terms of a client application 105, but it will be understood that this is not limiting.

[0040] An instance of a client application or software 105 on each computing device 102 is operatively coupled to at least one of the forwarding nodes 104F of the P2P network 106. This allows the wallet function of the client 105 to transmit the transaction 152 to the network 106. The client 105 can also contact one, some, or all of the storage nodes 104 to query the blockchain 150 for any transactions in which the respective party 103 is a recipient (or, in an embodiment, actually inspect the transactions of other parties in the blockchain 150, since the blockchain 150 is a public facility that provides trust of transactions in part through its public visibility). The wallet function on each computing device 102 is configured to form and transmit the transaction 152 according to a transaction protocol. Each node 104 executes software configured to validate the transaction 152 according to the node protocol and, in the case of a forwarding node 104F, forward the transaction 152 for propagation throughout the network 106. The transaction protocol and the node protocol correspond to each other, and a given transaction protocol implements a given transaction model together with a given node protocol. The same transaction protocol is used for all transactions 152 in the blockchain 150 (although a transaction protocol may allow different subtypes of transactions). The same node protocol is used by all nodes 104 in the network 106 (although many nodes may handle different transaction subtypes differently according to rules defined for that subtype, and different nodes may take on different roles and thus implement different corresponding aspects of the protocol).

[0041] As mentioned above, the blockchain 150 includes a chain of blocks 151, each of which includes a set of one or more transactions 152 created by the proof-of-work process, as described above. Each block 151 also includes a block pointer 155 that points back to a previously created block 151 in the chain, so as to define a sequential order to the blocks 151. The blockchain 150 also includes a pool of valid transactions 154 waiting to be included in a new block by the proof-of-work process. Each transaction 152 includes a pointer to a previous transaction, so as to define an order to the sequence of transactions (note: the sequence of transactions 152 is allowed to diverge). The chain of blocks 151 goes back to a genesis block (Gb) 153, which was the first block in the chain. Early in the chain 150, one or more original transactions 152 pointed to the genesis block 153, but not to a preceding transaction.

[0042] When a given party 103, for example Alice, wants to send a new transaction 152j to be included in the blockchain 150, she formulates the new transaction (using the wallet functionality of her client application 105) according to the relevant transaction protocol. Then, from the client application 105, she sends the transaction 152 to one of one or more forwarding nodes 104F to which she is connected. For example, this may be the forwarding node 104F that is closest or best connected to Alice's computer 102. When any given node 104 receives the new transaction 152j, it processes it according to the node protocol and its respective role. This includes first checking whether the newly received transaction 152j meets certain conditions to be "valid", examples of which will be detailed shortly. In some transaction protocols, the conditions for validation may be configurable per transaction by a script included in the transaction 152. Alternatively, the conditions may simply be a built-in feature of the node protocol, or may be defined by a combination of the script and the node protocol.

[0043] Provided that the newly received transaction 152j passes the tests to be considered valid (i.e., is "valid"), any storage node 104S that receives the transaction 152j adds the newly validated transaction 152 to a pool 154 in the copy of the blockchain 150 maintained at that node 104S. Additionally, any forwarding node 104F that receives the transaction 152j propagates the validated transaction 152 to one or more other nodes 104 in the P2P network 106. Because each forwarding node 104F applies the same protocol, assuming the transaction 152j is valid, this means that it will soon be propagated throughout the P2P network 106.

[0044] Once in the pool 154 in the copy of the blockchain 150 maintained in one or more storage nodes 104, the miner nodes 104M start competing to solve the proof-of-work puzzle of the latest version of the pool 154 that contains the new transaction 152 (other miners 104M are still trying to solve the puzzle based on their old view of the pool 154, but whoever gets there will first define where the next new block 151 ends and the new pool 154 begins, and eventually someone will solve the puzzle for the part of the pool 154 that contains Alice's transaction 152j). Once the proof-of-work has been done for the pool 154 that contains the new transaction 152j, it becomes part of one of the blocks 151 in the blockchain 150. Since each transaction 152 contains a pointer to the previous transaction, the order of the transactions is also immutably recorded.

[0045] Different nodes 104 may initially receive different instances of a given transaction and therefore may have conflicting views of which instances are "valid" before one instance is mined into a block 150, at which point all nodes 104 agree that only the mined instance is the valid instance. If a node 104 accepts one instance as valid and then discovers that a second instance has been recorded in the blockchain 150, it must accept it and discard (i.e., treat as invalid) the first unmined instance it accepted.

[0046] Figure 2 shows an example of a transaction protocol. This is an example of a UTXO-based protocol. A transaction 152 (abbreviated as "Tx") is the fundamental data structure of a blockchain 150 (each block 151 contains one or more transactions 152). The following is described with reference to an output-based or "UTXO"-based protocol. However, this is not limited to all possible implementations.

[0047] In a UTXO-based model, each transaction ("Tx") 152 includes a data structure that includes one or more inputs 202 and one or more outputs 203. Each output 203 may include an unspent transaction output (UTXO), which can be used as a source of input 202 for another new transaction (if the UTXO has not yet been redeemed). The UTXO specifies an amount of a digital asset (a store of value). It includes, among other information, the transaction ID of the transaction from which it originated. The transaction data structure may also include a header 201, which may include an indicator of the size of the input fields 202 and the output fields 203. The header 201 may also include an ID for the transaction. In an embodiment, the transaction ID is a hash of the transaction data (minus the transaction ID itself) and is stored in the header 201 of the outstanding transaction 152 submitted to the miner 104M.

[0048] For example, suppose Alice 103a wants to create a transaction 152j that transfers the amount of the digital asset in question to Bob 103b. In FIG. 2, Alice's new transaction 152j is labeled "Tx1". It takes the amount of the digital asset locked to Alice into the output 203 of the preceding transaction 152i in the sequence and transfers at least a portion of it to Bob. The preceding transaction 152i is labeled "Tx0" in FIG. 2. Tx0 and Tx1 are merely arbitrary labels. They do not necessarily mean that Tx0 is the first transaction in the blockchain 151 or that Tx1 is the immediate next transaction in the pool 154. Tx1 could point to any preceding (i.e., ancestor) transaction that still has an unspent output 203 locked to Alice.

[0049] The preceding transaction Tx0 may already be validated and included in the blockchain 150 by the time Alice creates her new transaction Tx1, or at least by the time she sends it to the network 106. It may already be included in one of the blocks 151 at that point, or it may still be waiting in the pool 154, in which case it will be included in the new block 151 immediately. Alternatively, Tx0 and Tx1 may be generated and sent to the network 102, or Tx0 may be sent after Tx1 if the node protocol allows for buffering of "orphan" transactions. The terms "preceding" and "following" as used herein in the context of a sequence of transactions refer to the order of transactions in a sequence defined by transaction pointers specified in the transaction (such as which transaction points to which other transaction). They may equally be replaced by "predecessor" and "inheritor" or "ancestor" and "descendant", "parent" and "child", etc. This does not necessarily mean the order in which they are created, sent to the network 106, or arrive at any given node 104. Nevertheless, a subsequent transaction (descendant transaction or "child") that points to a preceding transaction (ancestor transaction or "parent") will not be validated unless the parent transaction is validated. A child that arrives at node 104 before its parent is considered an orphan. It may be discarded or buffered for a certain amount of time to wait for its parent, depending on the node protocol and / or miner behavior.

[0050] One of the one or more outputs 203 of the preceding transaction Tx0 includes a particular UTXO, labeled herein as UTXO0. Each UTXO includes a value that specifies the amount of the digital asset represented by the UTXO, and a locking script that defines the conditions that must be met by an unlocking script in the input 202 of the following transaction for the following transaction to be validated, and thus for the UTXO to be successfully redeemed. Typically, the locking script locks the amount to a particular party (the beneficiary of the transaction in which it is included). That is, the locking script typically defines the unlocking conditions as follows: the unlocking script in the input of the following transaction includes a cryptographic signature of the party to whom the preceding transaction was locked.

[0051] A lock script (aka scriptPubKey) is a piece of code written in a domain-specific language recognized by the node protocol. A specific example of such a language is called "script" (Script, capital S). A lock script specifies the information needed to consume a transaction output 203, e.g., the requirements of Alice's signature. An unlock script appears in the transaction's output. An unlock script (aka scriptSig) is a piece of code written in a domain-specific language that provides the information needed to satisfy the criteria of the lock script. For example, it may include Bob's signature. An unlock script appears in the transaction's inputs 202.

[0052] In the example shown, UTXO0 of output 203 of Tx0 is A ], which means that Alice's signature SigP must be present in order for UTXO0 to be redeemed (or, more precisely, for a subsequent transaction that attempts to redeem UTXO0 to be valid). A[ChecksigPA] contains the public key PA from Alice's public / private key pair. Input 202 of Tx1 contains a pointer to Tx1 (e.g., by its transaction ID, TxID0, which in an embodiment is a hash of the entire transaction Tx0). Input 202 of Tx1 contains an index that identifies UTXO0 in Tx0, in order to identify it among any other possible outputs of Tx0. Input 202 of Tx1 further contains an unlock script that contains Alice's cryptographic signature, created by Alice applying her private key from her key pair to a given portion of data (sometimes called a "message" in cryptography). <sigpa>The data (or "message") that Alice needs to sign in order to provide a valid signature may be defined by the lock script, or by the node protocol, or by a combination of these.

[0053] When a new transaction Tx1 arrives at node 104, the node applies the node protocol, which involves running the lock script and the unlock script together to check if the unlock script satisfies the conditions defined in the lock script (which may include one or more criteria). In an embodiment, this involves concatenation of the two scripts.

number

[0054] The details of authentication using public-private cryptography will be well known to those skilled in the art. Essentially, if Alice signs a message by encrypting it with her private key, then with Alice's public key and the message in the clear (unencrypted message), another entity, such as node 104, can authenticate that the encrypted version of the message must have been signed by Alice. Signatures typically allow the holder of the public key to authenticate the signature by hashing the message, signing the hash, and tagging this as the signature on a clear version of the message. Thus, in embodiments, references to signing a particular piece of data or portion of a transaction, etc., may mean signing a hash of the piece of data or portion of the transaction.

[0055] If the unlock script in Tx1 satisfies one or more conditions specified in the lock script of Tx0 (in the example shown, Alice's signature is provided and authenticated in Tx1), the node 104 considers Tx1 valid. If it is a storage node 104S, this means adding it to the pool 154 of transactions waiting for proof-of-work. If it is a forwarding node 104F, it forwards the transaction Tx1 to one or more other nodes 104 in the network 106, which will cause it to be propagated throughout the network. Once Tx1 is validated and included in the blockchain 150, this defines it as having consumed UTXO0 from Tx0. Note that Tx1 is only valid if it uses unspent transaction outputs 203. If it tries to consume an output that has already been consumed by another transaction 152, Tx1 becomes invalid even if all other conditions are met. Therefore, node 104 also needs to check whether the UTXO referenced in the preceding transaction Tx0 has already been spent (already formed a valid input to another valid transaction). This is one of the reasons why it is important for blockchain 150 to impose a defined order on transactions 152. In practice, a given node 104 may maintain a separate database that marks UTXOs 203 that transactions 152 have spent, but ultimately, what defines whether a UTXO is spent is whether it already forms a valid input to another valid transaction in blockchain 150.

[0056] If the total amount specified in all of the outputs 203 of a given transaction 152 is greater than the total amount pointed to by all of its inputs 202, this is another basis for invalidity in most transaction models. Thus, such a transaction will not be propagated or mined into a block 151.

[0057] Note that in the UTXO-based transaction model, a given UTXO must be spent in its entirety; it is not possible to "leave" an amount defined in a UTXO while another amount is spent. However, an amount from a UTXO can be split into multiple outputs of a subsequent transaction. For example, the amount defined in UTXO0 of Tx0 can be split into multiple UTXOs of Tx1. Thus, if Alice does not want to give Bob the entire amount defined in UTXO0, she can use the remaining amount to give herself change or pay another party in the second output of Tx1.

[0058] In practice, Alice should usually also include a fee for the winning miner, because today, the reward for the generating transaction alone is usually not enough to motivate mining. If Alice does not include a fee for the miner, Tx0 will likely be rejected by the miner's node 104M, and thus, although technically valid, it will still not be propagated and included in the blockchain 150 (the miner's protocol does not force the miner 104M to accept the transaction 152 if the miner does not want to). In some protocols, the mining fee does not require its own separate output 203 (i.e., it does not require a separate UTXO). Instead, the difference between the total amount pointed to by the input 202 and the total amount specified in the output 203 of a given transaction 152 is automatically given to the winning miner 104. For example, suppose that a pointer to UTXO0 is the only input to Tx1, and Tx1 has only one output UTXO1. If the amount of the digital asset specified in UTXO0 is greater than the amount specified in UTXO1, the difference automatically goes to the winning miner 104M. However, nothing in this document precludes that a miner's fee may alternatively or additionally be explicitly specified in a unique one of the UTXOs 203 of transaction 152.

[0059] Alice and Bob's digital assets consist of the unspent UTXOs locked to them in any transaction 152 in the blockchain 150. Thus, typically, the assets of a given party 103 are distributed across the UTXOs of various transactions 152 throughout the blockchain 150. No single number is stored anywhere in the blockchain 150 that defines the total balance of a given party 103. It is the role of the wallet function in the client application 105 to aggregate the value of all the various UTXOs locked to each party that have not yet been spent in another onward transaction. This can be done by querying the copy of the blockchain 150 stored in any of the storage nodes 104S, for example, the storage node 104S that is closest to or best connected to each party's computer device 02.

[0060] Note that script code is often expressed diagrammatically (i.e., not in a precise language). For example, A ] to [ChecksigP A ]=OP_DUPOP_HASH160 <H(P A )>OP_EQUALVERIFYOP_CHECKSIG. "OP_..." represents a specific opcode in a scripting language. OP_CHECKSIG (also called "Checksig") is a scripting opcode that takes two inputs (a signature and a public key) and verifies the validity of the signature using the Elliptic Curve Digital Signature Algorithm (ECDSA). At runtime, all occurrences of the signature ("si"') are removed from the script, but additional requirements such as hash puzzles remain in the transaction to be verified by the "sig" input. As another example, OP_RETURN is a scripting language opcode for generating an unspent output of a transaction that can store metadata within the transaction, thereby immutably recording the metadata to the blockchain 150. For example, the metadata can include a document that is desirable to store on the blockchain.

[0061] A signature PA is a digital signature. In an embodiment, it is based on ECDSA using the elliptic curve secp256k1. A digital signature signs specific data. In an embodiment, for a given transaction, the signature signs some of the transaction inputs and all or some of the transaction outputs. The specific parts of the outputs to sign depend on the SIGHASH flag, which is a 4-byte code included at the end of the signature that selects which outputs are signed (and is therefore fixed at the time of signing).

[0062] A lock script is sometimes referred to as a "scriptPubKey" to indicate that the respective transaction includes the public key of the party being locked. An unlock script is sometimes referred to as a "scriptSig" to indicate that it provides a corresponding signature. However, more generally, it is not required in all applications of blockchain 150 that the conditions under which a UTXO is redeemed include authenticating a signature. More generally, a scripting language may be used to define one or more conditions. Thus, the more general terms "lock script" and "unlock script" are preferred.

[0063] Some blockchain protocols use scripting languages ​​that contain two types of elements: data and opcodes. Data in a script can be, for example, numbers, public keys, signatures, hash values, etc. Opcodes are functions that operate on the data in the script. In scripting languages, scripts are executed end-to-end (usually from left to right) and make use of a data structure commonly known as a "stack". Data is always pushed onto (i.e., placed on) the stack. Opcodes pop data off the stack (i.e., take data from the stack), perform operations on the data, and then optionally "push" new data onto the stack. A stack-based scripting language commonly used in many blockchains is simply called Script. The following is described in terms of the opcodes of the Script language.

[0064] Stack-based methods are well known to those skilled in the art. The following example describes an exemplary method of script implementation. Specifically, an exemplary verification and unlock process is shown below.

[0065] An example script is:<Bob’s signature><Bob’s public key> OP_DUP OP_HASH<Bob’s public address> OP_EQUALVERIFY OP_CHECKSIG. The script is executed from left to right.

[0066] Step 1:<Bob’s signature> Push onto the stack. [Table 1]

[0067] Step 2:<Bob’s public key> Push onto the stack (this is now the top element of the stack). [Table 2]

[0068] Step 3: The OP_DUP opcode operates on the top element of the stack,<Bob’s public key> Duplicate. [Table 3] Step 4: The OP_HASH opcode is<Bob’s public key> Pop out the , run it through a hash algorithm (followed by one or more optional operations),<Bob’s public address> Get and put it on the stack. [Table 4]

[0069] Step 5:<Bob’s public address> Push onto the stack (this is now the top element of the stack). [Table 5]

[0070] Step 6: The OP_EQUALVERIFY opcode pops the last two elements off the stack (<Bob’s public address> and<Bob’s public address> ), checks to see if the two addresses are identical. If they are not identical, the execution is considered unsuccessful. If the condition is TRUE, the next command is executed. [Table 6]

[0071] Step 7: The OP_CHECKSIG opcode is<Bob’s public key> and<Bob’s signature> and checks them to see if they are valid. Once this process is complete, Bob will be able to unlock the transaction and access the specified amount of digital assets. [Table 7]

[0072] Inscript Functions An embodiment of the present invention provides for implementing in-script synthetic functions within a blockchain transaction, which is accomplished by redefining the function of OP_RETURN (or alternatively configuring the opcode to execute the function attributed to OP_RETURN below).

[0073] FIG. 3 illustrates an example of node software 300 that may be executed by each node 104 of the blockchain network 106 in the example of the UTXO or output-based model. The node software 300 includes, among other components, a script engine 301, a stack 302, and an application level decision engine 303. The script engine 301 may include a script interpreter configured to execute the script by interpreting parts of the script as data elements or functions acting on the data elements and / or by pushing or reading data elements from the stack 302. Alternatively, the script engine 301 may utilize another form of execution, such as just-in-time (JIT) compilation. Generally, the term "execute" is used herein in its broadest sense of executing a script in any manner (and not in the narrow sense of executing compiled machine code instructions). Thus, "execute" may include interpretation in the present context. "Opcode" in the present context does not mean the opcode of an individual machine code instruction, but rather a higher level command that is mapped by the script engine 301 at each node 104 to a respective predefined function.

[0074] Although not shown, the node software may further include a protocol engine and a set of one or more blockchain-related functional modules. At any given node 104, these may include any one, two, or three of a mining module, a transfer module, and a storage module (depending on the node's role or roles). The protocol engine is configured to recognize different fields of a transaction 152 and process them according to the node protocol. Transaction 152m (Tx m ) is received, and another preceding transaction 152m-1 (Tx m-1 When the protocol engine has an input that points to an output (e.g., a UTXO) of Txm, the protocol engine identifies the unlock script and passes it to the script engine 401. The protocol engine then determines the value of Txm based on the pointer in the input of Txm. m-1 It identifies and searches for Tx m-1 If Tx is not already in the blockchain 150, each node can choose to use it from its own pool of pending transactions 154, or m-1 If Tx is already in the blockchain 150, the node may obtain it from a copy of block 151 in the blockchain 150 stored in the respective node or another node 104. m-1 In either case, the protocol engine may search for Tx m-1 The script engine 301 then identifies the lock script in the output pointed to by the script.

[0075] The script engine 301 therefore m-1 Lock script and Tx m 3 and the corresponding inputs of Tx1 and Tx2. For example, although Tx1 and Tx2 are shown in FIG. 4, it can be applied to any pair of transactions such as Tx0 and Tx1, etc. The script engine 301 executes the two scripts together as described above, which includes putting data on the stack 302 and retrieving data according to the script language (e.g., Script) based on the stack being used.

[0076] 3, Tx1's lock script includes one or more OCS opcodes (two in this example) and at least one OP_RETURN. When script engine 301 invokes OP_RETURN, it is configured to consume a data element from the top of stack 402 and interpret the data element as a reference to one of the OCS opcodes contained in Tx1's lock script. Script engine 301 is also configured to execute the portion of the lock script that follows the referenced OCS opcode, for example, by replacing the unexecuted portion of the lock script with the portion of the lock script that follows the referenced OCS opcode.

[0077] As mentioned above, when executing (e.g., validating) a transaction, the lock script of the transaction is executed together with the unlock script of the previous transaction. A transaction may contain more than one lock script. At least one of those lock scripts includes OP_RETURN and one or more instances of OP_CODESEPARATOR (OCS). Each instance of OCS separates a portion of the lock script. For example, there may be two OCS opcodes that separate three portions of the lock script. Unless the context requires otherwise, the first, second, third, etc. are merely labels to distinguish between different (e.g., OCS, OP_RETURN, portions, etc.) of the same item.

[0078] As part of the validation of a transaction, a lock script is executed, and if it includes OP_RETURN, when OP_RETURN is called, a data element is read from one of the stacks (e.g., the Main or Alt stack). Data elements may be read from both stacks and combined (e.g., added) to form a single data element. Data elements are generated during the execution of the lock script, e.g., up until the point where OP_RETURN is called. The data element may be a number or other type of variable, and is used to output the first part of the lock script that follows from the OCS that corresponds to the data element. In other words, the data element is interpreted as an index (or address) of a particular OCS. Here, the "first part of the lock script" does not necessarily mean that it is the main part of the lock script. Here, "first" is used as a label to refer to a part of the lock script, which may or may not be the main part depending on the data element read from the stack. For example, if there are three OCS opcodes in the lock script, they may be indexed by the numbers 1, 2, and 3. If the data element corresponds to a second OCS in the script, the portion of the lock script following the second OCS is output. The portion of the lock script may be, for example, added to a script template, added to a set of instructions to be executed, and / or executed.

[0079] When the first portion of the lock script is next executed, if it contains an instance of OP_RETURN, then when that instance of OP_RETURN is invoked, a data element may be read from the stack and used as the address of the OCS. Depending on the data element read from the stack, the same or a different OCS may be referenced. The portion of the lock script following the referenced OCS (called the "second portion") is output. Continuing with the example above, if the data element corresponds to the first OCS in the script, then the portion of the lock script following the first OCS is output. Alternatively, the data element may correspond to the second or third OCS, in which case the portion of the lock script that is output is that following the second or third OCS, respectively. If the contents of the lock script are selected accordingly, for example, an infinite loop may be created by repeatedly referencing the same set of OCS opcodes.

[0080] In some embodiments, within the lock script, each OP_RETURN is preceded by an opcode that, when called, pushes a data element onto the top of the stack. For example, each opcode preceding an OP_RETURN may push a data element onto the stack that corresponds to one of the OCS opcodes.

[0081] The script of the transaction may be read, executed, interpreted, etc. by a script engine (e.g., a script interpreter). Before executing the lock script, the script engine may scan the lock script for any instances of OP_RETURN. If the lock script contains at least one instance of OP_RETURN, the script engine may generate a sub-script that starts at the main OCS in the lock script and ends at the end of the lock script. This sub-script may be stored in memory. When OP_RETURN is called, a data element from a stack is consumed, e.g., the top element from the main stack. If the data element is not a positive integer and / or is greater than the total number of OCS opcodes in the sub-script, execution may terminate. If the data element is a positive integer and is less than or equal to the total number of OCS opcodes in the sub-script, the portion of the lock script that follows the OCS corresponding to the data element is output. For example, the unexecuted script (i.e., the portion of the lock script that follows OP_RETURN) is replaced by the portion of the lock script that follows the nth OCS. where n is the data element consumed by OP_RETURN.

[0082] When executing a script, a main script and a subscript may be stored in memory. The main script is the script to be executed on the stack. The subscript is static and is used as a reference script for the subscript, and parts of the subscript are read and copied. The subscript contains all of the lock script following the first OCS in the lock script. The main script is dynamic. Not only is it consumed as execution progresses, but it may also be overwritten by any part of the subscript by OP_RETURN during execution. For example, each time OP_RETURN is called, the main script is replaced by the part of the subscript that follows the OCS corresponding to the data element being consumed (i.e., the part of the original lock script that forms part of the subscript).

[0083] <Usage example> Figure 4 shows an example Inscript function execution. This example function implements the Euclidean algorithm, which takes two inputs (a, b) and outputs the greatest common divisor (GCD) of a and b. For simplicity, let a>b.

[0084] In this example, the inputs a and b are 105 and 28, respectively. The number 105 is lower on the stack than the number 28. The output is GCD(105,28). The script to be executed is: OCS OP_TUCK OP_MOD OP_DUP OP_IF OP_1 OP_RETURN OP_ENDIF OP_DROP. We can see that the script contains a single OCS and a single OP_RETURN. OP_RETURN follows OP_1 which pushes a value of 1 onto the stack. When OP_RETURN is called, a value of 1 is read and used to execute the part of the script following the corresponding OCS. Now, since OCS is the primary opcode in the script, this is equivalent to the script being repeated.

[0085] As shown in Figure 4, the output is 7, which is the GCD of 105 and 28. When the script is executed, it may be looped one or more times (once in this example). That is, 18 opcodes are called to calculate the greatest common denominator of 105 and 28. However, only 9 opcodes are needed to compose the script. The advantage of this is that larger composite scripts can be implemented from smaller scripts contained in transactions.

[0086] 5A-C show the execution of another exemplary inscript function. This exemplary function performs elliptic curve point multiplication. The input to the function is (a,G), where a is a scalar and G is a generation point. In this example, a is 7. The output from the function is a·G.

[0087] The script to be executed is:

number

[0088] As an example, when "OP_DUP [POINT_ADD] OP_2 OP_RETURN" is executed, OP_RETURN consumes data element "2" from the stack and proceeds to execute the script following OCS_2.

[0089] The script works as follows: (1) Push a 0 onto the ALT stack. This 0 helps us identify when we've reached the bottom of the ALT stack. (2) There are two inputs (a, G). Check whether a>1. If yes, proceed to point doubling. b. If no, start adding points. (3) For point doubling, we start by pushing a 1 onto the stack. This 1 acts like a counter, keeping track of how many times the point has been doubled. The counter is compared to a. A copy of G is made for future use. If the counter is greater than a, the counter is decremented by half and then that value is subtracted from a. This produces a new value of a that is smaller than the original value. Meanwhile, the result of the doubling is pushed onto the ALT stack, then a 1 is pushed onto the ALT stack to indicate that there is a value to be fetched from the ALT stack. c. OP_RETURN is then used to go to step 2 with the new value of a. 4) When there are no more doublings that can be performed, a check is made to see if a=1 or a=0. If a=1, then each element on the ALT stack is fetched one by one and a point addition is performed until the bottom of the stack is reached. b. If a=0, first drop G, then fetch one result from the ALT stack, and go back to step "a." above.

[0090] Note that, as abbreviations for a large group of opcodes, point addition is defined by [POINT_ADD] and point doubling is defined by OP_DUP[POINT_ADD] (or [POINT_DOUBLE]). [POINT_ADD] consumes the first two elements on the stack, P1 and P2, and pushes the point addition of P1 and P2 onto the stack. [POINT_DOUBLE] consumes the first element P on the stack and pushes point 2P onto the stack.

[0091] It will be understood that the above embodiments are described by way of example only. Clearly, the embodiments are not limited to opcodes having a particular "name". Rather, the embodiments are limited to opcodes having a particular function. The terms "OP_RETURN" and "OP_CODESEPARATOR" are used for simplicity.

[0092] According to a first instance of the teachings disclosed herein, there is provided a computer-implemented method for executing a transaction on a blockchain, the transaction including at least one output including a locking script, the locking script including an instance of a first opcode and one or more instances of a second opcode, each instance of the second opcode separating a portion of the locking script, the method comprising: reading a first data element from at least one stack upon invoking an instance of the first opcode, the first data element being generated during execution of the lock script by an unlock script of a different transaction; outputting a first portion of the locking script following an instance of the second opcode corresponding to the first data element; A method is provided that includes:

[0093] The first opcode may be a termination opcode. The second opcode may be a separation opcode.

[0094] According to a second, optional instance, the method according to the first instance may be provided, wherein the outputting step may include executing at least a portion of the first portion of the lock script.

[0095] According to a third, optional instance, there may be provided a method according to the first or second instance, comprising: generating a sub-script, the sub-script starting with a first instance of the instance opcode, followed by a remainder of the lock script that is executed after the first instance of the second opcode, the first portion of the lock script being the first portion of the sub-script.

[0096] According to a fourth, optional instance, a method according to the third instance may be provided, wherein the lock script and the sub-script may be stored in a memory of a node, and the outputting step may include replacing an unexecuted portion of the lock script with the first portion of the sub-script in the memory.

[0097] According to a fifth, optional instance, scanning the locking script for an instance of the first opcode before executing the locking script; generating said subscript if said lock script contains an instance of said opcode; There may be provided a method according to a third or fourth instance including:

[0098] According to a sixth, optional instance, a method according to the first to fifth instances may be provided, wherein the method may include a step of interpreting the first data element as an address of an instance of the second opcode.

[0099] According to a seventh, optional instance, the said supplementary law states: the first data element is not a positive integer; the first data elements are greater than the total number of instances of the second opcode; In at least one of the cases above, a method according to any of the first to sixth instances may be provided, comprising terminating execution of the lock script.

[0100] According to an eighth, optional instance, the first portion of the lock script includes a second instance of the first opcode, and the method further comprises: reading a second data element from at least one stack upon invoking the second instance of the first opcode, the second data element being generated during execution of a first portion of the lock script; outputting a second portion of the locking script following an instance of the second opcode corresponding to the second data element; A method according to any of the first to seventh instances may be provided, which may include:

[0101] According to a ninth, optional instance, a method according to the eighth instance may be provided, wherein the step of outputting the second portion of the lock script may include a step of executing at least a portion of the second portion of the lock script.

[0102] According to a tenth, optional instance, there may be provided a method according to any of the first to ninth instances subordinate to the fourth instance, wherein the second portion of the lock script may be a second portion of the sub-script, and the method may include a step of replacing an unexecuted portion of the first portion of the lock script with the second portion of the sub-script in the memory.

[0103] According to an eleventh instance of the teachings disclosed herein, there is provided a computer program embodied on a computer-readable storage device and configured to execute any of the first to tenth instances when executed on a node of a blockchain network.

[0104] According to a twelfth instance of the teachings disclosed herein, there is provided a computing device, comprising: a memory including one or more memory units; a processing device including one or more processing units; Including, A computing device is provided, wherein the memory stores code configured to execute on the processing device, the code being configured to execute any of first through tenth instances.

[0105] Other variations or uses of the disclosed technology may become apparent to those skilled in the art upon review of this specification, and the scope of the present disclosure is not limited by the described embodiments, but only by the scope of the appended claims.< / sigpa>

Claims

1. 1. A method of executing a transaction on a blockchain, the transaction including at least one output including a locking script, the locking script including an instance of a first opcode and one or more instances of a second opcode, each instance of the second opcode separating a portion of the locking script, the method being performed by a computing device of a node of a blockchain network; a script engine of the node, upon invoking an instance of the first opcode, reading a first data element from at least one stack, the first data element being generated during execution of the lock script by the script engine by an unlock script of a different transaction; outputting a first portion of the lock script following an instance of the one or more instances of the second opcode that corresponds to the first data element; The method includes:

2. The method of claim 1 , further comprising the step of: the script engine executing at least a portion of the first portion of the lock script.

3. 3. The method of claim 1, further comprising: the script engine generating a sub-script, the sub-script starting with a first instance of the second opcode followed by a portion of the lock script that executes after the first instance of the second opcode, the first portion of the lock script being the first portion of the sub-script.

4. 4. The method of claim 3, wherein the lock script and the sub-script are stored in a memory of the node, and further comprising the step of the script engine replacing an unexecuted portion of the lock script with the first portion of the sub-script in the memory.

5. prior to execution of the lock script by the script engine, the script engine scanning the lock script for instances of the first opcode; if the lock script includes an instance of the first opcode, the script engine generates the sub-script; The method according to claim 3 or 4, comprising:

6. A method according to any preceding claim, further comprising the step of: said script engine interpreting said first data element as an address of an instance of said second opcode.

7. below: the first data element is not a positive integer; the first data elements are greater than the total number of instances of the second opcode; The method according to any one of claims 1 to 6, further comprising the step of: the script engine terminating execution of the lock script in at least one of the following cases:

8. the first portion of the lock script includes a second instance of the first opcode, the method comprising: upon invoking the second instance of the first opcode, the script engine reads a second data element from at least one stack, the second data element being generated during execution of a first portion of the lock script; outputting a second portion of the lock script following an instance of the one or more instances of the second opcode that corresponds to the second data element; The method according to any one of claims 3 to 7 dependent on claim 2, comprising:

9. the script engine executing at least a portion of the second portion of the lock script; 9. The method of claim 8, comprising:

10. 10. The method of claim 9 when dependent on claim 4, wherein the second portion of the lock script is a second portion of the sub-script, the method including a step of the script engine replacing an unexecuted portion of the first portion of the lock script with the second portion of the sub-script in the memory.

11. A computer program which, when executed by a node of a blockchain network, causes the node to perform the method according to any one of claims 1 to 10.

12. 1. A computer device comprising: a memory including one or more memory units; a processing device including one or more processing units; Including, A computing device, wherein the memory stores code that, when executed on the processing device, causes the processing device to perform a method according to any of claims 1 to 10.