Time synchronization method and device among multiple nodes of a blockchain

By introducing a central clock node and encrypted synchronization requests into the blockchain, efficient clock synchronization between blockchain nodes is achieved, solving the problems of channel resource waste and single point failure, and reducing the synchronization pressure on nodes.

CN116017673BActive Publication Date: 2025-10-17CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211732077.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2025-10-17
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

The clock synchronization method in the existing blockchain relies on a single clock source for clock synchronization, resulting in serious waste of channel resources.

Method used

The central clock node of the entire blockchain is used to synchronize the clocks of the central clock nodes of each alliance chain. The central clock nodes of each alliance chain then synchronize the clocks of ordinary nodes on the chain. The synchronization request message is encrypted to ensure that only the upper-level node can decrypt and receive it.

Benefits of technology

It reduces the clock synchronization pressure of nodes, avoids excessive clock synchronization and single point failure problems, and avoids resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116017673B_ABST
    Figure CN116017673B_ABST
Patent Text Reader

Abstract

The application provides a time synchronization method and device among blockchain multi-nodes, computer equipment and computer readable storage medium, and relates to the technical field of communication. The method comprises the following steps: a second central clock node broadcasts an encrypted first clock synchronization request; a first central clock node receives the encrypted first clock synchronization request, decrypts the encrypted first clock synchronization request, and sends a first clock synchronization response message according to the decrypted first clock synchronization request; and the second central clock node receives the first clock synchronization response message returned by the first central clock node, and adjusts the clock of the second central clock node according to the first clock synchronization response message. According to the technical scheme provided by the application, the synchronization request message is encrypted, so that the central clock node responsible for the clock synchronization of the node can decrypt and receive the time synchronization request, and resource waste is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, in particular to a time synchronization method and device among multiple nodes of a blockchain, a computer device and a computer readable storage medium. BACKGROUND

[0002] At present, with the development of information technology, the application of the blockchain is more and more. The research on the synchronization method of the blockchain is also very important.

[0003] The existing clock synchronization method in the blockchain mostly adopts a clock synchronization protocol, all nodes rely on a single clock source for clock synchronization, and any clock synchronization signal sent by a node will be obtained by all nodes and synchronized, which causes serious waste of channel resources. SUMMARY

[0004] In order to at least partially solve the technical problems in the prior art that all nodes rely on a single clock source for clock synchronization and cause serious waste of channel resources, the present application is completed.

[0005] According to an aspect of the present application, a time synchronization method among multiple nodes of a blockchain is provided, the overall blockchain includes multiple alliance chains, the overall blockchain is provided with a first central clock node, each alliance chain is provided with a second central clock node, and the method comprises:

[0006] The second central clock node broadcasts an encrypted first clock synchronization request;

[0007] The first central clock node receives the encrypted first clock synchronization request, decrypts the encrypted first clock synchronization request, and sends a first clock synchronization response message according to the decrypted first clock synchronization request;

[0008] The second central clock node receives the first clock synchronization response message returned by the first central clock node, and adjusts its own clock according to the first clock synchronization response message.

[0009] In one embodiment, before the second central clock node broadcasts the encrypted first clock synchronization request, it further comprises:

[0010] The second central clock node registers with the first central clock node and obtains first registration information;

[0011] The first registration information includes a public key and a private key used by the first central clock node for encryption for data transmission.

[0012] In one embodiment, after obtaining the first registration information, it further comprises:

[0013] The second central clock node acquires the public key of the first central clock node and creates a session key;

[0014] The second central clock node encrypts the session key of the second central clock node according to the public key of the first central clock node;

[0015] The second central clock node encrypts the first clock synchronization request message according to the session key;

[0016] The second central clock node broadcasts the encrypted first clock synchronization request message, which comprises:

[0017] The second central clock node broadcasts the encrypted session key of the second central clock node and the encrypted first clock synchronization request message, and records the broadcast time t1.

[0018] In one embodiment, the first central clock node receives the encrypted first clock synchronization request message, and decrypting the encrypted first clock synchronization request message comprises:

[0019] The first central clock node receives the encrypted session key of the second central clock node and the encrypted first clock synchronization request message;

[0020] The first central clock node decrypts the encrypted session key of the second central clock node according to its own private key to obtain the session key of the second central clock node;

