Wanted to know what is it that makes bitcoin transaction secure and make it less vulnerable to attackers and hackers
1 Answer
Bitcoin transaction works on low-level primitive constructs of scripting languages and cryptography. In simple terms, you lock your funds to an equation and anyone who can provide a solution to that equation can spend the money. So there are no account level data, just unspent transaction outputs (UTXOs). Every time you need to spend your bitcoins, you just include these UTXOs as inputs to your transaction, provide a solution to the locking equation and send your funds to another locking equation (which can then be spent by providing solution to that equation). Most of this unlocking equations involve asymmetric cryptography of providing signature from your private key.
The most important aspect of Bitcoin transactions is that every information related to a transaction is entirely public. From the moment, you sign your transaction with your private key and broadcast it, the entire data of that transaction becomes a part of the public record (be it in the mempool before confirmation or in the blocks after confirmation). Since the signing process of Bitcoin transactions involve signing the entire transaction data as the message, any person in between cannot change an iota of information as it will render the transaction as invalid (let's leave signature malleability alone for now). This makes transactions secure against attackers who might want to modify the data.
The only thing that needs to be kept secure are your private keys. As the old adage goes, "Not your keys not your funds". Thus, care has to be taken to ensure that you keep your keys safe. Most of the attacks that you read about involving lost bitcoins is because of careless management of keys. You can use cold storage like hardware wallets, wherein your private keys will never enter a network connected device and as such will remain immune to network attacks.
The private key associated with signing the transaction is a random number in the 2256 bit key space. From the private key, you generate a public key using elliptic curve multiplication. This process is one-way - that is you cannot get private key if you know the public key - unless you solve the discrete log math problem or you brute force (try every combination of private key to get the resulting public key). No one has found a solution to the first case, and the second case is impossible due to the energy requirements. Moreover, the public key is hashed using RIPEMD160 and SHA256 hashing functions to generate a bitcoin address to which you send the bitcoins. These hashing functions are also one way. Now, the solution to the equation (in many cases) I was talking to is to provide the public key that hashes to the address and a private key whose signature would be verified using that public key. So if you do not re-use your address, you have a 2-layer security from private key to the address.