A kind of financial accounting method based on block chain technologyTechnical field
The present invention relates to block chains in the technical field of the application of financial system framework, specifically provides a kind of based on block chainThe financial accounting method of technology.
Background technique
In financial accounting field, the consolidated storage that traditional accounting system will be concentrated based on one, all generation businessData will be recorded centrally in the same library by tissue, for large-scale group, then need to put into higher cost constructionInformation centre, and data concentrate on a center and are easy to be tampered.In fact the generation of every business is all specific at oneTissue, only it should be understood that information relevant to business for a tissue, information without knowing entire consolidated storage,Distribution book keeping operation is a more reasonably selection.
Block chain technology is the technology of bit coin behind, maximum feature be can decentralization, such as to bit coinFor the Transaction Information of bit coin is safeguarded there is no information centre, and transaction record is difficult to be tampered with high peaceQuan Xing.
Summary of the invention
Technical assignment of the invention be in view of the above problems, provide it is a kind of can be realized financial accounting go to centerChange, save information construction cost, improves the financial accounting method based on block chain technology of financial data safety.
To achieve the above object, the present invention provides the following technical scheme that
A kind of financial accounting method based on block chain technology, by asymmetric encryption system by accounting item address,It is applied to UTXO in debit credit bookkeeping, in conjunction with block chain technology, by financial system decentralization.
UTXO, that is, UnspentTransaction Output, for the transaction output that do not consume.
The financial accounting method based on block chain technology is designed using decentralization, is exported using the transaction that do not consumeThe book keeping operation thought design of (abbreviation UTXO under Unspent Transaction Output) realizes the debit credit bookkeeping based on UTXOMethod, and block chain encryption technology is combined, so that whole controls of each oneself existing account of accounting unit for accessing the network,It is able to access that the account book of complete or collected works group again, keeps every notes account all safe, can be traced.The design can by financial system decentralization,Any accounting body can be accessed freely, while can guarantee the relatively reliable safety of financial system, more easily be extended.
Preferably, this method specifically includes the following steps:
S1, the distribution of accounting unit's code key: the accounting unit of each access network call packaged Secp256k1 andECDSA algorithm generates a pair of of private key and public key.
S2, accounting item address: after accounting unit gets code key, to can remember popular tourism carry out address.
S3, UTXO book keeping operation.
The database kept accounts using UXTO scheme, the variation of the not instead of accounting item remaining sum of record, debt-credit itself.It pressesAccording to the debit-credit bookkeeping of financial accounting, each account is all to have to borrow to have loan debt-credit must be equal.In the concept of UXTO most original,Transaction must have funds source to be referred to as input of trading, and must also have the whereabouts of fund to be known as output of trading, every business will be spentInput generates output, and record as one is referred to as " the transaction output not spent " i.e. UTXO, in original UTXO conceptTransaction input must be equal to transaction output.Debit-credit bookkeeping based on UTXO replaces the concept of transaction output input with debt-credit, " does not spendThe transaction of expense exports " develop into " amount of money that do not lend ", debit's subject is equivalent to transaction input, and it is defeated that credit account is equivalent to transactionOut, main feature is as follows:
1), in addition to the first stroke book keeping operation of accounting item related after online implementing, the source of all debits is all the one of frontSubject address in a or several UTXO;
2), accountant's department's destination address must be generated by the public key for initiating the accounting unit of book keeping operation;
3), the subject of debtor and creditor must be several accounting item addresses;
4), it is any one notes account do not borrow the amount of money be equal to credit account amount incurred add debit's subject balance;
5) it, is signed after the completion of every book keeping operation with abstract of the private key to accounting information, and public key is placed on head, in netIt carries out broadcasting etc. in network pending.Book keeping operation application in a period of time forms a block, and block is filled up by the node in networkThe abstract of signature is decrypted by the public key of every transaction, whether verifying abstract is consistent with the abstract of current transaction record,Whether verification public key matches with subject address, it is ensured that book keeping operation is not tampered with.
S4, block audit: each accounting unit carries out the independent audit of block, and the accounting records verified in a block areIt is no legal.
Each block has a block header information, includes to generate the time in head, the cryptographic Hash of previous block,The cryptographic Hash of real data in block, the depth of block.
The node broadcasts block information completed is audited, is verified and recognized validity after being received by network others node,Continue to calculate if node bifurcated, the block chain for reaching six depth at first is recognized.
S5, block chain report: inquiry account book, count each accounting item does not borrow the amount of money, calculates accounting item remaining sum, shapeAt report.
Preferably, there be a pair of public key and private key generated by elliptic curve in each accounting unit in step S1,Accounting unit is attached to public key in accounting records when keeping accounts, and makes a summary to accounting information, is carried out with private key to abstract resultSignature.
Elliptic curve encryption algorithm is a kind of rivest, shamir, adelman, rivest, shamir, adelman feature private key encryptionInformation can use public key decryptions, but cannot deduce private key from public key.
Preferably, when verifying, is decrypted signature with public key after being signed using private key to abstract result, if solutionAbstract after close is identical as the abstract of accounting information, then accounting information is not tampered with.
Preferably, being made a summary to accounting information using SHA256 algorithm.
SHA256 algorithm is the signature algorithm of mainstream, has high safety, is difficult to be cracked.
Preferably, after accounting unit gets key, traversing each accounting item in step S2, subject is uniquely markedKnowledge is extracted as symbolization of accounts, and the public key of accounting unit is first made a summary with SHA256, reuses the calculation of RIPEMD160 HashMethod forms 160 digital bits, switchs to the ASCII of regular length finally by Base58Check coding, finally and symbolization of accountsForm subject address.
Preferably, verifying accounting item address, verification book keeping operation permission, the book keeping operation quilt of confirmation when step S4 block is auditedIt is added into the block of accounting unit's record, the block being broadcasted at first is recognized by other accounting units, when block chain growthLength, which reaches the final confirmation of six book keeping operations, to be modified.
Preferably, the book keeping operation of confirmation is added into the block of accounting unit's record, to block and a upper block headThe cryptographic Hash in portion carries out SHA256 abstract operation, will make a summary operation as this cryptographic Hash kept accounts and be put into head, the area Shang YigeThe address of block is also placed in head, forms block chain.
Preferably, the block being broadcasted at first is recognized by other accounting units, other nodes are received after block information moreNew account book information no longer verifies if the book keeping operation verified is existing within a block.
Compared with prior art, the financial accounting method of the invention based on block chain technology has following prominent beneficialEffect: the financial accounting method based on block chain technology is realized using the book keeping operation thought design for the transaction output that do not consumeDebit-credit bookkeeping based on UTXO, and block chain encryption technology is combined, so that each accounting unit for accessing the network is existing certainlyWhole controls of own account, and it is able to access that the account book of complete or collected works group, keep every notes account all safe, can be traced.The design can be withBy financial system decentralization, any accounting body can be accessed freely, while can guarantee the relatively reliable peace of financial systemEntirely, it more easily extends.It can be realized the decentralization of financial accounting, save information construction cost, improve financial data safetyProperty, there is good application value.
Detailed description of the invention
Fig. 1 is the flow chart of the financial accounting method of the present invention based on block chain technology;
Fig. 2 is the schematic diagram of the specific embodiment of the financial accounting method of the present invention based on block chain technology.
Specific embodiment
Below in conjunction with drawings and examples, the financial accounting method of the invention based on block chain technology is made furtherIt is described in detail.
Embodiment
As shown in Figure 1, the financial accounting method of the invention based on block chain technology, it will by asymmetric encryption systemSubject address is counted, is applied to UTXO in debit credit bookkeeping, in conjunction with block chain technology, by financial system decentralization.
This method specifically includes the following steps:
S1, the distribution of accounting unit's code key: the accounting unit of each access network call packaged Secp256k1 andECDSA algorithm generates a pair of of private key and public key.
There is a pair of public key and private key generated by elliptic curve in each accounting unit, public when accounting unit keeps accountsKey is attached in accounting records, and is made a summary to accounting information using SHA256 algorithm, is signed with private key to abstract result.After being signed using private key to abstract result, when verifying, is decrypted signature with public key, if abstract and book keeping operation after decryptionThe abstract of information is identical, then accounting information is not tampered with, and otherwise illustrates that accounting information is tampered, this time book keeping operation is invalid.
S2, accounting item address: after accounting unit gets code key, to can remember popular tourism carry out address.
After accounting unit gets code key, program can carry out address to a set of accounting item system, and specific process isEach subject in accounting system is traversed, subject unique identification is extracted as symbolization of accounts, the public key of accounting unit is first usedSHA256 makes a summary, and reuses RIPEMD160 hash algorithm and forms 160 digital bits, compiles finally by Base58CheckCode switchs to the ASCII of regular length, finally forms subject address with symbolization of accounts.
S3, UTXO book keeping operation.
The book keeping operation thinking of UTXO from the fund book keeping operation method not spent between simple account, is extended to accounting by the present inventionDebtor-creditor relationship between subject is exactly the account being considered as accounting item in bit coin in simple terms.
UTXO book keeping operation is realized:
1) storage organization of UTXO book keeping operation table is as shown in the table:
2) book keeping operation implementation process:
A, private-public key is passed to as parameter, constructs the accounting object of accounting unit.
B, when business occurs, financial staff fills in bookkeeping voucher, program is extracted from bookkeeping voucher debt-credit subject withParameter of the amount incurred as UTXO book keeping operation function in book keeping operation class.
C, it is borrowed according to step S2 formation, the subject address of credit account.
D, the UTXO that book keeping operation all debit's subjects of functional query are not lent is recorded, and what the amount of money in these records indicated is notBy means of the amount of money (not being subject balance), as debit source.
E, the information obtained according to B, C, D generates one and does not lend UTXO book keeping operation.UTXO book keeping operation table will generate severalIdentical record is numbered in book keeping operation, these records are exactly a new UTXO, it includes: the note that an address is credit account addressRecord, the amount of money are credit amount (not borrowing the amount of money namely).One address is the record of debit's subject address, and the amount of money is more than debitVolume source subtracts the value after credit amount.At this time since the UTXO in D has been lent, it is impossible to lend.It is newly generatedThis UTXO subsequent can be lent, and concrete example is shown in Fig. 2.
50000 raw materials are bought to supplier, payment for goods is temporarily owed.10000 raw material are got again for producing, finally by bankDeposit first pays 40000 yuan of supplier.
Should first it remember according to debit credit bookkeeping:
Borrow: raw material --- 50000.
Borrow: accounts payable --- 50000.
Remember again:
Borrow: production cost --- 10000.
Borrow: raw material --- 10000.
Assuming that raw material subject value is 0 when accounting period is initial, production cost subject has 5000, UTXO accounting procedure as followsShown in figure:
Most postscript:
Borrow: accounts payable --- 40000.
Borrow: cash in banks --- 40000.
In the figure, because production cost belongs to assets, subject value increases when debit occurs, so production cost subject is positiveWhen initial non-debit negative.
When the first stroke business occurs, raw material are borrowed, borrow accounts payable, so accounts payable does not borrow the amount of money to increase by 50000, originalRemaining to be transferred to again is not borrowed after material debit occurs, and the raw material address become in 50000, UTXO 0001 from 0 is completePortion was lent, if next raw material when debit occurs again, subject source just can only be from UTXO 0002 and UTXO 0003In take, then UTXO0002 and UTXO0003 also all lending re-form a new UTXO.
When this process is covered, when needing to calculate each subject balance, needs to count all and do not lend the amount of money.
Such as count raw material, do not borrow the amount of money have in 0002-50000 and 0003 in 10000, the two is added-40000, because raw material belong to assets, debit increases when occurring, so the remaining sum of raw material is 40000;Accounts payable is counted,Not borrowing only 0004 is 10000, because belonging to debt, subject balance is reduced when debit occurs, so final accounts payable is remainingVolume is 10000.
F, whether legal according to financial rule verifying book keeping operation.
G, after step F passes through, the information in UTXO is spliced into character string, is made a summary to it shape using SHA256 digest algorithmIt makes a summary at one and carries out ciphering signature with private key, signing messages and public key are formed into head.
H, head and UTXO accounting information are combined into complete accounting records, are broadcast to network and wait book keeping operation confirmation.
S4, block audit: each accounting unit carries out the independent audit of block, and the accounting records verified in a block areIt is no legal.
Each accounting unit in network can be carried out the independent audit of block, verify the accounting records in a blockWhether legal, detailed process is as follows:
1) verify subject address: neighbor node receives the broadcast of a complete accounting records, the head walked according to g in 3Information reads public key, calculates public key address using 2 algorithm, audits the section for removing symbolization of accounts in this address and recordWhether mesh address matches, if matching illustrates that subject address is legal.
2) verification book keeping operation permission: if (1) passes through, private key signature is obtained according to the header information that G in 3 is walked, uses public key signatureDecryption makes a summary to UTXO accounting information using SHA256 digest algorithm, and whether comparison decrypted result and abstract are consistent, if oneCause illustrates that accounting information is legal.If verification is legal, explanation is an effective book keeping operation, is continued in Internet communication, if it is illegal notIt broadcasts again.
3) book keeping operation confirmed will be added into the block of this nodes records, to the Kazakhstan of block and a upper block headUncommon value carries out SHA256 abstract operation, will make a summary operation as this cryptographic Hash kept accounts and be put into head, the ground of a upper blockLocation is also placed in head, forms block chain.
4) block being broadcasted at first is recognized that other nodes update account book information after receiving block information by other nodes,If the book keeping operation verified has existed within a block, no longer verify.
5) it can not be modified when the length of block chain growth reaches the final confirmation of six book keeping operations.
S5, block chain report: inquiry account book, count each accounting item does not borrow the amount of money, calculates accounting item remaining sum, shapeAt report.
Embodiment described above, the only present invention more preferably specific embodiment, those skilled in the art is at thisThe usual variations and alternatives carried out within the scope of inventive technique scheme should be all included within the scope of the present invention.