An energy trading system is essential for the successful integration of Electric Vehicles (EVs) into the smart grid. In this paper, leveraging blockchain technology, we first propose a privacy-preserving charging-station-to-vehicle (CS2V) energy trading scheme. The CS2V scheme is useful in crowded cities where there is a need for a charging infrastructure that can charge many EVs daily. We also propose a privacy-preserving vehicle-to-vehicle (V2V) energy trading scheme. The V2V scheme is useful when charging stations are not available or far and cheaper prices can be offered from EVs, e.g., if they charge from renewable energy sources. In the V2V scheme, the privacy of both charging and discharging EVs including location, time, and amount of power are preserved. To preserve privacy in both schemes, EVs are anonymous, however, a malicious EV may abuse the anonymity to launch Sybil attacks by pretending as multiple non-exiting EVs to launch powerful attacks such as Denial of Service (DoS) by submitting multiple reservations/offers without committing to them, to prevent other EVs from charging and make the trading system unreliable. To thwart the Sybil attacks, we use a common prefix linkable anonymous authentication scheme, so that if an EV submits multiple reservations/offers at the same timeslot, the blockchain can identify such submissions. To further protect the privacy of EV drivers, we introduce an anonymous and efficient blockchain-based payment system that cannot link individual drivers to specific charging locations. Our experimental results indicate that our schemes are secure and privacy-preserving with low communication and computation overheads.