Anonymous red packet robbing method and device based on block chain and storage medium

文档序号:1817386 发布日期:2021-11-09 浏览:4次 中文

阅读说明:本技术 一种基于区块链的匿名抢红包方法、设备及储存介质 (Anonymous red packet robbing method and device based on block chain and storage medium ) 是由 马登极 王志文 吴思进 于 2021-09-03 设计创作,主要内容包括:本发明属于计算机技术领域,尤其涉及一种基于区块链的匿名抢红包方法、设备及储存介质。本发明提供的方法首先红包发起者没有参与红包领取交易的构建,无法追溯红包接收者,红包领取交易由红包接受者发起但基于红包合约签名,不透露自身的签名信息,实现匿名转账,保护了自身的隐私,保护领取用户的隐私。(The invention belongs to the technical field of computers, and particularly relates to an anonymous red packet robbing method based on a block chain, equipment and a storage medium. According to the method, firstly, the red envelope initiator does not participate in the construction of the red envelope getting transaction, and cannot trace back the red envelope receiver, the red envelope getting transaction is initiated by the red envelope receiver but is signed based on the red envelope contract, and the self signature information is not disclosed, so that anonymous transfer is realized, the self privacy is protected, and the privacy of the getting user is protected.)

1. An anonymous red packet robbing method based on a block chain is characterized by comprising the following contents:

roles in the anonymous red packet robbing method based on the block chain comprise: a red packet sending user, a red packet receiving user, a red packet contract and a block chain system; a block chain system is deployed with a red envelope contract;

the block chain-based anonymous red packet robbing method comprises the following steps:

a red packet sending user locally generates a first random number and calculates a first random number hash corresponding to the first random number;

constructing a red packet sending transaction based on the first random number hash, and generating a corresponding red packet ID for the red packet sending transaction, wherein transaction information of the red packet sending transaction comprises a plaintext of a total token amount contained in the red packet, the first random number hash corresponds to the total token amount contained in the red packet, the red packet ID is stored in a first Mercker tree, and the first Mercker tree is used for storing all red packet IDs based on the red packet contract;

the red envelope contract freezes a corresponding number of tokens in a user account for sending the red envelope;

the method comprises the steps that a red packet sending user generates red packet private information based on a red packet contract, wherein the red packet private information comprises a red packet ID and a plaintext of a first random number, and the red packet sending user publishes the red packet private information;

a red packet receiving user acquires red packet private information published by a red packet sending user; a red packet receiving user locally generates a second random number and calculates a second random number hash corresponding to the second random number; creating a first zero knowledge proof by a red packet receiving user and sending the first zero knowledge proof to the red packet contract, wherein the first zero knowledge proof is used for proving that the red packet receiving user knows the red packet private information;

the red envelope contract verifies the first zero knowledge proof, and the second random number hash of the red envelope receiving user is allowed to be registered to the red envelope ID if the verification is passed;

the red packet receiving users hash and register the generated second random numbers on the red packet ID, and the red packet contract allows one or more red packet receiving users to register on the same red packet ID at the same time;

after the registration condition of the second random number hashes meets a preset condition, distributing a corresponding number of tokens for all the second random number hashes registered on the red packet ID based on the number of the second random number hashes registered on the red packet ID and according to a preset distribution algorithm; the red packet sending user completes construction of red packet sending transaction based on the second random number Hash registered in the red packet ID and the number of tokens corresponding to the second random number Hash, and the red packet sending user sends transaction signature for the red packet and uploads the signature to the block chain;

a red packet receiving user constructs a red packet getting transaction according to a second random number hash and a second zero knowledge certificate, the red packet getting transaction and the second zero knowledge certificate are sent to the red packet contract, the red packet contract verifies the second zero knowledge certificate, and the red packet getting transaction is submitted to the block chain system if the verification is passed; and the second zero knowledge proves that the first random number Hash and the second random number Hash are taken as public inputs, and the clear text of the first random number, the clear text of the second random number and the red packet ID acquired by the red packet receiving user are taken as private inputs.

2. A computer device, characterized by one or more processors;

a memory for storing one or more programs,

the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method recited in claim 1.

3. A storage medium storing a computer program, characterized in that the program, when executed by a processor, implements the method of claim 1.

