CN110601819B - Processing method for random number, block chain link point device and storage medium - Google Patents

Processing method for random number, block chain link point device and storage medium Download PDF

Info

Publication number
CN110601819B
CN110601819B CN201910930049.XA CN201910930049A CN110601819B CN 110601819 B CN110601819 B CN 110601819B CN 201910930049 A CN201910930049 A CN 201910930049A CN 110601819 B CN110601819 B CN 110601819B
Authority
CN
China
Prior art keywords
event
block chain
sequence
random number
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910930049.XA
Other languages
Chinese (zh)
Other versions
CN110601819A (en
Inventor
周开班
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910930049.XA priority Critical patent/CN110601819B/en
Publication of CN110601819A publication Critical patent/CN110601819A/en
Application granted granted Critical
Publication of CN110601819B publication Critical patent/CN110601819B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the invention discloses a processing method for random numbers, a block chain node device and a storage medium, wherein the method comprises the following steps: responding to an event acquisition request of a client, and acquiring a random number, wherein the random number is generated by a target block chain node device in a block chain network to which the block chain node device belongs; carrying out hash calculation on the random number to obtain a hash value of the random number; converting the hash value to obtain a target value and a first threshold value corresponding to the hash value; determining an event acquisition result corresponding to the random number according to the target value and the first threshold value; and sending the event acquisition result to the client. By adopting the embodiment of the invention, the process of determining the event acquisition result according to the random number can be fairly disclosed, and the reliability of the event acquisition result is improved.

Description

Processing method for random number, block chain link point device and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method for processing a random number, a block link point device, and a storage medium.
Background
In daily life, there are many scenarios for acquiring events, such as acquiring electronic resource packages or acquiring articles, and an event issuer generates an event acquisition result when detecting an operation of an event acquirer, so that the event acquirer acquires an event corresponding to the event acquisition result.
In the process of generating the event acquisition result by the event issuer, whether the event acquirer can acquire the event corresponding to the event acquisition result is determined by the event issuer, and the process of generating the event acquisition result by the event issuer is opaque to the event acquirer, so that the process of generating the event acquisition result by the event issuer is insufficient in randomness and poor in fairness, and the reliability of the event acquisition result is low.
Disclosure of Invention
The embodiment of the invention provides a processing method of random numbers, a block chain node device and a storage medium, which can fairly disclose the process of determining event acquisition results according to the random numbers and improve the reliability of the event acquisition results.
In a first aspect, an embodiment of the present invention provides a method for processing a random number, where the method is applied to a block-link point device, and the method includes:
responding to an event acquisition request of a client, and acquiring a random number, wherein the random number is generated by a target block chain node device in a block chain network to which the block chain node device belongs; carrying out Hash calculation on the random number to obtain a Hash value of the random number; converting the hash value to obtain a target value and a first threshold value corresponding to the hash value; determining an event acquisition result corresponding to the random number according to the target value and the first threshold value; and sending the event acquisition result to the client.
In the technical scheme, after the block link point device obtains the random number, hash calculation is performed on the random number to obtain a hash value of the random number, the hash value is converted to obtain a target value and a first threshold value corresponding to the hash value, and an event obtaining result corresponding to the random number is determined according to the target value and the first threshold value. The process that the block chain link point device determines the event acquisition result corresponding to the random number according to the acquired random number is written into the block chain network in a digital form and is permanently stored by the block chain network and cannot be tampered, so that the process that the block chain link point device determines the event acquisition result according to the acquired random number is public and fair, and the reliability of the event acquisition result is improved.
In an implementation manner, according to the target value and the first threshold, a specific implementation manner of determining the event acquisition result corresponding to the random number may be: generating a numerical value interval corresponding to each event in the event cluster according to the first threshold and the weight of each event in the event cluster to be acquired; determining a target value interval to which the target value belongs in the generated value interval; and generating an event acquisition result according to the target value interval, wherein the event acquisition result is used for indicating the client to acquire an event corresponding to the target value interval.
In an implementation manner, a specific implementation manner of generating a numerical interval corresponding to each event in an event cluster according to a first threshold and a weight of each event in the event cluster to be obtained may be: acquiring an event cluster, wherein the event cluster comprises a plurality of events and the weight of each event; dividing the first threshold value according to the weight of each event to obtain a numerical value interval corresponding to each event in the event cluster; one event corresponds to one numerical interval, different events correspond to different numerical intervals, and the maximum value of each numerical interval is smaller than or equal to the first threshold.
In one implementation manner, before a target numerical value interval to which a target numerical value belongs is determined in a generated numerical value interval, an updated event cluster is obtained, wherein the updated event cluster comprises a plurality of updated events and the weight of each updated event; generating a numerical value interval corresponding to each event in the updated event cluster according to the first threshold and the weight of each event in the updated event cluster; and determining a target value interval to which the target value belongs in the updated value interval.
In an implementation manner, a specific implementation manner of converting the hash value to obtain the target value and the first threshold corresponding to the hash value may be: converting the hash value into a first sequence of numbers; obtaining a first threshold value according to the length of the first digital sequence; carrying out binary conversion on each digit in the first digit sequence according to a binary conversion algorithm to obtain a second digit sequence; converting the second digit sequence into the target value according to a decimal conversion algorithm.
In one implementation manner, according to the length of the first digit sequence, the specific implementation manner of obtaining the first threshold value may be: determining a third digital sequence according to the length of the first digital sequence, wherein the length of the third digital sequence is the same as that of the first digital sequence, and each digit in the third digital sequence is a preset threshold value; carrying out binary conversion on each digit in the third digit sequence according to a binary conversion algorithm to obtain a fourth digit sequence; the fourth digit sequence is converted to the first threshold value according to a decimal conversion algorithm.
In an implementation manner, the specific implementation manner of converting the hash value to obtain the target value and the first threshold corresponding to the hash value may be: converting the hash value into a first sequence of numbers; calculating the number contained in the first number sequence to obtain a target numerical value; determining a third digital sequence according to the length of the first digital sequence, wherein the length of the third digital sequence is the same as that of the first digital sequence, and each digit in the third digital sequence is a preset threshold value; and operating the digits contained in the third digit sequence to obtain a first threshold value.
In a second aspect, an embodiment of the present invention provides a block link point device, where the block link point device has a function of implementing the processing method for random numbers according to the first aspect. The functions can be realized by hardware, and the functions can also be realized by executing corresponding software by hardware. The hardware or software includes one or more units corresponding to the above functions.
In one implementation mode, the block link point device comprises an acquisition unit, a calculation unit, a conversion unit, a determination unit and a sending unit. The system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for responding to an event acquisition request of a client and acquiring a random number, and the random number is generated by a target block chain node device in a block chain network to which a block chain node device belongs; the calculating unit is used for carrying out Hash calculation on the random number to obtain a Hash value corresponding to the random number; the conversion unit is used for converting the hash value to obtain a target value and a first threshold value corresponding to the hash value; the determining unit is used for determining an event acquisition result corresponding to the random number according to the target value and the first threshold value; and the sending unit is used for sending the event acquisition result to the client.
In a third aspect, an embodiment of the present invention provides a block chain node device, including a memory and a processor, where the memory is used for storing a computer program; and a processor calling the computer program stored in the memory for executing the method for processing the random number according to the first aspect.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium for storing a computer program for a block-link node apparatus, which includes program instructions for executing the first aspect.
In the embodiment of the invention, the block chain link point device combines a processing method for random numbers with an intelligent contract technology based on a block chain technology, the process of determining an event acquisition result according to the random numbers is written into a block chain network in a digital form and is permanently stored by the block chain network, the process of determining the event acquisition result according to the random numbers by the block chain link point device in the block chain network each time is commonly witnessed by other block chain link point devices in the block chain network, the process of determining the event acquisition result according to the random numbers by the block chain link point device each time is transparent and cannot be tampered, the processing process of each acquired random number by the block chain link point device is the same, the process of determining the event acquisition result according to the acquired random numbers by the block chain link point device is public and fair, and the event acquisition result has high credibility.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic architecture diagram of a communication system according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a method for processing random numbers according to an embodiment of the present invention;
FIG. 3 is a flow chart illustrating another method for processing random numbers according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a block link point device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a block link point device according to an embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described below with reference to the drawings.
In daily life, there are many scenarios for acquiring events, such as acquiring electronic resource packages or acquiring articles, and an event issuer generates an event acquisition result when detecting an operation of an event acquirer, so that the event acquirer acquires an event corresponding to the event acquisition result. Taking a lottery event as an example, in the lottery event, two roles of a merchant and a customer are mainly involved, the merchant serves as an event issuer, the customer serves as an event acquirer, and when the merchant detects lottery operation of the customer, an event acquisition result is generated, so that the customer acquires an event corresponding to the event acquisition result.
In the process of generating the event acquisition result by the event issuer, whether the event corresponding to the event acquisition result can be acquired by the event acquirer is determined by the event issuer, the process of generating the event acquisition result by the event issuer is opaque to the event acquirer, for example, in a lottery activity, whether a customer can obtain a prize, several prizes are determined by a merchant, and the process of generating the event acquisition result by the merchant according to the detected lottery operation of the customer is opaque to the customer, so that the process of generating the event acquisition result by the event issuer is insufficient in randomness and poor in fairness, and the reliability of the event acquisition result is low.
In order to solve the above problems, embodiments of the present invention provide a method for processing a random number, a block chain node device, and a storage medium, in which an intelligent contract technology based on a block chain technology is introduced into a scene of an acquisition event. The processing method of the random number is stored in the blockchain network in the form of an intelligent contract, and when a trigger condition is reached, a blockchain link point device in the blockchain network calls the intelligent contract to automatically execute the processing method of the random number. Among them, smart contracts (smart contracts) are a computer protocol intended to propagate, verify or execute contracts in an informational manner. The intelligent contract is written into the block chain network in a digital form, and due to the characteristics of distributed storage and decentralization of the block chain, the intelligent contract based on the block chain technology not only can exert the advantages of the intelligent contract in the aspect of cost efficiency, but also can avoid the interference of malicious behaviors such as intentional tampering and the like on the normal execution of the intelligent contract.
By implementing the embodiment of the invention, the processing method of the random number is combined with the technology of the intelligent contract based on the block chain technology, and based on the characteristics of distributed storage and decentralization of the block chain technology, the intelligent contract executing the processing method of the random number is ensured to be openly transparent and can not be tampered by the processes of storage, reading and execution of each block chain node device in the block chain network, so that the process of generating the event acquisition result by an event issuer according to the operation of the detected event acquirer is openly disclosed, and the reliability of the event acquisition result is improved.
In order to better understand the method for processing random numbers, the block link point device, and the storage medium disclosed in the embodiments of the present invention, a communication system to which the embodiments of the present invention are applied will be described first.
Referring to fig. 1, fig. 1 is a schematic diagram of a communication system according to an embodiment of the present invention. As shown in fig. 1, the communication system may include: block chain link point device 101, client 102. The processing method of the random number can be as follows: in response to an event acquisition request from a client, block link point device 101 acquires a random number generated by a target block link point device in a block chain network to which block link point device 101 belongs; the block chain node point device 101 performs hash calculation on the random number to obtain a hash value of the random number; the block chain link point device 101 converts the hash value to obtain a target value and a first threshold value corresponding to the hash value; the block chain node point device 101 determines an event acquisition result corresponding to the random number according to the target numerical value and the first threshold; block link node device 101 sends the event acquisition result to client 102. Since the intelligent contract for executing the processing method for the random number is written into the block chain network in a digitized form, any one block chain node device in the block chain network can call the intelligent contract to execute the processing method for the random number, and thus the block chain node device 101 can be any one block chain node device in the block chain network. The client 102 may run in a terminal device, and a user may interact with the client 102 through the terminal device, where the terminal device may be a mobile terminal, a Personal Computer (PC) terminal, a laptop Computer (Tablet PC) terminal, or the like.
The block chain node device performs hash calculation on random numbers by using a hash algorithm, wherein the hash algorithm is also called as a hash algorithm and is a function for compressing messages with any length to a message digest with a certain fixed length, and the message digest with the fixed length is a hash value. It should be noted that the hash value is a short string of random letters and numbers. The hash algorithm includes, but is not limited to: the MD4 algorithm, MD5 algorithm, SHA-1 algorithm, SHA-256 algorithm, etc. Taking the working principle of the SHA-256 algorithm as an example, inputting any string of data into the SHA-256 algorithm will result in a 256-bit hash value. The same data input will obtain the same result, as long as the input data changes slightly, for example, one 1 in the input data becomes 0, a new result which is different from the original result will be obtained, and the hash value of the input data calculated according to the hash algorithm cannot be predicted in advance, so that the process of determining the event to obtain the result according to the random number has randomness. The hash algorithm also has a characteristic that it is difficult to find a reverse rule, that is, it is extremely difficult to calculate the corresponding input data according to the hash value, and it is considered impossible under the current technological conditions.
In this way, the random number is generated by a target block chain node device in the block chain network to which the block chain node device belongs, and the process of determining the event acquisition result according to the random number is written into the block chain network in a digital form and is permanently stored by the block chain network. The process that the block chain link point device determines the event acquisition result according to the random number each time is transparent and cannot be tampered, and other block chain link point devices in the block chain network can prove that the process that the block chain link point device determines the event acquisition result according to the random number each time is achieved, so that the process that the block chain link point device determines the event acquisition result according to the obtained random number is public and fair, and the reliability of the event acquisition result is improved.
In one implementation, as shown in the schematic architecture diagram of the communication system shown in fig. 1, the processing method of the random number may be: the client sends an event acquisition request to the block link point device, and the block link point device generates a random number in response to the event acquisition request of the client, namely the block link point device has the function of generating the random number of a target block link point device; after the random number is generated, the block chain node device carries out Hash calculation on the random number to obtain a Hash value of the random number; after the hash value of the random number is obtained, the block link point device converts the hash value to obtain a target value and a first threshold value corresponding to the hash value; after a target value and a first threshold value corresponding to the hash value are obtained, determining an event acquisition result corresponding to the random number by the block link point device according to the target value and the first threshold value; and after the event acquisition result corresponding to the random number is obtained, the block chain node device sends the event acquisition result to the client.
For example, in an application scenario of a lottery event, the block-link point device may be a block-link point device corresponding to a merchant, and the event acquisition result may be a winning result of a customer. After a client detects lottery drawing operation of a customer, an event acquisition request is generated according to the lottery drawing operation and is sent to a block chain node device corresponding to a merchant, the block chain node device corresponding to the merchant responds to the event acquisition request of the client to generate a random number, an intelligent contract is triggered, the block chain node device corresponding to the merchant automatically executes a processing method of the random number, the block chain node device corresponding to the merchant performs hash calculation on the random number to obtain a hash value of the random number, after the hash value of the random number is obtained, the block chain node device corresponding to the merchant converts the hash value to obtain a target value and a first threshold value corresponding to the hash value, the block chain node device corresponding to the merchant determines winning conditions of the customer participating in the lottery drawing activity according to the target value and the first threshold value and sends the winning conditions to the client, and the customer checks the winning conditions of the lottery drawing activity through the client.
In one implementation, as shown in the schematic architecture of the communication system in fig. 1, a block-link point device 101 in the communication system may include a first block-link point device and a second block-link point device. In a communication system comprising a client, a first block chain node device and a second block chain node device, the processing method of the random number may be: the client sends an event acquisition request to the first block chain link point device and the second block chain link point device; the first block chain node point device responds to an event acquisition request of a client and generates a random number, namely the first block chain node point device is a target block chain node point device for generating the random number; the second block chain node device responds to an event acquisition request of the client and requests the first block chain node device to acquire a random number; after the random number is obtained, the second block chain link point device carries out Hash calculation on the random number to obtain a Hash value of the random number; after the hash value of the random number is obtained, the second block chain node device converts the hash value to obtain a target value and a first threshold value corresponding to the hash value; after a target value and a first threshold value corresponding to the hash value are obtained, the second block chain node device determines an event obtaining result corresponding to the random number according to the target value and the first threshold value; and after the event acquisition result corresponding to the random number is obtained, the second block chain link point device sends the event acquisition result to the client.
For example, in an application scenario of a lottery event, the second blockchain node device may be a blockchain node device corresponding to a merchant, the first blockchain node device may be a target blockchain node device for generating a random number in a blockchain network, and the event acquisition result may be a prize winning condition of a customer. After detecting lottery drawing operation of a customer, a client generates an event acquisition request according to the lottery drawing operation, and sends the event acquisition request to a first block chain node device and a block chain node device corresponding to a merchant; the first block chain node device responds to an event acquisition request of a client and generates a random number; the method comprises the steps that a block chain node device corresponding to a merchant responds to an event acquisition request of a client and requests a first block chain node device to acquire a random number; after the block chain node device corresponding to the merchant acquires the random number, the intelligent contract is triggered, the block chain node device corresponding to the merchant automatically executes a processing method of the random number, the block chain node device corresponding to the merchant performs Hash calculation on the random number to obtain a Hash value of the random number, after the Hash value of the random number is obtained, the block chain node device corresponding to the merchant converts the Hash value to obtain a target value and a first threshold value corresponding to the Hash value, the block chain node device corresponding to the merchant determines a prize winning condition of a customer participating in a lottery drawing activity according to the target value and the first threshold value, the prize winning condition is sent to the client, and the customer checks the prize winning condition of the lottery drawing activity participating in this time through the client.
In one implementation, in a communication system including a client, a first block-link point device, and a second block-link point device, the method for processing the random number may further be: the client sends an event acquisition request to a first block chain node device, and the first block chain node device responds to the event acquisition request of the client and generates a random number, namely the first block chain node device is a target block chain node device for generating the random number; the first block chain node point device sends the generated random number to a client, and the client sends an event acquisition request to a second block chain node point device after receiving the random number from the first block chain node point device, wherein the event acquisition request carries the random number; the second block chain node responds to an event acquisition request of the client to acquire the random number, and hash calculation is carried out on the random number to acquire a hash value of the random number; after the hash value of the random number is obtained, the second block link point converts the hash value to obtain a target value and a first threshold value corresponding to the hash value; after a target value and a first threshold value corresponding to the hash value are obtained, the second block chain node device determines an event obtaining result corresponding to the random number according to the target value and the first threshold value; and after the event acquisition result corresponding to the random number is obtained, the second block chain link point device sends the event acquisition result to the client.
For example, in an application scenario of a lottery event, the second block chain node device may be a block chain node device corresponding to a merchant, the first block chain node device may be a target block chain node device for generating a random number in a block chain network, and the event acquisition result may be a prize winning condition of a customer. After detecting lottery drawing operation of a customer, a client generates an event acquisition request according to the lottery drawing operation and sends the event acquisition request to a first block chain node device; the first block chain node device responds to an event acquisition request of a client, generates a random number and sends the random number to the client; after receiving the random number from the first block chain node device, the client sends an event acquisition request to a block chain node device corresponding to a merchant, wherein the event acquisition request carries the random number; the block chain node device corresponding to the merchant responds to the event acquisition request of the client to acquire the random number; after the block chain node device corresponding to the merchant acquires the random number, the intelligent contract is triggered, the block chain node device corresponding to the merchant automatically executes a processing method of the random number, the block chain node device corresponding to the merchant performs Hash calculation on the random number to obtain a Hash value of the random number, after the Hash value of the random number is obtained, the block chain node device corresponding to the merchant converts the Hash value to obtain a target value and a first threshold value corresponding to the Hash value, the block chain node device corresponding to the merchant determines a prize winning condition of a customer participating in a lottery drawing activity according to the target value and the first threshold value, the prize winning condition is sent to the client, and the customer checks the prize winning condition of the lottery drawing activity participating in this time through the client.
In this way, the random number acquired by the block chain link point device is generated by the target block chain link point device in the block chain network to which the block chain link point device belongs, so that the reliability of the random number is improved, and further, the event acquisition result determined by the block chain link point device according to the random number also has higher reliability.
It should be understood that the communication system described in the embodiment of the present invention is for more clearly illustrating the technical solution of the embodiment of the present invention, and does not form a limitation on the technical solution provided in the embodiment of the present invention, and as a person having ordinary skill in the art knows that along with the evolution of the system architecture and the appearance of a new service scenario, the technical solution provided in the embodiment of the present invention is also applicable to similar technical problems.
Referring to fig. 2, fig. 2 is a flow chart of a method for processing a random number according to an embodiment of the present invention, where the method includes, but is not limited to, the following steps:
step S201: and the client sends an event acquisition request to the block link node device.
Specifically, when the client detects a user operation, the client may generate an event acquisition request according to the detected user operation, and send the event acquisition request to the block link point device, so that the block link point device acquires a random number in response to the event acquisition request of the client, and determines a corresponding event acquisition result according to the random number. For example, in the lottery activity, when the client detects the operation of clicking a 'start lottery' button in a user interface by a user, the client generates an event acquisition request according to the detected user operation and sends the event acquisition request to the block chain node device corresponding to the merchant, so that the block chain node device corresponding to the merchant responds to the event acquisition request of the client, acquires a random number and determines a corresponding prize winning condition according to the random number.
Step S202: the block chain node device responds to an event acquisition request of the client and acquires the random number.
Specifically, after receiving an event acquisition request from a client, the block link point device acquires a random number in response to the event acquisition request from the client, where the random number is generated by a target block link point device in a block chain network to which the block link point device belongs.
In one implementation, in the communication system shown in fig. 1, the communication system includes a client and a block-linked point device, and the block-linked point device may obtain the random number by: after the block chain node point device receives an event acquisition request from a client, the block chain node point device responds to the event acquisition request of the client, generates a block according to the event acquisition request and acquires block information of the block; after the block information of the block is acquired, the block link point device generates a random number according to the block information, namely the block link point device has the function of generating the random number of the target block link point device. It should be noted that the block information is used to identify the block, and the block information may be a hash value of a block header, a hash root of a merkel tree, or the like, which is not limited in the embodiment of the present invention. For example, in a lottery activity, after receiving an event acquisition request from a client, a blockchain device corresponding to a merchant responds to the event acquisition request, generates a block according to the event acquisition request, acquires block information, and generates a random number according to the block information.
In one implementation manner, in the communication system shown in fig. 1, the communication system includes a client and a block-linked point device, and the manner for the block-linked point device to obtain the random number may further be: after the client generates an event acquisition request according to the detected user operation, taking the event acquisition request as input data of a random number generator, and taking output data of the random number generator as a random number corresponding to the event acquisition request; after the random number is generated, the client sends an event acquisition request to the block chain node point device, wherein the event acquisition request carries the random number, and the block chain node point device responds to the event acquisition request to acquire the random number. The random number Generator may execute a random number generation algorithm such as a Linear congruence method (LCG) or a mersene rotation Method (MT), which is not limited in the embodiments of the present invention.
In one implementation, as shown in the communication system of fig. 1, a block-linked point device in the communication system may include a first block-linked point device and a second block-linked point device. In a communication system comprising a client, a first block link point device and a second block link point device, the block link point device may obtain a random number in the following manner: when the client detects user operation, the client generates an event acquisition request according to the detected user operation and sends the event acquisition request to the first block chain node device and the second block chain node device; the first block chain node device responds to an event acquisition request of a client, generates a block according to the event acquisition request and acquires block information of the block; after the block information of the block is obtained, the first block link point device generates a random number according to the block information, namely the first block link point device is a target block link point device for generating the random number; the second block chain node device responds to the event acquisition request of the client and requests the first block chain node device to acquire the random number. For example, in a lottery activity, the second block chain node device is a block chain node device corresponding to a merchant, the first block chain node device is a target block chain node device in a block chain network to which the block chain node device corresponding to the merchant belongs, when the client detects that a user clicks an operation of a 'start lottery' button in a user interface, the client generates an event acquisition request according to the detected user operation and sends the event acquisition request to the first block chain node device and the block chain node device corresponding to the merchant, and after the first block chain node device receives the event acquisition request from the client, the first block chain node device responds to the event acquisition request of the client, generates a block according to the event acquisition request, acquires block information, and generates a random number according to the block information; and responding to the event acquisition request of the client by the block chain node point device corresponding to the merchant, and requesting the first block chain node point device to acquire the random number.
In one implementation, in a communication system including a client, a first block-link point device, and a second block-link point device, the block-link point device may further obtain a random number by: when the client detects user operation, the client generates an event acquisition request according to the detected user operation and sends the event acquisition request to the first block link node device; the first block chain node device responds to an event acquisition request of a client, generates a block according to the event acquisition request and acquires block information of the block; after the block information of the block is obtained, the first block link point device generates a random number according to the block information and sends the random number to the client, namely the first block link point device is a target block link point device for generating the random number; after receiving the random number from the first block chain node device, the client sends an event acquisition request to the second block chain node device, wherein the event acquisition request carries the random number; the second block chain node acquires the random number in response to an event acquisition request of the client. For example, in a lottery activity, the second block chain node device is a block chain node device corresponding to a merchant, the first block chain node device is a target block chain node device in a block chain network to which the block chain node device corresponding to the merchant belongs, when the client detects that a user clicks an operation of a 'start lottery' button in a user interface, the client generates an event acquisition request according to the detected user operation and sends the event acquisition request to the first block chain node device, and after receiving the event acquisition request from the client, the first block chain node device responds to the event acquisition request of the client, generates a block according to the event acquisition request, acquires block information, generates a random number according to the block information, and sends the random number to the client; after receiving the random number from the first block chain node point device, the client sends an event acquisition request to a block chain node point device corresponding to a merchant, wherein the event acquisition request carries the random number; and the block chain node corresponding to the merchant responds to the event acquisition request of the client to acquire the random number.
Step S203: and the block chain node device performs Hash calculation on the random number to obtain a Hash value of the random number.
Specifically, after the block link node device acquires the random number by executing any one of the methods described in step S201 in the embodiment of the present invention, the acquired random number is used as input data of a hash algorithm, and the random number is calculated according to the hash algorithm, so that a hash value of the random number can be obtained. For example, the block link node device acquires a random number with a value of "1346", selects an MD5 algorithm in the hash algorithms to calculate the random number, and acquires a hash value of the random number of "82965d4ed8150294d4330ace00821d77". For another example, the block link point device obtains a random number with a value of "1346", selects an SH a-256 algorithm in the hash algorithm to calculate the random number, and obtains a hash value of "5631e5efadc1db19f6b2453cc6a2d6b76a81682d8c 85940343794 a2558a91e" of the random number.
Step S204: the block chain node device converts the hash value into a first digital sequence.
Specifically, the method for converting the hash value into the first digital sequence by the block chain node device may be: the block chain node device converts the letter sequence in the hash value into a corresponding numerical value in American Standard Code for Information Interchange (ASCII), and obtains a first number sequence corresponding to the hash value. Taking the hash value "3b" as an example, in American Standard Code for Information Interchange (ASCII), the value corresponding to the letter "b" is "98", and the block chain node device converts the hash value "3b" into the first number sequence corresponding to the hash value "3,9,8".
Step S205: the block chain link point device obtains a first threshold value according to the length of the first digital sequence.
Specifically, the block chain link point device may determine the third number sequence according to the length of the first number sequence, where the length of the third number sequence is the same as the length of the first number sequence, and each digit in the third number sequence is a preset threshold. The block chain link point device can carry out binary conversion on each digit in the third digit sequence according to a binary conversion algorithm to obtain a fourth digit sequence; the block chain link point device can record each digit in a fourth digit sequence with the length of N as the 0 th digit, the 1 st digit, \ 8230, the N-1 st digit from the right to the left according to a decimal conversion algorithm, and the block chain link point device is according to a formula "
Figure GDA0003988683860000121
Ith digit x 2 i "calculate the result corresponding to the fourth word sequence, and the block chain node device uses the result as the first threshold.
For example, the block chain node device converts the hash value into the first number sequence "3,9,8", where the length of the first number sequence "3,9,8" is 3 bits, the length of the third number sequence determined according to the first number sequence is also 3 bits, the preset threshold value may be the number "9" with the largest value in decimal, and the third number sequence determined by the block chain node device according to the first number sequence "3,9,8" is "9, 9". The block chain node point device converts each digit in the third digit sequence of 9,9 and 9 into a corresponding four-digit binary sequence according to a binary conversion algorithm, the four-bit binary sequence corresponding to the number "9" is "1,0, 1", the block chain node device converts the third digital sequence "9, 9" into the fourth digital sequence "1,0, 1,0,0,1". Block chain link point device according to the formula "
Figure GDA0003988683860000122
Ith digit x 2 i "calculating the result corresponding to the fourth numerical sequence" 1 × 20+0 × 2 1 +0×2 2 +1×2 3 +1×2 4 +0×2 5 +0×2 6 +1×2 7 +1×2 8 +0×2 9 +0×2 10 +1×2 11 ", the final result is" 2457", and the tile chain node means converts the fourth number sequence" 1,0, 1,0, 1 "into the first threshold value" 2457 "according to the decimal conversion algorithm.
In one implementation, the block link point device may establish a table recording lengths of the first number sequences and the first threshold, where the first number sequences with different lengths correspond to different first thresholds, and the first number sequences with the same length correspond to the same first threshold. The block-link dot device may determine the first threshold corresponding to the first number sequence by looking up a table according to the length of the first number sequence. For example, the length of the first number sequence is 2 bits, and the block link node device may determine that the first threshold corresponding to the first number sequence is "153" by looking up the table. As another example, if the first number sequence is 3 bits in length, the block chain node device may determine, by looking up the table, that the first threshold corresponding to the first number sequence is "2457".
Step S206: and the block chain link point device carries out binary conversion on each digit in the first digit sequence according to a binary conversion algorithm to obtain a second digit sequence.
Specifically, the block chain node point device may convert each digit in the first digit sequence into a corresponding four-digit binary sequence according to a binary conversion algorithm to obtain a second digit sequence, where the second digit sequence is composed of the four-digit binary sequence corresponding to each digit in the first digit sequence. Taking the first number sequence as "3,9,8" for example, the four-bit binary sequence corresponding to the number "3" is "0, 1", the four-bit binary sequence corresponding to the number "9" is "1,0, 1", the four-bit binary sequence corresponding to the number "8" is "1, 0", the block chain node device converts each digit in the first digit sequence 3,9,8 according to a binary conversion algorithm, A second digital sequence "0,0,1,1,1,0,0,1,1,0,0,0" is obtained.
Step S207: the block chain node device converts the second digit sequence into a target digit according to a decimal conversion algorithm.
Specifically, the block chain link device may be configured to record each digit in the second digit sequence with the length N as 0 th digit, 1 st digit, \ 8230, and N-1 st digit according to a decimal conversion algorithm from right to left, and the block chain link point device is configured according to a formula "
Figure GDA0003988683860000131
Ith digit x 2 i "calculate the result corresponding to the second word number sequence, and the block chain link point device takes the result as the target value. <xnotran> "0,0,1,1,1,0,0,1,1,0,0,0" , "</xnotran>
Figure GDA0003988683860000132
Ith digit x 2 i "calculation of the result corresponding to the second numerical sequence" 0X 20+ 0X 2 1 +0×2 2 +1×2 3 +1×2 4 +0×2 5 +0×2 6 +1×2 7 +1×2 8 +1×2 9 +0×2 10 +0×2 11 <xnotran> ", "920", , "0,0,1,1,1,0,0,1,1,0,0,0" "920". </xnotran>
In this way, each block chain node device obtains a random number, a hash value of the random number is obtained through calculation according to a hash algorithm, a first digit sequence corresponding to the hash value is obtained according to American Standard Code for Information Interchange (ASCII), a first threshold value is determined according to the length of the first digit sequence, a second digit sequence corresponding to the first digit sequence is obtained according to a binary conversion algorithm, and a target value corresponding to the second digit sequence is obtained according to a decimal conversion algorithm. The block chain node point device has the same processing process for each acquired random number, and the processing process for each acquired random number is transparent and cannot be tampered, so that the process that the block chain node point device acquires the target value corresponding to the hash value and the first threshold value is more fairly disclosed.
Step S208: and the block chain link point device determines an event acquisition result corresponding to the random number according to the target numerical value and the first threshold value.
Specifically, the block chain node point device can obtain an event cluster, wherein the event cluster comprises a plurality of events and the weight of each event; after the event clusters are obtained, the block chain node point device divides the first threshold value according to the weight of each event to obtain the value intervals corresponding to each event in the event clusters, wherein one event corresponds to one value interval, different events correspond to different value intervals, and the maximum value of each value interval is smaller than or equal to the first threshold value; the block chain node device can determine a target value interval to which the target value belongs in the generated interval, so that an event acquisition result is generated according to the target value interval, and the event acquisition result is used for indicating the client to acquire an event corresponding to the target value interval.
For example, in a lottery activity, the block chain link point device corresponding to the merchant may be a block chain link point device corresponding to the merchant, the event cluster obtained by the block chain link point device corresponding to the merchant is { obtain first-equal prizes, obtain second-equal prizes, and obtain third-equal prizes }, in the event cluster, the weight corresponding to the event "obtain first-equal prizes" is "15%", the weight corresponding to the event "obtain second-equal prizes" is "25%", and the weight corresponding to the event "obtain third-equal prizes" is "60%". And the block chain link point device corresponding to the merchant obtains a target numerical value '30' and a first threshold value '100' corresponding to the random number according to the obtained random number. The block chain link point device corresponding to the merchant divides the first threshold value '100' according to the weight of each event to obtain a numerical value interval corresponding to each event in the event cluster, the numerical value interval corresponding to the event 'obtaining the first equal prize' is [0, 15 ], the numerical value interval corresponding to the event 'obtaining the second equal prize' is [15, 40 ], and the numerical value interval corresponding to the event 'obtaining the third equal prize' is [40, 100]. The target value "30" belongs to the value interval [15, 40), and the block chain link point device corresponding to the trader determines the value interval [15, 40) to be the target value interval to which the target value "30" belongs. And the block chain node device corresponding to the merchant determines an event acquisition result according to the target value interval [15, 40) to which the target value "30" belongs, wherein the event acquisition result is used for indicating the client to acquire the event "win the second prize" corresponding to the target value interval. And the block chain link point device corresponding to the merchant determines that the random number obtains the second-class prize in the lottery activity according to the obtained random number.
For another example, in a lottery activity, the block link point device corresponding to the merchant may be a block link point device corresponding to the merchant, the event cluster obtained by the block link point device corresponding to the merchant is { obtain first-equal prize, obtain second-equal prize, obtain third-equal prize, and win }, in the event cluster, the weight corresponding to the event "obtain first-equal prize" is "10%", the weight corresponding to the event "obtain second-equal prize" is "15%", the weight corresponding to the event "obtain third-equal prize" is "25%", and the weight corresponding to the event "win no prize" is "50%". And the block chain link point device corresponding to the merchant obtains a target numerical value '60' and a first threshold value '100' corresponding to the random number according to the obtained random number. The block chain link point device corresponding to a merchant divides the first threshold value '100' according to the weight of each event to obtain a numerical value interval corresponding to each event in an event cluster, the numerical value interval corresponding to the event 'obtaining the first equal prize' is [0, 10 ], the numerical value interval corresponding to the event 'obtaining the second equal prize' is [10, 25 ], the numerical value interval corresponding to the event 'obtaining the third equal prize' is [25, 50 ], and the numerical value interval corresponding to the event 'losing the prize' is [50, 100]. The target value '60' belongs to the value interval [50, 100], and the block chain link point device corresponding to the merchant determines that the value interval [50, 100] is the target value interval to which the target value '60' belongs. And the block chain node device corresponding to the merchant determines an event acquisition result according to the target value interval [50, 100] to which the target value '60' belongs, wherein the event acquisition result is used for indicating the client to acquire the event 'loser' corresponding to the target value interval. And the block chain link point device corresponding to the merchant determines that the random number does not win the prize in the lottery at this time according to the acquired random number.
In this way, each time the block chain node point device acquires a random number, the block chain node point device can acquire a target value and a first threshold value corresponding to the random number, and according to the first threshold value corresponding to the random number and the weight corresponding to each event in the event cluster, the block chain node point device can generate an interval corresponding to each event, and determine an event acquisition result according to the target value interval to which the target value belongs in the generated interval. The interval corresponding to each event in the event cluster is determined by the first threshold and the weight corresponding to each event in the event cluster. For example, in the lottery activity, the weight corresponding to each event in the event cluster is determined by the merchant, the first threshold value is determined by the random number provided by the customer, and the customer and the merchant participate in the determination process of the event acquisition result together, so that the process of determining the event acquisition result according to the random number is more fair, and the reliability of the event acquisition result is higher.
In one implementation, before determining a target numerical value interval to which a target numerical value belongs in a generated interval, the block link point device may obtain an updated event cluster, where the updated event cluster includes a plurality of updated events and weights of the updated events, and after obtaining the updated event cluster, the block link point device may generate a numerical value interval corresponding to each event in the updated event cluster according to a first threshold and the weights of the events in the updated event cluster, and determine the target numerical value interval to which the target numerical value belongs in the updated numerical value interval, so as to generate an event acquisition result according to the target numerical value interval. For example, in an application scenario of a lottery event, the block link point device corresponding to the merchant may be a block link point device corresponding to the merchant, the block link point device corresponding to the merchant obtains an updated event cluster of { obtain first-equal prize, obtain second-equal prize, obtain third-equal prize, obtain fourth-equal prize, and no-win }, in the updated event cluster, the weight corresponding to the event "obtain first-equal prize" is "5%", the weight corresponding to the event "obtain second-equal prize" is "10%", the weight corresponding to the event "obtain third-equal prize" is "15%", the weight corresponding to the event "obtain fourth-equal prize" is "20%", and the weight corresponding to the event "no-win" is "50%". And the block chain link point device corresponding to the merchant obtains a target numerical value '30' and a first threshold value '100' corresponding to the random number according to the obtained random number. The block chain node device corresponding to the merchant generates a numerical value interval corresponding to each event in the updated event cluster according to a first threshold value of 100 and the weight of each event in the updated event cluster, the numerical value interval corresponding to the event that the first equal prize is obtained is [0,5 ], the numerical value interval corresponding to the event that the second equal prize is obtained is [5, 15 ], the numerical value interval corresponding to the event that the third equal prize is obtained is [15, 30 ], the numerical value interval corresponding to the event that the fourth equal prize is obtained is [30, 50 ], and the numerical value interval corresponding to the event that the second equal prize is not won is [50, 100]. The target value "30" belongs to the value interval [30, 50), and the block chain link point device corresponding to the trader determines the value interval [30, 50) to be the target value interval to which the target value "30" belongs. And the block chain link point device corresponding to the merchant determines an event acquisition result according to the target value interval [30, 50) to which the target value "30" belongs, wherein the event acquisition result is used for indicating the client to acquire the event "acquire four prizes" corresponding to the target value interval. And determining that the random number obtains four prizes in the lottery drawing activity according to the obtained random number by the block chain link point device corresponding to the merchant.
In this way, in the lottery activity, the merchant can change the lottery rule through each event in the updated event cluster or the weight of each event in the updated event cluster, so that the lottery activity is more flexible and diversified.
Step S209: and the block chain link point device sends the event acquisition result to the client.
Specifically, the block link point device may determine an event acquisition result corresponding to the random number according to the target value and the first threshold, and then may send the event acquisition result to the client. For example, in an application scenario of a lottery event, the blockchain node device may be a blockchain node device corresponding to a merchant, the random number may be a random number generated by the blockchain node device corresponding to the merchant in response to a winning request of a customer, and the event acquisition result may be a winning condition of the customer participating in the lottery event. The customer interacts with the block chain link point device corresponding to the merchant through the client, and after receiving a winning request from the client, the block chain link point device corresponding to the merchant responds to the winning request from the client and generates a random number according to the winning request, so that the winning condition of the lottery event participated by the customer is determined according to the random number, and the winning condition is sent to the client.
Therefore, according to the embodiment of the invention, after the block chain link point device acquires the random number, the event acquisition result can be determined according to the random number, and the process that the block chain link point device determines the event acquisition result according to the random number is that the block chain link point device and the random number participate together. In the block chain network, the process that the block chain node device determines the event acquisition result according to the random number can be commonly witnessed by other block chain node devices in the block chain network, so that the process that the block chain node device determines the event acquisition result according to the random number is fairer, and the reliability of the event acquisition result is higher.
Referring to fig. 3 based on the description of fig. 1, fig. 3 is a schematic flow chart of another method for processing random numbers according to an embodiment of the present invention, where the method includes, but is not limited to, the following steps:
step S301: and the client sends an event acquisition request to the block link node device.
Step S302: the block chain node device responds to the event acquisition request to acquire the random number.
Step S303: and the block chain performs hash calculation on the random number by the node device to obtain a hash value of the random number.
Step S304: the block chain node device converts the hash value into a first digital sequence.
In the embodiment of the present invention, the execution processes of steps S301 to S304 are the same as steps S201 to S204 in the embodiment shown in fig. 2, and the specific execution process may refer to the specific description of steps S201 to S204 in fig. 2, which is not described again in the embodiment of the present invention.
Step S305: and the block chain link point device calculates the numbers contained in the first number sequence to obtain a target number value.
Specifically, the block link point device may add the numbers included in the first number sequence to obtain the target value. For example, the first number sequence is "3,9,8", the block chain dot device adds the numbers contained in the first number sequence to obtain "3+9+8", and the final result is "20", and the block chain dot device adds the numbers contained in the first number sequence "3,9,8" to obtain the target number "20".
In one implementation, the block-link point device may further combine the numbers included in the first number sequence to obtain the target number. For example, the first number sequence is "3,8,7", the block chain dot apparatus combines the numbers contained in the first number sequence to obtain "3 × 100+8 × 10+7 × 1", the final result is "387", and the block chain dot apparatus combines the numbers contained in the first number sequence "3,8,7" to obtain the target number "387".
Step S306: the block chain link point device determines a third digit sequence according to the length of the first digit sequence.
Specifically, the block chain link point device may determine the third number sequence according to the length of the first number sequence, where the length of the third number sequence is the same as the length of the first number sequence, and each digit in the third number sequence is a preset threshold. For example, in a scheme in which the block chain node device adds or combines the numbers included in the first number sequence to obtain the target value, the block chain node device converts the hash value into the first number sequence "3,9,8", the length of the first number sequence "3,9,8" is 3 bits, the length of the third number sequence determined according to the first number sequence is also 3 bits, the preset threshold may be the number "9" with the largest value in decimal, and the third number sequence determined by the block chain node device according to the first number sequence "3,9,8" is "9, 9". For another example, in a scheme that the block chain node point device adds or combines numbers included in the first number sequence to obtain the target number, the block chain node point device converts the hash value into a first number sequence "3,8,7", where the length of the first number sequence "3,8,7" is 3 bits, the length of a third number sequence determined according to the first number sequence is also 3 bits, the preset threshold may be a number "8" with a largest value in the third number sequence, and the third number sequence determined by the block chain node point device according to the first number sequence "3,8,7" is "8, 8".
Step S307: and the block chain link point device calculates the numbers contained in the third number sequence to obtain a first threshold value.
Specifically, the method for calculating the numbers included in the third number sequence by the block chain node point device to obtain the first threshold is the same as the method for calculating the numbers included in the first number sequence by the block chain node point device to obtain the target value. For example, in the scheme that the block chain point device adds the numbers included in the first number sequence to obtain the target value, the first number sequence is "3,9,8", the target value is "20", the third number sequence is "9,9,9", the block chain point device adds the numbers included in the third number sequence to obtain "9+ 9", and the final result is "27", and the block chain point device adds the numbers included in the third number sequence "9,9,9" to obtain the first threshold value "27". For another example, in the scheme that the block link point device combines the numbers included in the first number sequence to obtain the target value, the first number sequence is "3,8,7", the target value is "387", the third number sequence is "8,8,8", the block link point device combines the numbers included in the third number sequence to obtain "8 × 100+8 × 10+8 × 1", and the final result is "888", and the block link point device combines the numbers included in the third number sequence "8,8,8" to obtain the target value "888".
In this way, each block chain node device obtains a random number, a hash value of the random number is obtained through calculation according to a hash algorithm, a first digital sequence corresponding to the hash value is obtained according to American Standard Code for Information Interchange (ASCII), a third digital sequence is determined according to the length of the first digital sequence, and the numbers contained in the first digital sequence and the third digital sequence are operated to obtain a target value corresponding to the first digital sequence and a first threshold value corresponding to the third digital sequence. The block chain node point device has the same processing process for each acquired random number, and the processing process for each acquired random number is transparent and cannot be tampered, so that the process that the block chain node point device acquires the target value corresponding to the hash value and the first threshold value is more fairly disclosed.
Step S308: and the block chain link point device determines an event acquisition result corresponding to the random number according to the target numerical value and the first threshold value.
Step S309: and the block chain link point device sends the event acquisition result to the client.
The execution processes of steps S308 and S309 in the embodiment of the present invention are the same as steps S208 and S209 in the embodiment shown in fig. 2, and the specific execution process may refer to the specific description of steps S208 and S209 in fig. 2, which is not described again in the embodiment of the present invention.
Based on the above description of the embodiment of the method for processing random numbers, please refer to fig. 4, fig. 4 is a schematic structural diagram of a block link point device according to an embodiment of the present invention, where the block link point device 40 may be used to perform the steps performed by the block link point device in the method embodiments corresponding to fig. 2 and fig. 3, and the block link point device 40 may include:
an obtaining unit 401, configured to obtain a random number in response to an event obtaining request of a client, where the random number is generated by a target block chain node device in a block chain network to which the block chain node device belongs;
a calculating unit 402, configured to perform hash calculation on the random number to obtain a hash value corresponding to the random number;
a converting unit 403, configured to convert the hash value to obtain a target value and a first threshold corresponding to the hash value;
a determining unit 404, configured to determine, according to the target value and the first threshold, an event acquisition result corresponding to the random number;
a sending unit 405, configured to send the event obtaining result to the client.
In one implementation, the block link point device 40 may further include:
an obtaining unit 401, further configured to obtain an event cluster;
an obtaining unit 401, further configured to obtain an updated event cluster;
a generating unit 406, configured to generate a numerical interval corresponding to each event in the event cluster according to the first threshold and the weight of each event in the event cluster;
the generating unit 406 is further configured to generate a numerical interval corresponding to each event in the updated event cluster according to the first threshold and the weight of each event in the updated event cluster.
In one implementation, the block link point device 40 may further include:
a receiving unit 407, configured to receive an event acquisition request from a client;
the generating unit 406 is further configured to generate a random number according to the event acquisition request.
It should be noted that, for details that are not mentioned in the embodiment corresponding to fig. 4 and the specific implementation manner of the step executed by each unit, reference may be made to the embodiment shown in fig. 2 and fig. 3 and the foregoing description, and details are not repeated here.
In one implementation, the relevant functions implemented by the various units in FIG. 4 may be implemented in connection with a processor and a communications interface. Referring to fig. 5, fig. 5 is a schematic structural diagram of a block link point device according to an embodiment of the present invention, where the block link point device 50 includes a processor 501, a memory 502, and a communication interface 503, and the processor 501, the memory 502, and the communication interface 503 are connected through one or more communication buses.
The Processor 501 is configured to support the block link node device to perform the corresponding functions of the block link node device in the Processing method for random numbers as described in fig. 2 and fig. 3, and the Processor 501 may be a Central Processing Unit (CPU), a Network Processor (NP), a hardware chip, or any combination thereof.
The memory 502 is used to store program codes and the like. Memory 502 may include volatile Memory (volatile Memory), such as Random Access Memory (RAM); the Memory 502 may also include a Non-Volatile Memory (NVM), such as a Read-Only Memory (ROM), a flash Memory (flash Memory), a Hard Disk (Hard Disk Drive, HDD) or a Solid-State Drive (SSD); the memory 502 may also comprise a combination of memories of the kind described above.
The communication interface 503 is used for receiving and transmitting data, for example, the communication interface 503 is used for receiving an event acquisition request from a client, or the communication interface 503 is used for transmitting an event acquisition result to the client, and the like.
In the embodiment of the present invention, the information management apparatus 50 includes a plurality of communication interfaces, wherein a communication interface for transmitting data and a communication interface for receiving data may not be the same communication interface.
The processor 501 may call the program code stored in the memory 502 to perform the following operations:
responding to an event acquisition request of a client, and acquiring a random number generated by a target block chain node device in a block chain network to which the block chain node device belongs;
carrying out Hash calculation on the random number to obtain a Hash value of the random number;
converting the hash value to obtain a target value and a first threshold value corresponding to the hash value;
determining an event acquisition result corresponding to the random number according to the target value and the first threshold value;
the event acquisition result is sent to the client through the communication interface 503.
Further, the processor 501 may further cooperate with the communication interface 503 to perform operations corresponding to the block-link point device in the embodiments shown in fig. 2 and fig. 3, which may be specifically referred to the description of the method embodiments and will not be repeated herein.
In an embodiment of the present invention, a chip is further provided, which includes a processor and a memory, where the memory is used to store a computer program, the processor is used to call and run the computer program from the memory, and the computer program is used to implement the method in the foregoing method embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on or transmitted over a computer-readable storage medium. The computer instructions may be transmitted from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), among others.
While the invention has been described with reference to a number of embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (7)