[0021] The encrypted first clock synchronization request message is decrypted according to the session key of the second central clock node to obtain the first clock synchronization request message;

[0022] A first clock synchronization response message is sent according to the first clock synchronization request message, and the first clock synchronization response message comprises: the time t2 when the first clock synchronization request is received, and the time t3 when the first clock synchronization response message is sent.

[0023] In one embodiment, the second central clock node receives the first clock synchronization response message returned by the first central clock node, and adjusts its own clock according to the first clock synchronization response message, which comprises:

[0024] The second central clock node receives the first clock synchronization response message returned by the first central clock node, and records the time t4 when the first clock synchronization response message is received;

[0025] The clock deviation Δt between the second central clock node and the first central clock node and the message propagation delay d are calculated according to the first formula, and the first formula is:

[0026]

[0027]

[0028] The second central clock node adjusts its own clock to t4-△t.

[0029] In one embodiment, each of the alliance chains is further provided with a common node, and the method further comprises:

[0030] The common node broadcasts the encrypted second clock synchronization request;

[0031] The corresponding second central clock node of the alliance chain where the common node is located receives the encrypted second clock synchronization request, decrypts the encrypted second clock synchronization request, and sends a second clock synchronization response message according to the decrypted second clock synchronization request;

[0032] The common node receives the second clock synchronization response message returned by the corresponding second central clock node of the alliance chain where the common node is located, and adjusts its own clock according to the second clock synchronization response message.

[0033] In one embodiment, before the common node broadcasts the encrypted second clock synchronization request, the method further comprises:

[0034] The common node of each alliance chain registers with the second central clock node of the alliance chain where the common node is located and obtains second registration information;

[0035] The second registration information includes a public key and a private key used by the common node for encryption for data transmission.

[0036] In one embodiment, after obtaining the second registration information, the method further comprises:

[0037] The common node obtains the public key of the second central clock node and creates a session key;

[0038] The common node encrypts the session key of the common node according to the public key of the second central clock node;

[0039] The common node encrypts the second clock synchronization request message according to the session key;

[0040] The common node broadcasts the encrypted second clock synchronization request includes:

[0041] The common node broadcasts the encrypted session key of the common node and the encrypted second clock synchronization request, and records the broadcast time t1'.

[0042] In an embodiment, the corresponding second center clock node of the alliance chain to which the common node belongs receives the encrypted second clock synchronization request, and decrypting the encrypted second clock synchronization request comprises:

[0043] The corresponding second center clock node of the alliance chain to which the common node belongs receives the encrypted session key of the common node and the encrypted second clock synchronization request;

[0044] The corresponding second center clock node of the alliance chain to which the common node belongs decrypts the encrypted session key of the common node according to its own private key to obtain the session key of the common node;

[0045] The encrypted second clock synchronization request is decrypted according to the session key of the common node to obtain a second clock synchronization request message;

[0046] A second clock synchronization response message is sent according to the second clock synchronization request, and the second clock synchronization response message includes a time t2' when the second clock synchronization request is received and a time t3' when the second clock synchronization response message is sent.

[0047] In an embodiment, the common node receives the second clock synchronization response message returned by the corresponding second center clock node of the alliance chain to which the common node belongs, and adjusts its own clock according to the second clock synchronization response message, comprising:

[0048] The common node receives the second clock synchronization response message returned by the corresponding second center clock node of the alliance chain to which the common node belongs, and records the time t4' when the second clock synchronization response message is received;

[0049] The clock deviation Δt' between the common node and the corresponding second center clock node of the alliance chain to which the common node belongs and the message propagation delay d' are calculated according to a second formula, and the second formula is:

[0050]

[0051]

[0052] The common node adjusts its own clock to t4'-Δt'.

[0053] According to another aspect of the present application, a time synchronization device between multiple nodes of a blockchain is provided, the overall blockchain includes multiple alliance chains, the overall blockchain is provided with a first center clock node, each of the alliance chains is provided with a second center clock node, comprising:

[0054] The second center clock node processing module is used for broadcasting an encrypted first clock synchronization request;

[0055] The first central clock node processing module is configured to receive the encrypted first clock synchronization request, decrypt the encrypted first clock synchronization request, and send a first clock synchronization response message according to the decrypted first clock synchronization request.

