Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application.
The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
Additionally, flowcharts used in this disclosure illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
Before describing embodiments of the present application, two communication modes on a blockchain will be described:
1. The communication established on the native blockchain is such that the communication-related operations are blockchain-level communications implemented by invoking the remote procedure call interface rpc api.
2. The encryption communication contract is established based on the block chain, and the communication-related operation such as sending and receiving is realized based on calling the communication contract.
The communication method based on the blockchain is not limited by the two communication implementation modes, and for convenience of explanation, the following embodiments of the application explain and explain in a way of establishing an encryption communication contract based on the blockchain, a privacy encryption area (communication pool) is established in advance in the communication contract, and messages sent by all users are stored in the communication pool, wherein the communication pool is a public communication pool, but by adopting the method provided by the application, communication messages stored in the communication pool except for two users participating in communication do not have communication behaviors between the two users participating in communication.
A blockchain-based communication method provided by the embodiment of the present application is explained below in conjunction with a plurality of specific application examples. Fig. 1 is a flow chart of a blockchain-based communication method according to an embodiment of the present application, wherein any blockchain node of a blockchain network is applied, and as shown in fig. 1, the method includes:
s101: and receiving a storage operation for the communication message sent by the first user equipment.
In an embodiment of the present application, the first user equipment and the second user equipment are both user equipment installed with preset communication software, and communication between the first user equipment and the second user equipment is achieved by sending a communication message on the preset communication software, where when the first user equipment wants to send a message to the second user equipment, the first user equipment may send a message storing operation to any blockchain node of the blockchain network by calling a message sending interface based on the preset communication software, where the communication message includes: hash value of destination address and message content.
S102: and storing the communication message in a preset communication pool.
In an embodiment of the present application, the preset communication pool is a preset privacy encryption area, and is a public communication pool, the communication pool is established based on a preset position, the established position of the communication pool can be stored in a blockchain communication contract, for example, the address of the preset communication pool can be stored at the position of a hash (0) of the blockchain communication contract, and a user can directly determine the preset communication pool for storing communication messages based on the blockchain communication contract and store the communication messages in the preset communication pool in the process of message transmission.
For example, in some possible embodiments, taking the second user equipment as B as an example, the storage manner of the communication message may be, for example, that the communication message is stored according to a preset format: SENDMESSAGE (DSTADDRHASH, msg), wherein msg is message content, DSTADDRHASH = hash (addressB); because the hash is a one-way hash function, the hash cannot be reversed, the real address of the second user equipment cannot be determined according to the hash address after the hash address is obtained, and the message content corresponding to the hash address can be obtained only after the second user equipment performs hash according to the real address and successfully matches with the hash address.
That is, in such a manner that only the hash address of the second user equipment is stored, the guaranteed message content can only be acquired by the second user equipment, and even if the other user equipment except the second user equipment knows DSTADDRHASH in the communication message, addressB cannot be obtained reversely according to DSTADDRHASH. That is, only the second ue B can know that the message is sent to the second ue B, and other ues can only know that the first ue a sent a communication message, but cannot know the communication destination (the second ue B) and the message content of the communication message, so that the privacy of the communication of the user when sending the communication message is ensured, and the disclosure of the communication object and the communication content is avoided.
In the embodiment of the application, in order to further ensure the privacy of the user message content, the message content in the communication messages stored in the communication pool is encrypted message content, and when the second user equipment receives the encrypted message content, the second user equipment can decrypt the encrypted message content according to a preset decryption mode and then read the encrypted message content.
For example, in some possible embodiments, the message content may be encrypted, for example, by: encrypting the message content through an asymmetric encryption algorithm, for example, the first user equipment can encrypt the message content through a private key of the first user and a public key of the second user, and after the second user obtains the encrypted message content, the second user decrypts the encrypted message content according to the private key of the second user and the public key of the first user, so that original message content information can be obtained; or in other possible embodiments, for example, the message content may be encrypted according to a password agreed in advance by the first user equipment and the second user equipment; it should be understood that the foregoing embodiments are merely exemplary, and the specific manner of encrypting the message content may be flexibly adjusted according to the needs of the user, and is not limited to the foregoing embodiments.
S103: a message event is sent to all blockchain nodes of the blockchain network.
After the storage operation of the communication message is successfully executed each time, the storage operation of the communication message is sent to all block chain links in the block chain network to send the message event corresponding to the storage operation of the communication message, so that user equipment can inquire whether the communication message which needs to be received by the user equipment or not, all the user equipment can inquire the message event through the message event, but only the user equipment corresponding to the hash value of the target address in the message event can know the message content in the message event and the sending target of the communication message.
In the embodiment of the application, if the communication message is successfully stored, that is, if the communication message is correctly stored in the communication pool, a message event is sent to all the block links of the block chain network, so that other user equipment is informed that a new communication message is currently stored in the communication pool, and the other user equipment can go to the communication pool to attempt to acquire the communication message to determine whether the communication message is a communication message sent to the user equipment.
In some possible embodiments, if the communication message fails to be deposited, a communication message depositing failure instruction may be sent to the first user device, and the first user may choose to discard sending the communication message or attempt to resend the communication message.
In an embodiment of the present application, the message event includes: the hash value of the target address and the storage position slot of the communication message in the preset communication pool are equal, for example, the slot of the current communication message stored in the communication pool is slot1, and then slot1 is the storage position corresponding to the communication message.
In some possible embodiments, the storage manner of the communication messages may be, for example, that the communication messages are sequentially stored in a preset communication pool according to the time of receiving the communication messages; that is, the communication messages are sequentially stored in the private communication area (communication pool) according to the time of the communication messages, it should be understood that the above embodiment is only illustrative, and the basis for storing the communication messages in the specific communication pool can be flexibly adjusted according to the needs of the user, and is not limited to the above embodiment.
That is, after the communication message is successfully stored, the format and content of the message event sent to all the blockchain nodes are event (DSTADDRHASH, slot 1), where the message event is used to enable the second user equipment corresponding to the target address to obtain the message content in the communication message from the preset communication pool based on the hash value and the storage location of the target address.
In such a message sending manner, after the communication message is successfully stored in the preset communication pool, the message event is sent to the block chain link, and the message event only includes the hash value of the target address and the storage position of the communication message in the preset communication pool, so that even if other user equipment acquires the message event through the block chain node, the message content in the message event cannot be determined according to the message event, and the message event cannot be sent to which user equipment, thereby ensuring the privacy of the message content and the privacy of the message object when the user sends the message.
For example, 100 communication messages are sent between the first user equipment a and the second user equipment B at 3 a.m., if the prior art is adopted, any user equipment on the blockchain does not acquire specific communication content between a and B, but any user equipment on the blockchain can know when the first user equipment a and the second user equipment B are in communication, that is, any user equipment can know how many communication processes with 100 communication records are performed between the first user equipment a and the second user equipment B at 3 a.m., so that the communication processes between the first user equipment a and the second user equipment B are exposed.
By adopting the method provided by the application, other user equipment except the second user equipment B only can know that the first user equipment A sends the communication message, but the specific content of the communication message sent by the first user equipment A and the specific content of the communication message sent by the first user equipment A cannot be known, namely, other users cannot acquire the communication process of the first user equipment A and the second user equipment B, so that the privacy of user communication is ensured, and no other user except the two communication parties can know the communication behaviors of the two communication parties.
By adopting the communication method based on the block chain, as the first user does not directly send the communication message to the second user when sending the message to the second user, but stores the communication message in the preset communication pool, sends the message event to all block chain links in the block chain network, receives the user equipment corresponding to each block chain link point in the message event, determines whether the user equipment is the second user equipment corresponding to the target address according to the target address in the message event, only the second user equipment corresponding to the target address can acquire the communication message from the preset communication pool based on the hash value and the storage position of the target address, and the setting mode is that other users can only see that the first user equipment transmits the message to other user equipment in the blockchain network, but the specific message content in the transmitted message and the specific user equipment to which the first user equipment transmits the message can not be known by other users, so that the communication privacy in the user communication process is ensured.
Optionally, on the basis of the above embodiment, the embodiment of the present application may further provide a blockchain-based communication method, and an implementation procedure of the method is described below with reference to the accompanying drawings. Fig. 2 is a schematic flow chart of a communication method based on a blockchain according to another embodiment of the present application, as shown in fig. 2, the method may further include:
s111: and receiving a message extraction instruction sent by the second user equipment.
In the embodiment of the present application, the sending manner of the message extraction instruction sent by the second user equipment may include, for example, the following two cases: if the preset communication software on the second user equipment is operated in real time, subscribing the information on the communication contract, thereby realizing the real-time receiving of the information event sent by the blockchain node and timely sending an information extraction instruction according to the information event; or if the preset communication software is not running in real time, the message event sent by the blockchain node may be received after the second user is online, that is, after the second user logs in the communication software, and the message extraction instruction is sent according to the received message event.
The message extraction instruction includes: hash value and storage location of the target address; because each user equipment has the unique corresponding address information, the user equipment which is uniquely corresponding to the address information can be directly determined according to the address information, and the hash value of the address information which is corresponding to the user equipment can be obtained after the hash conversion is carried out on the address information of the user equipment.
After receiving the message event sent by the blockchain node, the second user equipment can send a message extraction instruction including the hash value of the target address to the blockchain link when the first user equipment needs to extract the message sent to the second user equipment: still taking a storage address of a communication message as a slot1 as an example for illustration, after receiving a message event (DSTADDRHASH, slot 1) sent by a blockchain node, the second user equipment needs to take out the message according to the slot1 in the message event, wherein the slot1 is a storage position of the communication message in a communication pool, and at this time, the blockchain node needs to determine whether a message content corresponding to a hash value of a target address exists in the communication pool corresponding to the storage position according to the hash value of the target address; if yes, determining that the current second user equipment has message content to be extracted.
S112: and acquiring the message content in the communication message from a preset communication pool based on the hash value and the storage position of the target address.
In the embodiment of the present application, before executing S112, it is further required to determine whether the second user equipment has the authority to extract the message extraction instruction, where the determining manner may be, for example: determining whether the hash value of the target address in the communication message stored in the storage position is the same as the hash value corresponding to the address of the second user equipment, if so, determining that the second user equipment has the authority of extracting the message instruction, and extracting the corresponding message content in the storage position at the moment; if the second user equipment does not have the authority to extract the message instruction, namely, the hash value of the target address in the communication message stored in the storage position is determined, and when the hash value corresponding to the address of the second user equipment is different, the second user equipment is determined to have no authority to extract the message instruction, and at the moment, an extraction failure instruction is returned to the second user equipment.
S113: and returning the message content to the second user equipment.
When the second user equipment has the right of extracting the message instruction, the extracted message content is returned to the second user equipment, so that the communication between the first user equipment and the second user equipment is completed, other user equipment can only know that the first user equipment sends the message, but the receiving party of the communication message sent by the first user equipment and the specific message content in the communication message can not be known by other user equipment except the second user equipment of the receiving party of the message, the privacy communication between users is realized by the message sending mode, the privacy and the safety of the message in the communication process of the users are ensured, and the communication experience of the users is improved.
Optionally, on the basis of the above embodiment, the embodiment of the present application may further provide a blockchain-based communication method, and an implementation procedure of the method is described below with reference to the accompanying drawings. Fig. 3 is a flowchart of a communication method based on a blockchain according to another embodiment of the present application, where, as shown in fig. 3, before S101, the method may further include:
S121: and establishing a preset communication pool based on the preset position.
In the embodiment of the present application, the preset communication pool may be established at a location where the hash address is hash (0), for example, and it should be understood that the foregoing embodiment is only illustrative, and the preset location of the specific preset communication pool may be flexibly adjusted according to the needs of the user, and is not limited to the foregoing embodiment.
In the embodiment of the application, the communication between the block chain nodes is on-chain communication based on a preset contract, and the communication mode between the block chain nodes is agreed in the preset contract and the position information of the communication pool is stored.
After the preset communication pool is established based on the preset position, when the second user equipment extracts the communication message, the message extraction instruction includes the establishment position of the preset communication pool besides the hash value and the storage position of the target address, that is, the mode of extracting the message content by the second user equipment may be as follows: firstly, extracting communication pool position information in an instruction according to a message of a target block chain, and determining a preset communication pool corresponding to the communication pool position information; and extracting corresponding communication message content from a storage position corresponding to the communication message position information in the preset communication pool according to the communication message position information in the message extraction instruction of the target block chain.
For example, the second user equipment extracts the message content by a message extraction instruction including a slot1+hash (0), where slot1 is a storage location of the communication message in the communication pool, and hash (0) is a preset location of the communication pool, that is, the second user equipment is instructed to go to the communication pool with the preset location being hash (0) by slot1+hash (0), so as to extract the message content of the communication message corresponding to the position of slot1 in the communication pool.
The method provided by the application is based on the communication pool established at the preset position in the blockchain, all the communication messages sent by all users in the communication process are sequentially stored in the communication pool, wherein the storage format of each communication message in the communication pool is the hash value of the target address and the message content, when other users receive the message, the communication message is required to be extracted from the communication pool, and in the extraction process, only the receiver of the communication message can acquire the message content of the corresponding storage position according to the hash value corresponding to the address, namely, no other users can know the communication behaviors of the communication parties except the communication parties participating in the communication, so that the privacy of the users in the communication process is ensured.
The blockchain-based communication device provided by the application is explained below with reference to the accompanying drawings, and the blockchain-based communication device can execute any of the blockchain-based communication methods of fig. 1 to 4, and the specific implementation and the beneficial effects thereof are referred to above and are not repeated below.
Fig. 4 is a schematic structural diagram of a communication device based on blockchain according to an embodiment of the present application, as shown in fig. 4, the device includes: a receiving module 201, a storing module 202 and a transmitting module 203, wherein:
A receiving module 201, configured to receive a depositing operation for a communication message sent by a first user equipment; wherein the communication message comprises: hash value of target address and message content;
a storage module 202, configured to store the communication message in a preset communication pool;
A sending module 203, configured to send a message event to all blockchain nodes of the blockchain network; the message event includes: the message event is used for enabling the second user equipment corresponding to the target address to acquire the communication message from the preset communication pool based on the hash value and the storage position of the target address.
Optionally, on the basis of the foregoing embodiment, an embodiment of the present application may further provide a blockchain-based communication device, where an implementation procedure of the device shown in fig. 4 is described below by way of example with reference to the accompanying drawings. Fig. 5 is a schematic structural diagram of a communication device based on blockchain according to another embodiment of the present application, as shown in fig. 5, the device further includes: an acquisition module 204, wherein:
The receiving module 201 is specifically configured to receive a message extraction instruction sent by the second user equipment, where the message extraction instruction includes: hash value and storage location of the target address;
An obtaining module 204, configured to obtain, from a preset communication pool, a message content in a communication message based on a hash value and a storage location of a target address;
The sending module 203 is specifically configured to return the message content to the second user equipment.
As shown in fig. 5, the apparatus may further include: a storage module 202, configured to store the communication message in a preset communication pool according to the time of receiving the communication message.
Optionally, the sending module 203 is specifically configured to send a message event to all blockchain nodes of the blockchain network if the communication message deposit is successful.
As shown in fig. 5, the apparatus may further include: the establishing module 205 is configured to establish a preset communication pool based on the preset location.
As shown in fig. 5, the apparatus may further include: a determining module 206, configured to determine a preset communication pool corresponding to the communication pool position information according to the communication pool position information in the message extraction instruction of the target blockchain;
the obtaining module 204 is specifically configured to extract, according to the communication message location information in the message extraction instruction of the target blockchain, corresponding communication message content from a storage location corresponding to the communication message location information in the preset communication pool.
Optionally, the sending module 203 is specifically configured to determine whether the second user equipment has a right to extract the message extraction instruction; if not, returning an extraction failure instruction to the second user equipment.
The foregoing apparatus is used for executing the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
The above modules may be one or more integrated circuits configured to implement the above methods, for example: one or more Application SPECIFIC INTEGRATED Circuits (ASIC), or one or more microprocessors, or one or more field programmable gate arrays (Field Programmable GATE ARRAY FPGA), etc. For another example, when a module above is implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a central processing unit (Central Processing Unit, CPU) or other processor that may invoke the program code. For another example, the modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 6 is a schematic structural diagram of a blockchain-based communication device according to an embodiment of the present application, where the blockchain-based communication device may be integrated in a terminal device or a chip of the terminal device.
As shown in fig. 6, the blockchain-based communication device includes: a processor 501, a bus 502, and a storage medium 503.
The processor 501 is configured to store a program, and the processor 501 invokes the program stored in the storage medium 503 to perform the method embodiments corresponding to fig. 1-4. The specific implementation manner and the technical effect are similar, and are not repeated here.
Optionally, the present application also provides a program product, such as a storage medium, on which a computer program is stored, including a program which, when being executed by a processor, performs the corresponding embodiments of the above-mentioned method.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (english: processor) to perform some of the steps of the methods according to the embodiments of the application. And the aforementioned storage medium includes: u disk, mobile hard disk, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.