Technical Field

The invention belongs to the technical field of computers, and particularly relates to an anonymous red packet robbing method based on a block chain, equipment and a storage medium.

Background

Along with the intelligent development of science and technology, the functions of mobile phone communication software are more and more complete, when holidays come, more and more people send red packages to relatives and friends through the mobile phone communication software to set off the holiday atmosphere, and many businesses and the like also send red packages to the public in society for the purposes of propaganda, marketing and the like, the red package sending and receiving all have records, the information of a red package receiving user is disclosed, especially in the technical field of block chains, because the trade chain is required to be identified in the block chains, the existing red package sending and receiving schemes are displayed at present, a sender sends the red packages to a contract, the amount is frozen or the number is set, a receiver takes the contract, and the receiver leaves the receiving information, so the privacy of the user is not friendly. Therefore, there is a need for an anonymous red packet preemption method that can protect the privacy of the red packet retriever, for example, in a scenario where the sender discloses red packet information through a public medium and many people preempt the red packet.

Disclosure of Invention

In order to solve the technical problem, the invention provides an anonymous red packet robbing method, device and storage medium based on a block chain, which can protect the privacy of a red packet retriever.

In order to achieve the purpose, the invention adopts the following technical scheme.

In a first aspect, an anonymous red packet robbing method based on a blockchain is provided, which includes the following steps:

roles in the anonymous red packet robbing method based on the block chain comprise: a red packet sending user, a red packet receiving user, a red packet contract and a block chain system; a block chain system is deployed with a red envelope contract;

the block chain-based anonymous red packet robbing method comprises the following steps:

a red packet sending user locally generates a first random number and calculates a first random number hash corresponding to the first random number;

constructing a red packet sending transaction based on the first random number hash, and generating a corresponding red packet ID for the red packet sending transaction, wherein transaction information of the red packet sending transaction comprises a plaintext of a total token amount contained in the red packet, the first random number hash corresponds to the total token amount contained in the red packet, the red packet ID is stored in a first Mercker tree, and the first Mercker tree is used for storing all red packet IDs based on the red packet contract;

the red envelope contract freezes a corresponding number of tokens in a user account for sending the red envelope;

the method comprises the steps that a red packet sending user generates red packet private information based on a red packet contract, wherein the red packet private information comprises a red packet ID and a plaintext of a first random number, and the red packet sending user publishes the red packet private information;

a red packet receiving user acquires red packet private information published by a red packet sending user; a red packet receiving user locally generates a second random number and calculates a second random number hash corresponding to the second random number; creating a first zero knowledge proof by a red packet receiving user and sending the first zero knowledge proof to the red packet contract, wherein the first zero knowledge proof is used for proving that the red packet receiving user knows the red packet private information;

the red envelope contract verifies the first zero knowledge proof, and the second random number hash of the red envelope receiving user is allowed to be registered to the red envelope ID if the verification is passed;

the red packet receiving users hash and register the generated second random numbers on the red packet ID, and the red packet contract allows one or more red packet receiving users to register on the same red packet ID at the same time;

after the registration condition of the second random number hashes meets a preset condition, distributing a corresponding number of tokens for all the second random number hashes registered on the red packet ID based on the number of the second random number hashes registered on the red packet ID and according to a preset distribution algorithm; the red packet sending user completes construction of red packet sending transaction based on the second random number Hash registered in the red packet ID and the number of tokens corresponding to the second random number Hash, and the red packet sending user sends transaction signature for the red packet and uploads the signature to the block chain;

a red packet receiving user constructs a red packet getting transaction according to a second random number hash and a second zero knowledge certificate, the red packet getting transaction and the second zero knowledge certificate are sent to the red packet contract, the red packet contract verifies the second zero knowledge certificate, and the red packet getting transaction is submitted to the block chain system if the verification is passed; and the second zero knowledge proves that the first random number Hash and the second random number Hash are taken as public inputs, and the clear text of the first random number, the clear text of the second random number and the red packet ID acquired by the red packet receiving user are taken as private inputs.

In a second aspect, a computer device is provided, comprising one or more processors;

a memory for storing one or more programs,

the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method as described in the first aspect above.