[0056] The first adjusting module is configured to receive the first clock synchronization response message returned by the first central clock node, and adjust the clock of the second central clock node according to the first clock synchronization response message.

[0057] According to still another aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program stored in the memory, the processor executes the time synchronization method between the blockchain multi-nodes.

[0058] According to still another aspect of the present application, a computer readable storage medium is provided, which stores a computer program, and when the processor executes the computer program, the processor executes the time synchronization method between the blockchain multi-nodes.

[0059] The technical solution provided by the present application can include the following beneficial effects:

[0060] The time synchronization method, device, computer device and computer readable storage medium provided by the present application can reduce the clock synchronization pressure of the ordinary nodes, avoid excessive clock synchronization and single point failure problem, and avoid resource waste.

[0061] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art upon examination of the following or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS

[0062] The accompanying drawings are included to provide a further understanding of the technical solution of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the technical solution of the present application, and do not constitute a limitation on the technical solution of the present application.

[0063] Figure 1A flowchart of a time synchronization method between multiple nodes of a blockchain provided by an embodiment of the present application;

[0064] Figure 2 A flowchart of another time synchronization method between multiple nodes of a blockchain provided by an embodiment of the present application;

[0065] Figure 3 A node structure diagram of a time synchronization method between multiple nodes of a blockchain provided by an embodiment of the present application;

[0066] Figure 4 A node response message diagram of a time synchronization method between multiple nodes of a blockchain provided by an embodiment of the present application.

[0067] Figure 5 A structure diagram of a time synchronization device between multiple nodes of a blockchain provided by an embodiment of the present application;

[0068] Figure 6 A structure diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0069] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the specific embodiments of the present application are described in detail below with reference to the drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application.

[0070] Figure 1 A flowchart of a time synchronization method between multiple nodes of a blockchain provided by an embodiment of the present application, the overall blockchain includes multiple consortium chains, the overall blockchain is provided with a first central clock node, each of the consortium chains is provided with a second central clock node, as shown in Figure 1 The time synchronization method between multiple nodes of a blockchain provided by the embodiment includes:

[0071] Step S1, the second central clock node broadcasts an encrypted first clock synchronization request;

[0072] Step S2, the first central clock node receives the encrypted first clock synchronization request, decrypts the encrypted first clock synchronization request, and sends a first clock synchronization response message according to the decrypted first clock synchronization request;

[0073] Step S3, the second central clock node receives the first clock synchronization response message returned by the first central clock node, and adjusts its own clock according to the first clock synchronization response message.

[0074] Thus, the method provided by the embodiment makes the clock synchronization signal sent by each node only be able to be responded by the corresponding upper node, reduces the clock synchronization pressure of the node, and avoids the problems of excessive clock synchronization and single point failure. In addition, the synchronization request message is encrypted, so that only the center clock node responsible for the clock synchronization of the node can decrypt and receive the time synchronization request, and resource waste is avoided.

[0075] In one embodiment, before step S1, the method further comprises:

[0076] The second center clock node registers with the first center clock node and obtains first registration information; the first registration information comprises a public key and a private key of the first center clock node used for encryption for data transmission.

[0077] In one embodiment, after obtaining the first registration information, the method further comprises:

[0078] The second center clock node obtains the public key of the first center clock node and creates a session key;

[0079] The second center clock node encrypts the session key of the second center clock node according to the public key of the first center clock node;

[0080] The second center clock node encrypts the first clock synchronization request message according to the session key;

[0081] In one embodiment, step S1 can specifically comprise:

[0082] The second center clock node broadcasts the encrypted session key of the second center clock node and the encrypted first clock synchronization request, and records the broadcast time t1.

[0083] In one embodiment, step S2 can specifically comprise:

[0084] The first center clock node receives the encrypted session key of the second center clock node and the encrypted first clock synchronization request;

[0085] The first center clock node decrypts the encrypted session key of the second center clock node according to the private key of the first center clock node to obtain the session key of the second center clock node;

[0086] The first clock synchronization request message is obtained by decrypting the encrypted first clock synchronization request according to the session key of the second center clock node;

[0087] A first clock synchronization response message is sent according to the first clock synchronization request, where the first clock synchronization response message includes: time t2 when the first clock synchronization request is received, and time t3 when the first clock synchronization response message is sent.

