Are private keys transmitted in a bitcoin transaction?

Bitcoin private keys

When I first started doing research about bitcoin and blockchain technology back in 2015 it struck me that there seems to be a lot of confusion about what information is transmitted when making a bitcoin transaction. A particular question that frequently arises in this regard is “whether or not private keys are transmitted in a bitcoin transaction?”

Private keys are never transmitted in a bitcoin transaction. What you transmit when making a bitcoin transaction is a digital signature. A digital signature is a number that is produced from the private key by a special mathematical algorithm (ECDSA). This digital signature can be verified by anyone against the public key using the same mathematical algorithm. By verifying the digital signature against the public key, a third party can only confirm that the sender knows what the private key is. However, the third-party verifier has no way of knowing what the private key is.

To get a better understanding of this, let’s first briefly explore what steps are involved in a bitcoin transaction and then elaborate a bit more on what a digital signature is and how it works. In order not to overcomplicate things I will provide you with a conceptual explanation that will give you a basic understanding of the mechanisms involved.

A brief overview of how a bitcoin transaction works

1. The creation and signing of a bitcoin transaction

The first step of a bitcoin transaction is the creation of the bitcoin transaction.

You could think of it as the creation of a specific set of data that expresses the intent to transfer a certain amount of bitcoin from a source of bitcoin (input) to a destination (output). This set of data contains all information needed to execute the bitcoin transaction, such as the number of bitcoins to be sent, the destination address, etc. The transaction contains no private keys or any other confidential information.

Once a transaction has been created, it needs to be digitally signed by the owner(s) (see infra Section “What is a digital signature?”).

2. Broadcasting the signed transaction to the bitcoin network

The next step is to broadcast the digitally signed bitcoin transaction to the bitcoin network. The digitally signed bitcoin transaction will remain invisible to the bitcoin network until it has been broadcasted to the bitcoin network (much like a signed check remains invisible to the financial system until it has been submitted to a financial institution in order to be cleared). The bitcoin network is the global peer-to-peer network of nodes running the bitcoin P2P protocol (the bitcoin network consists of various types of nodes, e.g.  full blockchain nodes, mining nodes, etc.).

3. Propagating the transaction throughout the bitcoin network

Once the digitally signed bitcoin transaction is broadcasted to the bitcoin network, it will be propagated throughout the bitcoin network. When a signed bitcoin transaction arrives at a node that is part of the bitcoin network, it will be validated by that node. After validating the signed bitcoin transaction, the node will in turn propagate it to the other nodes to which such validating node is connected. Each of these connected nodes will in turn send the signed bitcoin transaction to each of their connected nodes. This process is repeated until all nodes within the bitcoin network have received the signed bitcoin transaction.

It is important to note that every node independently validates every signed bitcoin transaction before propagating it further. This makes the bitcoin network resistant to all sorts of possible attacks, such as denial-of-services attacks.

4. Recording the transaction on the blockchain

Finally, the signed bitcoin transaction will at some point be validated by a mining node that is part of the bitcoin network. Once validated by a mining node, the transaction will be included in a block of transactions (a set of transactions grouped together in one block) that is recorded on the bitcoin blockchain. After being recorded on the bitcoin blockchain and having been confirmed by a sufficient number of subsequent blocks in the bitcoin blockchain, the transaction is considered ‘confirmed’. Once confirmed, the new owner of the bitcoins will be able to spend them.

What is a digital signature?

Once a transaction has been created, it needs to be digitally signed by the owner(s) before it can be successfully broadcasted to and propagated throughout the bitcoin network. Without the digital signature of the sender the nodes of the bitcoin network will not be able to validate the transaction.

You could describe the digital signature as the mathematical mechanism for essentially combining (1) the private key with (2) the bitcoin transaction data (i.e. the ‘digital message’ so to speak). The sender applies a mathematical algorithm (i.e. the Elliptic Curve Digital Signature Algorithm) to the bitcoin transaction data (represented by a hash) and his private key. The output generated by the mathematical algorithm is a special sequence of numbers which constitutes the ‘digital signature’. This exact sequence of numbers can only be generated by the given inputs (i.e. the transaction data represented by a hash and the private key). If you modify one or more of the inputs, you will end up with a different digital signature.

