Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Fig. 1 is a flowchart of steps of a method for reading a transaction record, according to an embodiment of the present invention, as shown in fig. 1, applied to a blockchain network having at least one first blockchain and at least one second blockchain, where the method is performed on the second blockchain associated with the at least one first blockchain, and the method may include:
step 101, a read request initiated by a first initiator using a first device is obtained.
Wherein the first device is any external device of the blockchain network and the read request is for requesting reading of a transaction record stored on the first blockchain.
Illustratively, the read request includes transaction information corresponding to the transaction record to be read by the first initiator, such as transaction ID, transaction party information, transaction device information, and storage information (such as stored blockchain information), so that, in the case where a plurality of second blockchains are included in the blockchain network, the second blockchain corresponding to the read operation to be performed can be determined according to the transaction information included in the read request, and the corresponding second blockchain receives the read request and correspondingly performs the operations of the following steps.
Fig. 2 is a schematic structural diagram of a block chain network according to an embodiment of the present invention, which includes a first block chain and two second block chains, where the second block chain is used as a side chain of the first block chain, and the second block chain (i.e., the side chain) is associated with a block in the first block chain (i.e., the main chain) through metadata of the block. In a specific application, the blockchain network may be an ethernet, an EOS (english: Enterprise Operation System; chinese: Enterprise operating System) or a federation chain or a private chain of a super book, the first blockchain is used to confirm and record information of a user Operation, the user Operation may be a credit transaction, an Operation of storing a certain license certificate or an authentication certificate on the first blockchain is also referred to as a credit transaction, transaction information (including transaction entry information, for example) generated by the credit transaction is recorded on the first blockchain, and the second blockchain is used as a side chain of the first blockchain and may be used to confirm and record that the user reads the transaction entry information stored on the first blockchain, and one or more first blockchains and one or more second blockchains included in one blockchain network support automatic or manual flexible capacity expansion of the blockchain network, and automatic or manual flexible capacity expansion or capacity reduction of the internal nodes of the block chain network.
The read request is a read request sent by a first initiator (which may be a certain user) by using an external device of the blockchain network, and is an off-chain request; the first device for sending the read request may be any terminal or server device that can perform data communication with the second blockchain, and after receiving the read request, the second blockchain may correspondingly perform a read operation, and then return a result of the read operation to an external device, that is, the first device.
It should be noted that fig. 2 is only an example of the first blockchain and the second blockchain, and is not used to limit the first blockchain number and the second blockchain number and the association relationship between the second blockchain and the first blockchain.
Step 102, determining whether the first initiator has a read right to read the transaction record.
In a specific application, the read right of the first initiator may be verified according to payment information corresponding to the read request included in the read request or identity information corresponding to the first initiator, where the verification of the identity information may be based on pre-authorization information, such as a user information list or a device information list having the read right; the payment information is information generated by the first initiator operating to read the transaction record for a resource attribute value, such as a token value. That is, when the user sets the read right for the transaction information in the blockchain network, after receiving an external read request, the second blockchain first performs verification of the read right. For example, the preset conditions that can read the transaction entry information in the blockchain network are: paying or prepaying a corresponding token value, and thus, when the first initiator has paid or prepayed the token value required by the reading request correspondingly, determining that the first initiator has the reading authority; and/or the first initiator is any user in a user information list included in the pre-authorized information, or the first device used by the first initiator is any device in a device information list included in the pre-authorized information, so that the reading right of the first initiator can be judged, and the acquisition of the transaction record in the following steps can be performed.
Step 103, under the condition that the first initiator has the reading right, obtaining the transaction record corresponding to the reading request from the first blockchain.
In a specific application, the second blockchain responds to the read request, obtains the transaction entry information from the first blockchain, and returns the transaction entry information to an external request initiator as a read result of the read request. Data interaction can be carried out between the first block chain and the second block chain according to a preset data communication protocol, the second block chain is used for expanding the function of the first block chain, the reading request is sent to the first block chain by using a data interface corresponding to the data communication protocol after the reading request is obtained, and after the transaction item information corresponding to the reading request is found on the first block chain, the transaction record comprising the transaction item information is returned to the second block chain by using the data interface, so that the second block chain can carry out the operation in the followingstep 104, and the reading result is returned to the first requester.
In addition, when the second blockchain is associated with a plurality of first blockchains, the read request may further include information of the first blockchain storing the transaction record corresponding to the read request, for example, blockchain ID information, so that the second blockchain can perform data interaction with the corresponding first blockchain to obtain the transaction record.
And 104, outputting a reading result of the reading request according to the transaction record.
In a specific application, after the transaction record is obtained through the above steps, the transaction record can be directly used as a reading result and output to an initiator of the reading request.
Optionally, the transaction record may further include transaction entry information and associated identity information, that is, after the second blockchain receives the transaction record, the second blockchain performs identity verification on the first blockchain that sends the transaction entry information according to the associated identity information, and may compare metadata associated with the first blockchain and the second blockchain, so as to determine whether the associated identity information is consistent with metadata stored in advance in the founding block; if the transaction items are consistent, the identity authentication is passed, and the transaction item information in the transaction record can be output to the first initiator; otherwise, under the condition of inconsistency, it is indicated that the identity of the first block chain which sends the transaction entry information is wrong, that is, the sent transaction entry information is not the information corresponding to the read request, and the correct transaction entry information needs to be obtained again.
It will be appreciated that the above-described authentication operation is used to verify the first blockchain identity to avoid the situation where the first blockchain identity is tampered or forged due to an illegal attack, generating false transaction entry information.
According to the technical scheme provided by the invention, the operations of obtaining and authorizing verification of the reading request and reading and outputting the transaction record are carried out by utilizing the second block chain which is associated with at least one first block chain through data in the block chain network, so that the authority limit of the transaction record in the block chain network is realized, the confidentiality of the data is ensured, and the flexibility of the block chain network is improved. In addition, the authority verification and the data check of the transaction data are realized through the second block chain, the operation that the first block chain directly records, inquires and outputs can be avoided, extra operation pressure can not be caused on the first block chain, and the stability and the running speed of the first block chain are further improved.
In summary, according to the method for reading a transaction record provided by the present invention, a second blockchain associated with at least one first blockchain is preset in a blockchain network, so as to first determine whether a read request has a read permission to read the transaction record according to an obtained read request; then under the condition that the first initiator has the reading authority, acquiring a transaction record corresponding to the reading request from the first blockchain; and outputting the reading result of the reading request according to the transaction record. Therefore, the permission of the read request can be verified by using the second blockchain which is set in an associated manner with the first blockchain, and the read result corresponding to the read request with the read permission is output, so that privacy protection under a blockchain scene is realized, the security of transaction data is improved, and the flexibility of a blockchain network is expanded.
Optionally, fig. 3 is a flowchart illustrating specific steps of a method for reading a transaction record according to an embodiment of the present invention, as shown in fig. 3, beforestep 101, the method may include:
in the case of initialization, generating attached data of the created block of the second blockchain by using the metadata of the first blockchain, so as to associate the second blockchain with one or more blocks on the first blockchain,step 105.
In a specific application, when the second blockchain is initialized, since one blockchain includes a plurality of blocks, creating a first block of the second blockchain is referred to as initializing the second blockchain, and using metadata of a block of the first blockchain to which the first blockchain is to be associated, or using metadata of blocks of the first blockchain to which the first blockchain is to be associated as adjunct data of an established block of the second blockchain, which may or may not be encrypted, so as to associate the second blockchain with one or more corresponding first blockchains. The first block created earliest in the block chain is called a created block, and has a unique ID number.
Due to the fact that the side chain (namely the second block chain) is associated with the main chain (namely the first block chain) through metadata, a user can achieve operations which cannot be achieved on the main chain through the side chain; and because the side chain is an independent block chain and has a node network of the side chain, and the code and the data are relatively independent, the related side chain does not increase the burden of a main chain in the operation process, and the condition of excessive expansion of the data is avoided. In the embodiment of the invention, the second block chain is used as a side chain to be associated with the first block chain as a main chain, so that the operation which is originally required to be executed on the first block chain is distributed to the second block chain to be executed, the service pressure of the first block chain is reduced to ensure the execution efficiency of the operation, and the stability of a block chain system is improved; in addition, the association method of the second block chain and the first block chain in the embodiment of the present invention is to associate the second block chain with one or more blocks in the first block chain, that is, to adopt an association form with finer data particles, so as to reduce the complexity of association between blocks in the block chain system.
In addition, it should be noted that, the second blockchain proposed in the present invention is different from the blockchain in the existing blockchain network, and besides the function of the second blockchain in the blockchain network in the prior art can be implemented, for example, the second blockchain can be anchored in both directions in the blockchain network, the read operation of the transaction record and the save operation of the read record can also be performed on the associated first blockchain, the read authority of the transaction record can be set by verifying the read authority of the first requester, and the read and output operation can be set on the second blockchain, so as to reduce the operation pressure generated on the first blockchain.
Alternatively, as shown in fig. 4, step 105 may include the following sub-steps:
step 1051, obtain target metadata from the first blockchain.
Wherein the target metadata comprises metadata of one or more blocks of the first blockchain associated with the second blockchain.
Step 1052, the target metadata is used as the attached data of the created block of the second block chain.
Step 1053, hash value conversion is performed on the target metadata to obtain the attached data of the created block of the second block chain.
That is, in order to ensure the security of the metadata of the first block chain, the metadata may be encrypted, for example, by using a hash value algorithm, and the generated hash value is used as the attached data of the created block, so as to implement the association operation with the first block chain.
In a specific application, when a plurality of blocks are associated with the second blockchain, the metadata of the one or more blocks may be packaged so as to convert the metadata (i.e., the target metadata) into a hash value, thereby implementing the association operation between the one or more blocks of the first blockchain and the second blockchain. In addition, when the second blockchain is associated with a plurality of first blockchains, metadata of a plurality of blocks corresponding to the plurality of first blockchains may be packed, i.e., as described above. Or, the blocks used for association on each first block chain may be separately packaged, and the ID information of the first block chain is used to distinguish the blocks used for association, that is, metadata of one or more blocks associated with one first block chain is combined into a hash value, and the hash value is marked by the ID information of the first block chain, so that when the identity information is verified in a subsequent step, the corresponding metadata can be obtained to perform the identity verification of the first block chain.
Optionally, fig. 5 is a flowchart illustrating specific steps of a method for reading a transaction record according to an embodiment of the present invention, as shown in fig. 5, the determining whether the read request has a read right to read the transaction record instep 102 may include:
step 1021, obtaining the attribute information of the first initiator included in the read request.
For example, a certain first blockchain in the blockchain network may set pre-authorization information for limiting the right to read all transaction records on the first blockchain, such as a right list. The corresponding attribute information may be information indicating the identity of the first initiator, such as a user ID of the first initiator or a device ID of the first device used, and may also be payment information of the first initiator for the read request.
And 1022, verifying the attribute information according to a preset verification condition.
Exemplarily, in the case that the attribute information is identity information, the pre-authorized information corresponding thereto is: a list of device IDs and/or a list of user IDs with read rights, and the corresponding authentication conditions are: any initiator in the user ID list meets the verification condition and/or any device in the device ID list meets the verification condition, namely the first initiator is determined to have the reading authority; and if the first device is not in the device ID list or the first initiator is not an initiator in the user ID list, the authentication condition is not satisfied, that is, the read right is not provided. And/or, in case the attribute information is payment information, the verification condition includes that the first initiator has paid or prepaid the reading cost of the transaction record. For example, after the first initiator pays the reading cost, transaction record information of successful payment is generated in the blockchain network, and a transaction success message corresponding to the reading request is used as the payment information, or a preset switch for indicating the successful transaction is triggered, that is, the transaction record information is used as the payment information, and the verification condition is indicated to be met under the condition that the payment information exists; when the reading cost required by the reading request is not paid, no payment information is generated, that is, the verification condition is not met, and the operation ofstep 103 cannot be performed.
Further, in the case where the attribute information includes both the identity information and the payment information of the read request, that is, the authentication is performed instep 1022, that is, the identity information and the payment information are authenticated. For example, the verification condition may include: under the condition that the user ID of the first initiator belongs to the user ID list and the first initiator pays the corresponding reading cost; or, when the device ID of the first device belongs to the devices in the device ID list and the first initiator pays the corresponding reading cost, it is determined that the verification condition is met, and the embodiment of the present invention is not limited.
Instep 1023, in the case that the attribute information meets the verification condition, it is determined that the first initiator has the read right.
For example, in the case that the attribute information meets the verification condition, the operation ofstep 103, that is, acquiring the corresponding transaction record, may be performed. Otherwise, the reading request cannot continuously execute the reading operation, and an error message is returned, which indicates that the inquiry of the transaction record cannot be carried out.
Optionally, fig. 6 is a flowchart illustrating specific steps of a method for reading a transaction record according to an embodiment of the present invention, as shown in fig. 6, the outputting a reading result of a reading request according to a transaction record instep 104 may include:
step 1041, obtaining a matching degree between the associated identity information and the attached data of the created block of the second block chain.
Wherein the associated identity information comprises metadata of a block on the first blockchain for storing the transaction entry information.
Step 1042, determining the transaction record as a legal record when the matching degree between the associated identity information and the attached data of the created block of the second block chain exceeds a preset threshold.
In an example, the transaction record obtained from the first blockchain further includes associated identity information, that is, metadata of a block on the first blockchain storing the transaction record is subjected to similarity calculation of data content with attached data stored in an created block of the second blockchain at initialization, so as to serve as a matching degree between the associated identity information and the attached data of the created block of the second blockchain, and thus it is determined whether the sent transaction record is legal or not and whether the associated identity information is tampered or not according to the matching degree.
It should be noted that, when the second blockchain is bound to a block in the first blockchain, the corresponding preset threshold is 100%, that is, only when the associated identity information (i.e., metadata of the block) is completely consistent with the attached data of the created block of the second blockchain, that is, the matching degree is 100%, the transaction record is determined to be a legal record, and the read result can be output; otherwise, any inconsistency exists, which indicates that the transaction record has the possibility of tampering and cannot be output.
Or, when the second blockchain is associated with a plurality of blocks of the first blockchain or a plurality of blocks of one first blockchain and metadata of the plurality of blocks are packed together, the corresponding preset threshold is related to the number of the associated blocks, that is, the associated identity information needs to be consistent with a part of the attached data of the created block of the second blockchain (i.e., the part corresponding to the first blockchain), that is, the matching degree exceeds the corresponding preset threshold, that is, the transaction record can be determined to be legal. If the metadata of the blocks of the associated first block chains are separately packaged, the corresponding metadata in the auxiliary data of the created block is acquired according to the ID information of the first block chains, so as to compare the associated identity information with the auxiliary data of the created block.
And step 1043, determining a reading result according to the transaction entry information under the condition that the transaction record is a legal record.
In specific application, the transaction item information included in the transaction record determined as a legal record is used as a reading result to be output to an initiator of the reading request, so that the reading operation of the transaction record of this time is completed.
Or, optionally, the step may further include:
substep A1: and encrypting the transaction item information of the first blockchain.
Substep A2: and outputting the encrypted transaction item information of the first block chain as a reading result.
Namely, the transaction entry information in the transaction record is encrypted and then output, so that the security of the transaction entry information needing to be kept secret is ensured, encryption transmission is carried out, and the data confidentiality is further improved.
And step 1044, outputting the reading result.
Illustratively, after determining that the transaction record is a legitimate record, the transaction entry information is returned to the first initiator, i.e. the transaction entry information is sent back to the first initiator directly as a read result. Alternatively, the above sub-steps may be performed on the transaction entry information to ensure the security of the data, and the embodiment of the present invention is not limited.
In addition, it should be noted that, after determining that the transaction record is a legal record, the method may further include:
instep 1045, the read transaction information generated by the read request is recorded.
The read transaction information includes information of the first initiator and transaction entry information.
For example, the reading operation of one transaction record is taken as one reading transaction, after one reading transaction is completed, the information of the reading transaction is recorded, and the reading transaction information corresponding to the reading transaction is generated and stored on the second block chain, so that the reading transaction information can be conveniently viewed. Or, when a read request consistent with the information in the read transaction is received again, the information of the read transaction stored on the second blockchain can be directly output, so that the read operation of the transaction information is simplified, and the data storage and data reading pressure of the first blockchain is reduced. The transaction entry information of the transaction record may include information such as the original transaction party and the transaction content of the transaction record.
Fig. 7 is a block diagram of a device for reading transaction records according to an embodiment of the present invention, which is applied to a blockchain network having at least one first blockchain and at least one second blockchain, and is disposed on the second blockchain associated with the at least one first blockchain, as shown in fig. 7, where thedevice 700 includes:
arequest obtaining module 710, configured to obtain a read request initiated by a first initiator using a first device, where the first device is any external device of the blockchain network, and the read request is used to request to read a transaction record stored on the first blockchain.
And acondition determining module 720, configured to determine whether the first initiator has a read right to read the transaction record.
Therecord obtaining module 730 is configured to obtain the transaction record corresponding to the read request from the first blockchain when the first initiator has the read right.
And aresult output module 740, configured to output a reading result of the reading request according to the transaction record.
Optionally, on the basis of fig. 7, as shown in fig. 8, theapparatus 700 further includes:
an associatingmodule 750, configured to generate, before the step of obtaining the read request initiated by the first initiator using the first device, attached data of a created block of the second blockchain using the metadata of the first blockchain under the condition of initialization, so as to associate the second blockchain with one or more blocks of the first blockchain.
Optionally, fig. 9 is a block diagram of a condition determining module according to an embodiment of the present invention, where thecondition determining module 720, as shown in fig. 9, includes:
theinformation obtaining sub-module 721 is configured to obtain attribute information of the first initiator included in the read request.
Thecondition verifying submodule 722 is configured to verify the attribute information according to a preset verifying condition.
And theauthority determination sub-module 723 is used for determining that the first initiator has the read authority if the attribute information meets the verification condition.
Optionally, the transaction record includes transaction entry information and associated identity information, fig. 10 is a block diagram of a result output module according to an embodiment of the present invention, as shown in fig. 10, theresult output module 740 includes:
the matching degree obtaining sub-module 741 is configured to obtain a matching degree between the associated identity information and the attached data of the created block of the second block chain, where the associated identity information includes metadata of a block used for storing the transaction entry information on the first block chain.
A record determining sub-module 742 is configured to determine that the transaction record is a legal record if a matching degree between the associated identity information and the attached data of the created block of the second block chain exceeds a preset threshold.
Aresult determining submodule 743, configured to determine, when the transaction record is a legal record, a reading result according to the transaction entry information.
And aresult output sub-module 744 for outputting the read result.
Optionally, theresult determination submodule 743 includes:
anencryption unit 7431, configured to encrypt the transaction entry information of the first blockchain;
a determiningunit 7432, configured to output the encrypted transaction entry information of the first block chain as a reading result.
Optionally, as shown in fig. 10, theresult output module 740 may further include:
theinformation recording sub-module 745 is configured to record read transaction information generated by the read request after determining that the transaction record is a legal record when the associated identity information is consistent with the attached data of the created block of the second block chain, where the read transaction information includes information of the first requester and transaction entry information.
Optionally, fig. 11 is a block diagram of an association module according to an embodiment of the present invention, and as shown in fig. 11, theassociation module 750 includes:
the data obtaining sub-module 751 is configured to obtain target metadata, where the target metadata includes metadata of one or more blocks on a first blockchain associated with a second blockchain.
Adata generation submodule 752, configured to use the target metadata as attached data of the created block of the second block chain; or,
the data generating sub-module 752 is further configured to perform hash value conversion on the target metadata to obtain attached data of the created block of the second block chain.
In addition, an embodiment of the present invention further provides a terminal, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, where the computer program, when executed by the processor, implements each process of the above-mentioned method for reading a transaction record, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above-mentioned transaction record reading method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
For the above device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As is readily imaginable to the person skilled in the art: any combination of the above embodiments is possible, and thus any combination between the above embodiments is an embodiment of the present invention, but the present disclosure is not necessarily detailed herein for reasons of space.
The reading methods of transaction records provided herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The structure required to construct a system incorporating aspects of the present invention will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the invention and aiding in the understanding of one or more of the various inventive aspects. However, the method of the invention should not be construed to reflect the intent: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor may be used in practice to implement some or all of the functions of some or all of the components of the method of reading a transaction record according to an embodiment of the invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.