Disclosure of Invention
In view of the above, the invention provides an electric power transaction matching method based on asynchronous consensus, which can implement real-time matching of electric power transactions by constructing an information asynchronous consensus mechanism based on network fragmentation and transaction fragmentation technologies of a block chain.
The invention provides an electric power transaction matching method based on asynchronous consensus, which comprises the following steps:
carrying out identity registration on a user and generating an identity block;
when the business is handled, the identity authentication is carried out on the registered user;
after the user passes the identity authentication, the encrypted reporting of the electric energy supply/demand declaration quantity and the supply/demand electric energy price is carried out;
matching the transaction based on a preset transaction mode;
acquiring actual electricity generation/consumption data of a user and a user declared amount range;
the transaction data is subjected to network fragmentation and transaction fragmentation through an administrator node, a consensus node and a verification node, and efficient and credible sharing of the data is completed through a cross-fragment asynchronous consensus mechanism;
and carrying out transaction settlement based on the deviation between the actual electricity consumption of the user and the electricity winning amount in the previous transaction period.
Preferably, the identity registration and identity block generation for the user include:
after the mobile phone number verification is completed, acquiring basic identity information and biological characteristic information of a user;
carrying out Hash operation on the basic identity information and the biological characteristic information by using an encryption algorithm, and transmitting a Hash operation result to an identity authentication service system;
when the identity authentication service system passes the verification of the identity information based on the Hash operation result, user identity registration is completed and an initial reputation value of a user is set;
and after the user finishes identity registration, calculating a public key generated based on the identity of the user to generate a block address.
Preferably, the authenticating the identity of the user who has completed registration when transacting the service includes:
acquiring a user login name, a hash value of a private key used by a user mobile terminal for identity, timestamp information and a real-time identity signature value;
generating a real-time identity two-dimensional code based on the user login name, the identity hash value of the user mobile terminal using a private key, the timestamp information and the real-time identity signature value;
and reading the real-time identity two-dimensional code of the user, and performing identity authentication based on the real-time identity two-dimensional code.
Preferably, after the user passes the identity authentication, the encrypted reporting of the electric energy supply/demand declaration amount and the supply/demand electric energy price includes:
acquiring the declaration amount and sealing quotation of purchasing/selling electricity input by a user;
judging whether the reporting quantity exceeds the limit, if not, then:
broadcasting and sealing quotation in the whole network;
acquiring a user public quotation;
judging whether the public quotation is equal to the sealed quotation, if so:
and entering transaction matching.
Preferably, the matching of the transaction based on the preset transaction mode includes:
placing the user into an electricity purchasing/selling queue;
and judging whether the matching can be carried out according to the transaction rule, if so, completing the transaction matching.
An asynchronous consensus-based power transaction matching system, comprising:
the user registration module is used for carrying out identity registration on the user and generating an identity block;
the identity authentication module is used for authenticating the identity of the registered user when the service is transacted;
the main body quotation module is used for carrying out encrypted submission of the electric energy supply/demand declaration quantity and the supply/demand electric energy price after the user passes the identity authentication;
the transaction matching module is used for matching transactions based on a preset transaction mode;
the data integration module is used for acquiring actual electricity generation/consumption data of a user and a user declared amount range;
the data processing module is used for carrying out network fragmentation and transaction fragmentation on transaction data through the administrator node, the consensus node and the verification node, and completing efficient and credible sharing of the data through a cross-fragment asynchronous consensus mechanism;
and the allowance balancing module is used for carrying out transaction settlement based on the deviation between the actual electricity consumption of the user and the bid amount in the previous transaction period.
Preferably, the user registration module is specifically configured to:
after the mobile phone number verification is completed, acquiring basic identity information and biological characteristic information of a user;
carrying out Hash operation on the basic identity information and the biological characteristic information by using an encryption algorithm, and transmitting a Hash operation result to an identity authentication service system;
when the identity authentication service system passes the verification of the identity information based on the Hash operation result, user identity registration is completed and an initial reputation value of a user is set;
and after the user finishes identity registration, calculating a public key generated based on the identity of the user to generate a block address.
Preferably, the identity authentication module is specifically configured to:
acquiring a user login name, a hash value of a private key used by a user mobile terminal for identity, timestamp information and a real-time identity signature value;
generating a real-time identity two-dimensional code based on the user login name, the identity hash value of the user mobile terminal using a private key, the timestamp information and the real-time identity signature value;
and reading the real-time identity two-dimensional code of the user, and performing identity authentication based on the real-time identity two-dimensional code.
Preferably, the subject quotation module is specifically configured to:
acquiring the declaration amount and sealing quotation of purchasing/selling electricity input by a user;
judging whether the reporting quantity exceeds the limit, if not, then:
broadcasting and sealing quotation in the whole network;
acquiring a user public quotation;
judging whether the public quotation is equal to the sealed quotation, if so:
and entering transaction matching.
Preferably, the transaction matching module is specifically configured to:
placing the user into an electricity purchasing/selling queue;
and judging whether the matching can be carried out according to the transaction rule, if so, completing the transaction matching.
In summary, the invention discloses an electric power transaction matching method based on asynchronous consensus, which includes firstly performing identity registration and generating an identity block for a user, and then performing identity authentication for the registered user during service transaction; after the user passes the identity authentication, the encrypted reporting of the electric energy supply/demand declaration quantity and the supply/demand electric energy price is carried out; matching transactions based on a preset transaction mode, and acquiring actual electricity generation/consumption data of a user and a user declared amount range; the transaction data is subjected to network fragmentation and transaction fragmentation through an administrator node, a consensus node and a verification node, and efficient and credible sharing of the data is completed through a cross-fragment asynchronous consensus mechanism; and carrying out transaction settlement based on the deviation between the actual electricity consumption of the user and the electricity winning amount in the previous transaction period. The invention can realize real-time matching of electric power transaction by constructing an information asynchronous consensus mechanism based on network fragmentation and transaction fragmentation technologies of block chains.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, which is a flowchart of a method of embodiment 1 of the asynchronous consensus-based power transaction matching method disclosed in the present invention, the method may include the following steps:
s101, identity registration is carried out on a user and an identity block is generated;
when the electric power transaction matching needs to be completed, firstly, the system acquires the identity information of the user through the user registration module, evaluates the market access condition of the user, and generates the identity voucher and the initial credit value of the user for the user meeting the access condition.
Specifically, as shown in fig. 2, when the user registers at the mobile client or the PC, the user adopts the mobile phone dynamic password to verify the authenticity of the mobile phone number. After the mobile phone number verification is completed, the user fills in basic identity informationID t (including name, enterprise name, identity information, enterprise license information, etc.), and at the same time, finishing the user biological characteristic informationID f (such as human face, fingerprint, etc.) and setting user login nameID 0 And login passwordP 0 . The system background utilizes an encryption algorithm to carry out Hash operation on the text information and the picture information, and the Hash operation is carried out on the text information and the picture informationH(ID t || ID f )And transmitting the information to an identity authentication service system (comprising authentication of a public security system on identity information and authentication of an enterprise and commercial institution on enterprise information), checking the identity information by the identity authentication system, completing system registration by the user after the check is passed, and setting an initial credit value of the user by the system.
As shown in the figure3, after the user finishes the registration, the public security authentication service system issues the identity of the usertID(e.g. usingeID、CTIDAnd the system is uniformly named according to the difference of specific authentication service systems in system dockingtID). The user generates the public key by using the ECDSA algorithm (in the ECDSA algorithm, several parameters are important: G-the base point of the elliptic curve; n-is equivalent to the dotting times of the G base point)P A And a private key d A . Wherein the content of the first and second substances,P A =[d A ]G=(x A ,y A ) D is mixingAThe encryption is stored locally in the user, and the short-sending is performed to the user through SM3tIDThe identity information, the biological characteristic information and the like are subjected to Hash operation to obtain the Hash value of the user identityH ID =H(tID|| ID t || ID f ). Signature algorithm pair by SM2H ID And a registration timestampT r Carry out signature and setM 0 ={H ID ,T r Get the registered identity signature valueSIG r =(r,s)。
Block chain based distributed power transaction system for converting message M = &P A, M 0, SIG r Sending it to the public security authentication service system, which calculates the userH ID By passingP A ComputingSIG r . If the verification is passed, the system pairP A Calculating to generate block addressAddrAs the identity authentication block ID of the user, and simultaneously recording the user's ID in the blockH ID 、T r AndSIG r . The internal computing resource of the public security authentication service system completes the generation of the block through a consensus mechanism.
S102, when the business is processed, the identity authentication is carried out on the registered user;
when a user needs to perform system behaviors such as power transaction quotation and the like, the system starts the identity authentication module, decrypts information through the digital abstract and the public key of user information, compares the existing information of the user with historical information, realizes the identity authentication of the user and guarantees the safe and reliable access of the power transaction.
Specifically, as shown in fig. 4, when the user logs in, the user login name needs to be input
ID 0 And a login password
P 0 And uploading biometrics
ID f At the same time, the mobile terminal of the user can use the private key d
A Hashing identity
H ID Time stamp information T
uiCarry out real-time signature and placement
M i ={
H ID ,T ui }, generating a real-time identity signature value
=(
r i ,s i ). The system is based on
ID 0 、
H ID 、T
uiAnd
generating a real-time identity two-dimensional code
R i The two-dimension code refresh time set by the system is
t 0 (
t 0 Is a constant value, such as 1min, 2min, 5min, etc.).
The identity authentication module reads the real-time identity two-dimensional code of the user
R i Obtaining a message
. First, it is judged
R i If the current time is
t c With time stamp information T
uiDifference less than
t 0 Then, then
R i The timeliness is verified, and the system is further used
P A Computing verification signatures
. After the signature verification is passed, calculating
AddrAccessing the user identity block and comparing
H ID If they are consistent, calculating verification
SIG r And if the verification is passed, the user identity authentication is successful.
S103, after the user passes the identity authentication, carrying out encrypted reporting on the electric energy supply/demand declaration quantity and the supply/demand electric energy price;
after the user passes the identity authentication, the encrypted reporting of the electric energy supply/demand declaration quantity and the supply/demand electric energy price can be carried out on a system platform, the system firstly judges whether the declaration quantity of the user is in compliance, and if the compliance is met and the declaration time of the system is cut off, the system automatically enters a transaction matching stage.
Specifically, as shown in fig. 5, after the user passes the identity authentication, the user needs to input the self declaration amount of purchasing/selling electricity and the sealing quotation, wherein the sealing quotation has the user real quotation v and generates P through hash encryption, that is, the user real quotation v is generated into P
. Meanwhile, the system checks the declaration amount of the user, if the declaration amount of the user exceeds the constraint condition, the requirement needs to be declared again in the effective time, the transaction stage is skipped, and after the transaction of the period is finished, the system directly enters the allowance balance module. And for the user declaration information meeting the declaration quantity constraint condition, the system can carry out network broadcast on the sealed quotation and the corresponding declaration quantity. And when the declaration time is expired, the system can require the user to submit the public offer again when the user finishes the main offer, if the public offer is equal to the sealed offer of the previous network broadcast, the system can enter a transaction matching module, otherwise, the system directly enters a margin balancing module after the current period of transaction is finished.
S104, matching of transactions is carried out based on a preset transaction mode;
in the transaction matching stage, the system arranges a buyer and a seller into two sequences according to rules, and then carries out transaction matching through a Marshall algorithm, meanwhile, the system sets various transaction modes including margin unified clearing, high-low matching clearing and the like, and each provincial level transaction center can select a corresponding transaction mode in an intelligent contract module according to clearing regulations of the province to start electric intelligent transaction.
Specifically, as shown in fig. 6, the system first distinguishes between the electricity sale/purchase types of the users, and preferably green electricity. The system arranges the green electricity selling demands into a green electricity selling queue according to the sequence of quotations from low to high, and arranges the green electricity purchasing demands into a green electricity purchasing queue according to the sequence of quotations from high to low; meanwhile, the users with the non-green electricity transaction requirements are sorted according to the rule and placed into a non-green electricity selling/purchasing queue. And when the prices are the same, comprehensively sequencing according to the time of submitting the quoted price and the credit value of the user. After the sequencing is finished, the system finishes the transaction matching of the electricity purchasing and selling parties according to the Marshall algorithm. On the premise that the price quoted by the buyer is higher than that quoted by the seller, the buyer with the highest price and the seller with the lowest price are matched, and the buyer with the next highest price and the seller with the next lowest price are matched. And repeating the steps until all the rest buyer quotations are lower than the seller quotations, and ending the matching in the round. The matching of the green power consumers is preferably carried out, the rest consumers are put into the non-green power selling/purchasing queue, and then a round of transaction is carried out according to the above rules. And calculating the matched transaction price in each time according to the clearing mode, wherein if the matched clearing mode is high or low, the transaction price is the average price of both parties of the transaction, and if the matched clearing mode is the marginal unified clearing mode, the transaction price is the marginal transaction price.
S105, acquiring actual electricity generation/consumption data of a user and a user declared amount range;
in order to realize accurate settlement, the system is connected with an intranet service system through a data integration module, and firstly, the collection of actual electricity generation/consumption data of a user is completed; and secondly, acquiring a reasonable range of the user declaration quantity. Wherein, the input data is: the reasonable range of the user declaration quantity provided by the power grid model and the actual power generation/power consumption data of the user; the output data is: the actual power generation/power consumption data is output to the allowance balance module, and the reasonable user declaration amount range is output to the main quotation module.
The system uses the technologies of a Web front end, a Js back end and a Python back end, and meanwhile, in order to ensure the safety of network information, a firewall and an isolation device are arranged in a network link, so that the reading and the transmission of electric energy information and declared quantity information are realized, and market trading is participated. The network architecture is shown in fig. 7.
S106, performing network fragmentation and transaction fragmentation on transaction data through an administrator node, a consensus node and a verification node, and completing efficient and trusted sharing of the data through a cross-fragment asynchronous consensus mechanism;
and then, the data processing module is used for processing system data and processing consensus data among the nodes of the alliance chain where the system is located. (input data comprises user identity information, electric power transaction information related information, service system and model information acquired by a data integration module, and output data comprises data needing to be identified with other nodes on a alliance chain, and comprises identity blocks, declaration information, transaction matching result information, and the like.) wherein:
the administrator node: the node mainly serves for communication between the fragments and is used for message transmission. A voting mechanism based on credit is introduced into the model, credit values and credit levels are set for the nodes, and the nodes with high final ticket number are selected from all the fragments to serve as fragment manager nodes. Meanwhile, the fragment manager node is updated regularly.
And (3) consensus nodes: fragmented administrator node random selection
And (3) constructing a fragment node-by-node set by adding the main nodes of the fragment, wherein the nodes except the administrator node in the set are called as consensus nodes.
Verifying the node: the voting selection performance is excellent when each segment is initially operated
And each node is used as a verification node, and the verification node verifies whether the transaction in the fragments meets the fragment consistency through a PBFT consensus algorithm.
The system carries out network fragmentation and transaction fragmentation on transaction data to be processed, and establishes an asynchronous consensus mechanism between the fragments for preventing double-flower transaction risks. And a fragment manager node is established to coordinate the communication of the cross fragments, meanwhile, the manager node is dynamically elected in combination with the node credit, the safety credibility of the system is ensured, and the asynchronous consensus of the information between the fragments is completed through the manager node and the consensus node, so that the reliability, the safety and the consensus efficiency of the system consensus are improved. The principle is shown in fig. 8.
Specifically, the system sets two asynchronous consensus mechanisms according to different transaction processing data, one is time asynchronization: the method comprises the steps that an administrator node forms a dynamic strategy by analyzing data processing flow pressure, generates a corresponding consensus sequence list of consensus nodes, sends data needing consensus to a cache queue according to the sequence of the list, and finally sends the consensus data in the cache queue to the corresponding consensus nodes; the other is asynchronous event processing, different nodes are respectively set to process partial contents in the whole transaction data according to different authorities of the nodes and different administration data, then the results processed by the relevant nodes are collected to an administrator node, and the administrator node completes the processing of results of a higher layer. Asynchronous consensus processing can significantly reduce thread waiting, thereby greatly improving the overall performance of the system, significantly reducing time delay and improving user experience in a high-throughput power transaction scenario.
And S107, transaction settlement is carried out based on the deviation between the actual electricity consumption/power consumption of the user and the electricity winning amount in the previous transaction period.
And then, transaction settlement is carried out through the allowance balance module according to the deviation between the actual electric quantity of the electric meter acquired by the data integration module and the standard electric quantity of the user in the last transaction period. (input data: data of actual power generation/power consumption of user and bid winning amount of user; output data: data of settlement of deviation of actual power generation/power consumption of user and bid winning amount of user.)
For a consumer, when the actual consumption electric quantity of the consumer is less than the transaction electric quantity, the consumer is not refunded; when the actual consumption power of the consumer is more than the transaction power, the consumer needs to purchase power from the power grid to meet the power consumption requirement. When considering the prediction error, the individual consumer balance cost H is:
wherein: cbBuying the electricity price for the power grid; Δ W is the predicted deviation of the consumer, Δ W<0 means that the actual power consumption is less than the predicted value, otherwise, the actual power consumption is greater than the predicted value.
For a producer, when the actually generated electric quantity of the producer is more than the transaction electric quantity, the producer trades the surplus electric quantity with the power grid; and when the actually generated electric quantity of the producer is smaller than the transaction electric quantity, the producer needs to purchase the electric quantity from the power grid to make up for the insufficient self-output. The equilibrium payout F for a single producer is:
wherein: csSelling electricity prices for the power grid; delta Q is the predicted deviation of the producer<0 means that the actual power generation amount is smaller than the predicted value, and otherwise, the actual power generation amount is larger than the predicted value.
Specifically, the evaluation method can further evaluate the behaviors of the participating nodes/users through the evaluation reward and punishment module, and comprehensively considers the behaviors according to the accuracy of the user declaration amount, the user operation behavior and the performance condition. (input data: node/user verification result and final verification result of transaction in the last round of transaction verification; output data: node/user reputation value).
For the users with higher accuracy of reporting quantity and good user performance, a certain quantity of credit values can be awarded, the highest credit value is 100, and the initial credit value of the users is 60; for users who report quantity with low accuracy or have poor performance, the system deducts a certain quantity of credit values. When the user reputation value is lower than 50, the system will reclaim the user's operating rights. After each round of transaction verification is finished, the system broadcasts the credit value of each node through the whole network.
The calculation formula of the reputation value of each node is as follows:
V i =V 0 + Vr i ×T i (3)
wherein:V i representing the current reputation value of the ith node,V 0 representing the initial reputation value of the ith node,Vr i indicating the reward or penalty gained by the verification of the transaction by the ith node,T i indicating the corresponding penalty or number of awards.
In summary, the invention uses the electronic signature technology to realize the registration authentication of the system user; secondly, through the digital abstract, the privacy, the credibility and the safety of the quotation of a trading subject are ensured, a distributed storage technology is provided, the requirements of high-frequency and high-performance storage access of mass data are met, and a technical support is provided for efficient and orderly operation of a distributed power trading market; thirdly, a Marshall algorithm is combined, two mechanisms of high-low matching clearing and marginal unified clearing are designed, a multi-provincial electric power transaction clearing mode is compatible, point-to-point transaction matching of two transaction parties is realized, transaction matching efficiency is improved, meanwhile, by means of safety assessment operation of a power grid model, market transaction results are normalized, and the power grid runs safely; secondly, by utilizing an intelligent contract mechanism, a transaction triggering condition and an execution flow are designed, the defect of manual execution operation is reduced, and the credibility and the high efficiency of transaction settlement are ensured; and finally, by establishing a reasonable reward and punishment mechanism, the power consumption of renewable energy sources can be promoted, a competitive and orderly market transaction mode is established, credible transaction information is provided for the outside, and the transparent supervision is facilitated.
As shown in fig. 9, which is a schematic structural diagram of an embodiment of an asynchronous consensus-based power transaction matching system disclosed in the present invention, the system may include:
a user registration module 901, configured to perform identity registration on a user and generate an identity block;
an identity authentication module 902, configured to perform identity authentication on a user who has completed registration when performing service handling;
the main body quotation module 903 is used for carrying out encrypted submission of the electric energy supply/demand declaration quantity and the supply/demand electric energy price after the user passes the identity authentication;
a transaction matching module 904, configured to match transactions based on a preset transaction manner;
the data integration module 905 is used for acquiring actual electricity generation/consumption data of a user and a user declared amount range;
the data processing module 906 is configured to perform network fragmentation and transaction fragmentation on transaction data through an administrator node, a consensus node and a verification node, and complete efficient and trusted sharing of data through a cross-fragment asynchronous consensus mechanism;
and a balance module 907 for performing transaction settlement based on the deviation between the actual electricity consumption of the user and the electricity winning amount in the previous transaction period.
The working principle of the asynchronous consensus-based power transaction matching system disclosed in this embodiment is the same as that of the asynchronous consensus-based power transaction matching method embodiment, and is not described herein again.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.