The transaction data (represented by a hash) and the digital signature are both broadcasted to the bitcoin network, but not the private key.

By checking that the digital signature of a bitcoin transaction is one that could only have been produced by the sender’s private key (which in turns is related to the sender’s public key), you can ensure that the sender has access to the private key (i.e. that the sender is the owner of the bitcoins that are being transferred).

What kind of digital signature is used by bitcoin?

The “Digital Signature Standard” (DSS) is the digital signature algorithm that bitcoin uses for creating digital signatures. It was originally developed by the U.S. National Security Agency to generate a digital signature for the authentication of electronic documents.

DSS has this property that a random sequence of numbers is generated whenever a transaction is to be signed. This random sequence of numbers is incorporated into the digital signature to help ensure that it looks different each time.

How can you verify a digital signature?

The digital signature algorithm used for creating a digital signature is also used for the verification process. With the public key, the mathematical algorithm can be used on the signature to determine that it was originally produced from the transaction data (represented by a hash) and the private key, without needing to know the private key.

The following three different inputs are required for verifying the digital signature:

  1. the transaction data (represented by hash);
  2. the digital signature; and
  3. the public key of the sender.

By applying the mathematical algorithm we are basically trying to check that the signature that you see corresponding with the transaction data (represented by a hash), is one that would have been produced only by the sender’s private key.

As already stated above, you don’t actually need the private key to validate the digital signature. In fact, you won’t know what the private key is. In other words, the verification procedure will basically output a kind of a ‘yes’ or ‘no’ answer. It tells you, “Should I accept the signature, “or should I reject it?” It’s a basic validation procedure.

The following oversimplified example will help you better visualize this concept (this is merely an oversimplified example and not an accurate representation of how bitcoin works):

Let’s say John’s private key is 4 and his public key is 0.25 (A public key is generated from a private key, using elliptic curve multiplication, so both are mathematically related).

John sends a transaction with a hash of 7 (A hash algorithm turns an arbitrarily-large amount of data, e.g. bitcoin transaction data, into a fixed-length hash, which is basically a large number).

Let’s say John’s digital signature resulting from the mathematical algorithm in this example is: 4 (private key) * 7 (hash) = 28

The hash (7) and the digital signature (28) are then broadcasted to the bitcoin network.

A node of the bitcoin network will verify the digital signature (28) by applying a specific mathematical algorithm and using the public key (0.25) as one if its inputs. It will then compare the result of that calculation (28*0.25= 7) with the hash (7) that had been broadcasted alongside the digital signature (28).

Since the result of the verification (7) matches the hash (7), the node knows that John must have the correct private key for having created the digital signature (28), but without the node knowing what the private key is. The node will therefore validate the transaction.

Summary

Signing a transaction does not expose your private key. The hash of the transaction data and the digital signature are both broadcasted to the bitcoin network. The digital signature is then used to confirm that the sender knows the private key. This verification process is done by applying a specific mathematical algorithm which involves the public key of the sender. The verification procedure will output a kind of a ‘yes’ or ‘no’ answer. It tells you, “Should I accept the signature, “or should I reject it?” It’s a basic validation procedure.


Attention! Do you store your cryptocurrencies on an online platform? Please note, in that case you are not the actual owner of your cryptocurrencies!

In particular, you run the risk of losing all your cryptocurrencies, without any recourse, in the event that the online platform or your personal account falls victim to hacking or in the event of an unexpected closure (e.g. insolvency) of the online platform.

Protect yourself against hacking and take real ownership of your cryptocurrencies by storing your cryptocurrencies offline on your very own Trezor hardware wallet. Don’t wait before it’s too late and take immediate action now!

Click on the ‘Buy Now’ button below to buy a Trezor wallet from the official Trezor website.

Trezor Model T – hardware wallet

Want to spread the word about bitcoin? Get yourself a cool bitcoin shirt now!

Click on the button below.

180+ original designs available