In a third aspect, there is provided a storage medium storing a computer program which, when executed by a processor, implements the method as described in the first aspect above.

The method has the advantages that the privacy of the red packet receiving user can be effectively protected, the red packet sending user or other users can not inquire who receives the red packet, and the anonymous red packet receiving is realized.

Drawings

Fig. 1 is a schematic structural diagram of a computer device according to embodiment 2 of the present invention.

Detailed Description

The invention is described in further detail below with reference to specific embodiments and the attached drawing figures. Those skilled in the art will be able to implement the invention based on these teachings. Moreover, the embodiments of the present invention described in the following description are generally only some embodiments of the present invention, and not all embodiments. Therefore, all other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative effort shall fall within the protection scope of the present invention. Unless otherwise specified, the methods described in the examples of the present invention are all those known to those skilled in the art.

Example 1

The embodiment provides a method for fast customizing a block chain, which comprises the following steps:

roles in the anonymous red packet robbing method based on the block chain comprise: a red packet sending user, a red packet receiving user, a red packet contract and a block chain system; a block chain system is deployed with a red envelope contract;

the block chain-based anonymous red packet robbing method comprises the following steps:

a red packet sending user locally generates a first random number and calculates a first random number hash corresponding to the first random number;

constructing a red packet sending transaction based on the first random number hash, and generating a corresponding red packet ID for the red packet sending transaction, wherein transaction information of the red packet sending transaction comprises a plaintext of a total token amount contained in the red packet, the first random number hash corresponds to the total token amount contained in the red packet, the red packet ID is stored in a first Mercker tree, and the first Mercker tree is used for storing all red packet IDs based on the red packet contract;

the red envelope contract freezes a corresponding number of tokens in a user account for sending the red envelope;

the method comprises the steps that a red packet sending user generates red packet private information based on a red packet contract, wherein the red packet private information comprises a red packet ID and a plaintext of a first random number, and the red packet sending user publishes the red packet private information;

a red packet receiving user acquires red packet private information published by a red packet sending user; a red packet receiving user locally generates a second random number and calculates a second random number hash corresponding to the second random number; creating a first zero knowledge proof by a red packet receiving user and sending the first zero knowledge proof to the red packet contract, wherein the first zero knowledge proof is used for proving that the red packet receiving user knows the red packet private information;

the red envelope contract verifies the first zero knowledge proof, and the second random number hash of the red envelope receiving user is allowed to be registered to the red envelope ID if the verification is passed;

the red packet receiving users hash and register the generated second random numbers on the red packet ID, and the red packet contract allows one or more red packet receiving users to register on the same red packet ID at the same time;

after the registration condition of the second random number hashes meets a preset condition, distributing a corresponding number of tokens for all the second random number hashes registered on the red packet ID based on the number of the second random number hashes registered on the red packet ID and according to a preset distribution algorithm; the method comprises the steps that a red packet sending user completes construction of red packet sending transaction based on a second random number hash registered in a red packet ID and a token number corresponding to the second random number hash, and the red packet sending user sends a transaction signature for the red packet and uploads the transaction signature to a block chain;

a red packet receiving user constructs a red packet getting transaction according to a second random number Hash and constructs a second zero knowledge certificate and a third zero knowledge certificate, the red packet getting transaction, the second zero knowledge certificate and the third zero knowledge certificate are sent to a red packet contract, the red packet contract verifies the second zero knowledge certificate, if the verification is passed, the red packet receiving user is authorized to get a red packet check, the third zero knowledge certificate is seriously emphasized, the third zero knowledge certificate is used for proving that the total number of red packet check tokens is equal to the total number of the second check tokens plus the sum of transaction fees, and the red packet getting transaction is submitted to the block chain system; and the second zero knowledge proves that the first random number Hash and the second random number Hash are taken as public inputs, and the clear text of the first random number, the clear text of the second random number and the red packet ID acquired by the red packet receiving user are taken as private inputs.

