Offline payment system and method based on block chainTechnical Field
The invention relates to the technical field of block chains, in particular to a system and a method for block chain offline payment.
Background
With the popularization of mobile payment, people are becoming more and more accustomed to using mobile phones to replace wallets to carry out paperless transactions. The current payment forms are mainly the following two types: 1. when a user needs to pay/transfer money, the two-dimensional code of a merchant needs to be scanned through apps such as WeChat and Paibao, the amount of money is input, and the money can be transferred to the account of the merchant after payment verification is completed. 2. The user displays through the payment code function of the app, the merchant can deduct the amount of money from the user account through scanning by the code scanning machine, the amount of money is input by the merchant, the scanning directly deducts money, and each transaction record contains transaction information such as a transfer party, a receiving party, the amount of money, time and the like. The first payment mode depends on the stability of the network, and when the network signal is poor, the payment is easy to fail; the second mode not only limits the transfer amount, but also depends on the integrity of a merchant and the technical capability of a technical company, if a technical leak occurs, the phenomenon of embezzlement of the user funds is easily caused, and a specific code scanning gun and other equipment are needed, so that the offline payment between the user and the user cannot be realized.
The block chain system encrypts and hashes data and data operation records through a cryptography method, so that a public, transparent, non-falsifiable and traceable distributed database accounting system is formed. The block chain records all transaction records from the creation block, and when the block size reaches a certain degree, the historical transaction records cannot be tampered.
In the prior art, after a block chain network user such as a bitcoin, an ether house and the like performs transfer payment and then packs the transferred blocks to generate blocks, a transfer process closed loop is realized after a plurality of new blocks are generated and the current transaction cannot be tampered, and the whole process takes longer time (the transaction can be confirmed in more than ten minutes). This operation results in the characteristic of low online payment timeliness of the blockchain technology, and also affects the use experience of the user.
In the existing offline payment scene process, a specific device is required to perform two-dimensional code scanning on the offline device, and the transaction can be completed only by inputting the amount of money. The payment means is very dependent on the integrity of the merchant, and once the merchant inputs an amount larger than the agreed transaction amount, the user suffers from fund loss; the payment means depends on the stability of the code scanning equipment, if the equipment breaks down, the transaction cannot be carried out, and meanwhile, the code scanning equipment is large in size and inconvenient to carry.
Disclosure of Invention
The invention aims to provide an offline payment system and method based on a block chain, which improve transaction fluency and reduce the dependence on a network in a transaction process on the premise of ensuring fund security.
To achieve the above object, the offline payment method based on a block chain provided by the present invention specifically includes: acquiring a transfer amount and an appointed random number input by a payment user, and carrying out encryption signature processing on the transfer amount, the appointed random number, a payment terminal address and a timestamp to obtain payment encryption information and a corresponding payment signature certificate; generating a locking permission certificate of a preset period according to the authorization of the payment signature certificate; locking the account transfer fund amount part corresponding to the payment terminal address according to the payment terminal address and the locking-permission certificate generation amount locking request; acquiring a collection amount and an appointed random number input by a collection user, and carrying out encryption signature processing on the collection amount, the appointed random number, a collection end address and a timestamp to obtain collection encryption information and a corresponding collection signature certificate; the collection encryption information, the collection signature certificate, the payment encryption information and the payment signature certificate are broadcast and sent to a main node on a block chain network; analyzing the collection encryption information and the payment encryption information according to the collection signature certificate and the payment signature certificate to obtain payment original text information and collection original text information; when the obtained payment original text information is consistent with the appointed random number in the collection original text information and the transfer amount is consistent with the collection amount, initiating a transaction consensus request to other nodes on the block chain network; unlocking the transfer amount locked in the account corresponding to the payment end address according to the consensus result and the receiving end address and performing transfer processing; and generating a block according to the processing result and broadcasting.
In the above offline payment method based on a block chain, preferably, after generating a lock-allowing certificate of a preset period according to the payment signature certificate authority, the method further includes: generating bar code information according to the payment signature certificate, the locking permission certificate, the payment encryption information and the payment terminal address; and scanning and analyzing the bar code information to obtain the payment signature certificate, the locking permission certificate, the payment encryption information and the payment terminal address.
In the above offline payment method based on the block chain, preferably, the barcode information is two-dimensional code information.
In the above offline payment method based on a blockchain, preferably, the method further includes, before the step of: acquiring identity information and a payment account input by a payment user through a payment terminal, and generating a payment terminal address according to the payment account; generating a key pair of a payment user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the payment user, and sending the address of the payment end and a public key of the key pair to a block chain network for publication; and the block chain network generates a digital certificate according to the public key and feeds the digital certificate back to the paying user.
In the above offline payment method based on a blockchain, preferably, the method further includes, before the step of: acquiring identity information and a collection account input by a collection user through a collection end, and generating a collection end address according to the collection account; generating a key pair of a collection user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the collection user, and sending the address of a collection end and a public key of the key pair to a block chain network for publication; and the block chain network generates a digital certificate according to the public key and feeds the digital certificate back to the payee.
In the above offline payment method based on a blockchain, preferably, the method further includes: acquiring a receiver address and a received amount through a receiver, and digitally signing the receiver address according to a private key of a receiving user to acquire signature information; delivering the signature information, the address of the receiving end and the public key of the receiving user to a payment end; the payment end verifies the address of the collection end according to the signature information and the public key of the collection user, and provides the address of the payment end to the collection end after the verification is passed; the receiving end broadcasts the receiving end address, the paying end address and the receiving amount to a main node on a block chain network; and transferring accounts corresponding to the payment end address according to the payment end address and the collection end address, and generating a block according to a processing result and broadcasting.
The invention also provides an offline payment system based on the block chain, which comprises a payment end, a collection end and a block chain network; the payment terminal is used for acquiring transfer amount and appointed random number input by a payment user, and carrying out encryption signature processing on the transfer amount, the appointed random number, the address of the payment terminal and the timestamp to obtain payment encryption information and a corresponding payment signature certificate; generating a locking permission certificate of a preset period according to the authorization of the payment signature certificate; the receiving terminal is used for locking the account transfer fund part in the account corresponding to the address of the payment terminal according to the address of the payment terminal and the request for generating the amount locking according to the locking permission certificate; acquiring a collection amount and an appointed random number input by a collection user, and carrying out encryption signature processing on the collection amount, the appointed random number, a collection end address and a timestamp to obtain collection encryption information and a corresponding collection signature certificate; the collection encryption information, the collection signature certificate, the payment encryption information and the payment signature certificate are broadcast and sent to a main node on a block chain network; the block chain network is used for analyzing the collection encryption information and the payment encryption information according to the collection signature certificate and the payment signature certificate to obtain payment original text information and collection original text information; when the obtained payment original text information is consistent with the appointed random number in the collection original text information and the transfer amount is consistent with the collection amount, initiating a transaction consensus request to other nodes on the block chain network; unlocking the transfer amount locked in the account corresponding to the payment end address according to the consensus result and the receiving end address, and performing transfer processing; and generating a block according to the processing result and broadcasting.
In the above offline payment system based on the blockchain, preferably, the payment terminal further includes a barcode generator configured to generate barcode information according to the payment signature certificate, the locking permission certificate, the payment encryption information, and the payment terminal address; the receiving end also comprises a function of scanning and analyzing the bar code information to obtain the payment signature certificate, the locking permission certificate, the payment encryption information and the address of the payment end.
In the above offline payment system based on the blockchain, preferably, the system further includes a registration module, where the registration module is configured to obtain identity information and a payment account input by a payment user, and generate a payment terminal address according to the payment account; generating a key pair of a payment user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the payment user, and sending the address of the payment end and a public key of the key pair to a block chain network for publication; receiving a digital certificate fed back by the block chain network according to the public key; or, acquiring identity information and a collection account input by a collection user, and generating a collection end address according to the collection account; generating a key pair of a collection user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the collection user, and sending the address of a collection end and a public key of the key pair to a block chain network for publication; and receiving the digital certificate fed back by the block chain network according to the public key.
The invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the computer program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
The invention has the beneficial technical effects that: convenient and fast: the problem that the current mobile payment account transfer can not realize offline account transfer between users at user level is solved, and through the system, the users can carry out quick offline payment at any time and any place as long as any party is online. And (3) trust transfer: the payer and the payee contract the transaction random numbers and input the transfer amount, so that the problem that the input amount is more than the appointed amount to cause the money loss of the user in the current mobile payment is solved, and the user does not need to worry about the problem of more money deduction through the system. Performance is improved: the system completes the transaction after verifying the request information to be correct by the principle that the initial states in the state machine are consistent and the input is consistent and the result is necessarily consistent, and then performs consensus packaging, thereby solving the problem of long confirmation time in the current block chain transaction. The transaction confirmation time of the system is in the second level, and is greatly improved compared with the confirmation time in the minute level of the current block chain transaction.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention. In the drawings:
FIG. 1 is an architecture diagram of a payment blockchain master node network system;
FIG. 2 is a flow diagram of a Payment Block Link Point network request processing;
FIG. 3 is a block diagram of a payment wallet system;
fig. 4 is a flow diagram of a payment wallet user registration;
fig. 5 is a flow diagram of a payment wallet query;
FIGS. 6A and 6B are a payment flow diagram for a payment wallet payer offline;
FIGS. 7A and 7B are a payment flow diagram for a payment wallet payee offline;
fig. 8 is a schematic structural diagram of an offline payment system based on a blockchain.
Detailed Description
The following detailed description of the embodiments of the present invention will be provided with reference to the drawings and examples, so that how to apply the technical means to solve the technical problems and achieve the technical effects can be fully understood and implemented. It should be noted that, unless otherwise specified, the embodiments and features of the embodiments of the present invention may be combined with each other, and the technical solutions formed are within the scope of the present invention.
Additionally, the steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions and, although a logical order is illustrated in the flow charts, in some cases, the steps illustrated or described may be performed in an order different than here.
Referring to fig. 6A, the offline payment method based on a block chain provided by the present invention specifically includes: s101, acquiring a transfer amount and an appointed random number input by a payment user, and carrying out encryption signature processing on the transfer amount, the appointed random number, a payment terminal address and a timestamp to obtain payment encryption information and a corresponding payment signature certificate; s102, generating a locking permission certificate of a preset period according to the authorization of the payment signature certificate; s103, locking the account transfer fund part corresponding to the payment terminal address according to the payment terminal address and the locking request of the allowed locking certificate generation amount; s104, acquiring a collection amount and an appointed random number input by a collection user, and carrying out encryption signature processing on the collection amount, the appointed random number, a collection end address and a timestamp to obtain collection encryption information and a corresponding collection signature certificate; s105, the collection encryption information, the collection signature certificate, the payment encryption information and the payment signature certificate are broadcast and sent to a main node on a block chain network; s106, analyzing the collection encryption information and the payment encryption information according to the collection signature certificate and the payment signature certificate to obtain payment original text information and collection original text information; s107, when the appointed random numbers in the obtained payment original text information and the collection original text information are consistent, and the transfer amount is consistent with the collection amount, a transaction consensus request is sent to other nodes on the blockchain network; s108, unlocking the transfer amount locked in the account corresponding to the payment end address according to the consensus result and the receiving end address and performing transfer processing; s109, generating blocks according to the processing result and broadcasting. It should be noted that the payment end and the collection end are adopted in this embodiment only to facilitate understanding of the above-mentioned overall process, and in actual work, the user can use the same payment wallet to pay both from the payment end and the collection end, and the detailed description will be described in detail later and will not be explained one by one here.
In the above embodiment, an asymmetric encryption algorithm is used for data encryption and digital signature, and the specific steps are as follows:
1. a sender performs hash operation on original information M to obtain a hash value e, and encrypts the M by using a block chain encryption public key to obtain encrypted information; then the private key of the user of the sender applies e to carry out digital signature on M, and the signature and the encrypted information of M are sent to the receiver.
2. And the receiver decrypts the encrypted information by using the encrypted private key to obtain m, performs hash operation on the m to obtain a hash value E, and performs signature authentication on the hash value E and the received signature information.
The sender operation specifically comprises:
after the sender selects the random number t, the point H is calculated according to the following formulas 1 and 21And point H2The coordinates of (a):
H1tgi (formula 1)
H2=tQ2(formula 2)
Wherein G is a predetermined point in an X-Y coordinate system, Q2The encryption public key is the encryption public key;
the sender processes M according to the following formula 3 to obtain processed information M:
wherein n is a set parameter,is point H2The abscissa of (a);
thereafter, the sender will (m) as the resulting encrypted information;
wherein,is point H1The abscissa of (a).
After the sender selects the random number k, the point P coordinate (x) is calculated according to the following formula 51,y1) And the signature (r, s) of M is calculated according to the following formulas 6 and 7:
kG=(x1,y1) (formula 5)
r=x1mod n (equation 6)
s ═ k + e-r-d) mod n (equation 7)
Wherein G is a predetermined point in an X-Y coordinate system, n is a setting parameter, and d is a signature private key.
The receiving party performs signature authentication by using the obtained e and the received signature of M, and the method specifically includes:
the receiver calculates the coordinates of the point P according to the following formula 8:
P=u1g + Q (formula 8)
Wherein Q ═ dG, u1Calculated according to the following equation 9:
u1(s + r-e) mod n (equation 9)
The receiving party decrypts the encrypted information by using the encrypted private key to obtain M, and the method specifically comprises the following steps:
the receiving party will encrypt the private key withMultiplication to obtainThen, the original information M is obtained according to the following formula 4:
the receiver uses the abscissa x of the point P in the following equation 101Calculating a verification value v:
v=x1mod n (equation 10)
If v is equal to r, judging that the signature is valid; otherwise, the signature is judged to be invalid.
In an embodiment of the present invention, after generating the lock-allowing certificate for the preset period according to the payment signature certificate authority, the method further includes: generating bar code information according to the payment signature certificate, the locking permission certificate, the payment encryption information and the payment terminal address; scanning and analyzing the bar code information to obtain the payment signature certificate, the locking permission certificate, the payment encryption information and the payment terminal address; the barcode information may be two-dimensional code information or other information, and the function of the barcode information is to facilitate the receiving end to quickly obtain related information provided by the payment end, and a person skilled in the art can select appropriate barcode information for use according to actual needs.
In an embodiment of the present invention, the method may further comprise, before: acquiring identity information and a payment account input by a payment user through a payment terminal, and generating a payment terminal address according to the payment account; generating a key pair of a payment user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the payment user, and sending the address of the payment end and a public key of the key pair to a block chain network for publication; and the block chain network generates a digital certificate according to the public key and feeds the digital certificate back to the paying user. Or, obtaining identity information and a collection account input by a collection user through a collection end, and generating a collection end address according to the collection account; generating a key pair of a collection user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the collection user, and sending the address of a collection end and a public key of the key pair to a block chain network for publication; the block chain network generates a digital certificate according to the public key and feeds the digital certificate back to a payee; therefore, the user can complete identity registration through the above example, specifically, please refer to fig. 4, in which fig. 4 provides a registration process of the user of the payment wallet, in this example, the payment user and the receiving user both perform transactions through the payment wallet, and the detailed process is as follows:
step S401: the user opens the payment wallet to register for the first time, fills in user information, binds the bank card number, binds the payment device, and fills in mnemonic words.
Step S402: the payment wallet generates a globally unique wallet address based on a BIP-39 protocol according to the mnemonic words and the device information, and the wallet address is bound with the user device and is beneficial to supervision.
Step S403: generating a secret key pair by using an asymmetric encryption algorithm, and sending a wallet address and a public key in the secret key pair to the nearest block chain CA node; and sending the public key in the wallet address and the key pair to the nearest block chain master node, initializing the world state of the user wallet address by the nearest block chain master node, and broadcasting the world state to all nodes in the whole network.
Step S404: and the block chain CA node generates a digital certificate according to the uploaded user public key and returns the digital certificate to the user wallet.
Step S405: and the user wallet receives the generated digital certificate, performs initialization inquiry on the wallet to obtain an initial state, and the user registration is successful.
In actual work, after the registration is completed through the above process, an account number confirmation process may be performed, so that the user can conveniently confirm the transaction completion status, specifically, please refer to fig. 5:
step S501: a user logs in to a payment wallet through a networked mobile device, such as a cell phone, tablet, etc.
Step S502: the payment wallet sends a link request to the payment block link main network according to the discovery node information of the default configuration, and when the information reply of 2f +1 main nodes can be received, the link establishment is successful.
Step S503: and sending out a balance change inquiry request and a transaction inquiry request after the main network is successfully linked, and when 2f +1 identical balance change and transaction change replies are received, the successful data synchronization is shown.
Step S504: and returning the balance change information and the transaction change information to the front-end page and displaying the balance change information and the transaction change information to the user.
After the above process, the payment using the payment wallet can be executed, wherein the process of the payer for offline payment is shown in fig. 6B, which specifically includes the following steps:
step S601: the off-line payment user opens the wallet and inputs the appointed transfer amount and the appointed random number, wherein the random number can be a combination of a plurality of numbers, letters and Chinese characters, is the key of a subsequent transaction verification process, and is a necessary input field, otherwise, the off-line transfer function cannot be carried out. And then, the authenticity of the user is verified in verification modes such as a face, a fingerprint and a password of a user authentication module of a control management layer of the payment wallet, the next step can be carried out when the user passes the verification, and otherwise, the user verification failure is returned.
Step S602: the payment wallet encrypts a payment wallet address, a transfer amount, an appointed random number and a timestamp by using an asymmetric encryption algorithm through a block chain public key of a supporting layer encryption module, digitally signs encrypted information by using a private key of a payment user to generate a signature certificate, simultaneously generates a locking certificate with an allowable validity period of half an hour, generates a payment two-dimensional code by using the encrypted information, the signature certificate, the allowable locking certificate and the payment wallet address through a two-dimensional code generation algorithm, and displays the payment two-dimensional code to a payee.
Step S603: the online payee opens the payment wallet and receives the payment function and inputs the random number appointed with the payer.
Step S604: the payee scans the two-dimensional code displayed by the payer through the mobile device to obtain payment information.
Step S605: and the receiving wallet initiates an amount locking request according to the acquired address of the payment wallet and the permission locking certificate, locks part of amount of the payment user meeting the transfer amount, cannot perform other transfer transactions during the locking period, and enters the next step if the locking is successful.
Step S606: the receiving wallet encrypts a receiving wallet address, a transfer amount, an appointed random number and a timestamp by using an asymmetric encryption algorithm through a block chain public key of a supporting layer encryption module, digitally signs encryption information by using a private key of a receiving user to generate a signature certificate, and broadcasts and sends receiving encryption information, the signature certificate, payment encryption information and the payment certificate to a block chain main node.
Step S607: and the block chain node decrypts the signature certificate by using the CA certificate public key to obtain a user public key, and the authenticity verification is carried out on the payment encryption information and the collection encryption information, and the next step is carried out if the information is not tampered.
Step S608: and the block chain node decrypts the payment encryption information and the collection encryption information through a private key and verifies the validity period, and if the decryption is successful and the information is valid, the next step is carried out.
Step S609: and after the decryption is successful, obtaining payment original text information and collection original text information, comparing the appointed random numbers in the payment original text and the collection original text, and entering the next step if the appointed random numbers are consistent.
Step S610: and comparing the transfer amount in the payment original text and the collection original text, if the transfer amount is consistent, sending transfer success information to the user wallet, and sending transactable information to the main node to enter a next-stage consensus state.
Step S611: the purse of the receiving user receives f +1 successful transfer returns, according to the principle of a state machine, the initial state is consistent, the input is consistent, the final result is consistent, and the transaction in the main network of the block chain is necessarily and successfully identified. The front end displays that the transfer is successful.
Step S612: and the block chain main network successfully identifies the transfer, unlocks the payment address locking amount, transfers the account to the collection account number and modifies the time state of the payment address.
Step S613: and the leader node adds the transaction information into a transaction confirmation queue, performs block packaging and performs block broadcasting.
In an embodiment of the present invention, the method further includes a collection process of the collection end in an off-line state, as shown in fig. 7A, which specifically includes: s201, acquiring a receiver address and a received amount through a receiver, and digitally signing the receiver address according to a private key of a receiver to acquire signature information; s202, delivering the signature information, the address of the payee and the public key of the payee to a payer; s203, the payer verifies the address of the payee according to the signature information and the public key of the payee, and provides the address of the payer to the payee after the verification is passed; s204, the receiving end broadcasts and sends the receiving end address, the paying end address and the receiving amount to a main node on a block chain network; s205, transfer processing is carried out on the account corresponding to the address of the payment end according to the address of the payment end and the address of the collection end, and a block is generated and broadcasted according to the processing result. Through the above embodiment, the offline payment of the payee can be realized, and in actual work, the use process can refer to fig. 7B:
step S701: the payment user opens the payment wallet, carries out digital signature on the wallet address by using the user private key to generate signature information, and generates a collection two-dimensional code by the wallet address, the digital signature and the user public key through a two-dimensional code generation algorithm to be displayed to the payer.
Step S702: and the payee scans the two-dimensional code displayed by the payee through the mobile equipment to obtain the collection information, inputs the transfer amount, judges whether the balance is sufficient or not, and enters the next step if the balance is sufficient.
Step S703: and verifying the authenticity of the wallet address and verifying the timeliness of the message according to the acquired collection signature information, the public key and the wallet address, and entering a transfer process if the message is valid.
Step S704: and broadcasting and sending the transfer amount, the collection address and the payment address to the block chain node.
Step S705: and judging whether the collection address exists or not by the block link points, returning error information if the collection address does not exist, and performing transfer operation from the payment address to the collection address if the collection address exists and modifying the world state. Successfully sending transfer success information to the payment wallet.
Step S706: and the leader node adds the transaction information into a transaction confirmation queue, performs block packaging and performs block broadcasting.
Step S707: the payment user wallet receives f +1 successful transfer returns, according to the principle of a state machine, the initial state is consistent, the input is consistent, the final result is consistent, and the transaction must be identified successfully in the block chain main network. The front end displays that the transfer is successful.
Referring to fig. 8, the present invention further provides an offline payment system based on blockchain, which includes a payment end, a collection end and a blockchain network; the payment terminal is used for acquiring transfer amount and appointed random number input by a payment user, and carrying out encryption signature processing on the transfer amount, the appointed random number, the address of the payment terminal and the timestamp to obtain payment encryption information and a corresponding payment signature certificate; generating a locking permission certificate of a preset period according to the authorization of the payment signature certificate; the receiving terminal is used for locking the account transfer fund part in the account corresponding to the address of the payment terminal according to the address of the payment terminal and the request for generating the amount locking according to the locking permission certificate; acquiring a collection amount and an appointed random number input by a collection user, and carrying out encryption signature processing on the collection amount, the appointed random number, a collection end address and a timestamp to obtain collection encryption information and a corresponding collection signature certificate; the collection encryption information, the collection signature certificate, the payment encryption information and the payment signature certificate are broadcast and sent to a main node on a block chain network; the block chain network is used for analyzing the collection encryption information and the payment encryption information according to the collection signature certificate and the payment signature certificate to obtain payment original text information and collection original text information; when the obtained payment original text information is consistent with the appointed random number in the collection original text information and the transfer amount is consistent with the collection amount, initiating a transaction consensus request to other nodes on the block chain network; unlocking the transfer amount locked in the account corresponding to the payment end address according to the consensus result and the receiving end address, and performing transfer processing; and generating a block according to the processing result and broadcasting.
The payment terminal also comprises bar code information generated according to the payment signature certificate, the locking permission certificate, the payment encryption information and the payment terminal address; the receiving end also comprises a function of scanning and analyzing the bar code information to obtain the payment signature certificate, the locking permission certificate, the payment encryption information and the address of the payment end. In practical operation, the offline payment system based on the blockchain can be referred to as shown in fig. 1, and includes a payer network, a payee network, and a blockchain network. The payer network of the figure comprises a mobile phone and a tablet, and is accessed into a block chain network in a mode of payment wallet, payment website and the like, wherein the access equipment only performs light node access and only performs an initiating request operation without participating in block consensus and packaging work of a protocol layer, the payment network initiates a transaction user in an off-line state and needs to input transfer amount and an appointed random number, then the payment wallet is encrypted and signed, and finally a two-dimensional code generated by encrypted information, signature information and a signature certificate is displayed. The payee network shown in the figure comprises a mobile phone and a tablet which are connected into a block chain network in a mode of payment wallet, payment website and the like, the gathering network receives the transfer amount required to be input by a transaction user and appoints a random number in an online state, then the gathering wallet encrypts and signs, and finally the transaction request information of the payee and the transaction request information of the payer are sent to the block chain network together. The blockchain network as shown in the figure comprises a network layer and a storage layer, wherein the network layer is mainly a core processing layer for performing operations such as consensus communication and block packaging on each node. The storage layer is mainly a KV database, and the storage belt is information of the world state. Under the working state, after receiving payee transaction request information and payer transaction request information sent by a payer, each node verifies the correctness of the information, if the verification is successful, the verification returns to the completion and sends transactable information to the block chain main node, and if the main node receives f +1 transactable information, the transaction is a real transaction, and the broadcast consensus is carried out and the information is written into the storage layer.
In the above structure, the processing flow of the network request of the payment blockchain node may be as shown in fig. 2, and the specific steps are as follows:
a Request stage: and the payment wallet client side initiates a transaction request, and the payment wallet supporting layer broadcasting module broadcasts the transaction request to all the payment block chain nodes adjacent to the transaction request and waits for return.
And a message verification stage: and the payment block chain node receives the transaction request, performs signature verification, decryption, timeliness verification and transaction amount verification on the request, returns success information if the verification is successful, sends a verification success notice to the main node, displays a transfer success prompt if the payment wallet receives f +1 transaction success return information, and judges that the transaction is a legal transaction if the main node receives f +1 success notices, and performs the next step of consensus.
pre-prepare stage to commit stage: and the main node broadcasts and distributes the transaction information again, performs internal consensus on the block chain, and performs transaction packaging by the leader node at the final reply stage to generate the block.
In an embodiment of the present invention, the system further includes a registration module, where the registration module is configured to obtain identity information and a payment account input by a payment user, and generate a payment terminal address according to the payment account; generating a key pair of a payment user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the payment user, and sending the address of the payment end and a public key of the key pair to a block chain network for publication; receiving a digital certificate fed back by the block chain network according to the public key; or, acquiring identity information and a collection account input by a collection user, and generating a collection end address according to the collection account; generating a key pair of a collection user through an asymmetric encryption algorithm according to the identity information, feeding back a private key of the key pair to the collection user, and sending the address of a collection end and a public key of the key pair to a block chain network for publication; and receiving the digital certificate fed back by the block chain network according to the public key.
To sum up, the offline payment system based on the block chain provided by the present invention may include an interaction layer, a control management layer, and a support layer as a whole, specifically refer to fig. 3:
a system interaction layer: the system interaction layer comprises a registration login module, a system transaction module and an information query module, wherein the registration login module comprises registration, login and two-dimensional code generation, when a user registers for the first time, a secret key and a user address are generated according to a mnemonic word protocol and user information, the user address can be displayed on a mobile client in a two-dimensional code mode, and transaction and account transfer are carried out through the two-dimensional code of the user address; the system transaction module comprises an offline transaction and an online transaction, wherein the offline transaction adopts a state machine to ensure that the consensus is consistent; the information query module comprises money query, order query, information query and bill query.
And a control management layer: the control management layer is used for ensuring the safe transmission process of transaction data, is a system structure between the system interaction layer and the support layer, and comprises an authority management module and a key management module, wherein the identity verification module is used for verifying the identity of a user, and comprises multi-factor verification such as face recognition verification, fingerprint recognition verification, password verification and the like, and the key management module comprises key generation, key backup and key recovery; the key management module is internally provided with a public key and a private key, in the public key encryption, the public key is publicly transmitted between two communication parties and is issued in the block chain network, and the private key is used for decrypting data encrypted by the public key. In order to ensure that the transaction data is not modified in the transmission process and the user account is not stolen, the key management module adopts an asymmetric encryption technology. When an object needs to send data, the transmitted data needs to be encrypted by a private key of a sender, a receiver decrypts the transmitted data by a public key of the sender, when the object needs to receive the data, the sender needs to encrypt the data by the public key of the receiver, the receiver decrypts the data by the private key after receiving the data, when a user registers the system, a private key is generated according to user information and mnemonics, a corresponding public key is generated by the private key by an elliptic curve algorithm, and after hash calculation, a user address of an account used for transferring accounts and transactions is generated.
A support layer: the support layer is mainly a bottom layer block chain structure and comprises an encryption module, a locking contract module, a distributed book module and a broadcasting module. The account book module is mainly used for storing order information and account data; the locking contract module is mainly used for intelligently locking the payment amount when the payment is offline; the broadcasting module is mainly used for broadcasting the transaction information to the adjacent block chain main node; the encryption module is mainly used for encrypting transaction information through an asymmetric encryption algorithm and guaranteeing the safety of account transfer.
The invention also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method when executing the computer program.
The present invention also provides a computer-readable storage medium storing a computer program for executing the above method.
The invention has the beneficial technical effects that: convenient and fast: the problem that the current mobile payment account transfer can not realize offline account transfer between users at user level is solved, and through the system, the users can carry out quick offline payment at any time and any place as long as any party is online. And (3) trust transfer: the payer and the payee contract the transaction random numbers and input the transfer amount, so that the problem that the input amount is more than the appointed amount to cause the money loss of the user in the current mobile payment is solved, and the user does not need to worry about the problem of more money deduction through the system. Performance is improved: the system completes the transaction after verifying the request information to be correct by the principle that the initial states in the state machine are consistent and the input is consistent and the result is necessarily consistent, and then performs consensus packaging, thereby solving the problem of long confirmation time in the current block chain transaction. The transaction confirmation time of the system is in the second level, and is greatly improved compared with the confirmation time in the minute level of the current block chain transaction.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.