Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The energy transaction processing method based on the block chain can be applied to the energy transaction processing system based on the block chain shown in fig. 1. As shown in fig. 1, the energy transaction processing system based on blockchain is a dual blockchain system, and the system includes 2 blockchains and 3 types of roles. The 2 chains are respectively a user block chain and a transaction block chain, and the 3 types of roles are respectively a user, an auditor and a monitor. Wherein, the user block chain: the system is used for storing the basic user information, each block contains some basic user information, and the block header of the next block contains the hash value of the previous block, so that the link ensures that the basic user information is not illegally tampered, and the identity inquiry can be performed by a supervisor. Transaction block chaining: the method can be used for browsing the content of the initiated transaction and storing transaction information, the transaction information can be decrypted and checked by the auditing party, and the auditing party audits whether the transaction amount is legal or not. The user: transaction participants in a dual blockchain system include the initiator and recipient of the transaction. The initiator of the transaction comprises the initiation of electricity selling transaction and the initiation of electricity purchasing transaction, and the party receiving the initiation of the transaction is the receiver. And (4) an auditor: the system is trusted, has an auditing function, and audits transactions on the block chain. In practical application, the auditor is generally each power operator. And (4) a supervision party: trustable, has a supervision function, and can query and track the identity of illegal traders in the blockchain. In practical application, the supervising party is generally a power grid company or a subsidiary power grid company.
In one embodiment, as shown in fig. 2, a block chain-based energy transaction processing method is provided, which is described by taking the system in fig. 1 as an example, and includes the following steps:
step 202, the two parties of the energy transaction respectively encrypt the transaction information by using the public key of the auditing party and then broadcast the encrypted transaction information to the transaction block chain, wherein the transaction information comprises transaction content and transaction user information.
The user transaction information chaining and auditing process mainly includes operations such as broadcasting, browsing and auditing, as shown in fig. 3. The two parties of the energy transaction comprise a transaction initiator and a transaction object, wherein the transaction initiator is a buyer and the transaction object is a seller.
The two transaction parties carry out transaction, the transaction initiator broadcasts transaction contents to the transaction block chain, and the transaction contents comprise transaction time, transaction addresses, transaction amount and transaction quantity. At this time, the transaction object can browse the contents on the chain, and the chain contents of the transaction initiator can not be counterfeited. The transaction initiator and the transaction object pack transaction user information and transaction content to the auditor at the same time, and the transaction content and the transaction information are encrypted by the public key of the auditor and then broadcast to the transaction block chain.
And step 204, acquiring transaction information by the auditing party through the transaction block chain, decrypting the transaction information by using a private key of the auditing party to obtain transaction content and transaction user information, and if the auditing transaction is illegal according to the transaction content, determining an illegal transaction user by the auditing party according to the transaction user information.
Among them, the block chain technology, as an emerging technology, plays a great role in technical innovation and industrial innovation, and has characteristics of decentralization, tamper resistance, and the like, and is widely concerned in many fields. Compared with the traditional centralized management mechanism, the development of the block chain technology reduces the risks of centralized service data crash and malicious attack. The block chain technology is applied to energy transaction, the transaction mode does not need centralized financial institution supervision, and both transaction parties realize point-to-point transaction and can protect the privacy security of transaction users through a consensus mechanism, an encryption technology and a privacy protection technology.
And the auditing party acquires the transaction information from the transaction block chain, and decrypts the transaction information by using a private key of the auditing party to obtain transaction content and transaction user information. The auditing party decrypts the transaction information of the two transaction parties respectively by using the private keys of the auditing party to obtain the transaction content and the transaction user information of the transaction initiator and the transaction content and the transaction user information of the transaction object. The transaction initiator comprises electricity selling transaction initiation and electricity purchasing transaction initiation, and the party receiving the transaction initiation is a receiver.
And the auditing party audits whether the transaction is illegal according to the transaction content, if so, the transaction is illegal, and the corresponding transaction user is determined to be an illegal transaction user. Specifically, the transaction initiator and the transaction object of the transaction are determined as illegal transaction users.
According to the energy transaction processing method of the block chain, the two parties of the energy transaction broadcast the transaction information to the block chain after encrypting the transaction information by using the public key of the auditing party, the safety of the basic information of the user and the transaction information of the user can be ensured by using the block chain technology, the auditing party obtains the transaction information from the transaction block chain by using the traceable characteristic, the transaction information is decrypted by using the private key of the auditing party to obtain the transaction content and the transaction user information, whether the auditing is illegal transaction or not is judged according to the transaction content, and the illegal transaction user is determined when the illegal transaction exists. By utilizing the block chain technology, the privacy information of both transaction parties is protected, and meanwhile, the transaction is supervised through auditing, so that illegal transactions are monitored in time.
In another embodiment, as shown in fig. 4, a method for auditing whether a transaction is an illegal transaction according to the contents of the transaction includes:
s402, comparing the transaction content and the transaction information of the two transaction parties respectively.
And the auditing party decrypts the transaction content by using the private key, compares whether the transaction user information and the transaction content sent by the two transaction parties are consistent or not, and if the transaction user information and the transaction content are consistent, the transaction user information and the transaction information are falsified with a very small probability.
If the transaction information is consistent with the transaction information, executing step S404, and if the transaction information is not consistent with the transaction information, respectively encrypting the transaction information by using the public key of the auditor and broadcasting the encrypted transaction information to the transaction block chain.
And S404, auditing whether the transaction is illegal according to the transaction content.
Specifically, the transaction content includes a transaction amount and a transaction amount; auditing whether the transaction is illegal according to the transaction content, wherein the auditing step comprises the following steps: comparing whether the transaction amount is matched with the transaction amount, whether the transaction amount exceeds the limit and whether the transaction amount exceeds the limit; and if the transaction amount does not match the transaction amount, or the transaction amount exceeds the limit, determining that the transaction is illegal.
And if the transaction is illegal, executing the step that the auditing party determines the illegal transaction user according to the information of the transaction user.
Specifically, the public key of the auditor is PK _ s, and the private key is SK _ s. Because the transaction content is encrypted by the transaction user by using the public key of the auditing party, the auditing party can know the transaction information through the private key and audit. Setting the electricity price of a single transaction as P _ pr, the single transaction amount as n, the single transaction limit amount as HP _ pr, the transaction amount limit amount as lambda, and defining an auditing algorithm as follows:
Audit{P_pr,n|(P_pr,n)=decrypt[SK_s,C_text],(P_pr≤HP_pr)∪(n≤λ)},
if the algorithm output does not have the output value meeting the condition, the illegal transaction is determined. That is, the transaction amount P _ pr and the transaction amount n of a single transaction are obtained from the ciphertext decrypted by the private key of the auditor, and if any value exceeds the limit, the transaction is determined to be an illegal transaction.
In one embodiment, when illegal transactions are tracked, the information of transaction objects and transaction details is also ensured to be concealed, but illegal user information can be disclosed by auditing the illegal electric power transaction tracking. Based on this, in this embodiment, the transaction user information uploaded to the transaction block chain by the transaction parties is pseudonym information of the transaction user, where the pseudonym information is distributed to the registered user by the supervisor using the supervisor key during registration.
In particular, the pseudonym is relative to the true username of the transacting user. The pseudonym is assigned by the supervisor to the registered user using the supervisor key at the time of registration of the user. By using the pseudonymous name information to spread on the transaction block chain, even if the system is attacked maliciously, the transaction content cannot be known.
Specifically, as shown in fig. 5 and fig. 6, the user registration process, which involves 5 basic operations of registration, verification, authorization, pseudonym allocation, encryption and uplink, includes the following steps:
s502, the user sends a registration request to the user information chain.
Specifically, a user participating in an energy transaction performs identity registration and sends a request to join a user information chain.
S504, after the supervisor receives the registration request based on the user information link, the supervisor verifies the identity of the user, and if the verification is successful, pseudonym information is randomly distributed and returned to the user.
And the supervisor executes the identity information verification after receiving the request information, randomly allocates a pseudonym to the user if the identity verification is successful, and feeds back the pseudonym to the user if the verification is not successful, and the step S502 is executed again. The user identity information verification here may be to invoke a national identity card system to verify whether the user is a real user.
S506, after receiving the verification success and the pseudonym information, the user selects a user key, encrypts the user information and the pseudonym information according to the user key to obtain a first ciphertext, encrypts the user key by using a public key of the monitor to obtain a second ciphertext, and sends the first ciphertext and the second ciphertext to the monitor.
After receiving the verification success and the pseudonym information, the user selects a user key by himself, wherein the user key can be a first ciphertext cipher _ user obtained by encrypting the user information and the pseudonym by using a lightweight cryptographic algorithm and uploading the ciphertext cipher _ user to the user block chain. And then encrypting the key user _ key by using the public key of the monitor to obtain a second ciphertext _ user _ key, and sending the second ciphertext _ user _ key to the monitor.
Specifically, the uplink of the user identity information is executed by a registered user, the user is required to select a user key by himself in the uplink process and encrypt the identity information and the pseudonym, the privacy of uplink data only needs to be guaranteed here, but in order to accelerate the encryption speed, the user key adopts a lightweight block cipher algorithm LBlock, and the algorithm is a symmetric encryption algorithm and is characterized by being high in operation speed and high in safety. The user key generation method comprises the following steps:
(1) the user identity information is converted into a string of binary bit sequences, and each 64 bits are divided into m groups. The user selects an 80-bit KEY as an initial KEY, which is also a KEY to be sent to a supervisor later;
(2) let P _ text be X1||X0Representing a set of 64-bit plaintext, P1And P0Representing the left 32 bits and right 32 bits of plaintext, respectively. The initial KEY KEY is recorded as KEY ═ k79k78...k0Taking the first 32 bits of the initial key as the round key K of the first round1。
(3) The whole operation is iterated for 32 rounds, and each round has a round key KiParticipation makes the initial key mix-in difficult to calculate statistically or algorithmically. Round key KiIs the subkey KEYiThe first 32-bit round key generation scheme is as shown in fig. 7, where S is a substitution operation in a Func function, and in order to make the algorithm lighter and have a certain security effect and improve the operating efficiency of the whole system, only the first S box of 10S boxes designed by the algorithm is used as the substitution operation.
(4) The following iterative calculations are then performed: xi=Func(Xi-1,Ki-1)⊕(Xi-1<<<8) 2,3, 33, where Func denotes a round function, KiIndicating the round key. C _ text ═ X32| | | X33 represents a 64-bit ciphertext output, X32And X33Representing the left 32 bits and right 32 bits of the ciphertext, respectively. The Func function comprises digital substitution and position substitution, and the numerical substitution and the position substitution are operated by taking hexadecimal as a unit;
(5) since the binary bit sequence of the user information is divided into m groups, a total of m 32 rounds of iterative encryption operations are performed. And finally combining the m groups of obtained ciphertexts together.
S508, the supervisor receives the second ciphertext, decrypts the second ciphertext by using the own secret key to obtain a user secret key, decrypts the first ciphertext by using the user secret key to obtain user information and pseudonym information, detects whether the pseudonym information obtained by decryption corresponds to pseudonym information distributed during registration, and if so, successfully links the user information.
And the supervisor receives the second ciphertext _ user _ key, decrypts the first ciphertext _ user by using the user key, and checks whether the pseudonym in the first ciphertext corresponds to the identity information. If the user block link information is not corresponding to the user block link information, the pseudonym information is redistributed according to the registered user information.
The block chains are linked together through the hash value, so that the block chains can be used for checking information and ensuring that the information is not tampered. In the user basic information uplink operation, only the operation between a supervisor and a user is carried out, and an auditor does not participate.
As shown in fig. 1 and 8, after the auditor confirms the illegal transaction user, the method further includes:
s802, an identity tracking request is sent to the supervising party, and the identity tracking request carries the pseudonym information, the signature of the auditing party and the pseudonym information of the illegal transaction user.
Due to the fact that the pseudonym information is used, even if a malicious attacker or a supervision party knows the packaged information, the malicious attacker or the supervision party cannot know the transaction content and is connected with the pseudonym identity, and privacy is improved. The auditor audits and finds the illegal transaction user, and immediately sends the auditor signature, the transaction user pseudonym and the tracking request to the supervising party. The tracking algorithm is participated by an auditor and a monitor together, and because the auditor masters the pseudonym information of the users in the user block chain, when the auditor sends a request for tracking the identity of an illegal user, the information of the user can be inquired according to the pseudonym information, and corresponding measures are taken.
And S804, the supervising party verifies the signature of the auditing party, decrypts the pseudonym information of the illegal transaction user according to the secret key of the supervising party after the signature is verified, so as to obtain the real user information of the illegal transaction user, and feeds back the real user information of the illegal transaction user to the auditing party.
Specifically, after receiving a tracking request of an auditor, a supervising party verifies the signature. If the verification fails, the data is fed back to the auditor and is required to be sent again; and after verification, the supervising party finds out a corresponding user real identity information ciphertext on the user block chain according to the pseudonym information sent by the auditing party, decrypts by using a private key, and tracks the user real information.
Specifically, the input information in the algorithm is a message REQ _ text (a request for tracking pseudonym user information) and an auditor public key PK _ s, that is, the auditor sends an encrypted message hash, a message original text, and an auditor public key to a supervisor. If DEC [ PK _ s, CRY (SK _ s, hash (REQ _ text)) ] ═ hash (REQ _ text) is met, the verification passes, namely, a monitor decrypts by using a public key of an auditor to obtain the hash (REQ _ text), then the received message original text is operated by using the same hash algorithm, if two digest values are consistent, the verification passes, and then the monitor can use the pseudonym information in the message to inquire the identity of an illegal user.
In another embodiment, the method further comprises: and the auditing party records the illegal transaction user and marks the illegal transaction user when the recorded illegal transaction times reach a set value.
Specifically, the marking process may be that, if the user has an illegal transaction record, the user is given an alarm once and records, and after the alarm is given twice, the transaction right is cancelled and the user information is marked.
In another embodiment, the transaction information is broadcast to the transaction blockchain using an asymmetric encryption algorithm. Wherein, the transmission of the key also adopts an asymmetric encryption algorithm.
Specifically, a knapsack algorithm is used for generating a public key and a private key, and the public key and the private key are used for encryption and decryption, and the algorithm is high in encryption speed and high in safety performance.
(1) Generation of public and private keys
The receiver constructs a non-conflict non-supersequence X ═ X
1,x
2,...,x
n]And a random sequence Y ═ Y
1,y
2,...,y
n]While simultaneously letting Z ═ Y + α X, whichWherein Z is (Z)
1,z
2,...,z
n),
The recipient saves Z as a public key and Y and alpha as private keys.
(2) Encryption and decryption process
Encryption: converting the transmitted information into binary bit sequence, dividing every n bits, and using P _ text ═ P for each group of information1,p2,...,pn]And (4) showing. The sender encrypts each group of plaintext information by using the public key Z to obtain a ciphertext C _ text ═ Z1p1+z2p2+...+znpn。
And (3) decryption: the receiver uses Y and alpha for decryption, having
Pt_text=C_text(modα)
=(z1p1+z2p2+...+znpn)(modα)
=
((y1+αx1)p1+(y2+αx2)p2+...+(yn+αxn)pn)(modα)
=y1p1+y2p2+...+ynpn(modα)
Obtaining original sending information P _ text [ P ]) according to the following steps1,p2,...,pn],
As shown in fig. 1, the energy transaction processing method based on the block chain includes the following steps:
step 1: before a user participating in energy transaction joins a system, identity registration is needed, a supervisor checks identity information, after the check is passed, the user is allocated with a pseudonym, the user encrypts the identity information and the pseudonym and uploads the encrypted information to a user block chain, and key information is encrypted and sent to the supervisor.
Step 2: the transaction initiator initiates a transaction and broadcasts transaction information to a transaction block chain, and the transaction parties encrypt transaction contents and respective pseudonymous information by using a public key of an auditor.
And step 3: the auditing party decrypts the transaction information by using the private key of the auditing party and audits the transaction amount, and if the transaction amount is extremely mismatched with the transaction amount or the transaction amount exceeds a limit amount, the auditing party is considered to be illegal transaction.
And 4, step 4: when the illegal transaction is judged, the auditing party sends an illegal transaction user identity tracking request to the supervising party, and the pseudonym information of the transaction user and the signature of the auditing party are sent to the supervising party together.
And 5: after the supervising party checks the signature, the supervising party starts to inquire and track the user information, uses the private key of the supervising party to decrypt the key information of the user, then uses the private key of the user to decrypt the user information, and feeds back the information to the auditing party after the decryption is successful so as to reveal the illegal user.
Compared with the related technology, the energy transaction processing method based on the block chain has the advantages that a double-block chain system model facing the privacy protection of the energy transaction at the user side is constructed, the double chains are respectively introduced into the auditor and the monitor to realize the legality judgment of the energy transaction and the identity tracking of the illegal user, the separation of the basic identity information of the transaction user and the transaction information of the user is realized, and the privacy of the user information is guaranteed. Meanwhile, an encryption module combining a lightweight cryptographic algorithm and an asymmetric cryptographic algorithm is constructed, so that privacy security and data transmission security of user information are realized. The invention has the following beneficial effects:
(1) in an energy user transaction network, on one hand, registered users store basic identity information into a user block chain to prevent user information from being illegally tampered, and a supervisor can conveniently inquire and trace illegal user information; on the other hand, the transaction content issued by the transaction initiator is uploaded to the transaction block chain, the transaction amount and the transaction amount are audited by the auditing party, and whether illegal transactions exist is judged. In the double-block chain system model, an auditing party can only know the transaction amount and the transaction amount, a supervising party can only know the user identity participating in the transaction, and two parties cannot simultaneously master all information of the user, so that the separation of the user identity information and the user transaction information is realized.
(2) An encryption algorithm module for protecting user information and user data transmission is designed, the module combines a symmetric cryptographic algorithm and an asymmetric cryptographic algorithm, and is respectively applied to different encryption scenes, so that the security of encryption information and a secret key is ensured, and the operation efficiency of the algorithm is improved. A lightweight cryptographic algorithm is introduced to realize information encryption, an asymmetric algorithm encryption key and information chaining are adopted, an encryption algorithm module realizes privacy protection of user basic information and transaction information, and low efficiency of the system caused by slow algorithm operation is relatively guaranteed.
It should be understood that although the various steps in the flowcharts of fig. 2, 4-8 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2, 4-8 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps or stages.
In one embodiment, as shown in fig. 1, there is provided a block chain-based energy transaction processing method system: the method comprises the following steps: the energy resource management system comprises a transaction information block chain, nodes of both energy transaction parties and nodes of an auditing party.
The energy transaction system comprises a transaction block chain, a transaction information database and a transaction information database, wherein the transaction information database is used for storing transaction information of energy transaction parties, and the transaction information database is used for storing transaction information of energy transaction parties;
and through the transaction block chain, the auditing party acquires transaction information, decrypts the transaction information by using a private key of the auditing party to obtain transaction contents and transaction user information of both transaction parties, and if the transaction is audited to be illegal according to the transaction contents, the auditing party determines an illegal transaction user according to the transaction user information.
According to the energy transaction processing system based on the blockchain, two parties of the energy transaction broadcast the transaction information to the blockchain after encrypting the transaction information by using the public key of the auditing party, the safety of the basic information of the user and the transaction information of the user can be ensured by using the blockchain technology, the auditing party obtains the transaction information from the transaction blockchain by using the traceable characteristic, the transaction information is decrypted by using the private key of the auditing party to obtain the transaction content and the transaction user information, whether the auditing is illegal transaction or not is judged according to the transaction content, and the illegal transaction user is determined when the illegal transaction exists. By utilizing the block chain technology, the privacy information of both transaction parties is protected, and meanwhile, the transaction is supervised through auditing, so that illegal transactions are monitored in time.
In another embodiment, the system further comprises: a node of a supervisor;
the transaction user information is pseudonymous name information of the transaction user, and the pseudonymous name information is distributed to the registered user by a supervisor through a supervisor key during registration;
after an auditor confirms an illegal transaction user, sending an identity tracking request to a supervisor, wherein the identity tracking request carries an auditor signature and an auditor public key; the signature of the auditor is obtained by encrypting the pseudonym information of the illegal transaction user by using the public key of the auditor;
and the supervising party verifies the signature of the auditing party, decrypts the pseudonym information of the illegal transaction user according to the secret key of the supervising party after the signature is verified, so as to obtain the real user information of the illegal transaction user, and feeds back the real user information of the illegal transaction user to the auditing party.
In another embodiment, the system further comprises a user information chain for storing user information, wherein the user sends a registration request to the user information chain;
after receiving the registration request based on the user information link, the supervisor verifies the identity of the user, and if the verification is successful, pseudonym information is randomly distributed to return to the user;
after receiving verification success and pseudonym information, a user selects a user key, encrypts the user information and the pseudonym information according to the user key to obtain a first ciphertext, encrypts the user key by using a public key of a monitor to obtain a second ciphertext, and sends the first ciphertext and the second ciphertext to the monitor;
and the supervisor receives the second ciphertext, decrypts the second ciphertext by using the own key to obtain a user key, decrypts the first ciphertext by using the user key to obtain user information and pseudonym information, detects whether the pseudonym information obtained by decryption corresponds to pseudonym information distributed during registration, and if so, successfully links the user information.
The detailed method is described in the embodiments related to the method, and is not described herein again.
According to the energy transaction processing based on the block chain, in the energy user transaction network, on one hand, a registered user stores basic identity information into a user block chain, so that the user information is prevented from being illegally tampered, and a supervisor can conveniently inquire and trace the illegal user information; on the other hand, the transaction content issued by the transaction initiator is uploaded to the transaction block chain, the transaction amount and the transaction amount are audited by the auditing party, and whether illegal transactions exist is judged. In the double-block chain system model, an auditing party can only know the transaction amount and the transaction amount, a supervising party can only know the user identity participating in the transaction, and two parties cannot simultaneously master all information of the user, so that the separation of the user identity information and the user transaction information is realized.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.