[0088] In one embodiment, step S3 may include:

[0089] The second central clock node receives the first clock synchronization response message returned by the first central clock node, and records the time t4 of receiving the message;

[0090] The clock deviation Δt between the second central clock node and the first central clock node and the message propagation delay d are calculated according to a first formula. The first formula is:

[0091]

[0092]

[0093] The second central clock node adjusts its own clock to t4-Δt.

[0094] As a result, the central clock node of the entire blockchain is responsible for synchronizing the clocks of the central clock nodes of each consortium chain. In turn, the central clock nodes of each consortium chain synchronize the clocks of ordinary nodes on the chain. At the same time, the clock synchronization signal sent by each node can only be responded to by its corresponding upper-level node. This reduces the clock synchronization pressure on ordinary nodes and avoids excessive clock synchronization and single point of failure. Furthermore, by encrypting the synchronization request message, it can be ensured that the time synchronization request can only be decrypted and received by the central clock node responsible for the node's clock synchronization, avoiding resource waste.

[0095] In one embodiment, each of the alliance chains is also provided with ordinary nodes. Figure 2 A flow chart of another method for synchronizing time between multiple nodes of a blockchain provided by an embodiment of the present invention is shown as follows: Figure 2 As shown, the time synchronization method between multiple nodes of the blockchain also includes:

[0096] Step S4: ordinary nodes broadcast the encrypted second clock synchronization request, wherein ordinary nodes are nodes other than the second central clock node;

[0097] Step S5: The second central clock node corresponding to the consortium chain where the ordinary node is located receives the encrypted second clock synchronization request, decrypts the encrypted second clock synchronization request, and sends a second clock synchronization response message according to the decrypted second clock synchronization request;

[0098] Step S6, the certain common node receives the second clock synchronization response message returned by the corresponding second center clock node of the alliance chain where the common node is located, and adjusts the clock of the common node according to the second clock synchronization response message.

[0099] In one embodiment, before step S4, the method further comprises:

[0100] The common node of each alliance chain registers with the second center clock node of the alliance chain where the common node is located, and obtains second registration information;

[0101] The second registration information includes: a public key and a private key used by the common node for encryption for data transmission;

[0102] In one embodiment, after obtaining the second registration information, the method further comprises:

[0103] The common node obtains the public key of the second center clock node, and creates a session key;

[0104] The common node encrypts the session key of the common node according to the public key of the second center clock node;

[0105] The common node encrypts the second clock synchronization request message according to the session key;

[0106] In one embodiment, step S4 can include:

[0107] The common node broadcasts the encrypted session key of the common node and the encrypted second clock synchronization request, and records the broadcast time t1'.

[0108] In one embodiment, step S5 can include;

[0109] The corresponding second center clock node of the alliance chain where the common node is located receives the encrypted session key of the common node and the encrypted second clock synchronization request;

[0110] The corresponding second center clock node of the alliance chain where the common node is located decrypts the encrypted session key of the common node according to its own private key to obtain the session key of the common node;

[0111] The encrypted second clock synchronization request is decrypted according to the session key of the common node to obtain the second clock synchronization request message;

[0112] The second clock synchronization response message is sent according to the second clock synchronization request, and the second clock synchronization response message includes: the time t2' when the second clock synchronization request is received, and the time t3' when the second clock synchronization response message is sent.

[0113] In one embodiment, step S6 can be that the common node receives the second clock synchronization response message returned by the corresponding second center clock node of the alliance chain to which the common node belongs, and records the time t4' of receiving;

[0114] According to a second formula, the clock deviation Δt' of a certain common node and the corresponding second center clock node of the alliance chain to which the common node belongs, and the message propagation delay d' are calculated, and the second formula is:

[0115]

[0116]

[0117] The common node adjusts its clock to t4'-Δt'.

[0118] Figure 3 A node structure diagram of a blockchain multi-node time synchronization method provided by an embodiment of the application is shown in FIG. 1. Figure 3 As shown in FIG. 1, the second center clock nodes ATn of each alliance chain register information at the first center clock node BT0 of the overall blockchain to obtain their respective registration information ATn. The other clock nodes, i.e., common nodes, of each alliance chain register information from the corresponding center clock nodes to obtain their respective registration information (public key and private key).

