CN111930343A - Method, device and medium for acquiring random number and generating random number - Google Patents

Method, device and medium for acquiring random number and generating random number Download PDF

Info

Publication number
CN111930343A
CN111930343A CN202010517185.9A CN202010517185A CN111930343A CN 111930343 A CN111930343 A CN 111930343A CN 202010517185 A CN202010517185 A CN 202010517185A CN 111930343 A CN111930343 A CN 111930343A
Authority
CN
China
Prior art keywords
random number
random
transaction
chain code
timestamp
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.)
Pending
Application number
CN202010517185.9A
Other languages
Chinese (zh)
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.)
Shandong Inspur Quality Chain Technology Co Ltd
Original Assignee
Shandong Inspur Quality Chain Technology 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 Shandong Inspur Quality Chain Technology Co Ltd filed Critical Shandong Inspur Quality Chain Technology Co Ltd
Priority to CN202010517185.9A priority Critical patent/CN111930343A/en
Publication of CN111930343A publication Critical patent/CN111930343A/en
Pending legal-status Critical Current

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Finance (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Medical Treatment And Welfare Office Work (AREA)

Abstract

The embodiment of the application discloses a method, equipment and a medium for acquiring a random number and generating the random number, which comprises the following steps: when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit; taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library; and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node. According to the embodiment of the application, the corresponding random number is determined in the pre-stored random number library through the timestamp and the transaction ID, and the random number is sent to each node. Due to the uniqueness of the timestamp and the transaction ID, the random numbers acquired by each node are the same, and the success of write chain operation can be ensured.

Description

Method, device and medium for acquiring random number and generating random number
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, and a medium for acquiring a random number and generating the random number.
Background
Random numbers are a fundamental stone of modern cryptography-based information security systems. Random numbers have found wide application in blockchain based transactions.
In the prior art, when each node acquires a random number, since the random numbers acquired by each node when executing a chain code are different, the results of chain code operation may be inconsistent, and thus a write chain operation may fail.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, a device, and a medium for acquiring a random number and generating a random number, which are used to solve the problem in the prior art that a write chain operation fails because the random numbers acquired by each node may be different.
The embodiment of the application adopts the following technical scheme:
the embodiment of the application provides a method for acquiring random numbers, which comprises the following steps:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
Further, the inputting the timestamp and the transaction ID into the random number chain code and outputting a number with a preset number of bits specifically includes:
inputting a timestamp and a transaction ID into the random numeric chain code so that the random numeric chain code can splice the input timestamp and the transaction ID, and performing hash calculation on the spliced timestamp and the transaction ID to obtain a first hash value; and processing the first hash value and outputting the first hash value as a number with a preset digit.
Further, the random number chain code splices the input time stamp and the transaction ID, and performs hash calculation on the spliced time stamp and the transaction ID to obtain a first hash value; processing the first hash value, and outputting the first hash value as a number with a preset number of bits, specifically comprising:
the random number chain code splices the input time stamp and the transaction ID, and performs hash calculation on the spliced time stamp and the transaction ID to obtain a 16-system first hash value; intercepting the last five digits of the first hash value, converting the intercepted first hash value into 10-system digits, dividing by 10000 to obtain a remainder, and adding 1 to the remainder to obtain the digits of the preset digits.
Further, the transaction ID is a second hash value obtained by performing hash calculation on the identity information of the transaction initiating node and a second random number, where the second random number is generated by a random number generator.
The embodiment of the present application further provides a method for generating a random number, where the method includes:
calling a random number writing method in a random number chain code in a preset period, inputting a timestamp and a transaction ID into the random number chain code, generating a plurality of random numbers, and marking a corresponding serial number for each random number;
and storing a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
Further, before the step of marking the corresponding sequence number for each random number, the method further includes:
and setting the number of the serial numbers, and marking the random numbers by the first serial number when the generated random numbers exceed the number of the serial numbers.
Further, the inputting the timestamp and the transaction ID into the random number chain code to generate a plurality of random numbers specifically includes:
and inputting the time stamp and the transaction ID into the random number chain code so that the random number chain code can splice the input time stamp and the transaction ID, and performing hash calculation on the spliced time stamp and the transaction ID to generate a plurality of random numbers.
An embodiment of the present application further provides an apparatus for acquiring a random number, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
An embodiment of the present application further provides a medium for acquiring a random number, in which computer-executable instructions are stored, where the computer-executable instructions are set to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
An embodiment of the present application further provides an apparatus for generating a random number, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
calling a random number writing method in a random number chain code in a preset period, inputting a timestamp and a transaction ID into the random number chain code, generating a plurality of random numbers, and marking a corresponding serial number for each random number;
and storing a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: according to the embodiment of the application, the corresponding random number is determined in the pre-stored random number library through the timestamp and the transaction ID, and the random number is sent to each node. Due to the uniqueness of the timestamp and the transaction ID, the random numbers acquired by each node are the same, and the success of write chain operation can be ensured.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flowchart of a method for acquiring a random number according to an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating a method for generating a random number according to a second embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of a method for acquiring a random number according to an embodiment of the present disclosure, where the random number acquiring system may perform the following steps, which specifically include:
step S101, when each node needs a random number, the random number acquisition system calls a method for acquiring the random number in a random number chain code, inputs a timestamp and a transaction ID into the random number chain code, and outputs a number with a preset digit.
In step S101 of this embodiment of the present specification, each node may include a transaction initiating node and a participating node, and a timestamp is set for the transaction initiating node, for example, the transaction initiating node may set the timestamp to 13 minutes and 12 seconds at 14 hours, 15 days, and 5 months in 2020.
In step S101 in the embodiment of this specification, the transaction ID is a second hash value obtained by performing hash calculation on the identity information of the transaction initiating node and a second random number, where the second random number may be generated by a random number generator. It can be seen that there is uniqueness in the transaction ID. The identity information of the transaction initiating node may be identification information or a private key of the transaction initiating node.
In step S101 of the embodiment of the present specification, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset number of bits may specifically include:
inputting a timestamp and a transaction ID into the random numeric chain code so that the random numeric chain code can splice the input timestamp and the transaction ID, and performing hash calculation on the spliced timestamp and the transaction ID to obtain a first hash value; and processing the first hash value and outputting the first hash value as a number with a preset digit.
Further, the number of the preset digit number can be a number of 1-10000, the random number chain code splices the input time stamp and the transaction ID, and the spliced time stamp and the transaction ID are subjected to hash calculation to obtain a first hash value; processing the first hash value, and outputting the processed first hash value as a number with a preset number of bits, which may specifically include:
the random number chain code splices the input time stamp and the transaction ID, and performs hash calculation on the spliced time stamp and the transaction ID to obtain a 16-system first hash value; intercepting the last five digits of the first hash value, converting the intercepted first hash value into 10-system digits, dividing by 10000 to obtain a remainder, and adding 1 to the remainder to obtain the digits of the preset digits.
And step S102, the random number acquisition system takes the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library.
In step S102 in this embodiment of the present specification, a serial number exists at each random in the random number library, and the number with the preset number of bits may be a serial number corresponding to a random number in the random number library, for example, the number with the preset number of bits is 9456, and 9456 may be a serial number corresponding to a random number in the random number library.
Step S103, the random number obtaining system determines a first random number corresponding to the sequence number in the random number library and sends the first random number to each node.
In step S103 of the embodiment of the present specification, for example, the determined serial number is 9456, and the corresponding random number may be determined in the random number library according to the serial number.
Note that, since the time stamp and the transaction ID of each node are the same, the generated random numbers are also the same.
According to the embodiment of the application, the corresponding random number is determined in the pre-stored random number library through the timestamp and the transaction ID, and the random number is sent to each node. Due to the uniqueness of the timestamp and the transaction ID, the random numbers acquired by each node are the same, and the success of write chain operation can be ensured.
Corresponding to the first embodiment of the present specification, fig. 2 is a schematic flowchart of a method for generating a random number provided by the second embodiment of the present specification, where the random number generation system in the embodiment of the present specification may perform the following steps, which specifically include:
step S201, in a preset period, the random number generation system calls a method for writing a random number in a random number chain code, inputs a timestamp and a transaction ID to the random number chain code, generates a plurality of random numbers, and marks a corresponding serial number for each random number.
In step S201 of the embodiment of the present specification, the preset period may be set by a timer, for example, the timer may be set to call the method for writing the random number in the random number chain code by the random number generation system every 10 seconds.
In step S201 of the embodiment of the present specification, the timestamp is set for the transaction initiation node, for example, the transaction initiation node may set the timestamp to 13 minutes, 12 seconds at 14 hours, 15 days, 15 months, or 5 months in 2020.
In step S201 of the embodiment of this specification, the transaction ID is a second hash value obtained by performing hash calculation on the identity information of the transaction initiating node and a second random number, where the second random number may be generated by a random number generator. It can be seen that there is uniqueness in the transaction ID. The identity information of the transaction initiating node may be identification information or a private key of the transaction initiating node.
In step S201 of the embodiment of the present specification, before marking a corresponding sequence number for each random number, the method further includes: setting the number of sequence numbers, and marking the random number by the first sequence number when the generated random number exceeds the number of sequence numbers. For example, the upper limit of the number of the serial numbers is set to 10000, and when the number of the random numbers generated by the random number generation system exceeds 10000, the 10001 th random number is marked by the serial number 1.
In step S201 of the embodiment of the present specification, a timestamp and a transaction ID are input to the random number chain code, and a plurality of random numbers are generated, which specifically includes:
and inputting the time stamp and the transaction ID into the random number chain code so that the random number chain code can splice the input time stamp and the transaction ID, and performing hash calculation on the spliced time stamp and the transaction ID to generate a plurality of random numbers. After the spliced timestamp and the transaction ID are subjected to hash calculation, a character string is generated, and the character string can be converted into a corresponding random number.
It should be noted that the timestamp cannot be set at will, and should be equal to the current time as much as possible, the random number chain code may check whether an error between the incoming timestamp and the current time exceeds a preset value, and if the error exceeds the preset value, it may be determined that the timestamp is invalid, where the preset value may be 1 minute.
In step S202, the random number generator stores a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
According to the embodiment of the application, the corresponding random number is determined in the pre-stored random number library through the timestamp and the transaction ID, and the random number is sent to each node. Due to the uniqueness of the timestamp and the transaction ID, the random numbers acquired by each node are the same, and the success of write chain operation can be ensured.
An embodiment of the present application further provides an apparatus for acquiring a random number, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
An embodiment of the present application further provides a medium for acquiring a random number, in which computer-executable instructions are stored, where the computer-executable instructions are set to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
An embodiment of the present application further provides an apparatus for generating a random number, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
calling a random number writing method in a random number chain code in a preset period, inputting a timestamp and a transaction ID into the random number chain code, generating a plurality of random numbers, and marking a corresponding serial number for each random number;
and storing a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method for obtaining random numbers, the method comprising:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
2. The method according to claim 1, wherein the inputting a timestamp and a transaction ID into the random number chain code and outputting a number with a preset number of bits includes:
inputting a timestamp and a transaction ID into the random numeric chain code so that the random numeric chain code can splice the input timestamp and the transaction ID, and performing hash calculation on the spliced timestamp and the transaction ID to obtain a first hash value; and processing the first hash value and outputting the first hash value as a number with a preset digit.
3. The method for acquiring the random number according to claim 2, wherein the random number chain code concatenates the input timestamp and the transaction ID, and performs hash calculation on the concatenated timestamp and the transaction ID to obtain a first hash value; processing the first hash value, and outputting the first hash value as a number with a preset number of bits, specifically comprising:
the random number chain code splices the input time stamp and the transaction ID, and performs hash calculation on the spliced time stamp and the transaction ID to obtain a 16-system first hash value; intercepting the last five digits of the first hash value, converting the intercepted first hash value into 10-system digits, dividing by 10000 to obtain a remainder, and adding 1 to the remainder to obtain the digits of the preset digits.
4. The method according to any one of claims 1 to 3, wherein the transaction ID is a second hash value obtained by hashing identity information of the transaction initiating node with a second random number, and wherein the second random number is generated by a random number generator.
5. A method of generating random numbers, the method comprising:
calling a random number writing method in a random number chain code in a preset period, inputting a timestamp and a transaction ID into the random number chain code, generating a plurality of random numbers, and marking a corresponding serial number for each random number;
and storing a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
6. The method of generating random numbers according to claim 5, wherein before said tagging each random number with a corresponding sequence number, the method further comprises:
and setting the number of the serial numbers, and marking the random numbers by the first serial number when the generated random numbers exceed the number of the serial numbers.
7. The method according to claim 5, wherein the inputting a timestamp and a transaction ID into the random number chain code to generate a plurality of random numbers comprises:
and inputting the time stamp and the transaction ID into the random number chain code so that the random number chain code can splice the input time stamp and the transaction ID, and performing hash calculation on the spliced time stamp and the transaction ID to generate a plurality of random numbers.
8. An apparatus for obtaining a random number, the apparatus comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
9. A medium for acquiring random numbers, storing computer-executable instructions, the computer-executable instructions configured to:
when each node needs a random number, calling a method for acquiring the random number in a random number chain code, inputting a timestamp and a transaction ID into the random number chain code, and outputting a number with a preset digit;
taking the number of the preset digit as a serial number corresponding to the random number in a pre-stored random number library;
and determining a first random number corresponding to the sequence number in the random number library, and sending the first random number to each node.
10. An apparatus for generating random numbers, the apparatus comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
calling a random number writing method in a random number chain code in a preset period, inputting a timestamp and a transaction ID into the random number chain code, generating a plurality of random numbers, and marking a corresponding serial number for each random number;
and storing a plurality of random numbers and the sequence numbers corresponding to the random numbers in a random number library.
CN202010517185.9A 2020-06-09 2020-06-09 Method, device and medium for acquiring random number and generating random number Pending CN111930343A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010517185.9A CN111930343A (en) 2020-06-09 2020-06-09 Method, device and medium for acquiring random number and generating random number

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010517185.9A CN111930343A (en) 2020-06-09 2020-06-09 Method, device and medium for acquiring random number and generating random number

Publications (1)

Publication Number Publication Date
CN111930343A true CN111930343A (en) 2020-11-13

Family

ID=73317857

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010517185.9A Pending CN111930343A (en) 2020-06-09 2020-06-09 Method, device and medium for acquiring random number and generating random number

Country Status (1)

Country Link
CN (1) CN111930343A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112491996A (en) * 2020-11-18 2021-03-12 深圳前海微众银行股份有限公司 Method and device for generating service request
CN112580114A (en) * 2020-12-21 2021-03-30 歌尔光学科技有限公司 Information processing method, device, equipment and storage medium
CN112835555A (en) * 2021-01-22 2021-05-25 广东智源机器人科技有限公司 Random number generation method, device and equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112491996A (en) * 2020-11-18 2021-03-12 深圳前海微众银行股份有限公司 Method and device for generating service request
CN112491996B (en) * 2020-11-18 2022-08-12 深圳前海微众银行股份有限公司 Method and device for generating service request
CN112580114A (en) * 2020-12-21 2021-03-30 歌尔光学科技有限公司 Information processing method, device, equipment and storage medium
CN112580114B (en) * 2020-12-21 2023-05-16 歌尔科技有限公司 Information processing method, device, equipment and storage medium
CN112835555A (en) * 2021-01-22 2021-05-25 广东智源机器人科技有限公司 Random number generation method, device and equipment

Similar Documents

Publication Publication Date Title
CN107247749B (en) Database state determination method, consistency verification method and device
CN107562775B (en) Data processing method and device based on block chain
KR102194074B1 (en) Blockchain-based data processing method and device
JP6804668B2 (en) Block data validation method and equipment
CN111930343A (en) Method, device and medium for acquiring random number and generating random number
CN108173706B (en) Service marking method, device and equipment under multi-service system
CN109241026B (en) Data management method, device and system
CN109947643B (en) A/B test-based experimental scheme configuration method, device and equipment
CN108616361B (en) Method and device for identifying uniqueness of equipment
CN114547024A (en) SQL statement risk detection method, device, equipment and medium
CN113254163B (en) Processing method and device of block chain data
CN111934878A (en) Block chain-based data encryption and decryption method, equipment and medium
CN114297734A (en) Data identifier generation method, device, equipment and medium
CN110019975B (en) Random walk, random walk method based on cluster, random walk device and equipment
CN115203600A (en) Method, device, equipment and medium for generating short link
CN114594944A (en) Application construction system and device
CN110633321B (en) Data synchronization method, device and equipment
CN111641499A (en) Block chain-based private key restoration method, device, equipment and medium
CN114238934A (en) Equipment information acquisition method, device, equipment and medium
CN113452503A (en) Block chain-based private key retrieving method, device and medium
CN112199399A (en) Data processing method and device
CN111596946A (en) Recommendation method, device and medium for intelligent contracts of block chains
CN110995447A (en) Data storage method, device, equipment and medium
CN111640016A (en) Verification method, device, equipment and medium for private transaction
CN113452510B (en) Private key updating method and device based on block chain

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