  Peer-to-Peer (P2P) energy trading can facilitate integration of a large
number of small-scale producers and consumers into energy markets.
Decentralized management of these new market participants is challenging in
terms of market settlement, participant reputation and consideration of grid
constraints. This paper proposes a blockchain-enabled framework for P2P energy
trading among producer and consumer agents in a smart grid. A fully
decentralized market settlement mechanism is designed, which does not rely on a
centralized entity to settle the market and encourages producers and consumers
to negotiate on energy trading with their nearby agents truthfully. To this
end, the electrical distance of agents is considered in the pricing mechanism
to encourage agents to trade with their neighboring agents. In addition, a
reputation factor is considered for each agent, reflecting its past performance
in delivering the committed energy. Before starting the negotiation, agents
select their trading partners based on their preferences over the reputation
and proximity of the trading partners. An Anonymous Proof of Location (A-PoL)
algorithm is proposed that allows agents to prove their location without
revealing their real identity. The practicality of the proposed framework is
illustrated through several case studies, and its security and privacy are
analyzed in detail.
