Quantum cryptography or, more precisely, quantum key distribution (QKD), is one of the advanced areas in the field of quantum technologies. The confidentiality of keys distributed with the use of QKD protocols is guaranteed by the fundamental laws of quantum mechanics. This paper is devoted to the decoy state method, a countermeasure against vulnerabilities caused by the use of coherent states of light for QKD protocols whose security is proved under the assumption of single-photon states. We give a formal security proof of the decoy state method against all possible attacks. We compare two widely known attacks on multiphoton pulses: photon-number splitting and beam splitting. Finally, we discuss the equivalence of polarization and phase coding.