Disclosure of Invention
The technical problem to be solved by the invention is to provide a many-to-many private information sending and receiving method, and realize the block chain group private information exchange fast and safely.
In order to solve the technical problems, the technical solution of the invention is as follows:
a private message exchange method in a group based on a block chain comprises the following steps:
(1) the information sending node generates a piece of data Info;
(2) the system positions a group B where the information sending node is located, and extracts group information and a group type of the group B;
(3) the system obtains a group encryption mode according to the group type to obtain a group public key Bpk;
(4) the system generates a random integer Index which is less than or equal to the total number of the group members, and extracts member information P corresponding to the random number to obtain a member public key Ppk;
(5) the system encrypts Data by using the member public key Ppk and encrypts the random integer Index by using the group public key Bpk to obtain final Data (bpk (Index) + Ppk (info));
(6) the system sends the data to the group members in the group B, and the group members receive and extract the sent data;
(7) the receiving information node obtains the type of the group where the node is located, and extracts the public key of the group where the node is located;
(8) the receiving information node uses the group public key to decrypt the data header;
(9) the receiving information node obtains an original random number Index, and the receiving information node obtains a member corresponding to the random number;
(10) the receiving information node acquires the member public key;
(11) the receiving information node decrypts the latter half of the received data by using the member public key to complete data decryption.
A blockchain-based private message exchange system within a group, comprising:
the group manager is connected with the block chain network and used for managing the currently defined groups, and the groups are added by users in the service operation process;
the member manager is connected with the blockchain network and used for managing member information, wherein the information is control instruction information or descriptive information, and the members are describable objects which can be digitized;
in the key manager, the key manager is connected with the block chain network and is used for generating a key pair and a verification key and providing cryptographic service for the group and the members;
the group manager, the member manager and the key manager are sequentially connected.
Further, the group manager comprises a group attribute management module, a group type definition module and a group data management module.
Further, the group attribute management module is configured to define each attribute of the group, where the attributes include concise information of the group, a position and a group of the group, and other information used for providing an information recording capability for a service, the group type definition module is configured to define a type of the group, where the type is a type in a technical level and is used to perform different analyses on the group attribute, and the group data management module is configured to provide a data access capability for each other module and persistently store the defined data.
Furthermore, the member manager is a subset of the group manager, the member manager works depending on the group manager, and the member manager comprises a member attribute management module, a member type definition module and a member data management module.
Further, the member attribute management module is configured to define various attributes of the group, and define various attributes for different upper-layer service environments, the group type definition module is configured to define a type of the group, the type is a type of a technical layer, and the member data management module is configured to provide access to member data for other modules and provide persistent storage for the formed member data.
Furthermore, the type of the technical layer includes data, a contract, an account, equipment and a group, when the type of the technical layer is data, common text processing is performed on the member information, when the type of the technical layer is a contract, the member information is executed as a program, when the type of the technical layer is an account, the account is checked and checked, when the type of the technical layer is equipment, the controller is used as a controller to send an instruction, and when the type of the technical layer is a group, the group members are analyzed again.
Further, the key manager comprises a key pair production module, an encryption module and a verification module.
Further, the key pair production module is used for generating key pairs for groups and members, the encryption module is used for providing encryption service for data and selecting an encryption mode for upper-layer application, the verification module corresponds to the encryption module, and the verification module provides a password verification method.
Furthermore, the first type is an asymmetric encryption mode using a group key pair, the second type is a symmetric encryption mode using randomly extracted public keys of the group members, the third type is a method using all public keys of the group members to perform annular signature, the verification method has two types, the first type is to directly find out a key in the symmetric encryption for decryption, and the second type is to find out a corresponding key pair according to the adopted encryption mode in the asymmetric encryption and use another key for decryption.
The invention has the beneficial effects that:
the invention constructs a concept of 'virtual group' by logically forming a group of nodes into a group or logically one node, when a message needs to be sent to the owner of the group, only the message needs to be sent to the virtual node, thereby realizing the sending and receiving of many-to-many private information, constructing a structural model for fast and safe exchange of the private information of the group under a block chain, and solving the problem of limited point-to-point group sending in the block chain.
Detailed Description
The invention is described in further detail below with reference to the figures and specific examples. It should be noted that the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
In order to solve the problem that a block chain can only carry out point-to-point transmission and cannot carry out many-to-many private information sending and receiving and realize the exchange of private information in a block chain group, the application provides a concept of a virtual group, and the core idea of the virtual group is to logically form a group by a group of nodes or a logical node, and when the message needs to be sent to the owner of the group, the message only needs to be sent to the virtual node. Specifically, the present invention discloses a method for exchanging private messages in a group based on a block chain, as shown in fig. 1, including the following steps:
(1) the information sending node generates a piece of data Info; the sending information node is a node which needs to send data in a group, and before sending, a data Info needs to be generated;
(2) the system positions a group B where the information sending node is located, and extracts group information and a group type of the group B; the step is used for positioning the position of the information sending node and then recording the group attribute of the information sending node;
(3) the system obtains a group encryption mode according to the group type to obtain a group public key Bpk;
(4) the system generates a random integer Index which is less than or equal to the total number of the group members, and extracts member information P corresponding to the random number to obtain a member public key Ppk;
(5) the system encrypts Data by using the member public key Ppk and encrypts a random integer Index by using the group public key Bpk to obtain final Data bpk (Index) + Ppk (info); the final data is the data encrypted by the random key in the group, the step completes the sending and encryption process of the mass data,
(6) the system sends the data to the group members in the group B, and the group members receive and extract the sent data; all members in the group can extract the sent data, and the step starts the receiving process;
(7) the receiving information node obtains the type of the group where the node is located, and extracts the public key of the group where the node is located; because the group public key is determined by the group type, all members in the group can obtain the group public key by obtaining the group type per se;
(8) the receiving information node uses the group public key to decrypt the data header;
(9) the receiving information node obtains an original random number Index, and the receiving information node obtains a member corresponding to the random number; all members in the same group can receive the random integer Index, and determine the corresponding members according to the random number;
(10) the receiving information node obtains the member public key;
(11) the receiving information node decrypts the latter half of the received data by using the member public key to complete data decryption.
The method for exchanging private information in group uses random cipher key mode in group, the core realizing method is that the public key of the group is used to encrypt the random serial number of the current information, before encryption, the public key of one member in the group is first extracted by the serial number to do symmetric encryption, when other people in group send information to the group, one serial number is randomly extracted by themselves and then the public key corresponding to the serial number is extracted to encrypt the data and send out the data, the members in group can receive the data by decrypting the data through the public key of group and the obtained public key of the members. The method is suitable for group members to send information to the group members, and is high in encryption and decryption speed and convenient and fast to use.
The invention also discloses a private message exchange system in the group based on the block chain, which comprises:
the group manager is connected with the block chain network and used for managing the currently defined groups, and the groups are added by users in the service operation process; for example, a chat group added by a user, in some specific application scenarios, the initial phase is already set in the code, such as an internet of things application, and the system for controlling all light bulbs in a room is similar to the function of the group manager.
The member manager is connected with the blockchain network and used for managing member information, wherein the information is control instruction information or descriptive information, and the members are describable objects which can be digitized; for example, when the system is applied to social contact, the system is information such as a nickname and a personal signature of a person, and when the system is applied to the internet of things, the system may be control instruction information such as instruction information for turning on or off lights, and members of the member manager correspond to a subset of a group, and the group is a system for controlling all light bulbs in a room, i.e., the member is instruction information for turning on or off lights.
In the key manager, the key manager is connected with the block chain network and is used for generating a key pair and a verification key and providing cryptographic service for the group and the members;
the group manager, the member manager and the key manager are sequentially connected.
Preferably, the group manager includes a group attribute management module, a group type definition module, and a group data management module. Preferably, the group attribute management module is configured to define each attribute of a group, where the attributes include concise information of the group, a location of the group, and other information for providing an information recording capability for a service, and different definitions are provided in different upper layer application scenarios, for example, concise information of a group may be defined in a chat, and a location of a group may be defined in an application of the internet of things. The information defined herein may be used for different purposes depending on the design of the subsequent type definition module, and is conventionally used to provide information recording capability for services, and may be used to define different service operations in other cases. Preferably, the group type definition module is configured to define a type of a group, where the type is a type of a technical layer and is used to perform different analyses on a group attribute, the type of the technical layer is different from the type of a service layer, and the type of the service layer is actually embodied by a group attribute, that is, the type is defined by a group attribute management module, such as a chat group, where the type is an in-company chat group, where the in-company type is an attribute of the group, in a bottom-layer technical support, the group is a text-type description group, where a text type is the group type referred to herein, and according to different specific service requirements, the type support implemented here is also different, such as only being used for a text-description group, where only text information is recorded, and the type definition module only performs text processing when encountering the type, for example, if the group is defined as a program group, the type definition module will treat its members as a program when it encounters this type. In the invention, text type and contract type are mainly realized, and new type can be added or old type can be deleted according to different upper layer service requirements. Preferably, the group data management module is configured to provide data access capability for other modules, and perform persistent storage on defined data.
Preferably, the member manager is a subset of the group manager, the member management module is similar to the group management module, the member manager is attached to the group manager to work, and the member manager comprises a member attribute management module, a member type definition module and a member data management module. Preferably, the member attribute management module is configured to define each attribute of the group, and define each attribute for different upper service environments, the group type definition module is configured to define a type of the group, where the type is a type of a technical layer, and preferably, the type of the technical layer includes data, a contract, an account, a device, and a group, and when the type of the technical layer is data, the member information is subjected to ordinary text processing, and when the type of the technical layer is a contract, the member information is executed as a program, and when the type of the technical layer is an account, the account is subjected to an account balance operation, and when the type of the technical layer is a device, the member is used as a controller to send an instruction, and when the type of the technical layer is a group, the group member is analyzed again. The present invention implements different functions according to different types. Preferably, the member data management module is used for providing member data access for other modules and providing persistent storage for the formed member data.
Preferably, the key manager comprises a key pair production module, an encryption module and a verification module. The first one is an asymmetric encryption mode using the group key pair, namely, a pair of keys is distributed to the group, only people in the group have private keys, the public keys are open to all people, and when other people in the group and outside the group send messages to the group, only the public keys are used for encrypting and then sending the messages to the group, and any person in the group can decrypt the messages by using the private keys of the group. The method is suitable for the member outside the group to send the second kind of information to the member inside the group, it uses the random cipher key inside the group, and the invention is also the most common method, namely the public key of the group is used to encrypt the random serial number of the current information, before encrypting, the serial number is used to extract the public key of one member in the group to do symmetric encryption, when other persons in the group want to send information to the group, the other persons in the group randomly extract a serial number and then extract the corresponding public key of the serial number to encrypt and then send out the data, the member in the group decrypts the serial number and then uses the public key to decrypt. The second type is only suitable for sending information to the members in the group by the members in the group, but has the fastest speed and strong applicability. And thirdly, sending the message by adopting an intra-group ring signature mode, wherein when the members in the group and outside the group send messages to the group, the public key of all the persons in the group is used for carrying out ring signature, and then any person of the members in the group carries out decryption by using the private key of the person. The third method is also suitable for sending information from the members outside the group to the members inside the group, and has the highest security but the slowest speed, so that different encryption modes can be selected according to different requirements. The verification module corresponds to the encryption module and provides a password verification method, and the two verification methods are used for the first one, namely directly finding a key for decryption in symmetric encryption and the second one, namely finding a corresponding key pair according to the adopted encryption mode in asymmetric encryption and using the other key for decryption.
The invention manages different groups through a group manager, manages different members in the group through the member manager, encrypts and decrypts the group and the members through a key manager, constructs a concept of a virtual group by logically forming a group node into a group or a logical node, and realizes data transmission and transmission in the group by utilizing data transmission and reception among the virtual groups, thereby realizing multi-to-multi private information transmission and reception, constructing a structural model for fast and safe group private message exchange under a block chain, and solving the problem of limited group-to-point group transmission in the block chain.
The above description is only a preferred embodiment of the present invention, and does not limit the technical scope of the present invention, so that the changes or modifications made by the claims and the specification of the present invention should fall within the scope of the present invention.