## 4 Platform Design
### Proof of Location (PoL)  
Consumer node deployment and setting need to be supervised and certified by the DSO so that the nodes are allowed to join the trading network. Consumer node transactions are identified by their digital signature. However, since consumers are billed according to the consumption data uploaded by their respective assigned nodes, which are set to upload the consumer's consumption reading from the respective smart meter to the smart contract, it is crucial to ensure that the data uploaded is indeed coming from the certified nodes and not from any malicious clone or identity thief who could gain access to the consumer node private key. What is proposed is to add a proof of location (PoL) that must be included in every transaction issued by the consumer node to prove the transaction is coming from the known location of the certified node. Outdoor localization mainly uses Global Positioning System (GPS) as the main localization technique. However, GPS is not suitable for trustless decentralized scenarios. What is suggested is to use trilateration to localize the consumer nodes. Trilateration is a technique for node localization that determines object position, knowing its distance from at least 3 reference points. Considering 2-dimensional trilateration, a 2-dimensional frame needs to be set with an origin O (0,0) and three reference points, \(R_{p1}\), \(R_{p2}\) and \(R_{p3}\) with known coordinates (\(x_{1}\),\(y_{1}\) ), (\(x_{2}\),\(y_{2}\)) and (\(x_{3}\),\(y_{3}\) ), knowing the distances \(d_{1}\),\(d_{2}\) and \(d_{3}\) between a target point \(T_{p}(x_{T},y_{T})\)and \(R_{p1}\), \(R_{p2}\) and \(R_{p3}\), respectively, the couple \((x_{T},y_{T})\) can be deduced by solving the set of three expressions of Equation (3), as illustrated in Figure 14.  
\[ \begin{array}{l}d_{1}^{2}=(x_{t}-x_{1})^{2}+(y_{t}-y_{1})^{2}\\ d_{2}^{2}=(x_{t}-x_{2})^{2}+(y_{t}-y_{2})^{2}\\ d_{3}^{2}=(x_{t}-x_{3})^{2}+(y_{t}-y_{3})^{2}\\ \end{array}  \tag{3}\]  
In the proposed PoL model, three anchor nodes are deployed to cover a defined area with a defined number of consumer nodes. Consumer nodes send a PoL request to the 3 anchor nodes; each anchor node computes the distance separating him from the consumer node, then sends back the measured distance signed using his private key \(K_{j}^{Pr}\). Consumer nodes need to include the three signed locations they received from the 3 anchors as a PoL. Given a defined geographical location with a set of \(n\) Consumer nodes \(CN_{i}=CN_{0},CN_{1},\ldots,CN_{n}\) and a set of 3 anchor nodes \(An_{j}=An_{0},An_{1},An_{3}\) each consumer node i should send a PoL request \(Pol\_Req_{i\to j}\) to the anchor j and receive PoL response \(Pol\_Req_{j\to i}\), accordingly, as in Equation (4). \[Pol_{Req_{j\to i}}:\left\{ \begin{array}{l}Distance\,between\,An_{j}\,and\, CN_{i}\\ Timestamp\end{array} \right\}K_{j}^{Pr} \tag{4}\]  
There are two main techniques to measure the distance between a reference anchor and a target node, which use either the Time of Arrival (ToA) or the Received Signal Strength Indicator (RSSI). Although assessing the most suitable distance measurement technique is not within the scope of our paper, we found some reference papers proposing RSSI techniques for outdoor localization as in [67; 68; 69; 70] and we aimed to present a blueprint for Wi-Fi RSSI-based node localization, that potentially can be used for PoL in blockchain-based decentralized P2P energy trading. Given the RSSI of a received signal, the distance between the transmitter and the receiver nodes can be deduced according to the expression in Equation (5). \[d=10^{-(RSS-R_{1}+Pl_{0}-\delta)/10\gamma} \tag{5}\]  
where \(Pl_{0}\) is the path loss at a reference distance of (1 m) measured using the expression in (6), \(\lambda\) is the wave length of the emitted signal and \(\gamma\) is the path loss exponent and depends on the environment. \[Pl_{0}=20 log10\left(\frac{4\pi}{\lambda}\right) \tag{6}\]  
Figure 14: Trilateration technique.