[0119] Whenever an ATn registers information at the first center clock node BT0, the BT0 will assign an registration information (issue a certificate to the ATn, containing the information of the ATn) to the ATn as a label of the ATn. Similarly, when an ATnn applies for registration information to the second center clock node ATn of the alliance chain, the ATn will also assign an registration information to the ATnn as a label of the ATnn. The registration information of each node is only saved at its respective registered clock node and locally, and other nodes cannot know the registration information of the node. The node with the information registration function is responsible for issuing, verifying and maintaining the validity of the certificate.

[0120] The center clock nodes (such as BT0, AT1, ATn, etc.) of the upper-level blockchain are designated as the certification authority CA, which is responsible for creating and issuing digital certificates of other nodes (BT0 issues digital certificates to AT1, AT2... ATn, and AT1 issues digital certificates to AT11... AT1n). The digital certificate contains the registration information, thereby binding the node with the digital certificate. Only the CA can identify the digital certificate issued by it, and the CA is also responsible for the validity of the digital certificate issued by it.

[0121] The public key of BT0 is GBT0 and the private key is SBT0. Other nodes are similar (the public key of AT1 is GAT1 and the private key is SAT1). The public key of each node is known to other nodes.

[0122] When the alliance chain central time node AT1 (or AT2, …, ATn) needs to perform time synchronization with BT0, AT1 creates a session key S and encrypts S with the public key GBT0 of BT0, and encrypts a synchronization request message S0 with the session key S, and sends the obtained message to BT0. BT0 decrypts the message with its own private key SBT0 to obtain the session key S, and then decrypts S0 with the session key to obtain S0. Since other nodes AT2...ATn do not have the private key of BT0, it is ensured that the time synchronization request can only be decrypted and received by BT0, thereby avoiding resource waste.

[0123] Figure 4 A schematic diagram of a node response message of a blockchain multi-node time synchronization method provided by the embodiment of the application is shown in Figure 4 For example, node A is the second central clock node of the alliance chain AT1, node B is the ordinary node of the alliance chain AT1, △t represents the time deviation between the two nodes, d represents the message propagation delay, the propagation delays of the request message and the response message are consistent, and the time spent by the central clock node in analyzing the time synchronization message is ignored. Node B broadcasts a clock synchronization message request at the local clock t1, node A receives and analyzes the synchronization request message and records the receiving time as t2 (other nodes of the alliance chain AT1 will automatically discard the synchronization request message because they cannot analyze it); then waits for a period of time, node A replies to node B with a response message at the local time t3, and node B receives the response message at the local clock t4, so that

[0124]

[0125] It can be obtained that

[0126]

[0127] Node B adjusts the local clock to t4-△t, so that the clock synchronization of the nodes on the chain is realized.

[0128] Figure 5 A structure schematic diagram of a blockchain multi-node time synchronization device provided by the embodiment of the application is shown in the whole blockchain includes a plurality of alliance chains, the whole blockchain is provided with a first central clock node, each of the alliance chains is provided with a second central clock node, as shown in Figure 5 The blockchain multi-node time synchronization device 10 provided by the embodiment includes:

[0129] The second central clock node processing module 11 is configured to broadcast the encrypted first clock synchronization request.

[0130] a first central clock node processing module 12, configured to receive the encrypted first clock synchronization request, decrypt the encrypted first clock synchronization request, and send a first clock synchronization response message according to the decrypted first clock synchronization request;

[0131] The first adjustment module 13 is configured to receive a first clock synchronization response message returned by the first central clock node, and adjust the clock of the second central clock node according to the first clock synchronization response message.

[0132] In one embodiment, each of the consortium chains is further provided with a common node. The time synchronization device 10 between multiple nodes of a blockchain provided in this embodiment further includes:

[0133] A common node processing module, configured to broadcast an encrypted second clock synchronization request carrying the second registration information;

[0134] The second central clock node processing module is also used to receive the encrypted second clock synchronization request, decrypt the encrypted second clock synchronization request, and send a second clock synchronization response message according to the decrypted second clock synchronization request, wherein the second central clock node is the second central clock node corresponding to the alliance chain where the ordinary node is located.

[0135] The second adjustment module is configured to receive a second clock synchronization response message returned by the second central clock node, and adjust the clock of the common node according to the second clock synchronization response message.