1. A method for processing random numbers, the method being applied to a block chain node device, the method comprising:
responding to an event acquisition request of a client, and acquiring a random number generated by a target block chain node device in a block chain network to which the block chain node device belongs;
performing hash calculation on the random number to obtain a hash value of the random number;
converting the hash value to obtain a target value and a first threshold value corresponding to the hash value;
generating a numerical value interval corresponding to each event in the event cluster according to the first threshold and the weight of each event in the event cluster to be acquired; determining a target numerical value interval to which the target numerical value belongs in the generated numerical value interval; generating an event acquisition result according to the target value interval, wherein the event acquisition result is used for indicating the client to acquire an event corresponding to the target value interval;
sending the event acquisition result to the client;
the method for converting the hash value to obtain the target value and the first threshold corresponding to the hash value includes:
converting the hash value into a first sequence of numbers; obtaining the first threshold value according to the length of the first digit sequence; according to a binary conversion algorithm, carrying out binary conversion on each digit in the first digit sequence to obtain a second digit sequence; converting the second sequence of digits into the target value according to a decimal conversion algorithm;
or, converting the hash value into a first sequence of numbers; calculating the number contained in the first number sequence to obtain the target numerical value; determining a third digital sequence according to the length of the first digital sequence, wherein the length of the third digital sequence is the same as that of the first digital sequence, and each digit in the third digital sequence is a preset threshold; and operating the numbers contained in the third number sequence to obtain the first threshold value.
2. The method according to claim 1, wherein the generating a numerical interval corresponding to each event in the event cluster according to the first threshold and the weight of each event in the event cluster to be obtained comprises:
acquiring the event cluster, wherein the event cluster comprises a plurality of events and the weight of each event;
dividing the first threshold value according to the weight of each event to obtain a numerical value interval corresponding to each event in the event cluster;
one event corresponds to one numerical interval, different events correspond to different numerical intervals, and the maximum value of each numerical interval is smaller than or equal to the first threshold.
3. The method according to claim 1, wherein before determining a target value interval to which the target value belongs in the generated value interval, the method further comprises:
acquiring an updated event cluster, wherein the updated event cluster comprises a plurality of updated events and the weight of each updated event;
generating a numerical value interval corresponding to each event in the updated event cluster according to the first threshold and the weight of each event in the updated event cluster;
determining a target value interval to which the target value belongs in the generated value interval includes:
and determining a target value interval to which the target value belongs in the updated value interval.
4. The method of claim 1, wherein deriving the first threshold value based on the length of the first digit sequence comprises:
determining a third digital sequence according to the length of the first digital sequence, wherein the length of the third digital sequence is the same as that of the first digital sequence, and each digit in the third digital sequence is a preset threshold;
carrying out binary conversion on each digit in the third digit sequence according to the binary conversion algorithm to obtain a fourth digit sequence;
converting the fourth sequence of digits to the first threshold according to the decimal conversion algorithm.
5. A block link point device, comprising:
an obtaining unit, configured to obtain a random number in response to an event obtaining request from a client, where the random number is generated by a target block chain node device in a block chain network to which the block chain node device belongs;
the calculating unit is used for carrying out hash calculation on the random number to obtain a hash value of the random number;
the conversion unit is used for converting the hash value to obtain a target numerical value and a first threshold value corresponding to the hash value;
the determining unit is used for generating a numerical value interval corresponding to each event in the event cluster according to the first threshold and the weight of each event in the event cluster to be acquired; determining a target value interval to which the target value belongs in the generated value interval; generating an event acquisition result according to the target value interval, wherein the event acquisition result is used for indicating the client to acquire an event corresponding to the target value interval;
a sending unit, configured to send the event acquisition result to the client;
the method for converting the hash value to obtain the target value and the first threshold corresponding to the hash value includes:
converting the hash value into a first sequence of numbers; obtaining the first threshold value according to the length of the first digit sequence; carrying out binary conversion on each digit in the first digit sequence according to a binary conversion algorithm to obtain a second digit sequence; converting the second sequence of digits into the target value according to a decimal conversion algorithm;
or, converting the hash value into a first sequence of numbers; calculating the number contained in the first number sequence to obtain the target numerical value; determining a third digital sequence according to the length of the first digital sequence, wherein the length of the third digital sequence is the same as that of the first digital sequence, and each digit in the third digital sequence is a preset threshold; and operating the numbers contained in the third number sequence to obtain the first threshold value.
6. A block link point device, comprising:
a memory for storing a computer program;
a processor calling the computer program in the memory for performing the method of processing random numbers according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that it stores a computer program comprising program instructions which, when executed by a processor, cause the processor to carry out the method of processing random numbers according to any one of claims 1 to 4.
CN201910930049.XA 2019-09-26 2019-09-26 Processing method for random number, block chain link point device and storage medium Active CN110601819B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910930049.XA CN110601819B (en) 2019-09-26 2019-09-26 Processing method for random number, block chain link point device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910930049.XA CN110601819B (en) 2019-09-26 2019-09-26 Processing method for random number, block chain link point device and storage medium

