Bitcoin Transactions – A Look Under the Hood

By: David Marc
Updated: May 19, 2018

How bitcoin transactions work

A bitcoin is really just a string of public addresses. Every time a bitcoin is sent to a different address, that address is added to the end of the bitcoin, which demonstrates a change in ownership. This process is done using public-key cryptography.  (Lost you already?  Best to read our beginner’s guide to bitcoin first!)

Bitcoin addresses are also known as “public keys” and serve two basic functions. First, they act like a bank account number, providing a public address where you can send bitcoin. Second, a public key is bound to a single private key that digitally signs outbound bitcoin transactions. The connection of a private to public key is one-way, meaning that while the public key recognizes its private key it is bound to, it is mathematically impossible to find the private key from the public.

Let’s imagine that Alice wants to send Bob 15 bitcoin. Alice puts together a message that includes Bob’s bitcoin address, the bitcoin to be included in the transaction, and from which addresses the included bitcoin were received. Now, to maintain the continuity of the blockchain, older transactions may not be broken into smaller bits but must be included as a whole. This leads to the fourth bit of information included, the “change” that must be returned in a separate transaction to Alice.

This message and the private key are then run through what is known as a “hash function”, which outputs a digital signature. A hash function is a cryptographic process by which a big amount of information is transformed into a small, fixed information snippet. It is important to note that the slightest change to the input – changing a single digit, in fact – will produce an entirely different output! Thus, the only way in which a particular output – or digital signature in this case – can be recreated is to hash the very same inputs.

To verify that the digital signature has been generated by the private key, the corresponding public key checks that the hash output of the message and the private key does indeed produce the digital signature output. It is important to note that the private key is not needed in the verification process; the public key, by virtue of its link to the private key, is able to authenticate messages without referencing its counterpart. If the outputs match, the public key passes the transaction message out to the bitcoin network, which can be assured that Alice’s private key signed a transaction sending 15 bitcoin to Bob’s address.

Of course the network does not know that Alice and Bob sit behind the string of numbers that make up their public addresses, and users enjoy a level of anonymity in their transactions. However, unlike cash, each bitcoin can be followed back, address to address, as it has made the journey throughout the network. Truly inquiring minds might be able to place a physical person to one address or another, after which a bit of detective work could unmask additional users within the corresponding transaction chain.

Security

A few important notes. It is very important that private keys are safely kept. Knowing the private key grants access to its bitcoin. If the private key signs a message authorizing the transferring of bitcoin to a thief’s wallet, the public key will validate it and the network will include the transaction in the blockchain. Most large scale bitcoin heists are a result of inadequate protection of the private key, and so are the small heists that nobody hears about. The bitcoin industry has been extremely proactive in tackling the security challenge, and a number of new technologies – most notably multi-signature transactions – are transforming bitcoin security in particular and internet security in general. For more information, check out our introduction to bitcoin wallets.

Transaction speed

New transactions are written into the blockchain at 10 minute intervals. Transcription in the blockchain represents official confirmation that the transaction has been accepted by the network. If Bob were actually an online vendor, Alice might be forced to wait until he confirms the transaction has been recorded in the blockchain to receive her purchase. This might be necessary if Alice were evil, as she could attempt to quickly double spend the bitcoin sent to Bob prior to the transaction being included in the blockchain, stealing Bob’s services.

Transaction fees

If there are transaction fees they are usually extremely low, though the figure will rise as blocks fill up with transactions and a “fee market” emerges in which miners pick the transactions with the higher fees and skip transactions with lower fees. Certain wallets allow users to manually determine the fee they would like to include; others automatically set the fee based network congestion.

If you are interested in learning more, check out our introduction to mining article, in which we – surprise – introduce the concept of bitcoin mining.