Editing content from blockchain transactions
Merkle trees are used to edit or remove sensitive data from blockchain transactions, addressing confidentiality issues and compliance challenges by replacing scripts with Merkle roots, ensuring secure and compliant data handling.
Patent Information
- Application Number
- JP2024519817
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2021-10-06
- Filing Date
- 2022-09-06
- Publication Date
- 2024-10-04
AI Technical Summary
Blockchain transactions often contain sensitive or private data that cannot be altered once recorded, posing challenges in protecting confidentiality and compliance with data protection laws.
A method using Merkle trees to edit or remove sensitive data from blockchain transactions by replacing scripts containing the target data with their Merkle roots, allowing selective disclosure and compliance with data protection regulations.
Enables secure removal or hiding of sensitive data from blockchain transactions while maintaining transaction validity and integrity, ensuring compliance with data protection laws and reducing storage requirements.
Smart Images

Figure 2024536271000001_ABST
Abstract
Description
[Technical field]
[0001] The present disclosure relates to a method for redacting content stored in a blockchain transaction, which may be used, for example, to hide confidential, private, or illicit data. [Background technology]
[0002] Blockchain refers to a form of distributed data structure in which a duplicate copy of the blockchain is maintained at each of multiple nodes in a distributed peer-to-peer (P2P) network (hereafter referred to as the "blockchain network") and made publicly available. The blockchain includes a chain of data blocks, with each block including one or more transactions. Each transaction, other than the so-called "coinbase transaction," points to a preceding transaction in the sequence, which may span one or more blocks, back to one or more coinbase transactions. Coinbase transactions are further described below. Transactions submitted to the blockchain network are included in new blocks. New blocks are created by a process often called "mining," which involves multiple nodes each competing to perform a "proof-of-work," i.e., solving a cryptographic puzzle based on an ordered and validated representation of pending transactions waiting to be included in a new block of the blockchain. Note that the blockchain may be pruned at some nodes, and publication of blocks may be accomplished through mere publication of block headers.
[0003] Transactions in a blockchain may be used for one or more of the following purposes: to transfer digital assets (i.e., some digital tokens), to order a set of entries in a virtual ledger or registry, to receive and process timestamp entries, and / or to chronologically order index pointers. A blockchain may also be leveraged to layer additional functionality on top of the blockchain. For example, a blockchain protocol may allow for the storage of additional user data or indexes to data in a transaction. There is no pre-specified limit on the maximum amount of data that can be stored within a single transaction, and therefore more complex data can be incorporated. For example, this may be used to store electronic documents on the blockchain, or to store audio or video data.
[0004] Nodes in a blockchain network (often called "miners") perform a distributed transaction registration and validation process, which is described in more detail below. Briefly, during this process, nodes validate transactions and insert them into a block template that attempts to identify a valid proof-of-work solution. Once a valid solution is found, a new block is propagated to other nodes in the network, allowing each node to record a new block in the blockchain. To have a transaction recorded in the blockchain, a user (e.g., a blockchain client application) sends the transaction to one of the nodes in the network to be propagated. Nodes that receive a transaction may compete to find a proof-of-work solution that will incorporate the validated transaction into a new block. Each node is configured to enforce the same node protocol, which includes one or more conditions for a transaction to be valid. Invalid transactions are not propagated or incorporated into a block. Assuming the transaction is validated and thereby accepted onto the blockchain, the transaction (including any user data) remains registered and indexed at each of the nodes in the blockchain network as an immutable public record.
[0005] Nodes that successfully solve the proof-of-work puzzle and create the latest block are typically rewarded with a new transaction called a "coinbase transaction" that distributes an amount of digital assets, i.e., some number of tokens. Detection and rejection of invalid transactions is enforced by the actions of competing nodes, who act as agents of the network and are incentivized to report and thwart fraud. Widespread publication of information allows users to continuously audit node performance. By mere publication of block headers, participants can ensure 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 usable output includes an element that specifies an amount of a digital asset derivable from the preceding sequence of transactions. A usable output is sometimes called a UTXO (an “unspent transaction output”). An output may further include a locking script that specifies a condition for future redemption of the output. A locking script is a predicate that defines the condition 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., a reference) to such output in a preceding transaction and may further include an unlocking script to unlock the locking script of the pointed-to output. Thus, considering a pair of transactions, we refer to them as a first transaction and a second transaction (or “target” transaction). The first transaction includes at least one output that specifies an 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 that includes a pointer to the output of the first transaction and an unlock script for unlocking the output of the first transaction.
[0007] In such a model, when the second target transaction is sent to the blockchain network to be propagated and recorded in the blockchain, one of the validity criteria applied at each node is that the unlocking script meets all of the one or more conditions defined in the locking script of the first transaction, and another is that the output of the first transaction has not yet been redeemed by another prior valid transaction. A node that finds the target transaction invalid according to any of these conditions will neither propagate it (as a valid transaction, although it may propagate to register the invalid transaction) nor include it in a new block to be recorded in the blockchain.
[0008] Another type of transaction model is the account-based model. In this case, each transaction defines the amount to be transferred by referencing absolute account balances, not by referencing the UTXO of the preceding transaction in the sequence of past transactions. The current state of every account is stored and constantly updated by nodes separately from the blockchain. Summary of the Invention
[0009] Blockchains are designed to be immutable, meaning that once a transaction is written to the blockchain, it is considered impossible to change. However, transaction data may contain private or confidential information that may need to be protected from unauthorized access. As another example, transaction data may contain content that is illegal in at least some jurisdictions. Data that may be considered private, confidential, or illegal is referred to herein as "secret data" and is referred to as "secret" data because the distribution or granting of access to such data must be avoided. Thus, the question arises of how to handle secret data once it has already been written to the blockchain. It is also important to prevent the sharing of secret data on the blockchain, e.g., to properly protect the private data and comply with data protection laws. This problem can also be rephrased as how to remove or limit access to secret data stored in a blockchain transaction while ensuring that any remaining (i.e., non-secret) data belongs to the transaction and that it is possible to prove that the transaction is validated and can be used in future transactions.
[0010] According to one aspect disclosed herein, a computer-implemented method for editing data of a blockchain transaction is provided, the method including: obtaining a first blockchain transaction, the first blockchain transaction including one or more respective scripts including respective target data to be edited; for at least one of the one or more respective scripts, constructing a respective Merkle tree based on the respective script, the respective target data being split across one or more of the respective leaves of the respective Merkle tree; and generating an edited version of the first blockchain transaction by replacing the at least one respective script with a respective Merkle root of the respective Merkle tree.
[0011] The method allows for the redaction (or removal or obscuring) of target data (e.g., secret data) from a blockchain transaction using a Merkle tree. A transaction includes at least one script. The script may be at the input (unlock script) or output (lock script) of the transaction. The script includes the target data (data to be redacted). The target data may be secret data that is private, confidential, or illegal, as described above. In general, the target data may be data that is to be removed from the transaction, and does not necessarily have to be private, confidential, or illegal. For example, the target data may need to be removed from the transaction because of its size, e.g., the target data may include large images or audio files. As another example, the target data may need to be removed from the transaction because it contains a bug or other harmful data (harmful in the sense that it can cause damage to the computer that stores or processes the data).
[0012] The Merkle tree is constructed based on, or using, the script. Different parts of the script are used as different leaves of the Merkle tree. At least one leaf of the Merkle tree contains a portion of the target data. In some examples, a single leaf node contains the entire target data. In other examples, the target data is split across multiple leaves. As known in the art, the leaves of the Merkle tree are hashed to form leaf hashes, and pairs of leaf hashes are concatenated and hashed to form respective inner hashes. The process of concatenating and hashing pairs of inner hashes is repeated until a single hash (the Merkle root) remains. The script is replaced with the Merkle root to form an edited version of the transaction (the "edited transaction"). Thus, the target data is edited or removed from the transaction by replacing the script containing the target data with the Merkle root.
[0013] The edited transaction may be stored and / or shared in place of the original version of the transaction, thus preventing storage and / or distribution of the targeted (e.g., secret) data.
[0014] The method may be performed by a transaction generator, e.g., a user. For example, the method may be performed to generate a signature based on the edited transaction. The method may be performed by a transaction validator, e.g., a blockchain node. For example, the method may be performed to verify a signature based on the edited transaction, generate a transaction identifier for the edited transaction, and / or validate the edited transaction.
[0015] In some embodiments, the method may be used to implement a selective disclosure mechanism, whereby a prover can select a subset of transaction content to be disclosed to a verifier, while some content can remain hidden. This mechanism is script agnostic and facilitates selective disclosure of content embedded by any scripting mechanism. [Brief description of the drawings]
[0016] To aid in understanding embodiments of the present disclosure and to show how such embodiments may be carried into effect, reference will now be made, by way of example only, to the accompanying drawings, in which: [Figure 1] FIG. 1 is a schematic block diagram of a system for implementing a blockchain. [Diagram 2] 1 illustrates generally some examples of transactions that may be recorded on a blockchain. [Diagram 3] 1 illustrates a schematic diagram of an exemplary blockchain transaction structure that includes data embedded in an unusable output. [Figure 4] 1 shows a schematic example of Merklizing a pay-to-public-key hash (P2PKH) script. [Diagram 5] 13 shows a schematic example of Merkle rendering of an unusable output script; [Figure 6] FIG. 1 is a schematic block diagram of an example high-level architecture for using Merklized transactions, where a transaction using a previous Merklized script is created, the transaction is broadcast, and nodes use the edited previous transaction to validate the transaction against the previous Merklized script. [Figure 7] 1 illustrates diagrammatically an exemplary edited transaction, with the edited fields indicated by solid boxes with dashed lines; [Figure 8] 13 illustrates a schematic example of generating a secondary identifier for an edited transaction; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0017] 1. Exemplary System Overview FIG. 1 illustrates an exemplary system 100 for implementing a blockchain 150. The system 100 may be comprised of 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, which may be configured to form a peer-to-peer (P2P) network 106 within the packet-switched network 101. Although not shown, the blockchain nodes 104 may be configured as a nearly complete graph. Thus, each blockchain node 104 is highly connected to other blockchain nodes 104.
[0018] Each blockchain node 104 includes a peer computer device, with different ones of the nodes 104 belonging to different peers. Each blockchain node 104 includes one or more processors, e.g., processing devices including one or more central processing units (CPUs), accelerator processors, application specific processors and / or field programmable gate arrays (FPGAs), and other devices such as application specific integrated circuits (ASICs). Each node also includes memory, i.e., computer readable storage in the form of one or more non-transitory computer readable media. The memory may include one or more memory units employing one or more memory media, e.g., magnetic media such as hard disks, solid state drives (SSDs), electronic media such as flash memory or EEPROMs, and / or optical media such as optical disk drives.
[0019] The blockchain 150 includes a chain of data blocks 151, and a respective copy of the blockchain 150 is maintained at each of multiple blockchain nodes 104 in a decentralized or blockchain network 106. As mentioned above, maintaining a copy of the blockchain 150 does not necessarily mean storing the blockchain 150 in its entirety. Instead, the blockchain 150 can be pruned as long as each blockchain node 150 stores the block header (described below) of each block 151. Each block 151 in the chain includes one or more transactions 152, where a transaction in this context refers to a type of data structure. The nature of the data structure depends on the type of transaction protocol used as part of the transaction model or scheme. A given blockchain uses one particular transaction protocol throughout. In one common type of transaction protocol, the data structure of each transaction 152 includes at least one input and at least one output. Each output specifies an amount representing an amount of digital assets as a property, an example of which is a user 103 to whom the output is cryptographically locked (requiring that user's signature or other solution to be unlocked and thereby redeemed or used). Each input points to the output of a preceding transaction 152, thereby linking the transactions.
[0020] Each block 151 also contains a block pointer 155 that points to a previously created block 151 in the chain to define an order for the blocks 151. Each transaction 152 (other than a coinbase transaction) contains a pointer back to a previous transaction to define an order for the sequence of transactions (Note: a sequence of transactions 152 can branch). The chain of blocks 151 goes back to a genesis block (Gb) 153, which was the first block in the chain. One or more original transactions 152 earlier in the chain 150 pointed to the genesis block 153, not to a preceding transaction.
[0021] Each of the blockchain nodes 104 is configured to forward transactions 152 to other blockchain nodes 104, thereby propagating the transactions 152 throughout the network 106. Each blockchain node 104 is configured to create blocks 151 and store respective copies of the same blockchain 150 in their respective memories. Each blockchain node 104 also maintains an ordered set (or pool) 154 of transactions 152 waiting to be incorporated into a block 151. The ordered pool 154 is often referred to as a "mempool." This term in this specification is not intended to be limited to any particular blockchain, protocol, or model. This refers to an ordered set of transactions that the node 104 has accepted as valid, for which the node 104 is obligated not to accept other transactions that attempt to use the same output.
[0022] For a given current transaction 152j, its input (or each input) contains a pointer that references an output of a preceding transaction 152i in the sequence of transactions, specifying that this output should be redeemed or "used" in the current transaction 152j. Using or redeeming does not necessarily mean the transfer of a financial asset, although that is certainly one common use. More generally, using may be described as consuming an output or allocating it to one or more outputs in another onward transaction. In general, the preceding transaction may be any transaction in the ordered set 154 or any block 151. The preceding transaction 152i must exist and be validated for the current transaction to be valid, but the preceding transaction 152i does not necessarily need to exist when the current transaction 152j is created or sent to the network 106. Thus, "preceding" herein refers to something that precedes it in a logical sequence linked by a pointer, and not necessarily to a time of creation or transmission in a time sequence, and therefore does not necessarily preclude transactions 152i, 152j from being created or transmitted out of order (see the discussion below regarding orphan transactions). A preceding transaction 152i is also referred to as an antecedent transaction or a predecessor transaction.
[0023] 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 preceding transaction 152i is locked. The output of the current transaction 152j can then be cryptographically locked to the new user or entity 103b. Thus, the current transaction 152j can transfer the amount defined in the input of the preceding transaction 152i to the new user or entity 103b, as defined in the output of the current transaction 152j. In some cases, the transaction 152j can have multiple outputs to split the input amount among multiple users or entities (one of which can be the original user or entity 103a to give the change). In some cases, the transaction can also have multiple inputs to pool amounts from multiple outputs of one or more preceding transactions and redistribute them to one or more outputs of the current transaction.
[0024] According to an output-based transaction protocol such as Bitcoin, when a party 103, such as an individual user or an organization, wants to enact a new transaction 152j (manually or by an automated process adopted by the party), the enacting party transmits the new transaction from its computer terminal 102 to a recipient. The enacting party or recipient eventually transmits this transaction to one or more of the blockchain nodes 104 of the network 106 (which is currently typically a server or a data center, but could in principle be other user terminals). It is not excluded that the party 103 enacting the new transaction 152j transmits the transaction directly to one or more of the blockchain nodes 104 and in some examples does not transmit it to a recipient. The blockchain nodes 104 receiving the transaction check whether the transaction is valid according to a blockchain node protocol applied at each of them. 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 that depends on the previous transaction 152i in the ordered sequence of transactions 152. In such an output-based transaction protocol, this may include checking that the cryptographic signature or other authorization of the party 103 included in the input of the new transaction 152j matches a condition defined in the output of the preceding transaction 152i that the new transaction uses (or "assigns"), which condition typically includes at least checking that the cryptographic signature or other authorization in the input of the 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. Alternatively, it may be fixed solely by the blockchain node protocol or by a combination of these.In any event, if the new transaction 152j is valid, the blockchain node 104 forwards it to one or more other blockchain nodes 104 in the blockchain network 106. These other blockchain nodes 104 apply the same tests according to the same blockchain node protocol, and then 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.
[0025] In an output-based model, the definition of whether a given output (e.g., UTXO) is allocated (or "spent") is whether it has been validly redeemed by the input of another subsequent 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 is trying to redeem has not yet been redeemed by another transaction. Again, if it is not valid, the transaction 152j is not propagated (unless it is flagged as invalid and propagated for a warning) or recorded in the blockchain 150. This prevents double-spending, where a transactor tries to allocate the output of the same transaction multiple times. On the other hand, an account-based model prevents double-spending by maintaining account balances. Again, since the transaction order is defined, the account balances are always in a single defined state.
[0026] In addition to validating transactions, blockchain nodes 104 also compete to be the first to create a block of transactions in a process commonly referred to as mining, which is supported by "proof of work." At the blockchain nodes 104, new transactions are added to an ordered pool 154 of valid transactions that have not yet appeared in a block 151 recorded on the blockchain 150. The blockchain nodes then compete to assemble a new valid block 151 of transactions 152 from the ordered set of transactions 154 by trying to solve a cryptographic puzzle. Typically, this involves searching for a "nonce" value such that when the nonce is concatenated and hashed with a representation of the ordered pool 154 of pending transactions, the output of the hash satisfies a predefined condition. For example, the predefined condition could be that the output of the hash has a certain predefined 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 for its input. This search can therefore only be performed in a brute force manner, consuming a significant amount of processing resources at each blockchain node 104 attempting to solve the puzzle.
[0027] The first blockchain node 104 to solve the puzzle publishes this to the network 106 and provides its solution as a proof that can be easily checked later by other blockchain nodes 104 in the network (given the solution to the hash, it is easy to check that the output of the hash satisfies the conditions). This first blockchain node 104 propagates the block to threshold consensus of other nodes that accept this block and enforce the protocol rules. The ordered set of transactions 154 then becomes recorded as a new block 151 in the blockchain 150 by each of the blockchain nodes 104. A block pointer 155 is also assigned to the new block 151n that points to the previously created block 151n-1 in the chain. The significant amount of effort, e.g., in the form of a hash, required to create the proof-of-work solution indicates the intention of the first node 104 to follow the rules of the blockchain protocol. Such rules include not accepting a transaction as valid if it uses or assigns the same output as a previously validated transaction (also known as double spending). Once created, blocks 151 cannot be modified because they are known and maintained at 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.
[0028] Note that different blockchain nodes 104 competing to solve the puzzle at any given time may be doing so based on different snapshots of the pool of not-yet-published transactions 154 at any given time, depending on when they started searching for a solution or the order in which transactions were received. Whoever solves their respective puzzle first defines which transactions 152 will be included in the next new block 151n, and in what order, the current pool of not-yet-published transactions 154 is updated. The blockchain nodes 104 then continue competing to create blocks from the newly defined, ordered pool of not-yet-published transactions 154, and so on. There are also protocols to resolve any "forks" that may occur if two blockchain nodes 104 solve the puzzle within a very short time of each other, causing conflicting views of the blockchain to propagate between the nodes 104. In essence, whichever prong of the fork grows the longest will be the deterministic blockchain 150. Note that this does not affect users or agents of the network, since the same transactions appear in both forks.
[0029] According to the Bitcoin blockchain (and most other blockchains), a node that successfully constructs a new block 104 is given the ability to allocate the additional amount of accepted digital assets in a new special type of transaction that distributes an additional defined 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 usually called a "coinbase transaction," but may also be referred to as an "initiation transaction" or "generation transaction." This typically forms the first transaction of a new block 151n. The proof of work indicates the intention of the node constructing the new block to follow protocol rules that allow this special transaction to be redeemed later. Blockchain protocol rules may require a maturity period, e.g., 100 blocks, before this special transaction can be redeemed. Often, a normal (non-generative) transaction 152 also specifies an additional transaction fee in one of its outputs to further reward the blockchain node 104 that created the block 151n in which the transaction was published. This fee is commonly referred to as the "transaction fee" and is explained below.
[0030] Due to the resources involved in transaction validation and publishing, typically at least each of the blockchain nodes 104 takes the form of a server made up of one or more physical server units, or even an entire data center. However, in principle, any given blockchain node 104 can take the form of a user terminal or a group of user terminals networked together.
[0031] The memory of each blockchain node 104 stores software configured to execute on the processing unit of the blockchain node 104 to perform its respective one or more roles and process transactions 152 in accordance with the blockchain node protocol. It will be understood that any action attributed to a blockchain node 104 herein may be performed by software executing on the processing unit of the respective computing device. The node software may be implemented in one or more applications at the application layer, or at a lower layer, such as the operating system layer or protocol layer, or any combination thereof.
[0032] Also connected to the network 101 are computer devices 102 of multiple parties 103 each acting in the role of consuming users. These users may interact with the blockchain network 106 but do not participate in validating transactions or constructing blocks. Some of these users or agents 103 may act as senders and receivers of 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 a copy of the blockchain 150 (e.g., having obtained a copy of the blockchain from a blockchain node 104).
[0033] Some or all of the parties 103 may be connected as part of a different network, for example, a network overlaid on top of the blockchain network 106. Users of the blockchain network (often referred to as "clients") may be said to be part of a system that includes the blockchain network 106, but these users are not blockchain nodes 104 because they do not fulfill the role required of a blockchain node. Instead, each party 103 may interact with the blockchain network 106, thereby utilizing the blockchain 150 by connecting (i.e., communicating) with the blockchain node 106. Two parties 103 and their respective devices 102 are shown for illustrative purposes, namely, 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 there may be many more such parties 103 and their respective computer devices 102 and they may participate in the system 100, but for convenience they are not shown. Each party 103 may be an individual or an organization. Purely by way of example, the first party 103a is referred to herein as Alice and the second party 103b is referred to as Bob, although it will be understood that this is not limiting and that any reference to Alice or Bob herein may be replaced with "first party" and "second party," respectively.
[0034] The computer equipment 102 of each party 103 comprises a respective processing device including one or more processors, e.g., one or more CPUs, GPUs, other accelerator processors, application specific processors, and / or FPGAs. The computer equipment 102 of each party 103 further comprises a memory, i.e., computer readable storage in the form of one or more non-transitory computer readable media. This memory may comprise one or more memory units employing one or more memory media, e.g., magnetic media such as hard disks, electronic media such as SSDs, flash memories or EEPROMs, and / or optical media such as optical disk drives. The memory on the computer equipment 102 of each party 103 stores software including a respective instance of at least one client application 105 configured to run on the processing device. It will be understood that any action attributed to a given party 103 herein may be performed using software running on the processing device of the respective computer equipment 102. The computer equipment 102 of each party 103 comprises at least one user terminal, e.g., a desktop or laptop computer, a tablet, a smartphone, or a wearable device such as a smart watch. The computing equipment 102 of a given party 103 may also include one or more other networked resources, such as cloud computing resources accessed via a user terminal.
[0035] The client application 105 may initially be provided to the computing equipment 102 of any given party 103 on one or more suitable computer-readable storage devices, for example downloaded from a server or provided on a removable storage device such as a removable SSD, a flash memory key, a removable EEPROM, a removable magnetic disk drive, a magnetic floppy disk or tape, an optical disk such as a CD or DVD ROM, or a removable optical drive.
[0036] The client application 105 comprises at least a "wallet" functionality. It has two main functions. One of these is to allow each party 103 to create, authorize (e.g., sign) and send transactions 152 to one or more Bitcoin nodes 104 for propagation across the network of blockchain nodes 104 and thereby inclusion in the blockchain 150. The other is to report to each party the amount of digital assets that it currently owns. In an output-based system, this second function involves reconciling the amounts defined in the outputs of the various transactions 152 scattered across the blockchain 150 that belong to that party.
[0037] It should be noted that various client functions may be described as being integrated into a given client application 105, but are not necessarily limited thereto; instead, any client functionality described herein may be implemented in a suite of two or more separate applications that interface, for example, via an API, or one that is a plug-in to the other. More generally, client functions may be implemented at the application layer or a lower layer, such as an operating system, or any combination thereof. The following description is given with respect to client application 105, but will be understood to be non-limiting.
[0038] An instance of a client application or software 105 on each computing device 102 is operatively coupled to at least one of the blockchain nodes 104 of the network 106. This allows the wallet function of the client 105 to send transactions 152 to the network 106. The client 105 can also contact the blockchain node 104 to query the blockchain 150 for any transactions in which the respective party 103 is a recipient (or, in an embodiment, actually inspect other parties' transactions 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 function on each computing device 102 is configured to formulate and send 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 forward the transactions 152 to propagate them across the blockchain network 106. The transaction protocol and the node protocol correspond to each other, and a given transaction protocol goes with a given node protocol, and together they implement a given transaction model. The same transaction protocol is used for all transactions 152 in the blockchain 150. The same node protocol is used by all nodes 104 in the network 106.
[0039] When a given party 103, for example Alice, wishes to send a new transaction 152j to be included in the blockchain 150, Alice formulates the new transaction (using a wallet function in Alice's client application 105) according to the associated transaction protocol. Alice then sends the transaction 152 from her client application 105 to one or more blockchain nodes 104 to which Alice is connected. For example, this may be the blockchain node 104 that is best connected 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 includes first checking if the newly received transaction 152j meets certain conditions to be "valid", examples of which are described in more detail below. In some transaction protocols, the conditions for validation may be configurable per transaction by a script included in the transaction 152. Alternatively, the conditions may simply be a built-in feature of the node protocol or may be defined by a combination of the script and the node protocol.
[0040] Provided that the newly received transaction 152j passes the tests to be considered valid (i.e., it is "validated"), any blockchain node 104 that receives the transaction 152j adds the new validated transaction 152 to the ordered set of transactions 154 maintained at 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, this means that, assuming the transaction 152j is valid, it will be propagated immediately throughout the network 106.
[0041] Once accepted into the ordered pool 154 of pending transactions maintained at a given blockchain node 104, that blockchain node 104 begins competing to solve the proof-of-work puzzle for the latest version of each pool 154 that contains the new transaction 152. (Recall that other blockchain nodes 104 may be attempting to solve the puzzle based on different pools 154 of transactions, but whichever node solves it first defines the set of transactions contained in the latest block 151. Eventually, the blockchain node 104 will have solved the puzzle for the part of the ordered pool 154 that contains Alice's transaction 152j.) Once the proof-of-work has been done for the pool 154 that contains the new transaction 152j, it universally becomes part of one of the blocks 151 in the blockchain 150. Since each transaction 152 contains a pointer back to the previous transaction, the order of the transactions is also immutably recorded.
[0042] Different blockchain nodes 104 may initially receive different instances of a given transaction and therefore have conflicting views on which instance is "valid" until one instance is published in a new block 151 (at which point all blockchain nodes 104 agree that the published instance is the only valid instance). If a blockchain node 104 accepts one instance as valid and then discovers that another 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 published in block 151).
[0043] An alternative type of transaction protocol operated by some blockchain networks may be called an "account-based" protocol, as part of the account-based transaction model. In the account-based case, each transaction defines the amount to be transferred by referencing the absolute account balance, not by referencing the UTXO of the preceding transaction in the sequence of past transactions. The current state of every account is stored and constantly updated by the nodes of the network separately from the blockchain. In such a system, transactions are ordered using the running transaction tally (also called the "position") of the account. This value is signed by the sender as part of its cryptographic signature and hashed as part of the transaction reference calculation. In addition, an optional data field in the transaction may also be signed. This data field may point to a previous transaction, for example if a previous transaction ID is included in the data field.
[0044] 2. UTXO-based model FIG. 2 illustrates an exemplary transaction protocol. It is an example of a UTXO-based protocol. A transaction 152 (abbreviated as "Tx") is a fundamental data structure of a blockchain 150 (each block 151 contains one or more transactions 152). In the following, it is described with reference to an output-based or "UTXO"-based protocol. However, this is not limited to all possible embodiments. It should be noted that the exemplary UTXO-based protocol is described with reference to Bitcoin, but could equally be implemented on other exemplary blockchain networks.
[0045] In a UTXO-based model, each transaction ("Tx") 152 includes a data structure that includes one or more inputs 202 and one or more outputs 203. Each output 203 may include an unspent transaction output (UTXO), which may be used as a source of input 202 for another new transaction (if the UTXO has not yet been redeemed). The UTXO includes a value that specifies an amount of a digital asset. This represents a set number of tokens on the distributed ledger. The UTXO may also include a transaction ID of the underlying transaction, among other information. The transaction data structure may also include a header 201 that may include indicators indicating the size of the input field(s) 202 and output field(s) 203. The header 201 may also include an ID of the transaction. In an embodiment, the transaction ID is a hash of the transaction data (excluding the transaction ID itself) and is stored in the header 201 of the raw transaction 152 that is submitted to the node 104.
[0046] Suppose Alice 103a wants to create a transaction 152j that transfers an amount of the digital asset to Bob 103b. In FIG. 2, Alice's new transaction 152j is labeled "Tx1". It takes the amount of the digital asset locked to Alice in the output 203 of the previous transaction 152i in the sequence and transfers at least a portion of it to Bob. The previous transaction 152i is labeled "Tx0" in FIG. 2. Tx0 and Tx1 are just 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 can point to any previous (i.e., earlier) transaction that still has an unspent output 203 locked to Alice.
[0047] The preceding transaction Tx0 may already be validated and included in a block 151 of the blockchain 150 by the time Alice creates the new transaction Tx1, or at least by the time Alice 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 created and submitted to the network 106 together, or even Tx0 may be submitted after Tx1 if the node protocol allows for buffering of "orphan" transactions. The terms "preceding" and "subsequent" as used herein in the context of a sequence of transactions refer to the order of the transactions in a sequence defined by transaction pointers (e.g., which transactions point to which other transactions) specified in the transactions. They may similarly be replaced with "predecessor" and "successor," or "antecedent" and "descendant," "parent" and "child," etc. This does not necessarily imply the order of their creation, transmission to the network 106, or arrival at any given blockchain node 104. Nevertheless, a subsequent transaction (a later transaction or "child") that points to a preceding transaction (an earlier 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 buffered for a certain amount of time to wait for the parent or discarded, depending on the node protocol and / or node behavior.
[0048] One of the one or more outputs 203 of the preceding transaction Tx0 includes a particular UTXO, labeled herein as UTXO0. Each UTXO includes a value specifying the amount of the digital asset represented by the UTXO and a locking script that defines a condition that an unlocking script in the input 202 of the following transaction must satisfy in order for the following transaction to be validated and thus 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 an unlocking condition that includes a condition that an unlocking script in the input of the following transaction includes a cryptographic signature of the party to whom the preceding transaction is locked.
[0049] A lock script (commonly called 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 what information is needed to use the transaction output 203, e.g. the need for Alice's signature. An unlock script appears in the transaction's output. An unlock script (commonly called scriptSig) is a piece of code written in a domain-specific language that provides the information needed to satisfy the lock script criteria. For example, it may include Bob's signature. An unlock script appears in the transaction's input 202.
[0050] That is, in the illustrated example, UTXO0 in output 203 of Tx0 must have Alice’s signature Sig P in order for UTXO0 to be redeemed (or, more precisely, for a subsequent transaction that attempts to redeem UTXO0 to be valid). A Requires lock script [Checksig P A ]. [Checksig P A ] is the public key P of Alice's public-private key pair.A 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, to identify UTXO0 among any other possible outputs of Tx0. Tx1's input 202 includes an unlock script that includes Alice's cryptographic signature, created by Alice applying her private key of her key pair to a given portion of data (sometimes called a "message" in cryptography). <Sig P A The data (or "message") that needs to be signed by Alice to provide a valid signature may be defined by the lock script, or by the node protocol, or by a combination of these.
[0051] When a new transaction Tx1 arrives at a blockchain node 104, the node applies the node protocol, which involves running the lock script and the unlock script together to check if the unlock script satisfies the conditions defined in the lock script (which may include one or more criteria). In an embodiment, this involves concatenating the two scripts: <Sig P A > <P A > || [Checksig P A ] Here, "||" represents concatenation, "<...>" means to put data on the stack, and "[...]" are functions that are composed in the lock script (a stack-based language in this example). Equivalently, the scripts could be executed one after the other using a common stack rather than concatenating the scripts. Either way, when executed together, the scripts will create Alice's public key P as contained in the lock script in the output of Tx0. A, to authenticate that the unlock script in Tx1's input contains Alice's signature signing the expected portion of the data. In order to perform this authentication, the expected portion of the data itself (the "message") must also be included. In an embodiment, the data to be signed includes the entirety of Tx1 (i.e., a separate element specifying the signed portion of the plaintext data does not need to be included, as that is already inherently present).
[0052] The details of public-private cryptographic authentication are well known to those skilled in the art. Essentially, if Alice signs a message using her private key, then given Alice's public key and the plaintext message, another entity, such as node 104, can authenticate that the message must have been signed by Alice. Signing typically involves hashing the message, signing the hash, and tagging this as the signature to the message, allowing any holder of the public key to authenticate the signature. Thus, it should be noted that any reference herein to signing a particular portion of data or part of a transaction, etc., may, in embodiments, mean signing a hash of that portion of data or part of a transaction.
[0053] If the unlock script in Tx1 satisfies one or more conditions specified in the lock script of Tx0 (i.e., in the illustrated example, Alice's signature is provided and authenticated in Tx1), the blockchain node 104 considers Tx1 to be valid. This means that the blockchain node 104 will add Tx1 to the ordered pool 154 of pending transactions. The blockchain node 104 will also forward the transaction Tx1 to one or more other blockchain nodes 104 in the network 106 so that the transaction Tx1 is propagated throughout the network 106. Once Tx1 is validated and included in the blockchain 150, this defines the UTXO0 from Tx0 as spent. Note that Tx1 can only be valid if it uses unspent transaction outputs 203. If it attempts to use an output that has already been used by another transaction 152, Tx1 will be invalid even if all other conditions are met. Therefore, the blockchain node 104 also needs to check whether the referenced UTXO in the preceding transaction Tx0 has already been spent (i.e., whether it already formed a valid input to another valid transaction). This is one of the reasons why it is important for the blockchain 150 to impose a defined order on transactions 152. In practice, a given blockchain node 104 may maintain a separate database that marks which UTXOs 203 in which transactions 152 have been spent, but ultimately, what defines whether a UTXO has been spent is whether it already formed a valid input to another valid transaction in the blockchain 150.
[0054] 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 ground of invalidity in most transaction models, so such a transaction will not be propagated or included in block 151.
[0055] Note that in the UTXO-based transaction model, a given UTXO must be spent in its entirety. Part of the amount defined as spent in the UTXO cannot be "left" while another part is spent. However, it is possible to split the amount from the UTXO among multiple outputs of a subsequent transaction. For example, the amount defined in UTXO0 in Tx0 can be split among multiple UTXOs in Tx1. Thus, if Alice does not want to give Bob all of the amount defined in UTXO0, she can use a reminder to give the remainder to herself in the second output of Tx1 or to pay another party.
[0056] In practice, Alice would also typically need to include a fee for any Bitcoin node 104 that successfully includes Alice's transaction 104 in a block 151. If Alice does not include such a fee, Tx0 may be rejected by the blockchain node 104 and thus may not be propagated and included in the blockchain 150, even if it is technically valid (the node protocol does not force a blockchain node 104 to accept a transaction 152 if it does 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, any difference between the total amount pointed to by the input(s) 202 of a given transaction 152 and the total amount specified in the output(s) 203 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 (or used) by the node 104 that wins the proof-of-work competition to create the block containing UTXO1. However, it is not necessarily excluded that a transaction fee may alternatively or additionally be explicitly specified in one of the UTXOs 203 of transaction 152 itself.
[0057] Alice and Bob's digital assets consist of the UTXOs locked to them in any transaction 152 anywhere in the blockchain 150. Thus, typically, a given party 103's assets are scattered across the UTXOs of various transactions 152 across the blockchain 150. No number is stored anywhere in the blockchain 150 that defines the total balance of a given party 103. The role of the wallet function in the client application 105 is to collate together all the values of the various UTXOs that are locked to the respective parties and that have not yet been used in another subsequent transaction. This can be done by querying the copy of the blockchain 150 stored in any of the Bitcoin nodes 104.
[0058] Note that scripting code is often represented generally (i.e., without using a precise language). For example, an operation code (opcode) may be used to represent a particular function. "OP_..." refers to a particular opcode in the scripting language. As an example, OP_RETURN is an opcode in the scripting language that creates an unusable output of a transaction that can store data in the transaction when preceded by OP_FALSE at the beginning of the lock script, 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.
[0059] Typically, the input for a transaction is a public key P AIn an embodiment, this is based on ECDSA using the elliptic curve secp256k1. The digital signature signs a specific portion of the data. In some embodiments, for a given transaction, the signature signs some of the transaction inputs, and some or all of the transaction outputs. The specific portion of the outputs that are signed depends on the SIGHASH flag, which is a four-byte code that is typically included at the end of the signature (and is therefore fixed at the time of signing) to select which outputs are signed.
[0060] A lock script may typically be referred to as a "scriptPubKey", referring to the fact that each transaction contains the public key of the party being locked. An unlock script may typically be referred to as a "scriptSig", referring to the fact that it provides the corresponding signature. However, more generally, it is not required in all applications of blockchain 150 that the condition for a UTXO to be redeemed includes authenticating the signature. More generally, any condition or conditions may be defined using a scripting language. Thus, the more general terms "lock script" and "unlock script" may be preferred.
[0061] 3. Side Channels As shown in FIG. 1, the client applications on each of Alice's and Bob's computing devices 102a, 120b, respectively, may include additional communication capabilities. This additional functionality allows Alice 103a (at the instigation of either party or a third party) to establish a separate side channel 107 with Bob 103b. The side channel 107 allows for the exchange of data apart from the blockchain network. Such communication may be referred to as "off-chain" communication. For example, this may be used to exchange transactions 152 between Alice and Bob without the transaction (yet) being registered on the blockchain network 106 or progressing on the chain 150 until one of the parties chooses to broadcast the transaction to the network 106. Sharing transactions in this manner may be referred to as sharing a "transaction template." A transaction template may lack one or more inputs and / or outputs required to form a complete transaction. Alternatively or additionally, the side channel 107 may be used to exchange any other transaction-related data, such as keys, negotiated amounts or terms, data content, etc.
[0062] The side channel 107 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 mobile cellular network, or a local area network, such as a local wireless network, or over a direct wired or wireless link between Alice's device 102a and Bob's device 102b. In general, anywhere in this specification, the side channel 107 referred to may include any link or links over one or more networking technologies or communication media for exchanging data "off-chain", i.e., apart 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 107. Thus, it should be noted that when it is said that Alice and Bob exchange information or particular pieces of data, etc., over the side channel 107, this does not necessarily mean that all of these pieces of data must be transmitted over the exact same link or the same type of network.
[0063] 4. Editing transaction content A blockchain transaction includes inputs and outputs, each of which includes a script. Using blockchain scripts (Pay-to-Public-Key (P2PK), Pay-to-Public-Key-Hash (P2PKH), multi-signature, OP_RETURN, etc.), arbitrary data can be stored in the transaction. Outputs include scripts that can encode complex locking conditions, plus store additional data items that may or may not be part of the locking conditions. In a particular example, arbitrary data can be added to a transaction using a disabled script pattern known as an OP_FALSE OP_RETURN output. The script opcode combination OP_FALSE OP_RETURN used to store arbitrary data on the ledger will increase the size of the blockchain and consume disk space for blockchain nodes 104 that wish to store the complete data of the blockchain. Some data stored on the blockchain may be fraudulent, illegal, confidential, private, etc. Some data may fall into one of these categories at the time it is recorded on the blockchain or at a later date. Some data may fall into one of these categories in some jurisdictions but not in others. Thus, it is necessary to be able to redact data from a transaction in order to reduce the size of the transaction and / or comply with (jurisdiction-dependent) rules and regulations, among other reasons. Figure 3 shows the structure of an example blockchain transaction with an OP_FALSE OP_RETURN payload.
[0064] Embodiments of the present disclosure allow for the editing of data stored in a blockchain transaction, i.e., data that is included as part of a script in the input or output of the transaction. The data to be edited is referred to herein as "target data." Target data may be included as part of the input (unlock) script. For example, the transaction shown in FIG. 3 includes the data <SigA > <P A > (signature and public key). The target data may be included as part of the output (lock) script. For example, the same transaction may contain two lock scripts, both of which contain data. The first lock script contains the data P B The second locking script contains the data <data>(Any data such as media content, personal details (e.g. name and address), billing information, etc.) Target data may be included as part of usable (i.e. transferable and allocable) output or non-usable (i.e. non-transferable and non-allocable) output.
[0065] The redaction of the target data may be performed by any entity with access to the original blockchain transaction, which may be any transaction involving the data. For simplicity, we refer to the entity performing the redaction process as the "reductor." In some embodiments, the reductor may be a user, e.g., a party such as Alice 103a or Bob 103b, or rather a respective computing device 102a, 102b. In other embodiments, the reductor includes a blockchain node 104. These embodiments are described below.
[0066] The reductor obtains the target transaction, i.e., a transaction that includes the target data to be edited as part of the script. The reductor may generate the target transaction. For example, the reductor may be a user (e.g., Alice 103a) that generates the transaction. In this case, the reductor may also generate the target data, or the target data may be obtained (e.g., received) from elsewhere. In other examples, the reductor may not be the entity that generated the target transaction. For example, the target transaction may be obtained from the blockchain, or may be received from a blockchain node 104 or from a transaction generator. For example, the reductor may be a blockchain node 104 that receives the target transaction from Alice 103a, who generated the target transaction.
[0067] Upon obtaining the target transaction, the reductor generates a Merkle tree using a script (e.g., an unlock script or a lock script) that includes the target data. The entire script is used to generate the Merkle tree. The target data, in its raw form, forms one or more leaves of the Merkle tree. That is, one or more leaves of the Merkle tree include (or consist of) at least a portion of the target data. In some examples, a single leaf may include (or consist of) the target data, meaning that the entire target data is included as part of that leaf. Alternatively, the target data may be split across multiple leaves of the Merkle tree, meaning that different leaves include different portions of the target data. For example, the target data may be split into equal-sized chunks, or the target data may be split into a predetermined number of chunks. On the contrary, the target data may be split arbitrarily.
[0068] It should be noted that the term "Merkle tree" generally refers to a binary hash tree. In general, however, embodiments of the present disclosure may utilize any type of hash tree, for example, a tertiary hash tree. Thus, any reference to a "Merkle tree" may be replaced with the more general "hash tree" instead.
[0069] In some examples, the script may include only the target data. For example, the unlock script may include only the target data that was used to unlock the unlock script of the previous lock script. In that case, the Merkle tree may be based entirely on the target data. However, in practice, the script is likely to include other components in addition to the target data. For example, the script may include one or more functions configured to perform the respective operations. On the Bitcoin blockchain, these functions are known as opcodes. Additionally or alternatively, the script may include data that is not to be edited. For example, the script may include a public key hash that does not need to be edited and an image file that needs to be edited. In these examples, the target data forms only a part of the Merkle tree, i.e., one or more leaves of the Merkle tree. The function(s) and / or other data also form part of the Merkle tree. That is, one or more leaves of the Merkle tree may include (e.g., may consist of) one or more functions, and one or more leaves of the Merkle tree may include (e.g., may consist of) non-target data.
[0070] The different components of the script (e.g., functions, target data, other data, etc.) have an order, e.g., from left to right, that is respected when constructing the Merkle tree. The leaves of the Merkle tree are formed using the components of the script in the order in which they appear. For example, the script may include a first set of one or more functions followed by target data followed by a second set of one or more functions. The first set of Merkle tree leaves is formed from the first set of functions, the second set of Merkle tree leaves is formed from the target data, and the third set of Merkle tree leaves is formed from the second set of functions.
[0071] In some instances, one or more consecutive functions may be grouped together to form a single leaf of a Merkle tree, while in other instances, each function may form a single leaf of a Merkle tree.
[0072] In some examples, the script may include a data function (e.g., OP_PUSHDATA, OP_RETURN, etc.) configured to indicate target data when executed. The indicating of the target data may include outputting the target data to memory (e.g., stack-based memory) when executed. In these examples, the data function may be separated from the other functions such that it is the only function included in each leaf of the Merkle tree. The leaf that includes the data function may include other data, such as the length of the target data, for example in bytes. Alternatively, the length of the target data may be included as a different leaf of the Merkle tree. The length of the data may be used to determine the number of leaves of the Merkle tree.
[0073] 4 and 5, which are described in more detail below, illustrate the process of generating a Merkle tree based on a script that contains target data to be edited. As shown in FIG. 4, from left to right, a first group of functions (opcodes) forms the first leaf, followed by data functions and target data ( <pubkeyhash>) forms the second leaf, the second group of functions forms the third leaf, and the fourth leaf is formed by duplicating the third leaf. In Figure 5, the first data function (OP_RETURN) forms part of the first leaf, the second data function (OP_PUSHDATAX) together with the data length ([X-bytes]) forms part of the second leaf, and the target data is split across six leaf nodes.
[0074] Once a Merkle tree is generated based on the script, an edited version of the target transaction is generated by replacing the script with the Merkle root of the Merkle tree, thus the target data is encoded (and hidden) using the Merkle root.
[0075] A target transaction may include multiple respective scripts that contain respective target data. The above-described process of generating a Merkle tree based on the scripts may be performed for one, some, or all of the respective scripts. The respective scripts may be replaced by respective Merkle roots in the respective Merkle trees.
[0076] The reductor may send the edited transaction to one or more entities, such as a user 103 or a blockchain node 104. For example, the reductor may be a blockchain node 104 that receives a request from a user (e.g., Bob 103b) for a target transaction (not necessarily its edited version).
[0077] The redactor may generate a primary transaction identifier for the edited transaction. On some blockchains, the primary transaction identifier (TxID) is generated as a double SHA256 hash (or SHA256d = SHA256(SHA256(.))) of the serialized transaction (e.g., 32-bit Version, 32-bit LockTime, list of transaction inputs, list of transaction outputs, etc.). The primary transaction identifier TxID' for the edited transaction may be generated in a similar manner by hashing the edited transaction. The hash function used to generate the primary transaction identifier TxID' may be a SHA256 or double SHA256 hash function. Other hash functions, e.g., SHA512, may be used instead.
[0078] If the reductor is a transaction generator (e.g., a user, a wallet application, etc.), the reductor may generate a signature based on the edited transaction. Specifically, the signature is based on the message (i.e., is a function of the message), and the message is based on the edited transaction. For example, the message may be a serialized version of the transaction. Typically, the signature is based on the scripts of the transaction (whether those scripts are in raw form or hashed). Here, the signature is based on a Merkle root(s) that replaces one or more scripts. The signature signs one or more inputs and / or outputs of the edited transaction and is included in the inputs of the edited transaction. The signature may be a function of one or more additional items, e.g., a private key. For example, the signature may be an ECDSA signature. Another signature scheme may be used. For the edited transaction, the signature is included in the target transaction (i.e., the original, unedited version of the transaction) and submitted to the blockchain network 106 for validation. That is, an edited transaction is generated by replacing one or more scripts with their respective Merkle roots, a signature is generated based on the edited transaction and included in the original version of the transaction, and then the signed original transaction is sent to the blockchain network 106.
[0079] As mentioned above, the signature is included in the input of the target transaction. The input references the output of a previous transaction (the "previous output"). The output may include a script that contains the target data. Typically, part of the message to be signed is based on the previous output. Now, when constructing the message, the reductor builds a Merkle tree based on the script of the previous output (using the method described above) and replaces the script with the Merkle root. The message to be signed is then based on the Merkle root, rather than the script of the previous output.
[0080] If the reductor is a transaction validator (e.g., blockchain node 104), the transaction validator may obtain the target transaction, including the signature, and verify that the signature is valid for the message based on the edited transaction. The message is generated in the same manner as described above.
[0081] At least one of the scripts of the target transaction may be a lock script (first lock script). Here, "first" is used as a label and does not necessarily mean the first lock script in the list of lock scripts. If the reductor is a transaction validator, the reductor may store a Merkle root generated based on the first lock script in a database mapped to a modified primary transaction identifier of the target transaction. For example, the modified primary transaction identifier may be the key of a key-value pair, with the Merkle root of the first lock script being the value. If the target transaction has multiple outputs, the index of the output to which the first lock script belongs may form part of the key. The reductor may store multiple key-value pairs, each key associated with a respective output of a respective transaction. The database may be used to validate the transaction, as described below.
[0082] The transaction validator may obtain a second blockchain transaction that includes an input (first input) that references an output of the target transaction (e.g., the first output including the first locking script). Again, "first" is used simply as a label for the input that references the output of the target transaction. The first input of the second transaction includes the first unlocking script. The first output of the target transaction is referenced using the modified primary transaction identifier of the target transaction and an index of the first output. The transaction validator may validate the second transaction in one of several ways.
[0083] As a first option, the transaction validator retrieves the Merkle root mapped to the referenced output from the database and determines a partial lock script for the first lock script based on the first unlock script. The partial lock script includes a portion but not all of the lock script, e.g., all of the lock script up to the target data. The partial lock script also includes one or more hashes of the Merkle tree corresponding to the Merkle root. The hashes can be leaf hashes and / or inner hashes. Each hash is based directly (in the case of a leaf hash) or indirectly (in the case of an inner hash) on the target data. For example, referring to FIG. 3, the partial lock script can take the following form: OP_DUP OP_HASH160 H1H 23 The transaction validator may generate the partial locking script or may obtain it elsewhere, for example from the entity that submitted the second transaction to the blockchain or from a blockchain node 104.
[0084] The transaction validator uses information (e.g., data and / or functions) included in the first unlocking script to determine the format of the partial locking script, e.g., functions that are necessarily present (or at least likely to be present) in the partial locking script. The partial locking script may be determined based on a syntactic analysis of the first unlocking script. As an example, if the first unlocking script includes a signature followed by a public key, the transaction validator may assume that the first locking script includes a pay-to-public-key-hash script. The partial locking script may be set as a pay-to-public-key-hash script. As another example, the first unlocking script may include an indication of the format of the partial locking script. The transaction validator may perform a proof of inclusion to verify that the partial locking script belongs to a Merkle tree corresponding to a Merkle root. Upon verifying that the partial locking script belongs to a Merkle tree and is therefore part of the first locking script, the transaction validator validates the first unlocking script against the partial locking script. If the validation fails, the second transaction is rejected.
[0085] As a second option, rather than storing the Merkle root of the first output as the value of the key-value pair, the transaction validator may store the partial locking script of the first output as the value of the key-value pair mapped to the modified transaction identifier and the index of the first output. As described above, the partial locking script includes a portion of the first locking script in raw form (not including the target data) and one or more leaves or internal hashes of the Merkle tree generated based on the first locking script. For example, the partial locking script may include a set of functions and / or non-target data and a hash of the target data. Upon obtaining the second blockchain referencing the first output of the target transaction, the transaction validator retrieves the partial locking script from the database and validates the first unlocking script against the partial locking script. In other words, the remaining first locking script in raw form is executed together with the first unlocking script. If the validation fails, the second transaction is rejected.
[0086] As a third option, the first and second options may be combined. That is, the transaction validator may store both the Merkle root and the partial locking script in a database mapped to the modified primary transaction identifier and the index of the first output of the target transaction. In response to receiving the second transaction, the transaction validator may determine the raw portion of the partial locking script (e.g., based on an analysis of the first unlocking script) and perform a Merkle proof of inclusion using the partial locking script retrieved from the database to verify that the raw portion is indeed part of the first locking script. It then validates the raw portion of the partial locking script against the first unlocking script. If the validation fails, the second transaction is rejected.
[0087] The above description mainly focuses on generating a Merkle tree based on the individual scripts of the target transaction to generate an edited transaction. The reducer (which may be a user 103, a blockchain node 104, or another entity) may generate a Merkle tree based on the edited transaction. That is, a transaction-level Merkle tree is generated, whose leaves are formed from parts of the edited transaction. An example in which at least one of the fields of the edited transaction includes a Merkle root, such as the Merkle root of FIG. 3 or FIG. 4, is shown in FIG. 8. The Merkle root of the transaction Merkle tree serves as a second transaction identifier for the edited transaction. The edited transaction includes multiple fields, such as a version number, a lock time, one or more inputs, one or more outputs, etc. One or more leaves may include some or all of a single respective field. One or more leaves may include some or all of multiple respective fields.
[0088] This disclosure therefore recognises further ways in which Merkle trees can be utilized to enable validation of individual data fields of an edited transaction. The edited transaction is split (or parsed) into a set of data fields to generate a Merkle tree, i.e., different parts of the transaction are identified as separate data fields. The Merkle root acts as a novel secondary identifier for the transaction. For example, a querying user, who may be operating only a light client, can perform a proof using the secondary identifier to prove the presence of a (small) data field in the transaction, without having to retrieve and hash the complete transaction data.
[0089] 5. Selective Disclosure Using Merkle Script This section provides examples of how the embodiments described above can be implemented to edit blockchain content.
[0090] In this section, a new mechanism is provided that can be used to selectively disclose transaction data that utilizes Merkle analysis of blockchain scripts. Roughly speaking, a Merkle tree is computed for a particular script in a transaction, where the script can be an input or an output. The script is parsed from left to right, such that each sequence of consecutive opcodes is hashed with a hash function (e.g., SHA256) to create a leaf node.<data push> Whenever a script is encountered, the data can be hashed similarly to create a leaf node, or the data can be split into n chunks and each chunk hashed to create n leaf nodes. Once all the leaf nodes have been created, a Merkle tree root representing the script can be computed.
[0091] The properties of Merkle trees allow selective disclosure of information to be achieved very efficiently through hash computations rather than costly asymmetric operations such as signatures, secure multi-party computation, oblivious transfers, and zero-knowledge proofs.
[0092] 5.1 Merkle Script In embodiments, all scripts in a transaction are represented in Merkle-ized form as a "script Merkle tree". To summarize the approach, one can say that a script Merkle tree is generated from a script by treating each string of successive opcodes as a leaf node, treating each data push as a leaf node, and ordering the leaf nodes of the Merkle tree according to the order in which they appear in the script. An exemplary algorithm for Merklizing a script scriptMerklize(SCRIPT) is described below: 1. Parse the script from left to right: a. Each sequence of consecutive opcodes is grouped and the underlying raw representation in bytes is indexed as a leaf. b. <data>Each data push of the form =OP_PUSHDATAX [X bytes] [Data] is treated separately and indexed as a leaf, where OP_PUSHDATAX is one of OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4, and X is the size of [X bytes]. c. The leaves are ordered according to their index, with the leftmost leaf corresponding to the leftmost part of the script. 2. Create leaf nodes in the Merkle tree by hashing each leaf. Alternatively, one can take a double hash of each leaf instead (SHA256d=SHA256(SHA256(x)), where x is the pre-message). 3. A Merkle tree T is constructed and the root R is computed from the leaves, where padding is done in the usual way. A tree always has an even number of leaves. If there is an odd number of leaves, the last leaf may be duplicated. For example, if the last leaf in a tree is the left branch, then that last leaf is duplicated to the right leaf position.
[0093] OP_PUSHDATAX and [X bytes] are respectively examples of the data function and data length described in Section 4. The data length is used to indicate the length of the edited data.
[0094] In addition to the steps outlined above, we also add additional script-specific steps to allow for more granular selective disclosure of different parts of each data push in a given script. <data>The elements can be further decomposed. For example, the data contains media content in fixed-size frames that can naturally be divided into smaller blocks. In this scenario, we can simply add the following additional parts to our scriptMerklize() algorithm:
[0095] <data push> Whenever we encounter a , we can first split it into n chunks, compute the hash of each chunk, and create n leaves. The value of n can be fixed, or it can vary from script to script. Note also that in general, each of the chunks does not need to be of equal size.
[0096] If you do not split the following data,
number
number
[0097] Note: There is a trade-off to splitting the data into smaller chunks, but it comes at a computational cost due to hash function compression and increased Merkle tree calculations. Suppose the content data is 4480 bits. SHA256(content data) requires 9 compression functions and has only one leaf. However, if you split the content data into 448 bits, you have 10 data chunks, each chunk requiring one compression function, thus 10 compressions in total. The second option also increases the tree depth.
[0098] This algorithm produces a Merkle tree from any given script. The root R of this Merkle tree can be used in the updated TxID generation and SIGHASH algorithms described below. Consider now applying the above script Merkle algorithm to some example scripts.
[0099] 5.1.1 Working Example Example 1: Pay-to-Public-Key-Hash (P2PKH)
[0100] Given a simple "Pay-to-Public-Key-Hash" output, we can write the script as follows: SCRIPT=OP_DUP OP_HASH160 OP_PUSHDATA <pubkeyhash>OP_EQUALVERIFY OP_CHECKSIG Here, the SCRIPT is chunked into leaves like this:
number
[0101] An example of this is shown in Figure 4.
[0102] Note that the last leaf is duplicated as part of the tree computation. Also note that Merkle-izing a script does not remove or "hide" the script from the transaction. Instead, when we use the term "replace", we mean to use the Merkle root for the computation, not the script itself. We emphasize here that the ordering of the script and its data elements in the leaves of the Merkle tree must be preserved for onward validation of transactions that use it. Note that "onward validation" here refers to the validation of any future transactions that use the output of a transaction that has been edited and had one of its scripts replaced with Merkle-ization.
[0103] The subtlety here is that the validator, in addition to obtaining and executing the unedited portion of the script, may also need to perform an integrity check (i.e., a Merkle containment proof) to prove that the unedited script portion was part of the original script before it was partially edited. An exemplary process for this type of subsequent transaction validation is detailed below.
[0104] As an example of a possible edit, the P2PKH output in Figure 4 is used (i.e., assigned) in another transaction. Later, this P2PKH output can be edited (e.g., the script in Leaf1 is edited). Since we have H(leaf1), we know that the edited transaction is valid, and can therefore calculate the Merkle root of the script and the TxID that matches the transaction already mined. Furthermore, we can even prove that the pubkey in the scriptSig of the spend transaction is valid by taking the pubkey, manually recreating leaf1, the OP_PUSHDATA pubkeyhash, hashing it, and calculating a hash value that matches H(leaf1).
[0105] It is important to emphasize that this allows for efficient validation of onward spend of edited transactions when compared to alternative, more efficient ways of achieving the same effect, which may invoke zero-knowledge based protocols to prove integrity. The fact that Merkle tree validation tends to be more efficient than performing zero-knowledge proofs means that this method allows for more efficient validation of edited transactions.
[0106] Example 2: OP_FALSE OP_RETURN Assume that some data content is being inserted into a transaction with an OP_RETURN opcode, and that it contains some sensitive information (e.g., personal or illegal information) that requires selective disclosure of some parts while completely hiding other parts. Let: SCRIPT=OP_FALSE OP_RETURN <data> Where: <data>=OP_PUSHDATAX [X-bytes] [Data], where [X-bytes] is the byte length of [DATA].
[0107] We then build the leaves of the tree, and each leaf (from left to right) is either a set of opcodes or a data push. This means that every data push in a script is a leaf, and each cluster of opcodes is also a push. For example, a SCRIPT is chunked into leaves as follows, and data pushes are split into finer-grained chunks as explained above:
number
[0108] The data can be of various sizes. A system using this technique can configure n based on different criteria. Assume the size of the data is 4000 bits. The data can then be split using one of the following rules: The system fixes n and predefines it: Assume the system uses n=6. Then, each data leaf is
number
[0109] Figure 5 shows an example Merkle script with eight leaves, the first of which is a sequence of opcodes "OP_FALSE OP_RETURN", and the remaining leaves are data split into six chunks.
[0110] 5.2 Security Analysis Hash functions are subject to offline (brute force) attacks, and their use depends on whether the pre-image has sufficient entropy. If there is secret data in the transaction, it may be necessary to ensure that the secret part has sufficient entropy so that brute force attacks are not possible. More specifically, an adversary must not be able to extract the secret from the obfuscated (hashed or encrypted) message. Entropy here refers to the randomness gathered by the system for use in algorithms that require random data. Lack of good entropy makes the security system weak and unable to securely encrypt / obfuscate data. As a general rule of thumb, 128 bits is considered sufficient for all but the most sensitive applications.
[0111] In the following we classify how the mechanism of the present invention can be used by considering each case separately. If the secret data content has entropy greater than 128 bits: - Check whether each individual chunk of this secret content (i.e. the leaves of the Merkle tree) also has enough entropy. Privacy can still be maintained by concatenating with adjacent data until it has enough entropy, then only reveal the Merkle roots of those blocks. 1. For example, if Leaf2 does not have enough entropy, but has enough entropy when combined with Leaf1 and Leaf3, then H 4567 and Leaf4,…,Leaf N Only Leaf0, Leaf1, Leaf2, and Leaf3 are shared. If the entropy of the secret data content is less than 128 bits, but the entropy of the entire data content is greater than 128 bits: - Blocked (hidden) chunks are susceptible to offline attacks if they only hide the secret data content. - You can still maintain your privacy by: 1. Extract these 128 bits (public and private parts) and concatenate them to increase the entropy, 2. Keep this new value secret, 3. Leave the remainder of the public portion public; If the total script entropy is less than 128 bits - It is susceptible to offline attacks. - Still, for completeness, It does not disclose any part of the data other than the Merkle root of the data, as this is sufficient to validate the transaction.
[0112] 5.3 Layer 1 Application of Merkle Scripts We now consider how the concept of Merkle scripting can be applied to the design of a layer-1 blockchain system such as Bitcoin Core. The goal of this section is to explore how script Merkleization can be employed at the protocol level of a blockchain such as Bitcoin to allow nodes 104 to edit transaction information from their copy of the blockchain 150 without sacrificing the ability to validate future transactions related to those edits.
[0113] The previous section described in a general sense how to generate a Merkle root for a given script. This Merkle root can then be used in place of the script in existing computations that typically involve hashing the script itself, such as the SIGHASH algorithm or the TxID computation. The Layer 1 proposals in this section affect how the TxID is computed from the transaction data, but do not affect what is included in the transaction message itself. As explained in a later section, the construction of the TxID uses the script Merkle root instead of the raw opcodes, but the transaction itself still contains the script in its entirety.
[0114] Note that Merkle-ing a script is typically done when a piece of data needs to be edited after the original transaction has been broadcast.
[0115] The method requires modifications to the following aspects of existing blockchain implementations: Transaction ID (TxID) configuration SIGHASH algorithm Transaction Validation
[0116] These modifications allow a transaction to be validated even in the absence of the complete original transaction script data, which is useful if some of the transaction data is identified as fraudulent at some point after the transaction is included in block 151, because it allows node 104 to validate subsequent uses of the transaction outpoint that contains the illicit data (e.g., if the edited script validation fails while bootstrapping a node, the transaction may be assumed to be valid if it is sufficiently "deep" in the blockchain) and allows end users to perform proofs of existence of the remaining non-illicit data in the transaction.
[0117] 6 shows an example flow of a transaction. In step 1, the script of the target transaction is Merkled. The transaction may be signed, for example, using a modified SIGHASH algorithm described below. In step 2, the original target transaction (which may include the signature generated in step 1) is submitted to the blockchain 150. In step 3, the target data from the transaction is redacted by Merkling the script.
[0118] 5.3.1 Modification of TxID construction protocol In the current implementation of Bitcoin, the transaction identifier (TxID) is calculated as the SHA256d of the raw transaction data Tx and can be written as:
number
[0119] However, computing the TxID requires the full raw transaction data, which is desirable to avoid when dealing with corrupted or large data that may be undesirable to process. To accommodate Merkle-ized scripts, the TxID of every transaction can be computed using a new algorithm, computeTxID(), as follows: 1. Get the complete transaction data for transaction Tx. 2. Blank out the script data for each script to produce an abbreviated transaction, denoted as Tx'. 3. In place of each blanked out script, place the Merkle root of that script, previously computed by the scriptMerklize(SCRIPT) algorithm. The result is Tx". 4. Calculate TxID”=SHA256d(Tx”).
[0120] This defines a new (primary) transaction ID that can be used to uniquely reference a transaction without the risk of reconstructing the TxID that depends on edited script data.
[0121] Stated another way, a transaction has the same TxID even if parts of the script are later edited.
[0122] Note that in this example we chose to use the SHA256 hash function, which means that every script is replaced with a 32-byte hash digest, regardless of the size of the script being replaced. If a different hash function was chosen for the scriptMerklize() algorithm, the length of the replacement digest could be different.
[0123] 5.3.2 Modification of the SIGHASH algorithm Existing implementations of Bitcoin include the SIGHASH algorithm, which defines the serialization of Bitcoin transactions into messages to be signed by ECDSA signatures and used in the unlock script. A key feature of the SIGHASH algorithm is that when generating a serialized message to sign a particular transaction input, it ensures that the message also includes the previous lock script and the previous outpoint that have been consumed in that input. This means that the serialized message to be signed explicitly depends on the previous lock script. Importantly, it is necessary to ensure that this previous lock script was in fact part of a previous transaction, which is achieved by ensuring that the previous lock script was indeed part of the previous transaction, as the double hash is generated by the TxID. Prev The raw transaction that produces Tx Prev The complete SIGHASH algorithm can be written as follows, with the data types given in parentheses: 1.Tx current nVersion in (4 bytes, little endian) 2. SHA256d (32 byte hash) of the serialization of all input outpoints If the ANYONECANPAY flag is set, this must be 32 bytes of zeros. 3. SHA256d (32-byte hash) of the serialization of nSequence of all inputs If the ANYONECANPAY flag is set, this must be 32 bytes of zeros. 4. The outpoint used (32 bytes of transaction ID + 4 bytes of index, little endian). 5. Byte length of subScript (big endian). 6. subScript (defined below) 7. Output amount in satoshis (8-byte little endian). 8. nSequence of this outpoint (4 bytes, little endian) 9. SHA256d of the serialization of all output quantities and scriptPubKeys. These are Tx current The output is taken from If the SINGLE flag is set and the input index is less than the number of outputs, this should be the double SHA256 of the output with the scriptPubKey at the same index as the input. If the NONE flag is set, this must be 32 bytes of zeros. 10. Transaction Tx current nLocktime (4 bytes, little endian) 11. Signature sighash type (4 bytes, little endian)
[0124] Step 6 in the above algorithm relies on the subScript being generated using the previous lock script and prevOuts. The relationship between the previous transactions is as follows: "A new subScript is created from the previousScriptPubKey. The subScript starts with the most recent OP_CODESEPARATOR (the one immediately preceding the OP_CHECKSIG that is [being executed]) to the end of the previousScriptPubKey. If no OP_CODESEPARATOR is present, the previousScriptPubKey becomes the subScript.
[0125] This dependency of the SIGHASH algorithm on the raw previousScriptPubKey presents a problem in cases where the previous lock script being used may contain data that one would like not to share, such as illicit data, and thus if it is edited it will no longer be usable and step 6 will fail.
[0126] Example of further validation with the edited script: We use the term "subsequent validation" or "subsequent use" of a transaction T1 to refer to the validation of any subsequent transaction Tx2 that uses any output of Tx1. For example, let Tx1 and Tx2 be transactions that have already been mined in the blockchain:
number
[0127] The following scenario highlights how the existing SIGHASH algorithm will fail to handle redacted script data. Validate Tx2, where Tx2 is using the output of Tx1 which will be redacted later, since SIGHASH involves hashing the redacted output scriptPubKey which is now missing data. Validate Tx2, where SIGHASH involves hashing the OP_RETURN output which is currently missing data, so Tx2 is sending output which will be edited later.
[0128] This problem is solved by replacing the previousScriptPubKey used in the SIGHASH algorithm with the Merkle root for the lock script, which is generated using scriptMerklize(previousScriptPubKey). This means that the entire SIGHASH algorithm can be run, and thus the signatures validated, using only the Merkle root of the previous lock script. More generally, all scripts can be replaced with their scriptMerklize() root when signing them. This is a rule that can be implemented in new versions of the SIGHASH algorithm, such that any script signed by an ECDSA signature will have its Merkle root substituted during the message construction process.
[0129] 5.3.3 Subsequent Validation of Transactions When signing a transaction as described above, the SIGHASH algorithm (depending on the SIGHASH flag) typically involves hashing the output script (and other data) into a digest that is later signed. In our new construction, a new serialization algorithm for the message is used before signing (e.g., ECDSA). The difference is that the SIGHASH algorithm uses a Merkle root rather than the script itself. This allows for subsequent validation of the signature by parties that only received the edited transaction that it may have signed. Note that this modified SIGHASH algorithm is only called in the normal places, i.e. when the OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG, or OP_CHECKMULTISIGVERIFY operations are called.
[0130] For example, OP_RETURN data has been edited, OP_FALSE OP_RETURN <data>Consider the case of a transaction with an output containing: In the original Bitcoin transaction, we need the output script of the UTXO to hash, but in the edited transaction, this data is not available and we cannot reconstruct it. Therefore, we cannot reconstruct the signed digest. In our new construction, subsequent validation is possible if the Merkle root of the script is provided to the receiving party who must validate the transaction for the purposes of the hashing process for the signature. The signature in the transaction can be verified by running the same SIGHASH algorithm to generate the digest.
[0131] Note that this proposed modification to the SIGHASH algorithm is specifically designed to ensure that the creation and validation of ECDSA signatures is not hindered by editing of the script. The inventive modification achieves this for all signatures, regardless of whether those signatures attempt to use edited outputs or not.
[0132] The next section describes the steps necessary to perform transaction validation in this scenario, so that editing one part of a transaction does not prevent future transactions from using its outputs.
[0133] 5.3.4 Updated Transaction Validation In the previous section we showed how the SIGHASH algorithm can be updated so that it does not depend on the previous lock script for the input in its raw form. This allows us to verify the signature without knowing the complete previous raw lock script. However, when validating a transaction, verifying the ECDSA signature(s) in the unlock script is only one part of the process. When a spend transaction attempts to use a partially edited lock script, it is also necessary to verify that the part of the previous lock script being filled by the spend transaction was in fact part of the original lock script. This can be done by verifying the previous lock script with the previous TxID. Prev This can be done by mapping it to, which also encodes the Merkle script.
[0134] One way to do this is to use the format (TxID Prev ,i Prev ) out point
number
[0135] In the existing system, the UTXO database is Prev ,i Prev ) : Behaves like a key-value store of the form [Locking Script], where the key is stored in a unique identifier (TxID) based on an existing transaction identifier. Prev and output index i Prev where the value stored for an outpoint is its corresponding lock script. A high-level statement of the process performed in the node software when validating future use of this output is as follows: 1. Spending transaction Tx current and parses the outpoint TxID referenced by the input. Prev ,i Prev Get the. 2. For each obtained outpoint j, retrieve the corresponding [Locking script] from the UTXO database. 3.Tx Current For each input k of , validate its [Unlocking script] against the corresponding retrieved [Locking script]. The second step in the above process is when the previous lock script is attached to the referenced outpoint, under the assumption that the UTXO database has been correctly maintained and therefore the integrity of the previous lock script is sound.
[0136] If a node 104 wishes to implement the proposed Merkle script system rather than storing the entirety of the previous lock script(s), the above process can be modified to store the Tx Current This allows the integrity of partial locking scripts used in a locking script to be ensured. A partial locking script may provide some data leaves and hide others, and in some cases may only contain hashes of the hidden data leaves. For example, if a previous locking script has OP_CHECKSIG OP_FALSE OP_RETURN <data>If so, instead of storing the complete script, node 104 need only store the OP_CHECKSIG and the corresponding leaf hash for the OP_RETURN data leaf in Merkle format for the script.
[0137] There are roughly three ways one might try to modify a UTXO database implementation for this purpose: 1) storing Merkle-ized script root(s), 2) storing the desired partial script, or 3) a combination of both.
[0138] 5.3.4.1 Remembering the Merkle Root If the UTXO database stores the script Merkle root, it will Prev ,i Prev ) : It behaves like a key-value store of the form [Merkle root], where [Merkle root] is the root R that results from applying the scriptMerklize() algorithm to [Locking script].
[0139] The transaction validation process then proceeds to Current To ensure the integrity of the previous lock script(s) being consumed in, the following can be modified: 1. Spending transaction Tx Current and parses the out-point (TxID Prev ,i Prev ) to get the 2. For each obtained out-point j: 2.1 Extract the corresponding [Merkle root] from the UTXO database. 2.2 Tx Current 2. Parse the [Unlocking script] of the transaction to determine the [Partial Locking Script] used by the transaction. 2.3 Perform a Merkle containment proof to verify that the [Partial Locking Script] is a member of the set under the [Merkle Root]. 3.Tx Current For each input k of , validate its [Unlocking script] against the corresponding [Partial Locking script] that has been retrieved and integrity checked.
[0140] Note that in step 2.2, parsing was used to determine the previous partial unlock script. However, this is not the case for e.g. Tx Current If the input contains an explicit indication that a partial script has been satisfied, it may be replaced in the implementation in several ways. This partial script may also be delivered as part of the messaging protocol between the transaction submitter and the validator.
[0141] 5.3.4.2 Memorizing partial scripts If the UTXO database stores a partial script, the UTXO database stores the TxID Prev ,Index Prev It behaves like a key-value store of the form "Partial locking script: [Partial locking script]", where [Partial locking script] is the portion (or portions) of the locking script that a Bitcoin node chooses to retain as other script data is pruned and removed.
[0142] The transaction validation process then proceeds to Current To ensure the integrity of the previous lock script(s) being consumed in, it can be modified as follows: 1. Spending transaction Tx Current and parses the outpoint TxID referenced by the input. Prev ,Index Prev Get the. 2. For each obtained outpoint j, extract the corresponding [Partial locking script] from the UTXO database. 3.Tx Current For each input k of , validate its [Unlocking script] against the corresponding retrieved [Partial locking script].
[0143] This case is identical to the existing implementation, except that the retrieved script is only a portion of the complete previous locking script. Again, we use the assumption that the integrity of the UTXO database, and therefore the partial locking script, is guaranteed by node 104 having previously processed the entire history of blockchain 1.
[0144] Note that because nodes asked to block content may block different data depending on, for example, jurisdiction, court order, and preferences, there may be multiple versions of a prior lock script that are blocked in different ways. Note that the UTXO database may contain multiple partial prior lock scripts for the same outpoint, e.g., "TxID Prev ,Index Prev : [Partial script 1] [Partial script 2]" is memorized, Tx Current It may be necessary to indicate which partial scripts should be extracted to correspond to the unlock script used above. For example, assume a transaction contains a medical record with multiple distinct fields A, B, C. In one jurisdiction (e.g., the US) it may be necessary to block fields A and C, while in another jurisdiction (e.g., the UK) it may be necessary to block only fields A and B. Thus, a miner serving both the US and the UK needs to have both views of the transaction based on different blocking criteria.
[0145] This is especially relevant when a prior unlock script may have multiple different branches that can be satisfied independently. That is, a transaction with an OP_IF brandy may be validated with very different unlock scripts, perhaps one miner will hold the OP_IF... part, but another will hold the OP_ELSE... part. Each miner can only validate the use of this script based on one of two "views" of Tx, depending on which one is blocked. As in the case of Merkle root storage, this means that it is possible to determine which prior lock script part is in Tx. Current This can be done by providing an indication of whether the input is satisfied.
[0146] 5.3.4.3 Complex Storage In the last case, a node 104 may wish to implement a UTXO database by storing both the script Merkle root and partial scripts for outpoints in the UTXO set, allowing the node to regenerate Merkle proofs needed to validate spend transactions on the fly, rather than sourcing them from an external source.
[0147] The transaction validation process then proceeds to Current To ensure the integrity of the previous lock script(s) being consumed in, it can be modified as follows: 1. Spending transaction Tx Current and parses the out-point (TxID Prev ,i Prev ) to get the 2. For each obtained out-point j: 2.1 Extract the corresponding [Merkle root] from the UTXO database. 2.2 Tx Current 2. Parse the [Unlocking script] of the transaction to determine the [Partial Locking Script] used by the transaction. 2.3 Obtain a Merkle proof of a particular [Partial Locking Script] by using the leaves generated by the remaining Partial Locking Scripts. 2.4 Perform a Merkle containment proof to verify that the [Partial Locking Script] is a member of the set under the [Merkle Root]. 3.Tx Current For each input k of , validate its [Unlocking script] against the corresponding [Partial Locking script] that has been retrieved and integrity checked.
[0148] Note that this updated validation method is identical to the case where a node only stores the script Merkle root, except for the addition of step 2.3, where the Merkle proof is now generated from other partial script data stored in the UTXO database.
[0149] 5.3.5 Blocking Transaction Content by Selective Disclosure of Data Leaf In this section, we describe an inclusion proof for the secret data to be blocked, which allows us to easily validate the correctness of a transaction given the Merkle root, the leaves (i.e., the plaintext public data), and the hash values of the leaves (of the blocked data).
[0150] Below we provide a specific script (OP_FALSE OP_RETURN) but can easily be generalized to any Bitcoin script. Let us say:
number
[0151] Assume that the OP_RETURN data contains secret or illicit content. In such a case, share the maximum number of data blocks and child hashes to avoid disclosing any information about the secret content while the Merkle root can still be computed. For example, assume transaction TxID contains the following:
number
[0152] Figure 7 shows an example transaction that includes usable and unusable outputs. This example shows how the transaction looks from both a TxID calculation and transaction validation perspective.
[0153] 5.4 Transaction Merkle Tree As described above, a Merkle tree may be generated using the fields of an edited transaction to generate a secondary transaction identifier for the edited transaction for use in determining whether the transaction contains certain data, referred to as a “candidate data field.” The secondary transaction identifier is so called because in most blockchain protocols, each transaction is associated with a primary transaction identifier that is typically generated by hashing (or double hashing) the entire transaction.
[0154] An exemplary technique involves splitting a transaction by field into a set of data packets (or data fields) that can be used as leaves of a Merkle tree, with the root of the Merkle tree corresponding to a secondary transaction identifier. Here, splitting is equivalent to identifying the data fields of the transaction. In other words, the transaction does not actually need to be "split". Instead, different parts of the transaction can be identified (e.g., assigned) as different sets of data fields. The secondary transaction identifier is unique for a given transaction (e.g., a unique 256-bit numeric representation (hash value) of the given transaction). This hash value can be used to verify whether any individual field was a valid leaf of the Merkle tree without obtaining the entire set (i.e., the complete transaction).
[0155] Given a transaction Tx, one way to verify that it is included in a block of a blockchain is to verify that its corresponding TxID (primary transaction identifier) appears in the block. This check can be done by performing a Merkle tree proof (e.g., a Merkle proof) to verify that the transaction corresponding to TxID is part of the transaction set represented by the hash root in the block header. However, this check requires the verifier to first obtain the complete transaction message m=Tx and verify that TxID=H(Tx) does indeed hold for the given Tx and the expected TxID, where H is a hash function. This can be problematic for some users of the blockchain, especially when users implement light clients and / or the message m is large.
[0156] In the example, a secondary transaction identifier MTxID may be generated according to the following definition:
number
number
number
[0157] The method for generating the secondary transaction identifier MTxID can be divided into three main stages, as summarized below. Input:Tx F(Tx): 1) TxID:=H 2 (Tx) (note that this is an optional step). 2) Tx, N=2 k A set D of ordered data packets,
number
[0158] 5.4.1 Step 1: Calculate TxID The method may include generating a primary transaction identifier by hashing the transaction. The first stage is a SHA-256 double hash calculation performed on Tx, which generates a primary transaction identifier, TxID. Other hash functions may be used, and in some instances, only a single hash calculation is performed. Typically, the Tx message itself does not explicitly include the TxID. Subsequent stages therefore require this explicit pre-computation of the TxID, so that a Merkle tree can be constructed that explicitly encodes this primary identifier.
[0159] 5.4.2 Phase 2: Separation of Tx into an ordered dataset D The transaction data, including the message Tx, is separated into individual packets that can be used as leaves of the Merkle tree T. The transaction may be split into its existing fields. Most of these fields contain simple numeric data that is generally very small in size, typically in the range of 1-32 bytes. Thus, most of the transaction is concerned with the sigScript and scriptPubKey fields, which are concerned with input (unlock) and output (lock), respectively. The fields of the transaction may be differentiated using three categories: input fields, output fields, and other fields. In some examples, the transaction is split into these three categories, e.g., one data field containing all input fields, one data field containing all output fields, and one data field containing other fields. The input and output fields may be separated into non-scripted and scripted fields, where the non-scripted fields contain numeric data and the scripted fields contain scripted data.
[0160] The following table shows how a transaction can be divided into a set of data fields. [Table 1]
[0161] The table shows that the Tx message can be divided into its constituent fields to form a set of packets D in a number of ways.
[0162] In some examples, a transaction may be divided into at least one data field containing input data of the transaction (e.g., txid_prev), at least one data field containing output data of the transaction (e.g., values), and at least one data field containing non-input and non-output data of the transaction (i.e., other data, e.g., version). Each data field may consist of only one type of data, e.g., only input data.
[0163] In other examples, a transaction may be divided into more data fields. For example, the set of data fields may include at least one data field containing script input data (e.g., scriptSig) of the transaction, at least one data field containing non-script input data (e.g., vout) of the transaction, at least one data field containing script output data (e.g., scriptPubKey) of the transaction, and at least one data field containing non-script output data (e.g., scriptPubKeyLen) of the transaction.
[0164] It should be noted that, according to this disclosure, each scriptSig and scriptPubKey may be replaced with the corresponding Merkle root of the Merkle tree generated based on the respective script.
[0165] A transaction Tx may be divided into the following set of ordered data packets: D1= <version>、 D2=<txin_count> 、 D3=<txout_count> 、 D4= <locktime>、 D5=<txid_prev>|| <vout> || <scriptsiglen> || <sequence> 、 D6= <scriptsig>Merkle root of D7= <value> || <scriptpubkeylen> 、 D8= <scriptpubkey>Merkle root.
[0166] The choice to split the data in this way, where each packet Di is a leaf of a binary Merkle tree, has several advantages. First, all non-scripted inputs are concatenated to form packet D5, and similarly, all non-scripted outputs are concatenated to form D7. This means that every input and output of a transaction is split into exactly two parts: a non-scripted component and a scripted component (or, more precisely, its Merkle root). This is advantageous because it means that every input and output can be paired as sibling leaves. Thus, inputs and outputs can be completely separated from other fields, and the scripted and non-scripted components of each input or output can also be separated.
[0167] In addition to these fields, the TxID may also be included as a leaf of the Merkle tree T. Following the above example, this means that the data field D9= <txid>In general, a transaction has many inputs and many outputs, each of which is split into two components by an algorithm F. Thus, the total number of data blocks in this tree T, N=|D|, is given by:
number
[0168] N=2 k Such as
number
[0169] 5.4.3 Step 3: Create a Merkle tree T using D and compute the root R The method includes using the set of data fields as leaves of a transaction Merkle tree. The transaction Merkle tree includes a leaf layer, one or more internal layers, and a root layer. The leaf layer includes multiple leaf nodes (also called leaf hashes because each node is a hash digest). Each leaf node is generated by hashing a respective data field of a transaction. At least one of the leaf hashes is based on a primary transaction identifier. In some examples, the one or more leaf hashes are generated by hashing the primary transaction identifier. In some examples, one or more fields of a transaction are concatenated with the primary transaction identifier and then hashed to generate a respective leaf hash. Each internal layer includes multiple internal nodes (or internal hashes). Each internal hash in a given internal layer is generated by hashing the concatenation of at least two hashes from lower layers. For example, the first or lowest internal layer (i.e., the internal layer directly connected to the leaf layer) includes an internal node generated by hashing the concatenation of at least two leaf hashes. The root layer includes the Merkle root of the transaction tree, i.e., the secondary transaction identifier. The secondary transaction identifier is generated by hashing the concatenation of the internal hashes of the highest internal layer (ie, the internal layer directly connected to the root layer) of the one or more internal layers.
[0170] The secondary transaction identifier (the Merkle root of the transaction Merkle tree) may be included in the creation transaction of the block, which may then be recorded in the blockchain. Alternatively, as described below, the secondary transaction identifier may be included in a transaction that is sent to the nodes via one or more nodes of the network.
[0171] Algorithm F takes an ordered set of data packets D and constructs a Merkle tree T by using these packets as leaves. Figure 8 shows an example construction of a binary Merkle tree. In this example, the first four data fields D1,...,D4 are the miscellaneous fields of the transaction, and the next 2×(n in +n out ) Data fields are input and output fields represented as pairs of scripted D5, D6 and non-scripted D7, D8 field data. The remaining data fields are at least one field D9, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, D31, D32, D33, D34, D35, D36, D37, D38, D40, D41, D42, D43, D44, D45, D46, D47, D48, D49, D50, D51, D52, D53, D54, D55, D56, D57, D58, D60, D61, D62, D63, D6 10 and for some integer k, N=2 k Any padding required to reach D N Includes:
[0172] 6. Further notes Other variations or use cases of the disclosed techniques may become apparent to one of ordinary skill in the art given the disclosure herein. The scope of the present disclosure is not limited by the described embodiments, but only by the appended claims.
[0173] For example, some embodiments above are described with respect to the Bitcoin network 106, the Bitcoin blockchain 150, and the Bitcoin nodes 104. However, it will be understood that the Bitcoin blockchain is one particular example of the blockchain 150, and the above description may generally apply to any blockchain. That is, the present invention is not limited to the Bitcoin blockchain. More generally, any references above to the Bitcoin network 106, the Bitcoin blockchain 150, and the Bitcoin nodes 104 may be replaced with references to the blockchain network 106, the blockchain 150, and the blockchain nodes 104, respectively. The blockchains, blockchain networks, and / or blockchain nodes may share some or all of the described characteristics of the Bitcoin blockchain 150, the Bitcoin network 106, and the Bitcoin nodes 104 as described above.
[0174] In a preferred embodiment of the present invention, the blockchain network 106 is the Bitcoin network, and the Bitcoin nodes 104 perform at least all of the described functions of creating, issuing, propagating, and storing blocks 151 in the blockchain 150. It is not excluded that there may be 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 function of propagating and / or storing blocks without creating and issuing blocks (recall that these entities are not considered to be nodes of the preferred Bitcoin network 106).
[0175] In other embodiments of the present invention, the 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 creating, issuing, propagating, and storing blocks 151 of the blockchain 150. For example, on those other blockchain networks, a "node" may be used to refer to a network entity that is configured to create and issue blocks 151 but not store and / or propagate those blocks 151 to other nodes.
[0176] Even more generally, any reference above to the term “Bitcoin node” 104 may be replaced with the term “network entity” or “network element”, where such entity / element is configured to perform some or all of the roles of creating, issuing, propagating, and storing blocks. The functionality of such network entity / element may be implemented in hardware in the same manner as described above with reference to blockchain node 104.
[0177] It will be understood that the above embodiments have been described by way of example only. More generally, a method, apparatus or program may be provided according to any one or more of the following statements:
[0178] <Statement 1> A computer-implemented method for editing data of a blockchain transaction, comprising: Obtaining a first blockchain transaction, the first blockchain transaction including one or more respective scripts including respective target data to be edited; for at least one of the one or more respective scripts, constructing a respective Merkle tree based on the respective script, wherein the respective target data is partitioned across one or more of the respective leaves of the respective Merkle tree; generating an edited version of the first blockchain transaction by replacing at least one respective script with a respective Merkle root of a respective Merkle tree; The method includes:
[0179] <Statement 2> A method as described in Statement 1, wherein each respective script includes one or more functions, and the step of constructing respective Merkle trees includes grouping one or more respective sequences of consecutive functions as respective leaves of the Merkle tree.
[0180] <Statement 3> The method described in Statement 2, wherein each respective script includes a respective data function configured to, when executed, indicate respective target data, and wherein the step of constructing respective Merkle trees includes including the respective data function as part of a respective leaf of the respective Merkle tree.
[0181] <Statement 4> The method described in Statement 3, wherein each respective script includes a respective data length of the respective target data, and the step of constructing each respective Merkle tree is based on the respective data length.
[0182] <Statement 5> The method of statement 4, wherein the step of constructing each Merkle tree includes including each data length as part of each leaf of each Merkle tree that is the same as each data function.
[0183] <Statement 6> The method of any of the preceding statements, wherein each target data is partitioned across a plurality of respective leaves of a respective Merkle tree.
[0184] <Statement 7> The first blockchain transaction includes a plurality of respective scripts including respective target data, and the method further includes: for each of a plurality of respective scripts, constructing a respective Merkle tree based on the respective script, wherein the respective target data is partitioned across one or more of the respective leaves of the respective Merkle tree; generating an edited version of the first blockchain transaction by replacing each respective script with a respective Merkle root of a respective Merkle tree; The method according to any of the preceding statements, including
[0185] <Statement 8> The method of any of the preceding statements, comprising generating a primary transaction identifier for an edited version of the first blockchain transaction by hashing the edited version of the blockchain transaction.
[0186] <Statement 9> A method according to any of the preceding statements, comprising: sending an edited version of the blockchain transaction to an entity in response to a request for the first blockchain transaction.
[0187] <Statement 10> A method according to any of the preceding statements, comprising storing an edited version of the first blockchain transaction in a memory.
[0188] <Statement 11> The method according to any of the preceding statements, executed by a transaction generator.
[0189] <Statement 12> A step of generating a signature for a message, where one or more portions of the message are based on an edited version of the first blockchain transaction; Including the signature in an input of a first blockchain transaction; submitting a first blockchain transaction to a blockchain network for validation; The method according to claim 11, comprising:
[0190] <Statement 13> The method according to statement 12, wherein the signature is an Elliptic Curve Digital Signature Algorithm (ECDSA) signature.
[0191] <Statement 14> The method of statement 12 or statement 13, wherein the input references an output of a previous blockchain transaction including a respective script including the respective target data, a portion of the message is based on the output of the previous blockchain transaction, a portion of the message based on the output of the previous blockchain transaction is based on the Merkle root of a Merkle tree constructed based on the respective script, and each target data is partitioned across one or more of the respective leaves of the respective Merkle trees.
[0192] <Statement 15> The method according to any of statements 1 to 10, wherein the method is executed by a transaction validator.
[0193] <Statement 16> Extracting a signature from an input of a first blockchain transaction; verifying a signature on a message, where one or more portions of the message are based on an edited version of the first blockchain transaction; The method described in statement 15.
[0194] <Statement 17> The method described in statement 16, wherein the input references an output of a previous blockchain transaction including a respective script including the respective target data, a portion of the message is based on the output of the previous blockchain transaction, a portion of the message based on the output of the previous blockchain transaction is based on the Merkle root of a Merkle tree constructed based on the respective script, and each target data is partitioned across one or more of the respective leaves of the respective Merkle trees.
[0195] <Statement 18> The method of statement 15 or any statement subordinate thereto, comprising storing an edited version of the first blockchain transaction in the blockchain.
[0196] <Statement 19> At least one of the respective scripts is a first locking script of a first output of a first blockchain transaction, and the method further comprises: storing in a database each Merkle root that is mapped to a modified primary transaction and an index for each of the first outputs; The method according to any one of statements 8 and 15 to 18, comprising:
[0197] <Statement 20> A step of obtaining a second blockchain transaction, the second blockchain transaction including a first input that references a modified primary transaction identifier of the first blockchain transaction and an index of the first output, the first input including a first unlocking script; The method includes: Retrieving from the database the modified primary transaction identifier and each Merkle root mapped to a respective index of the first output; determining a partial locking script for a first output based on a first unlocking script for a first input; performing a Merkle containment proof to verify that the partial lock script is a respective leaf of a respective Merkle tree corresponding to a respective Merkle root; Validating the first unlock script against the partial lock script; Validating the second blockchain transaction by The method according to claim 19, comprising:
[0198] <Statement 21> At least one of the respective scripts is a first locking script of a first output of a first blockchain transaction, and the method further comprises: storing a partial locking script in a database mapped to the modified primary transaction identifier and an index of each of the first outputs, the partial locking script including at least a portion of the first locking script but not including the target data; The method according to any one of statements 8 and 15 to 18, comprising:
[0199] <Statement 22> A step of obtaining a second blockchain transaction, the second blockchain transaction including a first input that references a modified primary transaction identifier of the first blockchain transaction and an index of the first output, the first input including a first unlocking script; The method includes: Retrieving from the database each partial lock script mapped to the modified primary transaction identifier and each index of the first output; Validating the first unlock script against the partial lock script; Validating the second blockchain transaction by The method according to statement 21, comprising:
[0200] <Statement 23> Retrieving from the database each Merkle root and partial lock script that is mapped to the modified primary transaction identifier and each index of the first output; determining a partial locking script for the first output based on a first unlocking script for the first input; obtaining a Merkle proof for the determined partial lock script using one or more respective leaves generated based on the retrieved partial lock script; performing a Merkle containment proof to verify that the determined partial lock scripts are respective leaves of respective Merkle trees corresponding to respective Merkle roots; validating the first unlock script against the determined partial lock script; The method according to statements 19 and 21, comprising:
[0201] <Statement 24> The edited transaction includes multiple fields, and the method is generating a transaction Merkle tree, each of a plurality of respective leaves of the transaction Merkle tree being formed from one or more fields of the edited transactions; generating a secondary transaction identifier for the edited transaction, the secondary transaction identifier including the Merkle root of the transaction Merkle tree; The method according to any of the preceding statements, including
[0202] <Statement 25> The method of statement 24, wherein one or more leaves of the transaction Merkle tree are formed from multiple fields of the edited transaction.
[0203] <Statement 26> The method of statement 24 or statement 25, wherein one or more leaves of the transaction Merkle tree are formed from a single field of an edited transaction.
[0204] <Statement 27> The method of statement 24 or any statement dependent thereon, wherein one or more leaves of the transaction Merkle tree are formed from respective portions of respective fields of edited transactions but not from complete respective fields.
[0205] <Statement 28> A computer device, a memory comprising one or more memory units; A processing device comprising one or more processing units, the memory storing code configured to be executed on the processing device, the code being configured, when on the processing device, to perform a method according to any of statements 1 to 27; 1. A computer device comprising:
[0206] <Statement 29> A computer program embodied in a computer-readable storage device and configured to execute the method according to any one of statements 1 to 27 when executed on one or more processors.< / txid> < / scriptpubkey> < / scriptpubkeylen> < / value> < / scriptsig> < / sequence> < / scriptsiglen> < / vout> < / locktime> < / version> < / data> < / data> < / data> < / data> < / data> < / data> < / data> < / pubkeyhash> < / data> < / data> < / data> < / pubkeyhash> < / data>
Claims
1. 1. A computer-implemented method for compiling data of a blockchain transaction, comprising: Obtaining a first blockchain transaction, the first blockchain transaction including one or more respective scripts including respective target data to be edited; for at least one of the one or more respective scripts, constructing a respective Merkle tree based on the respective script, the respective target data being partitioned across one or more of the respective leaves of the respective Merkle tree; generating an edited version of the first blockchain transaction by replacing the at least one respective script with a respective Merkle root of the respective Merkle tree; The method includes:
2. 2. The method of claim 1 , wherein each respective script includes one or more functions, and wherein said step of constructing the respective Merkle trees includes grouping one or more respective sequences of consecutive functions as respective leaves of the Merkle tree.
3. 3. The method of claim 2, wherein each respective script includes a respective data function configured to, when executed, reveal the respective target data, and wherein said step of constructing the respective Merkle trees includes including the respective data function as part of a respective leaf of the respective Merkle tree.
4. 4. The method of claim 3, wherein each respective script includes a respective data length of the respective target data, and wherein constructing the respective Merkle trees is based on the respective data lengths.
5. 5. The method of claim 4, wherein said step of constructing said respective Merkle trees comprises including said respective data lengths as part of each leaf of said respective Merkle trees as said respective data functions.
6. 2. The method of claim 1, wherein the respective target data is partitioned across a plurality of the respective leaves of the respective Merkle tree.
7. The first blockchain transaction includes a plurality of respective scripts including respective target data, and the method further comprises: for each of the plurality of respective scripts, constructing a respective Merkle tree based on the respective script, the respective target data being partitioned across one or more of the respective leaves of the respective Merkle tree; generating the edited version of the first blockchain transaction by replacing each respective script with a respective Merkle root of the respective Merkle tree; The method of claim 1 , comprising:
8. 2. The method of claim 1, comprising generating a primary transaction identifier for the edited version of the first blockchain transaction by hashing the edited version of the blockchain transaction.
9. 2. The method of claim 1, further comprising: sending the edited version of the blockchain transaction to an entity in response to a request for the first blockchain transaction.
10. 2. The method of claim 1, further comprising storing the edited version of the first blockchain transaction in a memory.
11. The method of claim 1 , wherein the method is performed by a transaction validator.
12. Extracting a signature from an input of the first blockchain transaction; verifying the signature on a message, where one or more portions of the message are based on the edited version of the first blockchain transaction; The method of claim 11.
13. 13. The method of claim 12, wherein the inputs reference an output of a previous blockchain transaction including a respective script that includes the respective target data, a portion of the message is based on the output of the previous blockchain transaction, the portion of the message based on the output of the previous blockchain transaction is based on a Merkle root of a Merkle tree constructed based on the respective script, and the respective target data is partitioned across one or more of the respective leaves of the respective Merkle trees.
14. At least one of the respective scripts is a first locking script of a first output of the first blockchain transaction, and the method further comprises: storing in a database the respective Merkle roots mapped to the modified primary transactions and the respective indices of the first outputs; The method of claim 8 , comprising:
15. obtaining a second blockchain transaction, the second blockchain transaction including a first input that references the modified primary transaction identifier of the first blockchain transaction and the index of the first output, the first input including a first unlock script; said method comprising: Retrieving from the database the modified primary transaction identifier and the respective Merkle roots mapped to the respective indexes of the first output; determining a partial lock script for the first output based on the first unlock script for the first input; performing a Merkle containment proof to verify that the partial lock script is a respective leaf of the respective Merkle tree corresponding to the respective Merkle root; validating the first unlock script against the partial lock script; validating the second block chain transaction by 15. The method of claim 14, comprising:
16. At least one of the respective scripts is a first locking script of a first output of the first blockchain transaction, and the method further comprises: storing a partial locking script in a database mapped to the modified primary transaction identifier and an index of each of the first outputs, the partial locking script including at least a portion of the first locking script but not including the target data; The method according to claim 8.
17. obtaining a second blockchain transaction, the second blockchain transaction including a first input that references the modified primary transaction identifier of the first blockchain transaction and the index of the first output, the first input including a first unlock script; said method comprising: retrieving from the database the respective partial locking scripts mapped to the modified primary transaction identifier and the respective indexes of the first output; validating the first unlock script against the partial lock script; validating the second block chain transaction by 17. The method of claim 16, comprising:
18. The edited transaction includes a plurality of fields, and the method further comprises: generating a transaction Merkle tree, each of a plurality of respective leaves of the transaction Merkle tree being formed from one or more fields of the edited transactions; generating a secondary transaction identifier for the edited transaction, the secondary transaction identifier including a Merkle root of the transaction Merkle tree; The method of claim 1 , comprising:
19. 1. A computer device comprising: a memory comprising one or more memory units; A processing device comprising one or more processing units, the memory storing code configured to be executed on the processing device, the code being configured, when on the processing device, to execute the method of any one of claims 1 to 18; 1. A computer device comprising:
20. A computer program embodied on a computer readable storage and configured to, when executed on one or more processors, perform the method of any one of claims 1 to 18.
Citation Information
Patent Citations
Certification method for authenticity of electronic document and electronic document disclosure system
JP2007129507A
Integrity verification of pseudonymized documents
US20090070361A1
Verification of data fields of blockchain transactions
WO2020240296A1