Publications (2)

Publication Number Publication Date
CN110601819A CN110601819A (en) 2019-12-20
CN110601819B true CN110601819B (en) 2023-02-14

Family

ID=68864528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910930049.XA Active CN110601819B (en) 2019-09-26 2019-09-26 Processing method for random number, block chain link point device and storage medium

Country Status (1)

Country Link
CN (1) CN110601819B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111259428A (en) * 2020-01-22 2020-06-09 腾讯科技(深圳)有限公司 Data processing method and device based on block chain, node equipment and storage medium
CN111429186A (en) * 2020-04-08 2020-07-17 杭州左链科技有限公司 Fancy carp lottery incentive method, equipment and storage medium
CN111586013B (en) * 2020-04-29 2022-02-22 数网金融有限公司 Network intrusion detection method, device, node terminal and storage medium
CN112751846B (en) * 2020-12-28 2022-09-06 杭州趣链科技有限公司 Block chain-based electronic game random reward control method, device and equipment
CN115206018A (en) * 2022-06-16 2022-10-18 湖南天河国云科技有限公司 Lottery drawing method and lottery drawing equipment based on block chain prediction machine

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018104728A1 (en) * 2016-12-05 2018-06-14 Quanta Technology Ltd Random number generation
CN110135909A (en) * 2019-05-15 2019-08-16 山东工商学院 Data processing method, system, equipment and storage medium based on zero-knowledge proof
CN110164021A (en) * 2019-06-13 2019-08-23 北京艾摩瑞策科技有限公司 A kind of random lottery drawing method and equipment of application block chain
CN110189465A (en) * 2019-06-13 2019-08-30 北京艾摩瑞策科技有限公司 A kind of random lottery drawing method and its equipment by means of block chain
CN110223436A (en) * 2019-06-13 2019-09-10 北京艾摩瑞策科技有限公司 A kind of lottery ticket of application block chain is extra-large method and apparatus at random

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018104728A1 (en) * 2016-12-05 2018-06-14 Quanta Technology Ltd Random number generation
CN110135909A (en) * 2019-05-15 2019-08-16 山东工商学院 Data processing method, system, equipment and storage medium based on zero-knowledge proof
CN110164021A (en) * 2019-06-13 2019-08-23 北京艾摩瑞策科技有限公司 A kind of random lottery drawing method and equipment of application block chain
CN110189465A (en) * 2019-06-13 2019-08-30 北京艾摩瑞策科技有限公司 A kind of random lottery drawing method and its equipment by means of block chain
CN110223436A (en) * 2019-06-13 2019-09-10 北京艾摩瑞策科技有限公司 A kind of lottery ticket of application block chain is extra-large method and apparatus at random