[0136] Through the time synchronization device between multiple blockchain nodes provided by this embodiment, the central clock node of the entire blockchain is responsible for clock synchronization with the central clock nodes of each consortium chain, and the central clock node of each consortium chain then synchronizes the clocks of other nodes on the chain. At the same time, the clock synchronization signal sent by each node can only be responded to by its corresponding upper-level node, reducing the clock synchronization pressure on other nodes and avoiding excessive clock synchronization and single point failure issues. In addition, by encrypting the synchronization request message, it can be ensured that the time synchronization request can only be decrypted and received by the central clock node responsible for the clock synchronization of the node, avoiding resource waste.

[0137] Based on the same technical concept, the embodiment of the present invention also provides a computer device, such as Figure 6 As shown, the computer device 5 includes a memory 51 and a processor 52. The memory 51 stores a computer program. When the processor 52 runs the computer program stored in the memory 51, the processor 52 executes the aforementioned blockchain multi-node time synchronization method.

[0138] Based on the same technical concept, the embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor, and the processor executes the time synchronization method between the multiple nodes of the blockchain.

[0139] In summary, the time synchronization method between the multiple nodes of the blockchain, the device, the computer equipment and the computer readable storage medium provided by the embodiment of the present application can reduce the clock synchronization pressure of other nodes, avoid excessive clock synchronization and single point failure problems. In addition, by encrypting the synchronization request message, it can be ensured that the central clock node responsible for the clock synchronization of the node can decrypt and receive the time synchronization request, thereby avoiding resource waste.

[0140] Those skilled in the art can understand that all or some steps in the method disclosed above, the functions of the modules / units in the system and the device can be implemented as software, firmware, hardware and appropriate combinations thereof. In the hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be performed by several physical components in cooperation. Some or all physical components can be implemented as software executed by a processor, such as a central processor, a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software can be distributed on a computer readable medium, which can include computer storage media (or non-transitory media) and communication media (or transitory media). As known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, as known to those skilled in the art, communication media generally includes computer readable instructions, data structures, program modules or other data in modulated data signals such as carriers or other transmission mechanisms, and can include any information delivery medium.

[0141] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions recorded in the above embodiments can be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for synchronizing time between multiple nodes in a blockchain, characterized in that: The overall blockchain includes multiple alliance chains, the overall blockchain is provided with a first central clock node, and each of the alliance chains is provided with a second central clock node. The method includes: The second central clock node broadcasts the encrypted first clock synchronization request; The first central clock node receives the encrypted first clock synchronization request, decrypts the encrypted first clock synchronization request, and sends a first clock synchronization response message according to the decrypted first clock synchronization request; The second central clock node receives the first clock synchronization response message returned by the first central clock node, and adjusts its own clock according to the first clock synchronization response message.

2. The time synchronization method according to claim 1, wherein: Before the second central clock node broadcasts the encrypted first clock synchronization request, the method further includes: The second central clock node registers with the first central clock node and obtains first registration information; The first registration information includes: a public key and a private key used by the first central clock node to encrypt data transmission.

3. The time synchronization method according to claim 2, characterized in that: After obtaining the first registration information, the following steps are also included: The second central clock node obtains the public key of the first central clock node and creates a session key; The second central clock node encrypts a session key of the second central clock node according to the public key of the first central clock node; The second central clock node encrypts the first clock synchronization request message according to the session key; The second central clock node broadcasting the encrypted first clock synchronization request includes: The second central clock node broadcasts the encrypted session key of the second central clock node and the encrypted first clock synchronization request, and records the broadcast time t1.

4. The time synchronization method according to claim 3, characterized in that: The first central clock node receives the encrypted first clock synchronization request, and decrypting the encrypted first clock synchronization request includes: The first central clock node receives the encrypted session key of the second central clock node and the encrypted first clock synchronization request; The first central clock node decrypts the encrypted session key of the second central clock node according to its own private key to obtain the session key of the second central clock node; decrypting the encrypted first clock synchronization request according to the session key of the second central clock node to obtain a first clock synchronization request message; A first clock synchronization response message is sent according to the first clock synchronization request, where the first clock synchronization response message includes: time t2 when the first clock synchronization request is received, and time t3 when the first clock synchronization response message is sent.

