# Proof of Flow: A Design Pattern for the Green Energy Market
## 4 Proof of Flow Design Pattern
### Resolving Potential Disputes between DERs and Aggregator  
When there are no discrepancies between the energy flows measured and recorded by the Aggregator's and DERs' smart meters, ARIA rewards DERs according to the amount of energy received by the Aggregator. This flow should align with the capacity declared by DERs in the Join() function with a tolerance error of \(t\) (set in ARIA by the Operator and to which DERs and Aggregators must adhere). However, in case of disputes or for verification purposes, the Operator may request Proofs of Flow from both the DERs and the Aggregator for a specific epoch. The Operator performs such requests by emitting events ProvidePoF or ProvidePoFs (see Section 4.5). Proofs of Flow data must be signed by smart meters and passed to the ProveTheFlow() or the ProveTheFlows() functions that record the requested relevant data in a blockchain event. Data in the Proof of Flow can have one among several time resolutions. At block-time level, they present a detailed and granular view of the energy flow. Alternatively, they provide an overview delivering a summary over a longer time period. In this latter case, the involved data are shown in Table 2.  
Disputes can be initiated by DERs which received a reward lower than expected. To trigger a dispute, the DER needs to execute the RaiseDisputeEvent() function of ARIA, that emits a Dispute event. The function's input requires the Proof of Flow data (see Tables 1 and 2) for the corresponding epoch, its nonce, and the blockstamps for the period that resulted in a smaller reward. Once the Operator, which is responsible for the smart meters of both the Aggregator and the DER, detects a Dispute event on the blockchain, it can start the dispute resolution process that involves the emission of a ProvidePoF, or ProvidePoFs, event addressed to the Aggregator, which, in turn, is requested to provide the Proof of Flow from its smart meter for the same period in question. If the Aggregator fails to respond, within a specific number of epochs, denoted as \(D\), the Operator will impose a fine to penalize the Aggregator's behavior and to compensate the financially impacted DER. When, otherwise, the Operator receives the Aggregator's Proof of Flow in time, it can analyze and compare the data to investigate the reasons for the discrepancy between the flows detected by the smart meters. This solution entails DERs and the Aggregator entrusting the smart meters provided by the Operator; however, the open-source nature of the smart meter's software ensures transparency and accountability. Furthermore, DERs and the Aggregator do not own the private keys used by the smart meters to cryptographically sign data, which prevents them from tampering with the recorded information. The smart meter is an external actor to the blockchain; nevertheless, it provides an equivalent degree of security by using the same cryptographic technology, i.e. encryption to prove its identity and cryptographically sign stored data. This is a key advantage since energy flow data can be published only when necessary, rather than storing them on the blockchain indefinitely, even when they are no longer needed. However, there are scenarios that require the Operator's involvement in addressing disputes. Disputes could arise for the following reasons. 1. The Aggregator could provide to the SweepEpoch() function values for the energy flows lower than the ones detected by its smart meter. 2. A DER or the Aggregator could alter the smart meter's software, resulting in it detecting and recording a different energy flow than the actual one. 3. A DER or the Aggregator could tamper with the physical system which detects the energy flow without affecting the smart meter's software. 4. A malfunction could result in inaccurate recorded data. Case 1 is a straightforward scenario since the Proof of Flow data provided by the Aggregator's smart meter would prove the real energy flow. This would result in penalties for the Aggregator.