System based on main and sub account books in distributed account book
Technical Field
The invention relates to a system based on a main and sub account book in a distributed account book.
Background
The algorithm generated by the distributed account book technology is powerful and subversive, has the opportunity to change the implementation modes of public and private services, and improves the productivity through a wide application scene.
Ledgers are one of the core elements of business activities from the very beginning of the last years and are used to record a large number of things-most commonly assets like money and property rights. The media for these data records have evolved from mud boards, to papyrus, to kraft papers and paper. However, for so long, electronic computerization of data was the only significant innovation in this area, which initially was simply turning paper data into electronic data. Computer algorithms now make it possible for the first time to collaboratively maintain digital distributed ledgers, which have attributes and capabilities that go beyond traditional paper ledgers.
The distributed ledger is essentially an asset database that can be shared at multiple sites, at different geographical locations, or over a network of multiple organizations. Participants in a network may obtain a copy of a unique, real ledger. Any changes in the ledger will be reflected in all copies, with reaction times in minutes or even seconds. The assets stored in this ledger may be financial, legally defined, physical or electronic. The security and accuracy of the assets stored in the ledger are maintained on the basis of cryptography by controlling the access rights of the ledger through the use of public and private keys and signatures. The records in the ledger may be updated by one, some or all participants together, according to rules of consensus agreed upon in the network.
Blockchains are the underlying technology of such distributed ledgers, originally designed for point-to-point digital today's system bitcoins implemented in 2008. The block chain algorithm enables the transaction of bitcoin to be centralized in the 'blocks' and added into the 'chain' formed by the absorption blocks through the cryptographic signature. The bitcoin ledger is built in a distributed and "license-free" way, and anyone can add a block containing a transaction by solving the cryptographic difficulties required to generate a new block. Currently, the incentive mechanism for this system is to receive a 25-bit dollar reward after resolving the issue and generating each region. Anyone who has only the network and computer examples has the opportunity to solve these cryptographic challenges and add the transaction to the ledger, is called a "bitcoin miner. The ore mining metaphor is proper, so the excavation of the bitcoin consumes a large amount of computer computing power, and therefore, high energy consumption is brought about.
Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide a system architecture based on master and slave accounts in a distributed account book.
In order to achieve the purpose, the invention adopts the following technical scheme:
in the system based on the main and sub accounts in the distributed account book, a main account book and N sub account books, all nodes of which participate in consensus, run in the same distributed account book in parallel;
a main account book with all nodes participating in consensus is automatically created during network initialization;
the N sub accounts are created according to needs through system functions, blocks generated by each sub account are anchored to a main account network in a transaction type, any node in the network can create one sub account according to own business requirements, the sub account is broadcasted to all nodes through a P2P network, and local main account data is updated through a consensus mechanism, so that the main account data of all nodes are consistent.
Preferably, the main ledger book includes system global information, which at least includes a sub ledger book list, sub ledger book block header information, a mapping relationship between a creator and a sub ledger book, a mapping relationship between a network node and a sub ledger book, and sub ledger book state information.
Preferably, each node only stores data of the main ledger and data of the sub ledger added by the node.
Preferably, the system further comprises a management tool and a client tool based on a command line, and the management tool mainly provides the functions of distributed ledger management and viewing.
Preferably, the system also comprises a sub-account book creating function, and a main body with distributed account book management authority can send a Node to any Node in the network according to business requirements through a system management toolanySubmitting a request for creating a sub-account book;
preferably, the creating of the sub-ledger includes the steps of:
step 1: when a sub-account book is created, the unique Name of the sub-account book, the service description Desc of the sub-account book, the node identification set NodeIDs participating in the sub-account book and the Consensus algorithm Consenssus are required to be appointed;
step 2: the system management tool assembles and creates an instruction command { Name | | Desc | | NodeIDs | | Consenssus } of the sub-account book according to the input parameters, and uses a private key K based on public key cryptographypriSigning the instruction data, and then obtaining a message { command | | Kpub| Sign } is sent to any connectable node server node a in the network;
and step 3: when the node server NodeA receives the instruction message, the public key K is extractedpubGenerating an algorithm F (K) by the account numberpub) Calculating to obtain the Account of the client Account initiating the instruction requestclientVerifying the Account of the clientclientWhether to be associated with the administrator Account preconfigured in the networkadminIf the account number is consistent with the public key K, the message is discarded, and the public key K is continuously used after the account number passes the verificationpubVerifying the message signature ensures that the message has not been tampered with;
and 4, step 4: when a node in the network executes an instruction for creating a sub-account book, the node is firstly confirmed to be a subset of a node set of the sub-account book, then an account book example is initialized and calculation and storage resources are allocated for the node, and the Name is used as an index to store the detail information of the sub-account book in a persistent medium;
wherein the administrator AccountadminWhen the distributed account book is initialized, a key pair { K ] is generated in advancepub,KpriH, generating an algorithm F (K) through an account numberpub) And calculating and configuring the data to all node servers in the network.
Preferably, the transaction type is a transaction broadcast policy, which includes the steps of:
step 1: the distributed account book access program can submit a Transaction request Transaction to a target sub-account book in the network by specifying the name of the account book leader;
step 2: after receiving Transaction request Transaction, the node server takes the name of the account book, namely the hedger name as an index, and acquires node set data Nodes of the target account book from the back-end storage of the main account booksubThen, the P2P network is used to broadcast the Transaction request Transaction to the node set Nodessub;
And step 3: when the account name leader name is not specified, the node server receiving the Transaction request Transaction should default the main account as the target account and broadcast the Transaction request Transaction to the whole network.
Preferably, the sub-ledger block generation of the sub-ledger includes the following steps:
step 1: the sub-accounts exist independently and have all processes in the life cycle of the distributed account book technology, when a condition for creating a new Block is triggered, a Leader node which obtains the right of creating the Block collects and packs Transaction requests transactions to be processed according to a preset priority sequence and Block constraint limits to generate a new Block Blocknew;
Step 2: the Leader node uses its private key to pair the new Block BlocknewAfter signing, trying to match a new Block Block according to a preset consensus algorithmnewA consensus is achieved, and the consistency of the account book data owned by each participant is ensured;
and step 3: after the Leader node receives enough forward feedback meeting the consensus algorithm, the new Block Block is sentnewBlock header information (BlockHeader)newTransactional anchoring into the master ledger enhances the non-tamper-ability and trustworthiness of the ledger.
By the scheme, the invention at least has the following advantages:
the system architecture realizes data isolation from a physical layer, and guarantees the privacy and safety of service data; the sub account book and the sub account book are independent in logic and do not interfere with each other and run in a network in parallel, and therefore the overall data processing capacity of the distributed account book is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and in order to make the technical solutions of the present invention more clearly understood and to implement them in accordance with the contents of the description, the following detailed description is given with reference to the preferred embodiments of the present invention and the accompanying drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic structural view of the present invention.
Detailed Description
The following detailed description of embodiments of the present invention is provided in connection with the accompanying drawings and examples. The following examples are intended to illustrate the invention but are not intended to limit the scope of the invention.
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Examples
As shown in fig. 1, in a system based on a master sub-ledger in a distributed ledger, a master ledger and N sub-ledgers, all nodes of which participate in consensus, run in parallel in the same distributed ledger;
a main account book with all nodes participating in consensus is automatically created during network initialization;
the N sub accounts are created according to needs through system functions, blocks generated by each sub account are anchored to a main account network in a transaction type, any node in the network can create one sub account according to own business requirements, the sub account is broadcasted to all nodes through a P2P network, and local main account data is updated through a consensus mechanism, so that the main account data of all nodes are consistent.
The main account book comprises system global information and at least comprises a sub-account book list, sub-account book block header information, a mapping relation between a creator and the sub-account book, a mapping relation between a network node and the sub-account book and sub-account book state information.
In the invention, each node only stores the data of the main account book and the data of the sub account book added by the node.
The invention also comprises a management tool and a client tool based on the command line, and mainly provides the functions of distributed account book management and viewing.
The invention also comprises a sub-account book establishing function, and a main body with distributed account book management authority can pass through a system management tool to any Node in the network according to business requirementsanySubmitting a request for creating a sub-account book;
the creation of the sub-account book comprises the following steps:
step 1: when a sub-account book is created, the unique Name of the sub-account book, the service description Desc of the sub-account book, the node identification set NodeIDs participating in the sub-account book and the Consensus algorithm Consenssus are required to be appointed;
step 2: the system management tool assembles and creates an instruction command { Name | | Desc | | NodeIDs | | Consenssus } of the sub-account book according to the input parameters, and uses a private key K based on public key cryptographypriSigning the instruction data, and then obtaining a message { command | | Kpub| Sign } is sent to any connectable node server node a in the network;
and step 3: when the node server NodeA receives the instruction message, the public key K is extractedpubGenerating an algorithm F (K) by the account numberpub) Calculating to obtain the Account of the client Account initiating the instruction requestclientVerifying the Account of the clientclientWhether to be associated with the administrator Account preconfigured in the networkadminIf the account number is consistent with the public key K, the message is discarded, and the public key K is continuously used after the account number passes the verificationpubVerifying the message signature ensures that the message has not been tampered with;
and 4, step 4: when a node in the network executes an instruction for creating a sub-account book, the node is firstly confirmed to be a subset of a node set of the sub-account book, then an account book example is initialized and calculation and storage resources are allocated for the node, and the Name is used as an index to store the detail information of the sub-account book in a persistent medium;
wherein the administrator AccountadminWhen the distributed account book is initialized, a key pair { K ] is generated in advancepub,KpriH, generating an algorithm F (K) through an account numberpub) And calculating and configuring the data to all node servers in the network.
Wherein, F (K)pub) The algorithm comprises the following steps:
1. compressing public key K with hash function H1pubObtaining a public key fingerprint value D;
2. appointing a version prefix mark V with the length of 16 bits, and combining through V + D operation to obtain Msg;
3. then, a 256-bit hash function H2 is used for compressing the Msg to obtain a fingerprint value, and the first 32 bits are removed to obtain a checksum Sum;
4. merging the version prefix identification V, the public key fingerprint value D and the checksum Sum to obtain a value S1;
5. and calculating the encoding value of S1 by using an encoding algorithm Base58 to obtain a final Account value Account.
The transaction type is a transaction broadcasting strategy, and the method comprises the following steps:
step 1: the distributed account book access program can submit a Transaction request Transaction to a target sub-account book in the network by specifying the name of the account book leader;
step 2: after receiving Transaction request Transaction, the node server takes the name of the account book, namely the hedger name as an index, and acquires node set data Nodes of the target account book from the back-end storage of the main account booksubAnd then requests the transaction by using P2P networkTransaction broadcast to node set Nodessub;
And step 3: when the account name leader name is not specified, the node server receiving the Transaction request Transaction should default the main account as the target account and broadcast the Transaction request Transaction to the whole network.
The generation of the sub account book block of the sub account book comprises the following steps:
step 1: the sub-accounts exist independently and have all processes in the life cycle of the distributed account book technology, when a condition for creating a new Block is triggered, a Leader node which obtains the right of creating the Block collects and packs Transaction requests transactions to be processed according to a preset priority sequence and Block constraint limits to generate a new Block Blocknew;
Step 2: the Leader node uses its private key to pair the new Block BlocknewAfter signing, trying to match a new Block Block according to a preset consensus algorithmnewA consensus is achieved, and the consistency of the account book data owned by each participant is ensured;
and step 3: after the Leader node receives enough forward feedback meeting the consensus algorithm, the new Block Block is sentnewBlock header information (BlockHeader)newTransactional anchoring into the master ledger enhances the non-tamper-ability and trustworthiness of the ledger.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, it should be noted that, for those skilled in the art, many modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.