Also Published As

Publication number Publication date
CN110601819A (en) 2019-12-20

Similar Documents

Publication Publication Date Title
CN110601819B (en) Processing method for random number, block chain link point device and storage medium
CN109558748B (en) Data processing method and device, electronic equipment and storage medium
US10547618B2 (en) Method and apparatus for setting access privilege, server and storage medium
CN108985066B (en) Intelligent contract security vulnerability detection method, device, terminal and storage medium
CN108667717B (en) Block chain processing method, medium, device and computing equipment based on instant messaging message record
CN111885050B (en) Data storage method and device based on block chain network, related equipment and medium
CN110851535B (en) Data processing method and device based on block chain, storage medium and terminal
CN110247753B (en) Block output method and device based on block chain node point network
CN109995523B (en) Activation code management method and device and activation code generation method and device
CN112751729A (en) Log monitoring method, device, medium and electronic equipment
US20200218575A1 (en) Optimizing Runtime Environments
CN112380464B (en) Short link generation method and related equipment
CN111191255A (en) Information encryption processing method, server, terminal, device and storage medium
CN112631924A (en) Automatic testing method and device, computer equipment and storage medium
CN113778652A (en) Task scheduling method and device, electronic equipment and storage medium
CN112182109A (en) Distributed data coding storage method based on block chain and electronic equipment
CN111339141A (en) Data transmission method, block link node equipment and medium
CN111367923A (en) Data processing method, data processing device, node equipment and storage medium
CN111340574B (en) Risk user identification method and device and electronic equipment
CN110930253B (en) Method and device for generating main key inside intelligent contract, computer equipment and storage medium
US20220114276A1 (en) Controlling a data network with respect to a use of a distributed database
CN112783500B (en) Method and device for generating compiling optimization information and electronic equipment
CN111324645A (en) Data processing method and device for block chain
CN112002352B (en) Random music playing method and device, computer equipment and storage medium
CN110880974B (en) Data communication method and device based on block chain network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant