Method and apparatus for validating data in a blockchain network
The Merkle proof mechanism addresses the challenge of validating transactions in blockchain networks by ensuring transaction integrity and inclusion verification, enhancing the efficiency of end-user devices in blockchain data validation.
Patent Information
- Application Number
- JP2022579950
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-06-26
- Filing Date
- 2021-06-15
- Publication Date
- 2025-09-24
- Estimated Expiration
- 2041-06-15
AI Technical Summary
Existing blockchain networks face challenges in efficiently validating transactions and ensuring the integrity of data within a blockchain network, particularly for end-user devices that do not have a full copy of the blockchain, necessitating improved methods and apparatus for proving transaction inclusion in blocks.
A computer-implemented method involving a Merkle proof mechanism is employed to validate transactions, where a Merkle tree is used to determine the validity of a transaction by comparing a computed hash with the Merkle root in the block's header, ensuring the transaction's position within the block is verified through a series of hash concatenations and comparisons.
This approach enhances the ability of end-user devices to efficiently validate transactions and ensure data integrity within a blockchain network, providing a reliable method for proving transaction inclusion and adherence to blockchain protocols.
Smart Images

Figure 0007743451000004 
Figure 0007743451000005 
Figure 0007743451000006
Abstract
Description
[Technical Field]
[0001] The present disclosure relates to blockchain networks, and in particular to methods and apparatus for validating data within a blockchain network, such as validating the existence and indexing of transactions within a block. [Background technology]
[0002] A blockchain refers to a form of distributed data structure in which multiple nodes in a decentralized peer-to-peer (P2P) network (hereinafter also referred to as a "blockchain network") maintain and publicly publish duplicate copies of the blockchain. A blockchain is formed by a chain of blocks of data, each containing one or more transactions. Each transaction, except for so-called "coinbase transactions," points to the preceding transaction in the sequence. A sequence may span one or more blocks up to one or more coinbase transactions. Coinbase transactions are discussed below. Transactions submitted to a blockchain network are included in new blocks. New blocks are generated through a process known as "mining." "Mining" involves multiple nodes competing to perform "proof-of-work," i.e., solving a cryptographic puzzle based on the presentation of a defined set of ordered and validated pending transactions awaiting inclusion in a new block of the blockchain. Notably, a blockchain may be pruned at a node, and block publication can be achieved through the publication of only the block header.
[0003] Transactions in a blockchain are used to perform one or more of the following: carry digital assets (i.e., multiple digital tokens), order a set of journal entries in a virtual ledger or registry, receive and process timestamp entries, and / or time-sequence index pointers. Blockchains can also be used to layer additional functionality on top of a blockchain. Blockchain protocols may allow additional user data or indexes to be stored on data within a transaction. There is no pre-specified limit on the maximum amount of data that can be stored within a single transaction. Thus, more complex data can be incorporated. For example, this could be used to store electronic documents, or audio or video data within a blockchain.
[0004] Nodes (sometimes called "miners") in the blockchain network perform a distributed transaction registration and validation process, described below. Briefly, during this process, nodes validate transactions, insert them into a block template, and attempt to identify a valid proof-of-work solution for it. Once a valid solution is found, the new block is propagated to other nodes in the network, allowing each node to record the new block in the blockchain. To have a transaction recorded in the blockchain, a user (e.g., a blockchain client application) submits the transaction to one of the nodes in the network for propagation. Nodes receiving the transaction compete to find a proof-of-work solution and include the validated transaction in a new block. Each node is configured to implement the same node protocol, which includes one or more conditions for a transaction to be valid. Invalid transactions are not propagated or included in a block. Assuming the transaction is validated and thereby accepted into the blockchain, the transaction (including any user data) therefore remains registered and indexed at each node in the blockchain network as an immutable public record.
[0005] Nodes that successfully solve the proof-of-work puzzle to generate the latest block are typically rewarded with a new transaction, called a "coinbase transaction," that generates a new quantity of digital assets, or tokens. Detection and rejection of invalid transactions is performed by competing nodes, who act as agents of the network and are incentivized to report and prevent illicit activity. Widespread publication of information allows users to continuously audit node performance. By simply publishing block headers, participants can guarantee the ongoing integrity of the blockchain.
[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 that specifies the amount of a digital asset derivable from the preceding transaction sequence. A spendable output is sometimes called a UTXO (unspent transaction output). An output may further include a locking script that specifies conditions for the output's future redemption. A locking script is a predicate that defines the conditions required to validate and transfer a digital token or asset. Each input of a transaction (other than a coinbase transaction) includes a pointer (i.e., reference) to such an output in a preceding transaction and may further include an unlocking script to unlock the pointed-to output's locking script. Consider a pair of transactions that can be labeled a first transaction and a second transaction (or "target" transaction). The first transaction includes at least one output that specifies the amount of a digital asset and includes a locking script that defines one or more conditions for unlocking the output. The second target transaction includes at least one input including a pointer to an output of the first transaction and an unlock script for unlocking the output of the first transaction.
[0007] In such a model, when a second target transaction is sent to the blockchain network to be propagated and recorded in the blockchain, one validity criterion applied by 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 neither propagate it (as a valid transaction) (but may register an invalid transaction) nor include it in a new block to be recorded 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 transferred by referencing back to the UTXO of a previous transaction in the past sequence of transactions. The current state of all accounts is stored and constantly updated by nodes separate from the blockchain.
[0009] To make a blockchain network practical for multiple participants, end-user devices may operate client applications (sometimes called "wallets" or Simplified Payment Verification (SPV) software). Such client applications do not have the functionality of a full blockchain node and do not have a full copy of the blockchain. Through the client application, end-user devices can send requests to blockchain nodes for data that proves that a particular transaction exists on the blockchain, i.e., is included in a block, or has been "confirmed." It would be advantageous to have improved methods and apparatus for providing such data to enable end-user devices or other nodes to prove that a transaction is included in a block or to prove other functions of a block. [Brief explanation of the drawings]
[0010] By way of example, reference is made to the following accompanying drawings which illustrate exemplary embodiments of the present application:
[0011] [Figure 1] 1 illustrates an exemplary system for implementing a blockchain.
[0012] [Figure 2] 1 shows an example of a transaction protocol.
[0013] [Figure 3A] 1 illustrates an exemplary implementation of a client application.
[0014] [Figure 3B] 1 illustrates an exemplary user interface of a client application.
[0015] [Figure 4] An example of node software for a blockchain node is shown.
[0016] [Figure 5A] Here is an example of a Merkle tree:
[0017] [Figure 5B] Here is an example of a "partial" Merkle tree:
[0018] [Figure 6] Here is an example of a Merkle path:
[0019] [Figure 7] An example of how to validate blockchain data, in flowchart form.
[0020] Like reference numbers in the figures are used to denote like elements and features. DETAILED DESCRIPTION OF THE INVENTION
[0021] In one aspect, a computer-implemented method for determining validity of data in a blockchain may be provided, the method comprising: receiving from a remote node an index of transactions in a block and a set of ordered hashes for a Merkle proof; Starting at the bottom level of the Merkle tree, at each level of the Merkle tree until the top level is reached, selecting, in order, the provided hashes from the ordered set of hashes; concatenating the provided hash and the calculated hash of the current level in an order determined based on the index; hashing the concatenation to find the computed hash of the next level up; determining, from the index and each pair of the calculated hash and a corresponding hash from the set of ordered hashes, whether the transaction is the last transaction in the block; comparing the top-level computed hash with the Merkle root in the block's header; outputting the results of the comparing and determining steps; may include:
[0022] In some implementations, the received index may be a position index indicating the position of the transaction within a set of ordered transactions in the block. In some implementations, the method may further include, for each level above a lowest level, determining an index for that level based on the indexes of the levels below modulo 2.
[0023] In some implementations, determining that the transaction is the last transaction in the block may include determining that each calculated hash other than a top-level calculated hash is a right element in the Merkle tree.
[0024] In some implementations, determining that the transaction is the last transaction in the block may include determining that, for any computed hash that is a paired left element, the corresponding provided hash is equal to the computed hash.
[0025] In some implementations, determining whether the transaction is the last transaction in the block may include determining that the transaction is not the last transaction in the block based on determining that at least one calculated hash is a left-hand element and the corresponding provided hash is not equal to the at least one calculated hash.
[0026] In some implementations, based on determining that at least one computed hash is an element of the right side and the corresponding provided hash is equal to the at least one computed hash, stomach determining that the index is invalid.
[0027] In some implementations, the method may further include initially sending a request for Merkle proof data with an identifier of the transaction to the remote node. In some implementations, the receiving step includes receiving a message including a version field, an index field including the index, and a path field including a data structure including the set of ordered hashes.
[0028] In some implementations, the computed hash of the lowest level of the Merkle tree may be the transaction identifier for the transaction.
[0029] In some implementations, the order determined based on the index may include determining whether the calculated hash is the left element or the right element in a pair with the corresponding provided hash, and determining whether the calculated hash is the left element or the right element is based on determining whether the index at that level is even or odd based on the index modulo 2.
[0030] In some implementations, the ordered set of hashes includes syntax elements that signal duplicate hashes, instead of including duplicate hash values.
[0031] In another aspect, a computing device may be provided that implements a node in a blockchain, the computing device may include memory, one or more processors, and computer-executable instructions that, when executed, cause the processors to perform one or more of the methods described herein.
[0032] In yet another aspect, a computer-readable medium may be provided having processor-executable instructions stored thereon that, when executed by one or more processors, cause the processors to perform at least one of the methods described herein.
[0033] Other exemplary embodiments of the present disclosure will become apparent to those skilled in the art from a reading of the following detailed description in conjunction with the drawings.
[0034] As used herein, the term "and / or" is intended to cover all possible combinations and subcombinations of the listed elements, including the listed elements alone, any subcombination, or all of the elements, and does not necessarily exclude additional elements.
[0035] As used herein, the term "at least one of ... or ..." is intended to cover all possible combinations and subcombinations of the listed elements, including the listed elements alone, any subcombination, or all of the elements, and does not necessarily exclude additional elements, and does not necessarily require all elements.
[0036] <Example System Overview> 1 illustrates an exemplary system 100 for implementing a blockchain 150. The system 100 may include a packet-switched network 101, which is typically a wide-area internetwork such as the Internet. The packet-switched network 101 includes multiple blockchain nodes 104 that may be arranged to form a peer-to-peer (P2P) network 106 within the packet-switched network 101. Although not shown, the blockchain nodes 104 may be arranged as a nearly complete graph. Each blockchain node 104 is therefore highly coupled to other blockchain nodes 104.
[0037] Each blockchain node 104 includes a peer computing device, with different ones of the nodes 104 belonging to different peers. Each blockchain node 104 includes processing equipment implemented by one or more processors, e.g., one or more central processing units (CPUs), accelerator processors, application-specific processors, and / or other devices such as field programmable gate arrays (FPGAs) and application-specific integrated circuits (ASICs). Each node also includes memory, i.e., computer-readable storage in the form of a non-transitory computer-readable medium or media. Memory includes 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.
[0038] A blockchain 150 includes a chain of blocks of data 151, each copy of which is maintained at each of multiple nodes 104 in a distributed or blockchain network 160. As noted above, maintaining a copy of the blockchain 150 does not necessarily mean storing the entire blockchain 150. Instead, data can be removed from the blockchain 150 as long as each blockchain node 150 stores the block header (described below) for each block 151. Each block 151 in the chain includes one or more transactions 152, where a transaction in this context represents 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 uses one particular transaction protocol throughout. In one common type of transaction protocol, the data structure for each transaction 152 includes at least one input and at least one output. Each output specifies a quantity representing an amount of a digital asset as an asset. In this example, the output is cryptographically locked to user 103 (requiring that user's signature or other solution to unlock it and thereby redeem or spend it). Each input points to an output of a preceding transaction 152, thereby linking the transactions.
[0039] Each block 151 also contains a block pointer 155 that points back to a previously generated block 151 in the chain, defining a sequential order for the blocks 151. Each transaction 152 (other than a coinbase transaction) has a pointer to a previous transaction, defining an order for the sequence of transactions (Note: the sequence of transactions 152 is allowed to diverge). The chain of blocks 151 goes back to the 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 rather than to a preceding transaction.
[0040] Each blockchain node 104 is configured to forward transactions 152 to other blockchain nodes 104, thereby propagating the transactions 152 across the network 106. Each blockchain node 104 is configured to generate blocks 151 and store respective copies of the same blockchain 150 in its respective memory. Each blockchain node 104 also maintains an ordered set 154 of transactions 152 waiting to be incorporated into a block 151. The ordered set 154 is sometimes referred to as a "mempool." This term, as used herein, is not limited to any particular blockchain, protocol, or model. It represents an ordered set of transactions that the node 104 has accepted as valid and that the node 104 is obligated to not accept other transactions that attempt to use the same output.
[0041] For a given current transaction 152j, the inputs (or each of them) contain a pointer referencing 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, a previous transaction can be any transaction in the ordered set 154 or any block 151. A previous transaction 152i does not necessarily have to exist when the current transaction 152j was created or sent to the network 106, but a previous transaction 152i must exist and be validated for the current transaction to be valid. Thus, "preceding" herein 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 preclude transactions 152i, 152j from being created or transmitted 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.
[0042] The input of the current transaction 152j also includes an input authorization, e.g., 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 then be cryptographically locked to a new user or entity 103b. Thus, the current transaction 152j can transfer the amount defined in the input of the previous transaction 152i to the new user or entity 103b defined in the output of the current transaction 152j. In some cases, a transaction 152j may have multiple outputs to divide the input amount among multiple users or entities (one of which may be the original user or entity 103a to provide 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.
[0043] According to a Bitcoin-like output-based transaction protocol, when an entity 103, such as a user or a machine, wants to act on a new transaction 152j, it sends the new transaction from its computer terminal 102 to a recipient. The entity or recipient eventually sends this transaction to one or more blockchain nodes 104 of the network 106 (which today are typically servers or data centers, but in principle could also be other user terminals). In some instances, it is not excluded that the entity 103 acting on the new transaction 152j could send the transaction to one or more blockchain nodes 104 instead of to a recipient. The blockchain nodes 104 receiving the transaction check whether the transaction is valid according to a blockchain node protocol applied to each blockchain node 104. The blockchain node protocol typically requires the blockchain 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 case of such output-based transaction protocols, this may involve checking that a cryptographic signature or other authentication of entity 103 included in the input of new transaction 152j matches a condition defined in the output of the preceding transaction 152j that the new transaction assigns, which condition typically includes at least checking that the cryptographic signature or other authentication in the input of new transaction 152j unlocks the output of the preceding transaction 152i to which the input of the new transaction is linked. The condition may be defined at least in part by a script included in the output of the preceding transaction 152i, or may be simply fixed in the blockchain node protocol, or a combination thereof.In any case, if the new transaction 152j is valid, the blockchain node 104 forwards the new transaction to one or more other blockchain nodes 104 in the blockchain network 106. These other blockchain nodes 104, following the same node protocol and applying the same tests, forward the new transaction 152j to one or more further nodes 104, and so on. In this manner, the new transaction is propagated throughout the network of blockchain nodes 104.
[0044] In the output-based model, the definition of whether a given allocated output (e.g., UTXO) is allocated is whether it has already been validly redeemed by an input of another onward transaction 152j according to the blockchain node protocol. Another condition for a transaction to be valid is that the output of the preceding transaction 152i that it attempts to allocate or redeem has not yet been allocated / redeemed by another transaction. Again, if it is not valid, the transaction 152j is not propagated or recorded in the blockchain 150 (unless it is flagged as invalid and propagated to change). This prevents double-spending, where a transactor attempts to allocate the same transaction output multiple times. On the other hand, the account-based model prevents double-spending by maintaining account balances. Again, because of the defined order of transactions, the account balance has a single, defined state at a time.
[0045] In addition to validating transactions, blockchain nodes 104 also compete to be the first to create a block of transactions in a process called mining, which is underpinned by a "proof-of-work." Blockchain nodes 104 add new transactions to an ordered set 154 of valid transactions that have not yet appeared in a block 151 recorded in the blockchain 150. Blockchain nodes then compete to assemble a new valid block 151 of transactions 152 from the ordered set 154 of transactions by attempting to solve a cryptographic puzzle. This typically involves looking for a "nonce" value such that when the nonce is concatenated with a representation of the ordered set 154 of transactions and hashed, the hash output satisfies a predetermined condition. For example, the predetermined condition may be that the hash output has a predetermined number of leading zeros. Note that this is just one particular type of proof-of-work puzzle; other types are not excluded. A property of a hash function is that it has an unpredictable output given its input. Therefore, this search can only be performed by brute force and therefore consumes a significant amount of processing resources at each blockchain node 104 attempting to solve the puzzle.
[0046] A first blockchain node 104 that solves the puzzle notifies the network 106 and provides its solution as a proof. This solution can be easily checked by other blockchain nodes 104 in the network (given the solution to the hash, it is easy to verify that the hash output satisfies the conditions). The first blockchain node 104 propagates the block upon agreement of a threshold of other nodes to accept the block, thus enforcing the protocol rules. The ordered set of transactions 154 is then recorded by each of the blockchain nodes 104 as a new block 151 in the blockchain 150. The new block 151n is also assigned a block pointer 155, pointing to the previously created block 151n-1 in the chain. The significant amount of effort required to generate the proof-of-work solution, e.g., in the form of a hash, signals the first node 104's intention to follow the rules of the blockchain protocol. Such rules include not accepting a transaction as valid if it assigns the same output as a previously validated transaction, otherwise known as a double-spend. Once created, blocks 151 cannot be modified because they are known and maintained by each of the blockchain nodes 104 in the blockchain network 106. Block pointers 155 also impose an order on the blocks 151. As transactions 152 are recorded in ordered blocks at each blockchain node 104 in the network 106, this provides an immutable public ledger of transactions.
[0047] Note that different blockchain nodes 104 competing to solve the puzzle at any given time may be solving the puzzle based on different snapshots of the ordered set of unpublished transactions 154, depending on when they began searching for a solution or the order in which transactions were received. Whoever solves the puzzle first defines the transactions 152 to be included in the next new block 151n, in the order in which the current set of unpublished transactions 154 is updated. Blockchain nodes 104 then continue competing to produce blocks from the newly defined current ordered set of unpublished transactions 154. There is also a protocol for resolving potential "forks," which occur when two blockchain nodes 104 solve the puzzle within a very short time of each other, causing inconsistent views of the blockchain to propagate between the nodes 104. In essence, whenever a branch of a fork grows, the longest one becomes the final blockchain 150. Note that this does not affect users or agents of the network, since the same transactions appear in both branches.
[0048] According to the Bitcoin blockchain (and most other blockchains), a node that successfully constructs a new block 104 is granted the ability to allocate an approved amount of digital assets in a new special type of transaction that distributes a predetermined amount of digital assets (as opposed to an agent-to-agent or user-to-user transaction that transfers an amount of digital assets from one agent or user to another). This special type of transaction is typically called a "coinbase transaction," but may also be called an "initiation transaction." It typically forms the first transaction of a new block 151n. The proof-of-work signals that the node that constructed the new block intends to follow protocol rules so that this special transaction can later be redeemed. Blockchain protocol rules may require this special transaction to expire, e.g., 100 blocks, before it can be redeemed. Regular (non-producing) transactions 152 often specify an additional transaction fee in one of their outputs to further reward the blockchain node 104 that produced the block 151n in which the transaction was published. This fee is typically called a "transaction fee," and is described below.
[0049] Due to the resources involved in validating and publishing transactions, at least each of the blockchain nodes 104 typically takes the form of a server including one or more physical server units, or an entire data center. However, in principle, any given blockchain node 104 could take the form of a user terminal or a group of user terminals networked together.
[0050] The memory of each blockchain node 104 stores software configured to run on the processing unit of the blockchain node 104 to perform one or more respective roles and process transactions 152 in accordance with the blockchain node protocol. It will be understood that any operation attributed to a blockchain node 104 may be performed by software executing on the processing unit of each computing device. The node software may be implemented in one or more applications at the application layer, or at a lower layer such as the operating system layer or protocol layer, or any combination thereof.
[0051] Also connected to the network 101 are computing devices 102 for each of a plurality of parties 103 that act as consumer users. These users can interact with the blockchain network but do not participate in validating, composing, or propagating transactions and blocks. Some of these users or agents may act as senders and receivers in transactions. Other users may interact with the blockchain 150 without necessarily acting as senders or receivers. For example, some parties may act as storage entities that store copies of the blockchain 150 (e.g., have obtained a copy of the blockchain from a blockchain node 104).
[0052] Some or all of the parties 103 may be coupled as part of a different network, e.g., a network overlaid on the blockchain network 106. Users of the blockchain network (often called "clients") can be said to be part of the system that includes the blockchain network. However, these users are not blockchain nodes 104 because they do not perform the required role of a blockchain node. Instead, each party 103 may utilize the blockchain 150 by interacting with the blockchain network 106 and thereby coupling (i.e., communicating) with the blockchain nodes 106. Two parties 103 and their respective devices 102 are shown for illustrative purposes: a first party 103a and its respective computer device 102a, and a second party 103b and its respective computer device 102b. It will be understood that many more such parties 103 and their respective computer devices 102 can exist and participate in the system 100, but are not shown for convenience. 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, although it will be understood that this is not limiting and that references herein to Alice or Bob can be interchangeably referred to as "first party" and "second party," respectively.
[0053] Each party's 103 computing device 102 includes a respective processing unit that includes one or more processors, e.g., one or more CPUs, GPUs, other accelerator processors, application-specific processors, and / or FPGAs. Each party's 103 computing device 102 also includes memory, i.e., computer-readable storage in the form of a non-transitory computer-readable medium or media. This memory may include one or more memory units that use 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. The memory on each party's 103 computing device 102 stores software, such as a respective instance of at least one client application 105, configured to operate on the processing unit. It will be understood that any actions attributed to a party 103 given herein may be performed using software executing on the processing unit of each party's 102 computing device. Each party's 103 computing device 102 includes at least one user terminal, e.g., a desktop or laptop computer, a tablet, a smartphone, or a wearable device such as a smartwatch. The computing device 102 of a given party 103 may include one or more other networked resources, such as cloud computing resources, accessed via a user terminal.
[0054] 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, flash memory key, removable EEPROM, removable magnetic disk drive, magnetic floppy disk or tape, optical disk, for example a CD or DVD ROM, or removable optical drive.
[0055] The client application 105 includes at least a "wallet" functionality, which has two main functions. One of these is to allow each party 103 to create, authorize (e.g., sign), and send transactions 152 to be propagated throughout the network of blockchain nodes 104 and thereby included in the blockchain 150. The other is to report to each party the amount of digital assets it currently owns. In an output-based system, this second function involves reconciling the amounts defined among the outputs of various transactions 152 scattered throughout the blockchain 150 that belong to that party.
[0056] NOTE: While various client functions are sometimes described as being integrated into a given client application 105, it is understood that this is not necessarily limiting; instead, any client function described herein may be implemented in two or more different application suites, 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 thereof. While the following is described in terms of a client application 105, it is understood that this is not limiting.
[0057] An instance of a client application or software 105 on each computing device 102 is operably coupled to at least one of the blockchain nodes 104 of the network 106. This enables the wallet functionality of the client 105 to transmit transactions 152 to the network 106. The client 105 can also contact the blockchain nodes 104 to query the blockchain 150 for any transactions in which the respective party 103 is a recipient (or, in embodiments, actually inspect the transactions of other parties in the blockchain 150, since the blockchain 150 is a public facility that provides trust in transactions, in part, through its public visibility). The wallet functionality on each computing device 102 is configured to form and transmit transactions 152 according to a transaction protocol. As described above, each blockchain node 104 executes software configured to validate transactions 152 according to the blockchain node protocol and to forward transactions 152 for propagation throughout the blockchain network 106. Transaction protocols and node protocols correspond to each other, and a given transaction protocol, together with a given node protocol, implements a given transaction model. The same transaction protocol is used for all transactions 152 in the blockchain 150. The same node protocol is used for all nodes 104 in the network 106.
[0058] When a given party 103, such as Alice, wishes to submit 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 associated transaction protocol. She then sends the transaction 152 from her client application 105 to one or more blockchain nodes 104 to which she is connected. For example, this may be the blockchain node 104 with the best connection to Alice's computer 102. When any given blockchain node 104 receives the new transaction 152j, it processes it according to the blockchain node protocol and its respective role. This may include first checking whether the newly received transaction 152j meets certain conditions for being "valid," examples of which will be detailed shortly. In some transaction protocols, the conditions for validation may be configurable on a per-transaction basis via 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.
[0059] Provided that the newly received transaction 152j passes the tests to be considered valid (i.e., is "validated"), any blockchain node 104 that receives the transaction 152j adds the new validated transaction 152 to the ordered set 154 of the blockchain maintained by that blockchain node 104. Additionally, any blockchain node 104 that receives the transaction 152j propagates the validated transaction 152 to one or more other blockchain nodes 104 in the network 106. Because each blockchain node 104 applies the same protocol, assuming the transaction 152j is valid, this means that it will soon propagate throughout the network 106.
[0060] Once placed in the ordered set of transactions 154 maintained at a given blockchain node 104, the blockchain nodes 104 begin competing to solve a proof-of-work puzzle for the latest version of their respective ordered sets of transactions, including the new transaction 152. (Note that other blockchain nodes 104 attempt to solve the puzzle based on different ordered sets of transactions 154, but whoever comes first defines the ordered set of transactions included in the latest block 151.) Eventually, the blockchain nodes 104 solve the puzzle for the part of the ordered set 154 that includes Alice's transaction 152j. Once proof-of-work has been done for the ordered set 154 that includes the new transaction 152j, it becomes part of one of the blocks 151 in the blockchain 150 in an immutable manner. Because each transaction 152 includes a pointer to the previous transaction, the order of the transactions is also immutably recorded.
[0061] Different blockchain nodes 104 may initially receive different instances of a given transaction and may therefore have conflicting views of which instances are "valid" before one instance is published into a new block 151, at which point all blockchain nodes 104 agree that only the published instance is the valid instance. If a blockchain 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 instance it originally accepted (i.e., the one not yet published in a block 151).
[0062] As part of the account-based transaction model, another type of transaction protocol operated by some blockchain networks is sometimes called an "account-based" protocol. In an account-based model, each transaction transfers by referencing an absolute account balance, rather than defining the amount transferred by referencing back to the UTXO of a previous transaction in a series of past transactions. The current state of every account is stored and constantly updated by the network's nodes, separate from the blockchain. In such a system, transactions are ordered using an account's sequential transaction record (the so-called "position"). This value is signed by the sender as part of their cryptographic signature and hashed as part of the transaction reference calculation. Additionally, an optional data field can also sign a transaction. This data field may point back to a previous transaction, for example, if a previous transaction ID is included in the data field.
[0063] <UTXOベースのモデル> 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 intended to be limiting to all possible implementations. Note that the exemplary UTXO-based protocol is described with reference to Bitcoin, but could equally be implemented on other exemplary blockchain networks.
[0064] In a UTXO-based model, each transaction (“Tx”) 152 is 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). A UTXO includes a value that specifies an amount of a digital asset, which represents a set number of tokens on a distributed ledger. Among other information, a UTXO may also include the transaction ID of the transaction from which it originated. The transaction data structure may also include a header 201, which may include indicators of the sizes of the input and output fields 202 and 203. The header 201 may also include the transaction's ID. In some embodiments, the transaction ID is a hash of the transaction data (excluding the transaction ID itself) and is stored in the header 201 of an unprocessed transaction 152 submitted to a node 104.
[0065] For example, suppose Alice 103a wants to create transaction 152j to transfer the amount of the digital asset in question to Bob 103b. In Figure 2, Alice's new transaction 152j is labeled "Tx1." It takes the amount of the digital asset locked to Alice and transfers at least a portion of it to Bob in the output 203 of the previous transaction 152i in the sequence. The previous transaction 152i is labeled "Tx0" in Figure 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 previous (i.e., ancestor) transaction that still has an unspent output 203 locked to Alice.
[0066] The preceding transaction Tx0 may already be validated and included in a block 151 of the blockchain 150 when Alice creates her new transaction Tx1, or at least when she submits it to the network 106. It may already be included in one of the blocks 151 at that time, or it may still be waiting in the ordered set 154, in which case it will be included in the new block 151 immediately. Alternatively, Tx0 and Tx1 may be generated and submitted to the network 106, or Tx0 may be submitted after Tx1 if the node protocol allows for buffering of "orphan" transactions. The terms "preceding" and "following" used herein in the context of a sequence of transactions refer to the order of transactions in a sequence defined by transaction pointers specified within the transaction (e.g., which transactions point to which other transactions). They may be equivalently replaced by "preceding" and "successor," or "ancestor" and "descendant," "parent" and "child," etc. This does not necessarily imply the order in which they are created, sent to the network 106, or arrive at any given blockchain node 104. Nevertheless, a subsequent transaction (a descendant transaction or "child") that points to a preceding transaction (an ancestor transaction or "parent") is not validated unless the parent transaction is validated. A child that arrives at a blockchain 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 node behavior.
[0067] One of the one or more outputs 203 of the preceding transaction Tx0 is a particular UTXO, labeled herein as UTXO0. Each UTXO includes a value specifying 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 subsequent transaction for the subsequent transaction to be validated, and therefore 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 subsequent transaction includes the cryptographic signature of the party to whom the preceding transaction was locked.
[0068] 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" (capital S) used by blockchain networks. A lock script specifies the information needed to consume a transaction output 203, e.g., requirements for Alice's signature. An unlock script appears in the transaction 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 input 202.
[0069] In the example shown, UTXO0 of output 203 of Tx0 is A ], which means that Alice's signature SigP must be present for UTXO0 to be redeemed (or, more precisely, for any subsequent transaction that attempts to redeem UTXO0 to be valid). A [Checksig P A] is the public key P from Alice's public-private key pair. A , a representation (i.e., a hash) of Tx1's input 202. Tx1's input 202 includes a pointer to Tx1 (e.g., by its transaction ID, TxID0, which in an embodiment is a hash of the entire transaction Tx0). Tx1's input 202 includes an index that identifies UTXO0 within Tx0, in order to distinguish it among any other possible outputs of Tx0. Tx1's input 202 also includes an unlock script that contains Alice's cryptographic signature, created by Alice applying her private key from her key pair to a predetermined portion of data (sometimes called a "message" in cryptography). <SigP A The data (or "message") that Alice needs to sign to provide a valid signature may be defined by the lock script, or by the node protocol, or a combination of these.
[0070] When a new transaction Tx1 arrives at a blockchain node 104, the node applies the node protocol, which may involve running the lock script and the unlock script together to check whether the unlock script meets the conditions defined in the lock script (which may include one or more criteria). In an embodiment, this involves concatenating the two scripts. <SigP A > <P A > || [Checksig P A ]
[0071] where '||' denotes concatenation, '<...>' means placing data on a stack, and '[...]' is the function to be executed by the lock script (in this example, a stack-based language). Equivalently, the scripts may be executed one by one on a common stack rather than concatenating them. Either way, when executed together, the scripts will use Alice's public key P, which is included in the lock script in the output of Tx0. Ais used to authenticate that the unlock script in Tx1's input contains Alice's signature, which signs the expected portion of the data. The expected portion of the data ("message") must also be included to perform this authentication. In an embodiment, the signed data includes the entirety of Tx1 (thus, there is no need to include a separate element specifying the signed portion of the data in plaintext, since the signed portion of the data is already inherently present).
[0072] The details of authentication using public-private cryptography will be well known to those skilled in the art. Essentially, if Alice signs a message using her private key, then another entity, such as node 104, given Alice's public key and the message in plaintext, can authenticate that the message must have been signed by Alice. Signing typically involves hashing the message, signing the hash, and tagging the message as the signature, thereby allowing the owner of the public key to authenticate the signature. Thus, it should be noted that, in this specification, references to signing a particular portion of data, part of a transaction, etc., can, in embodiments, mean signing a hash of that portion of data or part of a transaction.
[0073] 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 blockchain node 104 considers Tx1 valid. This means that the blockchain node 104 adds Tx1 to its ordered set of transactions 154. The blockchain node 104 forwards transaction Tx1 to one or more other blockchain nodes 104 in the network 106, thereby broadcasting it throughout the network 106. Once Tx1 is validated and included in the blockchain 150, it is defined as having consumed UTXO0 from Tx0. Note that Tx1 is only valid if it uses unspent transaction outputs 203. If it attempts to consume outputs that have already been consumed by another transaction 152, Tx1 becomes invalid, even if all other conditions are met. Therefore, blockchain node 104 also needs to check whether the UTXO referenced in the preceding transaction Tx0 has already been spent (whether it already forms a valid input to another valid transaction). This is one reason why it is important for blockchain 150 to impose a defined order on transactions 152. In practice, a given blockchain 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.
[0074] If the total amount specified in all outputs 203 of a given transaction 152 is greater than the total amount pointed to by all its inputs 202, this is another basis for invalidity in most transaction models. Therefore, such a transaction is not propagated and is not included in block 151.
[0075] Note that in the UTXO-based transaction model, a given UTXO must be spent in its entirety; it is not possible to "leave" some of the amount defined in the UTXO while another amount is spent. However, amounts from a UTXO can be split among multiple outputs of subsequent transactions. For example, the amount defined in UTXO0 of Tx0 can be split among 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.
[0076] Notably, Alice must also typically include a fee for the Bitcoin node 104 that publishes her transaction. If Alice does not include a fee for the miner, Tx0 will likely be rejected by the miner's blockchain node 104, and thus, while technically valid, it will still not be propagated and included in the blockchain 150 (the node protocol does not force blockchain nodes 104 to accept the transaction 152 if they do not want to). In some protocols, the transaction 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 indicated by the input 202 and the total amount specified in the output 203 of a given transaction 152 is automatically given to the blockchain node 104 that publishes the transaction. For example, suppose 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 may be allocated by the node 104 that publishes the block containing UTXO1. However, nothing necessarily precludes that a transaction fee may alternatively or additionally be explicitly specified in a unique one of the UTXOs 203 of transaction 152.
[0077] Alice and Bob's digital assets consist of the UTXOs locked to them in any transaction 152 in the blockchain 150. Thus, typically, a given party 103's assets are dispersed across the UTXOs of various transactions 152 throughout the blockchain 150. No single number is stored anywhere in the blockchain 150 that defines a given party's 103 total balance. It is the role of the wallet function in the client application 105 to compile 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 on one of the Bitcoin nodes 104.
[0078] Note that script code is often expressed generally (i.e., without using a precise language). For example, an operation code (opcode) may be used to represent a specific function. "OP_...." represents a specific opcode in a scripting language. As an example, OP_RETURN, when preceded by OP_FALSE at the beginning of a lock script, is an opcode in a scripting language to generate an unspent output of a transaction that can store data within the transaction, thereby immutably recording the data in the blockchain 150. For example, the data may include a document that is desired to be stored in the blockchain.
[0079] Typically, the input to a transaction is a public key P AIn embodiments, this is based on ECDSA using the elliptic curve secp256k1. The digital signature signs specific data. In some embodiments, for a given transaction, the signature signs some of the transaction inputs and all or some of the transaction outputs. The specific portion of the outputs to sign depends on the SIGHASH flag, which is a four-byte code typically included at the end of the signature that selects which outputs are signed (and is therefore fixed at the time of signing).
[0080] A lock script is sometimes referred to as a "scriptPubKey," indicating that each transaction typically includes the public key of the party being locked. An unlock script is sometimes referred to as a "scriptSig," indicating that it typically provides the corresponding signature. However, more generally, it is not required in all applications of blockchain 150 that the conditions for redeeming a UTXO include authenticating a signature. More generally, a scripting language may be used to define one or more conditions. Therefore, the more general terms "lock script" and "unlock script" are preferred.
[0081] As shown in FIG. 1, the client applications on each of Alice's and Bob's computing devices 102a, 102b may include additional communication capabilities. This additional functionality allows Alice 103a to establish a separate side channel 301 with Bob 103b (at the invitation of either party or a third party). The side channel 301 allows for the exchange of data separately from the blockchain network. Such communication is sometimes referred to as “off-chain” communication. For example, it may be used to exchange transactions 152 between Alice and Bob without them being registered on the blockchain network 106 or progressing on the chain 150 until one of the parties chooses to broadcast the transactions 152 to the network 106. Sharing transactions in this manner is sometimes referred to as sharing a “transaction template.” The transaction template may lack one or more inputs and / or outputs necessary to form a complete transaction. Alternatively or additionally, the side channel 301 may be used to exchange any other transaction-related data, such as keys, negotiated amounts or terms, data content, etc.
[0082] The side channel 301 may be established over the same packet-switched network 101 as the blockchain network 106. Alternatively or additionally, the side channel 301 may be established over a different network, such as a local area network, such as a mobile cellular network or a local wireless network, or a direct wired or wireless link between Alice and Bob's devices 102a, 102b. In general, the side channel 301 referred to anywhere herein may include any one or more links via one or more networking technologies or communication media for exchanging data "off-chain," i.e., separately from the blockchain network 106. When more than one link is used, the bundle or collection of off-chain links as a whole may be referred to as the side channel 301. Thus, it should be noted that when Alice and Bob are said to exchange particular information, pieces of data, etc., over the side channel 301, this does not necessarily mean that all of these pieces of data need to be transmitted over the exact same link or the same type of network.
[0083] <Client software> 3A illustrates an example implementation of a client application 105 for implementing embodiments of the disclosed techniques. The client application 105 may include a transaction engine 401 and a user interface (UI) layer 402. The transaction engine 401 is configured in accordance with the processes described above to perform the underlying transaction-related functions of the client 105, such as forming transactions 152, receiving and / or sending transaction and / or other data via side channels 301, and / or sending transactions to one or more nodes 104 for propagation through the blockchain network 106.
[0084] The UI layer 402 is configured to render a user interface via user input / output (I / O) means of each user computing device 102, including outputting information to each user 103 by user output means of the device 102 and receiving input from each user 103 by user input means of the device 102. For example, the user output means may include one or more display screens (touch or non-touch screen) to provide visual output, one or more speakers to provide audio output, and / or one or more tactile output devices to provide tactile output, etc. The user input means may include, for example, one or more touchscreen input arrays (the same or different from those used for the output means), one or more cursor-based devices such as a mouse, trackpad, or trackball, one or more microphones and voice recognition algorithms for receiving voice or speech input, one or more gesture-based input devices for receiving input in the form of manual or physical gestures, or one or more mechanical buttons, switches, joysticks, etc.
[0085] It should be noted that while various functions herein may be described as being integrated into the same client application 105, this is not necessarily limiting and may instead be implemented in two or more separate applications, e.g., one plugging into the other or interfacing via an API (application programming interface). For example, the functionality of the transaction engine 401 may be implemented in an application separate from the UI layer 402, or in the functionality of a given module, or the transaction engine 401 may be split among more than one application. Also, it does not exclude some or all of the described functionality being implemented, for example, in the operating system layer. When reference is made elsewhere in this specification to a single or given application 105, it is understood that this is merely by way of example and, more generally, that the described functionality may be implemented in any form of software.
[0086] 3B provides a simulated representation of an example user interface (UI) 500 that may be rendered by the UI layer 402 of the client application 105a on Alice's device 102a. It is understood that a similar UI may be rendered by the client 105b on Bob's device 102b, or any other party's device.
[0087] 3B illustrates UI 500 from Alice's perspective. UI 500 includes one or more UI elements 501, 502, 502 that are rendered as separate UI elements via user output means.
[0088] For example, the UI elements may include one or more user-selectable elements 501, such as different buttons on a screen or different options in a menu. The user input means is configured to allow the user 103 (in this case Alice 103a) to select or operate one of the options by clicking or touching the UI elements on the screen or by speaking the name of the desired option (note: "manual" as used herein simply means the opposite of automatic and is not necessarily limited to the use of hands).
[0089] Alternatively or additionally, the UI elements may include one or more data entry fields 502. These data entry fields 502 may be rendered via a user output means, e.g., on-screen, and data may be entered into the fields via a user input means, e.g., a keyboard or touch screen. Alternatively, data may be received orally, e.g., based on voice recognition.
[0090] Alternatively or additionally, the UI elements may include one or more information elements 503 that are output to output information to the user. For example, the information may be drawn on a screen or rendered audibly.
[0091] For example, this / these may be rendered on the screen or audibly rendered. The functionality of these UI elements will be discussed in more detail shortly. It is also understood that the UI 500 shown in FIG. 3B is merely a schematic mockup and may, in reality, include one or more additional UI elements, which are not shown for the sake of brevity.
[0092] <Node software> FIG. 4 illustrates example node software 450 that may be executed by each blockchain node 104 of the network 106 in the example UTXO or output-based model. Note that another entity may execute the node software 450 without being classified as a node 104 on the network 106, i.e., without performing the actions required of a node 104. The node software 450 may include, but is not limited to, a protocol engine 451, a scripting engine 452, a stack 453, an application-level decision engine 454, and a set of one or more blockchain-related function modules 455. Each node 104 may execute node software including, but not limited to, all three of the following: an agreement module 455C (e.g., proof-of-work), a propagation module 455P, and a storage module 455S (e.g., a database). The protocol engine 451 is typically configured to recognize different fields of a transaction 152 and process them according to the node protocol. Transaction 152j (Tx j ) is received, and another preceding transaction 152i (Tx m-1 ), the protocol engine 451 executes Tx j The protocol engine 451 then identifies the unlock script in the Tx j Based on the pointer in the input of Tx i Identify and search for Tx imay be published on the blockchain 150. In this case, the protocol engine can obtain Txi from a copy of block 151 of the blockchain 150 stored in the node 104. Alternatively, Tx i may not yet be published on the blockchain 150. In that case, the protocol engine 451 selects Tx from the ordered set of unpublished transactions 154 held by the node 154. i In either case, the script engine 451 can obtain Tx j , identifies the lock script in the referenced output, and passes it to the script engine 452.
[0093] The script engine 452 therefore i Lock script and Tx j 2, but the same can be applied to any pair of transactions. The script engine 452 executes the two scripts together as described above, which includes placing data on the stack 453 and retrieving data according to the stack-based scripting language (e.g., Script) being used.
[0094] By executing the scripts together, script engine 452 determines whether the unlock script meets one or more criteria defined in the lock script, i.e., whether it "unlocks" the output that the lock script is contained in. Script engine 452 returns the result of this determination to protocol engine 451. If script engine 452 determines that the unlock script meets one or more criteria specified in the corresponding lock script, it returns the result "true." Otherwise, it returns the result "false."
[0095] In the output-based model, a "true" result from the script engine 452 is one of the conditions for the validity of the transaction. Typically, there are one or more additional protocol-level conditions evaluated by the protocol engine 451 that must also be satisfied, and Tx j the total amount of digital assets specified in the output of Tx does not exceed the total amount pointed to by its input; i The output pointed to by the transaction Tx has not yet been consumed by another valid transaction, etc. The protocol engine 451 evaluates the result from the script engine 452 together with one or more protocol-level conditions, and if all of them are true, the transaction Tx j The protocol engine 451 outputs an indication of whether the transaction is valid to the application level decision engine 454. Tx j Only if the decision engine 454 determines that the transaction has been validated, the decision engine 454 may then trigger one or both of the agreement module 455C and the propagation module 455P to perform their respective blockchain-related functions as Tx j , which may choose to control the execution of Tx in each of the nodes' ordered transaction sets 154 for incorporation into block 151. j and a consensus module 455C that adds Tx to another blockchain node 104 in the network 106. j Optionally, in embodiments, the application-level decision engine 454 may apply one or more additional conditions before triggering either or both of these functions. For example, the decision engine may choose to publish a transaction only conditional on both the transaction being validated and having sufficient transaction fees remaining.
[0096] It is noted that the terms "true" and "false" herein are not necessarily limited to returning a result expressed in the form of only a single binary digit (bit), although that is certainly one possible implementation. More generally, "true" can represent any state that indicates a successful or positive outcome, and "false" can represent any state that indicates an unsuccessful or non-positive outcome. For example, in an account-based model, a "true" outcome may be indicated by a combination of an implicit protocol-level validation of a signature and an additional positive output of a smart contract (the overall outcome is considered to convey true if both individual outcomes are true).
[0097] Other variations or uses of the disclosed technology may become apparent to those skilled in the art after reading the disclosure herein. The scope of the present disclosure is not limited by the described embodiments, but only by the appended claims.
[0098] For example, some embodiments described above have been described in terms of the Bitcoin network 106, the Bitcoin blockchain 150, and the Bitcoin nodes 104. However, it is understood that the Bitcoin blockchain is one particular example of a blockchain 150, and the above description may apply generally to any blockchain. That is, the present invention is in no way limited to the Bitcoin blockchain. More generally, references to the Bitcoin network 106, the Bitcoin blockchain 150, and the Bitcoin nodes 104 above may be replaced with the blockchain network 106, the blockchain 150, and the blockchain nodes 104, respectively. The blockchain, blockchain network, and / or blockchain nodes may share some or all of the above-described characteristics of the Bitcoin blockchain 150, the Bitcoin network 106, and the Bitcoin nodes 104.
[0099] In some embodiments of the present invention, the blockchain network 106 is the Bitcoin network, and the Bitcoin nodes 104 perform at least all of the above-described functions of generating, publishing, propagating, and storing blocks 151 in the blockchain 150. It is not excluded that there are other network entities (or network elements) that perform only one or some, but not all, of these functions. That is, a network entity may perform the functions of propagating and / or storing blocks, but may not generate and publish blocks (recall that these entities are not considered to be suitable Bitcoin network 106 nodes).
[0100] In some other embodiments of the present invention, blockchain network 106 may not be the Bitcoin network. In these embodiments, it is not excluded that a node may perform at least one or some, but not all, of the functions of generating, publishing, propagating, and storing blocks 151 of blockchain 150. For example, in these other blockchain networks, "node" may be used to refer to a network entity that is configured to generate and publish blocks 151 but does not store and / or propagate the blocks 151 to other nodes.
[0101] More generally, references above to the term "Bitcoin node" 104 may be replaced with the term "network entity" or "network element." Such entities / elements are configured to perform some or all of the roles of generating, publishing, propagating, and storing blocks. The functionality of such network entities / elements may be implemented in hardware in the same manner as described above with reference to blockchain nodes 104.
[0102] <Merkleプルーフ> As mentioned above, mining nodes group transactions into blocks. The payload of a block contains an ordered set of transactions, including the coinbase transaction. Each block has a block header that contains various data fields, including the Merkle root. The Merkle root may be thought of as a summary or "fingerprint" of the data in the payload, i.e., the ordered set of transactions. The Merkle root is determined by constructing a Merkle tree.
[0103] A Merkle tree for an ordered set of elements is constructed by hashing each element, concatenating pairs of adjacent hashed elements, and recursively creating the next layer by hashing the concatenated hashed elements. A simple example of a Merkle tree 500 is shown in Figure 5A.
[0104] In this example, for ease of explanation, Merkle tree 500 is associated with an ordered set of only eight elements. Merkle trees in other examples may be smaller or, more typically, much larger. The layers of Merkle tree 500 are labeled from bottom to top, with layer 0 being the base layer and layer 3 being the Merkle root 502 in this example. Merkle tree 500 is formed by first creating a base layer by hashing the elements. That is, each base layer node 504 is the hash of the corresponding element at that position. In the case of Bitcoin, each base layer node 504 is the hash (double-SHA256, in the case of Bitcoin) of the corresponding transaction. The double-SHA256 hash of a transaction is also its transaction identifier, TXID. Thus, in the case of Bitcoin, each base layer node 504 is the TXID corresponding to the transaction at that position in the ordered set of transactions in the block.
[0105] To construct the layer 1 nodes of the Merkle tree 500, base layer nodes are grouped into pairs. Within each pair, the elements are concatenated and then hashed to find the value of the parent node in the layer above. For example, if base layer pair 506 contains TxID2 and TxID3, the two TxIDs are concatenated as TxID2||TxID3, resulting in raw The resulting value is hashed to calculate element 508.
[0106] Layer 2 elements are computed as the hash of the concatenated pair of layer 1 elements, and so on. For example, element 512 is computed from the hash of the concatenated pair of element 510 and element 508. Building layers by computing intermediate hashes of nodes in the intermediate layers of Merkle tree 500 continues until we reach a single element in the top layer, called the Merkle root 502.
[0107] Every block is exactly 2 n It is understood that not all layers have the complete set of transactions containing this number of elements. In such cases, we may end up with a "partial" Merkle tree. Figure 5B shows an example where there are five elements in layer 0 (e.g., five transactions in a block). First Although the four elements can be paired, the last transaction, denoted by reference numeral 520, does not have a corresponding pair element. It is understood that a missing pair element in the base layer occurs only if the last element is the left member of the pair. To construct a Merkle tree in this situation, a "copy" of the left element is used as the right element. That is, TxID4, denoted by reference numeral 520, is concatenated with itself and hashed to find the value of the parent element of node 522. Similarly, because node 522 does not have a corresponding right element in its pair, the element of node 522 is concatenated with itself and hashed to find the value of the parent element of node 524 in layer 2.
[0108] The Merkle root 502 is inserted into the header of a block to act as a fingerprint for the transactions within the block.
[0109] Merkle trees help enable lightweight nodes, such as client applications on end-user devices, to determine whether a particular transaction exists in a block on a blockchain without having to download the entire block or the entire blockchain. The client application can determine whether a transaction exists in a block based on a Merkle proof, which traces a path from the transaction through the Merkle tree to a Merkle root, verifying that the transaction is included in the block.
[0110] A node can request data related to a transaction for which it can perform a Merkle proof. In one example, the requested data may be provided in the form of an ordered set of hashes corresponding to paired hashes in the Merkle tree required along the path to reach the Merkle root, along with a binary signal indicating whether the computed and / or provided hash is the left or right element of each pair.
[0111] For the purposes of this discussion, the following notation can be used: An element that is computed using a hash of available data (e.g., transaction data, or a connected element of a Merkle tree) can be denoted using c[n], where n represents the layer of the tree, with the lowest or base layer being at n=0. An element of the tree that is provided by another node for the purposes of a Merkle proof, e.g., an intermediate hash, can be denoted using p[n].
[0112] Figure 6 shows an example of a Merkle path through a Merkle tree 600. The Merkle path in this case is related to validating the existence of transaction Tx in a block. To achieve a Merkle proof using this Merkle path, a computing device has transaction Tx (or at least TxID) and a set of ordered hashes (intermediate hashes) corresponding to the elements needed to form pairs along the Merkle path. In this example, the ordered set includes p[0], p[1], and p[2].
[0113] The computing device also needs a mechanism to determine whether the provided intermediate hash is the left or right element of the pairing. This can possibly be signaled using a binary flag. The binary flag may indicate, for each layer, whether the computed hash (or provided hash) is the left or right element. In some cases, instead of signaling whether the computed hash (or provided hash) at each layer is the left or right element, the position of the computed hash at the lowest or base layer, i.e., its index within the set of ordered elements, may be signaled. In some implementations, these may be substantially equivalent. For example, bitwise signaling of the left (0) or right (1) path tracing the computed element of layers 2 to 0 traveling down the Merkle path from the Merkle root 602 results in bits [0,1,0]. Similarly, the index i=2 of the c[0] element may be signaled, which is 010 in binary. Other implementations may use different signaling or coding.
[0114] To perform a Merkle proof, a computing device determines the c[0] element by hashing transaction Tx (in this example, double-SHA256) to obtain the TxID. In some cases, it may already have the TxID. It then concatenates it with the first provided hash of the ordered set of hashes, p[0]. The computing device determines from the index i or bit signaling whether the computed hash c[0] is a left or right element and concatenates accordingly. It then hashes the concatenation to determine c[1]. It continues this process until it determines c[3], which it compares with the Merkle root 602 found in the block header. If there is a match, the computing device determines that transaction Tx is included in the block. If there is no match, transaction Tx is not included in the block (or the provided Merkle path hash contains an error).
[0115] The position of an element within the set of ordered elements in a layer is called its "index" and is sometimes denoted by i or indexOf(c[n]) when referring to the calculated index of the element in the nth layer. In the lowest or base layer, the index i ranges from 0 to one less than the number of transactions in the block.
[0116] In one aspect, the present application discloses a data structure for signaling Merkle proof data that advantageously includes an index position field, which facilitates determining the left / right position of each computational element rather than a top-down tracing of a path based on a bit vector. In another aspect, the present application provides at least one extended validity check within the Merkle proof process. In some cases, the extended validity check allows for verification of the number of transactions in a block and / or proof of the validity of an index.
[0117] Using a position index as a mechanism for determining the left or right position of a computed element along a Merkle path, a simple modulus calculation can be used to determine the left / right side. The "mod2" operation effectively produces a result that signals whether the value is even or odd. For example, the expression "indexOf(c[n])mod2" produces a 0 for even values of indexOf(c[n]) and a 1 for odd values of indexOf(c[n]). The value of indexOf(c[n]) can then be divided by 2 to determine the index value of the computed element in the layer above, i.e., indexOf(c[n+1]). Implementations can use a floor function when dividing by 2 to drop the remainder when performing division operations with floating-point numbers.
[0118] One extended validity check that can be enabled using positional indexing is if the index indicates that one of the computed elements is an element to the right, e.g., indexOf(c[n])mod2==1. case , the corresponding left-side element p[n] cannot be equal to c[n], or the position index is likely to be incorrect. Such a situation may result in a valid Merkle root computation despite an incorrect position index. For example, if the appropriate position index points to a left-side element at the end of the transaction list, but the position index points to an element that was incorrectly copied to the right, the Merkle root computation may be correct even though the index value is incorrect.
[0119] A further extended validity check potentially enabled by using a position index is the ability to identify the last transaction in a block. A computing device may or may not know the total number of transactions in a block. Because the number of transactions is a field in the block but not necessarily in the block header, a computing device may not have such information. Regardless of whether it has that information, a computing device may be able to validate that a transaction is indeed the last transaction in the block by finding that the corresponding provided hash p[n] is equal to c[n] if the computed value is all right-hand elements at all layers of the Merkle tree, or if the computed value c[n] is a left-hand element at any layer. By validating that the transaction is the last of the ordered set, i.e., the last transaction in the block, the computing device thereby determines (or validates, if it already has that information) the number of transactions in the block.
[0120] It is understood that in some data structure implementations, rather than providing p[n] that is a copy of c[n] in the set of ordered hashes, the providing node may signal that c[n] should be a copy of that layer. A particular code, signal, flag, or other syntax element may be used to signal that a copy of c[n] should be used instead of the provided hash.
[0121] An example data structure for sending Merkle proof data is shown below:
number
[0122] In the above example, the position index of c[0] within the lowest layer of the Merkle tree is provided in the index field. The version field can be used to signal various options. For example, the original transaction may or may not be signaled, the Merkle root may or may not be included, the block header may or may not be included, etc. The version field signals which combination of features are included. Exemplary versions include, but are not limited to:
number
[0123] The path field contains an ordered set of the provided hashes. In some instances, the path data structure is the complete set of the provided hashes, and in some instances, it contains enough information that can be expanded or decoded to produce the complete set of provided hashes. The inclusion of the original TxID (e.g., c[0]) and Merkle root is determined based on the version code.
[0124] In some instances, if p[n] is a copy of c[n], p[n] may not be included in the path data structure and may be replaced with a syntax element to signal that p[n] is a copy. For example, in JSON, the special string '*' may be used to signal a copy.
[0125] The duplicated_indexes and duplicated_indexes_count fields may or may not be included. If included, the number of copied p[n] elements and the layer n at which they occur may be signaled using these fields. It is understood that when this mechanism for signaling copied p[n] elements is used, the path field does not include any hash or syntax elements signaling copying for those layers.
[0126] FIG. 7 illustrates, in flowchart form, a simplified example method 700 for determining whether a transaction is included in a block. Method 700 may be implemented by a networked computing device, which may be a blockchain node or an end-user device, using, for example, a client application. Method 700 may be embodied by processor-executable instructions. When executed by a processor, the processor-executable instructions cause the processor to perform the described operations. The operations may include memory access functions, signal or data transmission and reception functions, display operations, and other operations associated with components coupled to the processor. The instructions may be embodied in one or more software modules, applications, routines, etc.
[0127] Method 700 may begin, in some cases, as indicated by operation 702, by a computing device issuing a request to a remote node. The remote node may be a blockchain node or an end user device. For example, the computing device may be a first end user device and the remote node may be a second end user device, both engaged in negotiating or finalizing a transaction. The request relates to confirming that a particular transaction, Tx, is included in a block on the blockchain. In some examples, the request may be sent to multiple remote nodes. The request may include a copy of Tx or a unique identifier for Tx (e.g., TxID).
[0128] In response to the request, at operation 704, the computing device may receive a response message including at least a location index and path data associated with Tx within the particular block. The path data may include an ordered set of hashes. The ordered set of hashes may include provided hashes for performing a Merkle proof for Tx within the Merkle tree of the particular block.
[0129] In operation 706, the computing device starts at the bottom level of the Merkle tree, recursively computes computed elements, identifies corresponding provided elements in the set of ordered hashes, concatenates them according to index, and hashes them to find the parent computed element. The computing device builds a Merkle path until it reaches the Merkle root. The computing device may know that it has reached the Merkle root based on knowing the number of levels in the Merkle tree, or it may be able to infer the number of levels in the Merkle tree from the fact that there are no more hashes in the set of ordered hashes.
[0130] In operation 708, the computing device determines whether the transaction is the last transaction in the block from the index and the pair of the calculated hash and the corresponding provided hash. If the index indicates that the calculated element is a right-hand element at all levels except the Merkle root, the computing device can identify the transaction as the last transaction in the block based on the index. This situation occurs when the Merkle tree is "complete," i.e., there are exactly two elements in the base layer. n elements, and this occurs only if the transaction is the rightmost element. In the case of a "partial" (e.g., non-full) Merkle tree, the computing device can further identify that a transaction is the last transaction in a block whenever the computed element is the left member of a pair of which the corresponding provided right member p[n] is a copy. That is, c[n] = p[n] for all n where indexOf(c[n]) = 0.
[0131] Although operation 708 is shown separately for ease of discussion, it will be understood that it can be performed simultaneously with operation 706 when the Merkle path is constructed.
[0132] At operation 710, the computing device may determine whether an error is detected. One error may be a determination that the computed Merkle root does not match the Merkle root in the block header. Another error may be the detection of a case where the computed element is the right-hand element and the hash provided in the left-hand position of the pair is a copy of the computed element. In either case, at operation 712, the computing device outputs an error notification. The error notification may indicate the nature of the detected error: a mismatched Merkle root or a left-hand side copy error. Otherwise, the computing device outputs a success notification at operation 714, confirming that the Merkle proof is valid and that transaction Tx is included in the block at the specified position index. The success notification may further indicate whether Tx was determined to be the last Tx in the block, and if so, the total number of transactions in the block.
[0133] The notification of acts 712 and 714 may include output on a computing device, such as an audible notification, a visual notification, and / or a tactile notification. The notification may include displaying a user interface message detailing the results of the Merkle Proof analysis and determination. In some cases, the notification may include sending a result message to one or more remote nodes, including the remote node from which the path data was obtained in act 704.
[0134] An example implementation is shown in the following sample code. The sample code is provided in JavaScript format, where the set of hashes provided is a data structure of length "hashes.length", which further indicates the number of layers in the Merkle tree, and the Merkle root is provided as the last element of the hashes data structure. In this example, the computing device has a copy of the transaction denoted by "tx". The hashing algorithm used in this example is Bitcoin's standard double-SHA256 hash, denoted by the function "sha256d()".
number
[0135] It is understood that the code above is one exemplary implementation, and that other coding languages, structures, and techniques may be used in other implementations.
[0136] The data provided by the remote node may include a Merkle root, a block header containing the Merkle root, and / or a block hash. In some cases, a computing device, such as an end-user device running a client application, may have or have access to pre-validated block headers and a block hash-to-header index. In that case, the remote node may provide the block hash to enable the computing device to identify the corresponding pre-validated block header and extract its Merkle root to validate the proof. Advantageously, the pre-validated block header and corresponding block hash information may have been obtained from one or more other remote blockchain nodes, thereby providing the computing device with confidence that the block headers currently represent the longest proof-of-work chain and have been validated by multiple blockchain nodes.
[0137] The various embodiments described above are merely examples and are not intended to limit the scope of the present application. Various innovations described herein will be apparent to those skilled in the art, as will variations within the intended scope of the present application. In particular, features from one or more of the exemplary embodiments described above may be selected to generate alternative exemplary embodiments, including subcombinations of features not explicitly set forth above. Furthermore, features from one or more of the exemplary embodiments described above may be selected and combined to generate alternative exemplary embodiments, including combinations of features not explicitly set forth above. Features suitable for such combinations and subcombinations will be readily apparent to those skilled in the art upon review of the present application as a whole. The subject matter described and claimed herein covers and encompasses all appropriate technical modifications.
Claims
1. 1. A computer-implemented method for determining validity of data in a blockchain, comprising: receiving from a remote node an index of transactions in a block and a set of ordered hashes for a Merkle proof; Starting at the bottom level of the Merkle tree, at each level of the Merkle tree until the top level is reached, selecting, in order, the provided hashes from the ordered set of hashes; concatenating the provided hash and the calculated hash of the current level in an order determined based on the index; hashing the concatenation to find the computed hash of the next level up; determining, from the index and each pair of the calculated hash and a corresponding hash from the set of ordered hashes, whether the transaction is the last transaction in the block; comparing the top-level computed hash with the Merkle root in the block's header; outputting the results of the comparing and determining steps; A method comprising:
2. The method of claim 1 , wherein the received index is a position index that indicates the position of the transaction within an ordered set of transactions within the block.
3. 3. The method of claim 2, further comprising the step of: for each level above the lowest level, determining an index for that level based on the index of the level below divided by two.
4. 4. The method of claim 1, wherein determining that the transaction is the last transaction in the block comprises determining that each computed hash other than a top-level computed hash is a right element in the Merkle tree.
5. 5. The method of claim 1, wherein determining that the transaction is the last transaction in the block comprises determining that, for any computed hash that is a paired left element, the corresponding provided hash is equal to the computed hash.
6. 6. The method of claim 1, wherein determining whether the transaction is the last transaction in the block comprises determining that the transaction is not the last transaction in the block based on determining that at least one calculated hash is a left-hand element and the corresponding provided hash is not equal to the at least one calculated hash.
7. 7. The method of claim 1, further comprising determining that the index is invalid based on determining that at least one calculated hash is a right-hand element and the corresponding provided hash is equal to the at least one calculated hash.
8. The method of any one of claims 1 to 7, further comprising the step of initially sending a request for Merkle proof data with an identifier of the transaction to the remote node.
9. 9. The method of claim 8, wherein receiving comprises receiving a message including a version field, an index field including the index, and a path field including a data structure including the set of ordered hashes.
10. The method of any one of claims 1 to 7, wherein the computed hash of the lowest level of the Merkle tree is the transaction identifier of the transaction.
11. 11. The method of claim 1, wherein the order determined based on the index comprises determining whether the calculated hash is a left element or a right element in a pair with the corresponding provided hash, and determining whether the calculated hash is a left element or a right element is based on determining whether the index at that level is even or odd modulo 2 of the index.
12. The method of any one of claims 1 to 11, wherein the ordered set of hashes, instead of including duplicate hash values, includes syntax elements that signal duplicate hashes.
13. 1. A computing device comprising: one or more processors; Memory and computer-executable instructions stored in said memory, which, when executed by said one or more processors, cause said processors to perform the method of any one of claims 1 to 12; and 1. A computing device comprising:
14. 13. A computer readable medium storing processor executable instructions, the processor executable instructions comprising instructions that, when executed by one or more processors, cause the processors to perform the method of any one of claims 1 to 12.
Citation Information
Patent Citations
Managing trust points in ledger systems
WO2020035091A2