5. The time synchronization method according to claim 4, characterized in that: The second central clock node receiving the first clock synchronization response message returned by the first central clock node, and adjusting its own clock according to the first clock synchronization response message includes: The second central clock node receives the first clock synchronization response message returned by the first central clock node, and records the time t4 of receiving the message; The clock deviation Δt between the second central clock node and the first central clock node and the message propagation delay d are calculated according to a first formula. The first formula is: The second central clock node adjusts its own clock to t4-Δt.

6. The time synchronization method according to claim 1, wherein: Each of the alliance chains is further provided with a common node, and the method further comprises: Ordinary nodes broadcast the encrypted second clock synchronization request; The second central clock node corresponding to the consortium chain where the ordinary node is located receives the encrypted second clock synchronization request, decrypts the encrypted second clock synchronization request, and sends a second clock synchronization response message according to the decrypted second clock synchronization request; The ordinary node receives the second clock synchronization response message returned by the corresponding second central clock node of the alliance chain to which it belongs, and adjusts its own clock according to the second clock synchronization response message.

7. The time synchronization method according to claim 6, characterized in that: Before the ordinary node broadcasts the encrypted second clock synchronization request, the method further includes: The ordinary nodes of each alliance chain register with the second central clock node of the alliance chain to which they belong and obtain the second registration information; The second registration information includes: a public key and a private key used by the common node to encrypt data transmission.

8. The time synchronization method according to claim 7, characterized in that: After obtaining the second registration information, the following steps are also included: The common node obtains the public key of the second central clock node and creates a session key; The common node encrypts the session key of the common node according to the public key of the second central clock node; The common node encrypts the second clock synchronization request message according to the session key; The ordinary node broadcasts the encrypted second clock synchronization request including: The common node broadcasts the encrypted common node session key and the encrypted second clock synchronization request, and records the broadcast time t1'.

9. The time synchronization method according to claim 8, characterized in that: The second central clock node corresponding to the alliance chain where the ordinary node is located receives the encrypted second clock synchronization request, and decrypts the encrypted second clock synchronization request, comprising: The second central clock node corresponding to the alliance chain where the ordinary node is located receives the encrypted session key of the ordinary node and the encrypted second clock synchronization request; The corresponding second central clock node of the alliance chain where the ordinary node is located decrypts the encrypted ordinary session key according to its own private key to obtain the ordinary node session key; decrypting the encrypted second clock synchronization request according to the session key of the common node to obtain a second clock synchronization request message; A second clock synchronization response message is sent according to the second clock synchronization request, wherein the second clock synchronization response message includes: time t2' when the second clock synchronization request is received, and time t3' when the second clock synchronization response message is sent.

10. The time synchronization method according to claim 9, characterized in that: The ordinary node receives the second clock synchronization response message returned by the corresponding second central clock node of the alliance chain where the ordinary node is located, and adjusts its own clock according to the second clock synchronization response message, including: The ordinary node receives the second clock synchronization response message returned by the corresponding second central clock node of the alliance chain where it is located, and records the time t4' of receiving the message; The clock deviation Δt' between the common node and the corresponding second central clock node of the alliance chain where the common node is located, as well as the message propagation delay d' are calculated according to the second formula. The second formula is: The common node adjusts its own clock to t4'-Δt'.

11. A time synchronization device between multiple nodes of a blockchain, characterized in that: The overall blockchain includes multiple alliance chains, the overall blockchain is provided with a first central clock node, and each alliance chain is provided with a second central clock node, including: A second central clock node processing module, configured to broadcast the encrypted first clock synchronization request; a first central clock node processing module, configured to receive the encrypted first clock synchronization request, decrypt the encrypted first clock synchronization request, and send a first clock synchronization response message according to the decrypted first clock synchronization request; The first adjustment module is configured to receive a first clock synchronization response message returned by the first central clock node, and adjust the clock of the second central clock node according to the first clock synchronization response message.

12. A computer device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor runs the computer program stored in the memory, the processor executes the time synchronization method between multiple nodes of a blockchain according to any one of claims 1 to 10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the processor performs the time synchronization method between multiple nodes of a blockchain according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Internet of vehicles equipment identity authentication and key negotiation method based on block chain

    CN112929179A

  • Partition block chain system design method

    CN113032370A