<h2>Cryptography and Encryption</h2>

<p>In the wider world, cryptography is used for a variety of security related purposes:</p>

<ul>
<li>Authentication (proof of identity, or proof of ownership)</li>
<li>Non-repudiation (author cannot later deny authorship of data)</li>
<li>Confidentiality (secrecy - third parties can't see the data)</li>
<li>Integrity (proof that data has not been changed or tampered with)</li>
</ul>

<p>When we say "encryption" without clarifying further, we are <em>usually</em> talking about the use of cryptography to ensure confidentiality (secrecy of data, but not secrecy of a transmission having occurred - the latter might involve steganography or private channels etc).</p>

<p>Bitcoin's peer-to-peer protocol doesn't need secrecy but it does need a form of authentication and integrity proof that is provided by digital-signatures. </p>

<p>Traditionally digital-signature algorithms used RSA which involves encrypting a hash of data but not encrypting the data itself. Bitcoin uses <a href="https://en.wikipedia.org/wiki/Elliptic-curve_cryptography" rel="nofollow noreferrer">Elliptic Curve cryptography</a> which produces digital signatures without involving encryption of a hash.</p>

<p>So the author is perhaps pointing out that the data sent by Bitcoin peer-to-peer protocols is not encrypted for confidentiality and does not involve encryption.</p>

<h2>Terminology</h2>

<p>The word crypto-graphy literally means hidden writing. There is a certain irony in using this term for elliptic curve cryptography which cannot directly be used for hiding the text of messages - what many people mean by encryption is the process of converting normal readable <em><a href="https://en.wikipedia.org/wiki/Plaintext" rel="nofollow noreferrer">plaintext</a></em> into unreadable <em><a href="https://en.wikipedia.org/wiki/Ciphertext" rel="nofollow noreferrer">ciphertext</a></em>.</p>

CC BY-SA 4.0
2019-08-28T17:56:10.030Z
If by traditionally you mean "in RSA". Looking at the variety of digital signature schemes that exist, ones that reduce to encrypting a hash are rare. In particular, ECDSA, the digital signature scheme used in Bitcoin, does not use anything that could be useful for encryption.
Pieter Wuille
CC BY-SA 4.0
2019-08-28T17:24:59.557Z
2019-08-29T17:58:16.403Z
2019-08-29T17:58:16.403Z
RedGrittyBrick
<p>Standard transactions are digitally signed using a private key. If a middle man tampers with the transaction, then the digital signature verification would fail, because the only way to produce a valid signature is to have the original private key. This would cause the transaction to fail and the network would reject it as invalid.</p>

<p>This signature algorithm is called <a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm" rel="nofollow noreferrer">ECDSA</a> and a common address type that requires signature verification is a <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh" rel="nofollow noreferrer"><code>P2SH(P2WPKH)</code></a> (Pay to Script Hash - Pay to Witness Public Key Hash).</p>

<p>Also, it is important that the transactions are not encrypted, otherwise the rest of the network would not be able to verify that the transaction was valid (and prevent double spends, etc.).</p>

CC BY-SA 4.0
2019-08-28T05:26:06.633Z
"if a middle man tampers with the transaction, then the digital signature verification would fail, because the only way to produce a valid signature is to have the original private key".......................one can possibly keep the signature intact and modify the beneficiary can't they?
RaGa__M
CC BY-SA 4.0
2019-08-28T05:39:04.620Z
@Explorer_N no, the signature is made over the relevant parts of the transaction, including the recipients address. Modifying any of that data will cause the signature verification to fail.
chytrik
CC BY-SA 4.0
2019-08-28T06:03:32.063Z
@Explorer_N Related question discussing about modification of recipient: https://bitcoin.stackexchange.com/questions/90028/what-is-stopping-me-from-modifying-the-mempool-of-my-node-may-it-be-pos-or-pow
Ugam Kamat
CC BY-SA 4.0
2019-08-28T05:08:26.820Z
2019-08-28T05:08:26.820Z
JBaczuk
<p>Thanks to all the contributors; I realized I was bit hasty..After continue reading the book (6th chapter now!) during my spare time I come across this passage</p>

<blockquote>
  <p>A digital signature serves three purposes in bitcoin (see the
  following sidebar). First, the signature proves that the owner of the
  private key, who is by implication the owner of the funds, has
  authorized the spending of those funds. Secondly, the proof of
  authorization is undeniable (nonrepudiation). Thirdly, the signature
  proves that the transaction (or specific parts of the transaction)
  have not and cannot be modified by anyone after it has been signed.</p>
</blockquote>

<p>Third purpose answers this question.</p>

CC BY-SA 4.0
2019-08-31T14:49:28.413Z
2019-08-31T14:49:28.413Z
RaGa__M
<p>The above statement is taken out of a book which I've been reading: Mastering Bitcoin 2nd Edition.</p>

<blockquote>
  <p>...as its communications and transaction data are not encrypted and do
  not need to be encrypted to protect the funds...</p>
</blockquote>

<p>Just started about bitcoin, going through the third chapter and when I come across the above lines, I merely struck by one question, and that is, if the communication happens between (peers' / wallet to bitcoin network) is not encrypted...then I am just thinking a scenario</p>

<p>X is sending BTC to Z (obviously by mentioning Z's address in txn)</p>

<p>Y (bad guy) cuts in the communication which is not encrypted (as per the above reading) and tampers the transaction that X has been sent ( by Just putting his address in beneficiary )</p>

<p>I mean, honestly, it is a very naive scenario that anyone could think of and I know there would be something in bitcoin (which I am not aware of) could prevent this from happening, so, giving clarification on how this kind of attacks being handled or mitigated in Bitcoin would be much helpful for this post.</p>

CC BY-SA 4.0
2020-04-29T05:47:43.987Z
Related: https://bitcoin.stackexchange.com/q/95564/5406
Murch
<transaction-verification><encryption><terminology>
Ironically, encryption is not an important part of bitcoin (?)
RaGa__M
# Ironically, encryption is not an important part of bitcoin (?)

(Asked by: username_0 on 2019-08-28)

The above statement is taken out of a book which I've been reading: Mastering Bitcoin 2nd Edition.

> ...as its communications and transaction data are not encrypted and do
> not need to be encrypted to protect the funds...

Just started about bitcoin, going through the third chapter and when I come across the above lines, I merely struck by one question, and that is, if the communication happens between (peers' / wallet to bitcoin network) is not encrypted...then I am just thinking a scenario

X is sending BTC to Z (obviously by mentioning Z's address in txn)

Y (bad guy) cuts in the communication which is not encrypted (as per the above reading) and tampers the transaction that X has been sent ( by Just putting his address in beneficiary )

I mean, honestly, it is a very naive scenario that anyone could think of and I know there would be something in bitcoin (which I am not aware of) could prevent this from happening, so, giving clarification on how this kind of attacks being handled or mitigated in Bitcoin would be much helpful for this post.

**Tags:** transaction-verification, encryption, terminology

> **Comments:**
> **username_1**: Related: https://bitcoin.stackexchange.com/q/95564/5406  

---

## 3 answers

### Answer by username_2 on 2019-08-28. Score: 4

## Cryptography and Encryption

In the wider world, cryptography is used for a variety of security related purposes:

* Authentication (proof of identity, or proof of ownership)
* Non-repudiation (author cannot later deny authorship of data)
* Confidentiality (secrecy - third parties can't see the data)
* Integrity (proof that data has not been changed or tampered with)

When we say "encryption" without clarifying further, we are *usually* talking about the use of cryptography to ensure confidentiality (secrecy of data, but not secrecy of a transmission having occurred - the latter might involve steganography or private channels etc).

Bitcoin's peer-to-peer protocol doesn't need secrecy but it does need a form of authentication and integrity proof that is provided by digital-signatures.

Traditionally digital-signature algorithms used RSA which involves encrypting a hash of data but not encrypting the data itself. Bitcoin uses [Elliptic Curve cryptography](https://en.wikipedia.org/wiki/Elliptic-curve_cryptography) which produces digital signatures without involving encryption of a hash.

So the author is perhaps pointing out that the data sent by Bitcoin peer-to-peer protocols is not encrypted for confidentiality and does not involve encryption.

## Terminology

The word crypto-graphy literally means hidden writing. There is a certain irony in using this term for elliptic curve cryptography which cannot directly be used for hiding the text of messages - what many people mean by encryption is the process of converting normal readable *[plaintext](https://en.wikipedia.org/wiki/Plaintext)* into unreadable *[ciphertext](https://en.wikipedia.org/wiki/Ciphertext)*.

> **Comments:**
> **username_3**: If by traditionally you mean "in RSA". Looking at the variety of digital signature schemes that exist, ones that reduce to encrypting a hash are rare. In particular, ECDSA, the digital signature scheme used in Bitcoin, does not use anything that could be useful for encryption.  

---

### Answer by username_4 on 2019-08-28. Score: 3

Standard transactions are digitally signed using a private key. If a middle man tampers with the transaction, then the digital signature verification would fail, because the only way to produce a valid signature is to have the original private key. This would cause the transaction to fail and the network would reject it as invalid.

This signature algorithm is called [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) and a common address type that requires signature verification is a [`P2SH(P2WPKH)`](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh) (Pay to Script Hash - Pay to Witness Public Key Hash).

Also, it is important that the transactions are not encrypted, otherwise the rest of the network would not be able to verify that the transaction was valid (and prevent double spends, etc.).

> **Comments:**
> **username_0**: "if a middle man tampers with the transaction, then the digital signature verification would fail, because the only way to produce a valid signature is to have the original private key".......................one can possibly keep the signature intact and modify the beneficiary can't they?  
> **username_5**: @Explorer_N no, the signature is made over the relevant parts of the transaction, including the recipients address. Modifying any of that data will cause the signature verification to fail.  
> **username_6**: @Explorer_N Related question discussing about modification of recipient: https://bitcoin.stackexchange.com/questions/90028/what-is-stopping-me-from-modifying-the-mempool-of-my-node-may-it-be-pos-or-pow  

---

### Answer by username_0 on 2019-08-31. Score: 0

Thanks to all the contributors; I realized I was bit hasty..After continue reading the book (6th chapter now!) during my spare time I come across this passage

> A digital signature serves three purposes in bitcoin (see the
> following sidebar). First, the signature proves that the owner of the
> private key, who is by implication the owner of the funds, has
> authorized the spending of those funds. Secondly, the proof of
> authorization is undeniable (nonrepudiation). Thirdly, the signature
> proves that the transaction (or specific parts of the transaction)
> have not and cannot be modified by anyone after it has been signed.

Third purpose answers this question.


---