The principle of this embodiment is that, first, the transaction method adopted in this embodiment is similar to a mimblewick, the actual amount of the transaction does not appear in the transaction, each transaction amount is configured with a corresponding random number as a private key, the output of the transaction, that is, the commitment in the mimblewick, conforms to the commitment formula c ═ v × G + r ×, where G and H are the generation points on an elliptic curve both in a public state, v is the actual amount of the transfer, r is the private key of v, the private key thereof must be known when v is used, the transaction is substantially similar to a check, a specific address is not bound, but the address is set by a user who knows the private key, so that the initiator does not need to know the address of the transfer and cannot trace back the address of the recipient, this embodiment also adopts this manner, a specific skilled person can know from the mimblewick, in the technical scheme of this embodiment, first, the red packet sending user performs hash red packet sending transaction based on the first random number, the method comprises the steps that firstly, unconsumed transaction output for constructing a red packet is frozen by a contract, a corresponding red packet ID is generated for the red packet sending transaction, then a red packet sending user publishes the red packet ID and a first random number plaintext, a red packet receiving user acquires the red packet ID and the first random number plaintext, then a first zero knowledge proof is constructed according to the red packet ID and the first random number plaintext, the fact that the red packet ID and the first random number plaintext are acquired is proved under the condition that the two contents are not disclosed, the red packet contract verifies that the red packet receiving user has the right to register a second random number Hash on the red packet ID, after the registration reaches a preset condition, the red packet sending user completes the red packet sending transaction, the red packet sending transaction expense unconsumed transaction output generates a red packet check with the number consistent with the registered number, the receipt of the red packet check is the corresponding second random number, and the second random number of the red packet Hash provided by the red packet check can be constructed to lead the red packet check It should be noted that the red envelope pickup transaction is signed by a red envelope contract, in general, the red envelope receiving user constructs the red envelope receiving user signature and sends the red envelope receiving user signature to the block chain, then the consensus is carried out, the token in the check is extracted from the contract address of the red envelope contract to the address set by the token after the execution of the red envelope pickup transaction, so that the problem exists in that the red envelope receiving user signature is published, because the pickup transaction of the red envelope check is correspondingly recorded, all people know that the owner of the signature picks up the red envelope, the signature is published externally, some organizations or famous people can almost correspond to the private key signature thereof, the signature is exposed, the privacy of the user is also exposed, therefore, in the application, the red envelope receiving user constructs the red envelope pickup transaction signed by the red envelope contract, and the exposed signature is the red envelope contract, the cost is to pay transaction fee, and provide third zero knowledge proof to prove that the transaction is legal, so that the red packet contract can sign the transaction, so that it is simple to prove that the transaction is legal, the third zero knowledge proof is an equation, the input of the red packet pickup transaction is equal to the output, the input of the red packet pickup transaction is a red packet check, the output is a plurality of second checks and transaction fees, so that the number of the tokens of the red packet check is equal to the sum of the total token amount of all the second checks and the transaction fees, the second check is a check with a random number set by a red packet receiving user, the random number of the check is only known by the red packet receiving user after the second check is changed into the second check, and the check belongs to the red packet receiving user (the original random number is not outside the red packet receiving user, and the red packet sending user knows the secret random number of all the red packet checks, and therefore cannot be considered to belong entirely to the red packet recipient user).

Example 2

A computer device, the device comprising: one or more processors; memory for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to perform the method of embodiment 1.

A storage medium storing a computer program which, when executed by a processor, implements the method as described in embodiment 1 above.

Fig. 1 is a schematic structural diagram of an apparatus provided in this embodiment.

As shown in fig. 1, as another aspect, the present application also provides a computer apparatus 500 including one or more Central Processing Units (CPUs) 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the apparatus 500 are also stored. The CPU501, ROM502, and RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.

The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication via a network such as the internet, and the processing driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.

In particular, according to the embodiments disclosed in the present application, the method described in the above embodiment 1 may be implemented as a computer software program. For example, embodiments disclosed herein include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method described in any of the embodiments above. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511.

As yet another aspect, the present application also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus of the above-described embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described herein.

The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

The units or modules described in the embodiments of the present application may be implemented by software or hardware. The described units or modules may also be provided in a processor, for example, each of the described units may be a software program provided in a computer or a mobile intelligent device, or may be a separately configured hardware device. Wherein the designation of a unit or module does not in some way constitute a limitation of the unit or module itself.

The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the present application. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:客户端收银方法、装置、设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!