Vehicle-to-vehicle charging and discharging energy exchange among electric vehicles (EVs) achieve economical and low-loss energy transactions. However, due to the openness of the border, EV power trading faces security issues. When an EV user communicates with a local aggregator, attackers may eavesdrop on the communication links to perform traffic analysis attacks. Moreover, unregistered illegal users may parade themselves as legitimate users and submit a bill query request to the local aggregator. In this paper, we develop a decentralized EV charging service architecture to defend against traffic analysis attacks and prevent users from tampering with transaction bills. Based on the architecture, we propose a blockchain-based secure transaction mechanism for electronic vehicles with multiple temporary identities. Specifically, we first propose a power transaction encryption protocol that utilizes multiple temporary identities to publish information streams, thereby preventing eavesdropping attacks and making the assignment between suppliers and demanders. We then propose a secure query transaction scheme that adds the accumulator value of the user's temporary identity into the Merkle tree, which identifies the query issued by legitimate users and verifies the query results. Extensive experimental results show that the proposed secure transaction mechanism promotes the user satisfaction and user utility by 5% and 10%, respectively, and promotes the security level by three times.