<blockquote>
  <p>Does the consensus "know" when a transaction cannot be made for some reason ?</p>
</blockquote>

<p>Yes, this is done by utilizing <a href="https://en.wikipedia.org/wiki/Public-key_cryptography" rel="nofollow noreferrer">public key cryptography</a> to cryptographically sign transactions in a way that proves ownership of an unspent output. </p>

<p>Nodes keep a copy of the blockchain, which they know to be an accurate account of what addresses all the bitcoins in existence currently reside in. When a node hears about a new transaction, they will check to make sure the signature is valid. Public key cryptography allows a node to check that a signature is created using the right private key, without actually learning what that private key is (which is pretty neat). This is done by cryptographically verifying that the public address and the transaction signature were created by the same private key. </p>

<p>So if you tried to make a false transaction, to move coins you don't own, or don't exist, then network nodes would easily identify your tx as invalid, and not accept it, or relay it on. </p>

<p>The 'consensus layer' of the protocol strictly defines these sort of rules. All clients must adhere to the consensus layer rules in order to be a part of the network. </p>

CC BY-SA 3.0
2017-12-11T14:14:59.720Z
Thanks ! It makes sense now, the whole assymetric encryption
Max
CC BY-SA 3.0
2017-12-08T19:06:12.907Z
2017-12-11T19:00:23.170Z
2017-12-11T19:00:23.170Z
chytrik
<p>You can think of a bitcoin address like a machine that produces locks and a bitcoin wallet like a machine that produces unforgeable, labeled keys.</p>

<p>Say Alice received 1 bitcoin from Bob and wants to send it to Charlie. If Alice has 1 bitcoin to send, that means there is 1 bitcoin that is locked with a lock from her lock-making machine.</p>

<p>When Alice wants to send that 1 bitcoin to Charlie, she must have his address. She uses his address as a lock-making machine and makes a lock that only Charlie can unlock. She feeds this to her key-making machine and makes a key to the lock that only she can make a key to but labels it with the lock she got from Charlie's lock making machine.</p>

<p>This new key only opens the 1 bitcoin Alice will send to Charlie, and only Alice could make it. The attached new lock can only be opened by Charlie, since only he has the matching key-making machine.</p>

<p>You consider someone to have "sent you a bitcoin" if they locked it with a lock that only you can open.</p>

<p>So, a block that contains invalid transactions is itself invalid and ignored. You can only form valid transactions that transfer bitcoins with the appropriate keys or the transactions are invalid.</p>

<p>This might make you wonder what you need consensus for at all. And the problem is that Alice could maliciously make multiple keys that open the same lock, transferring the same 1 bitcoin to both Charlie and Dave. We need consensus to agree which of a set of conflicting transaction, each individually valid, we can rely on.</p>

CC BY-SA 4.0
2019-05-05T19:50:22.113Z
Thanks for the explanation. But where does the PoW comes in (for those systems that rely on it)? Would it be fair to say that it is to "slow" things down a little, to at least not make it free for malicious agents to submit blocks?
DPM
CC BY-SA 3.0
2017-12-08T19:03:40.857Z
2017-12-08T19:03:40.857Z
David Schwartz
<p>I'm really new to the whole concept of blockchain. </p>

<p>I do understand how consensus protects from changing past blocks and allows to keep a clear and valid blockchain, but I am having a hard time trying to wrap my head around fake transactions.</p>

<p>Let me explain. As I understand it :</p>

<ul>
<li>Nodes in the network produce transactions.</li>
<li>They are repeated all across the network</li>
<li>At the same time, some nodes try to mine a block.</li>
<li>When someone resolves the hash, they can create their block.</li>
<li>The block is accepted by everybody on the network as they can immediately check Proof of Work (via the hash + the data)</li>
</ul>

<p>Ok so this basically means that everybody follows the consensus (otherwise, everything said by anybody else would be garbage to a Node, and the other way round : we would have an isolated node). But how do they know that the transactions <strong>themselves</strong> written in the new block are correct ?</p>

<p>For instance, let A and B be two accounts. What prevents a node from randomly saying "B gave n bitcoins to A", and that information being completely false ? B would obviously benefit from doing that.</p>

<p>Maybe I don't understand how consensus is enforced in nodes themselves as well... is everybody running the same "program" ? Is it something in the protocol itself ? Does the consensus "know" when a transaction cannot be made for some reason ?</p>

<p>Thanks for your help</p>

<blockchain><fraud>
How does consensus protect from lying about transactions?
Max
# How does consensus protect from lying about transactions?

(Asked by: username_0 on 2017-12-08)

I'm really new to the whole concept of blockchain.

I do understand how consensus protects from changing past blocks and allows to keep a clear and valid blockchain, but I am having a hard time trying to wrap my head around fake transactions.

Let me explain. As I understand it :

* Nodes in the network produce transactions.
* They are repeated all across the network
* At the same time, some nodes try to mine a block.
* When someone resolves the hash, they can create their block.
* The block is accepted by everybody on the network as they can immediately check Proof of Work (via the hash + the data)

Ok so this basically means that everybody follows the consensus (otherwise, everything said by anybody else would be garbage to a Node, and the other way round : we would have an isolated node). But how do they know that the transactions **themselves** written in the new block are correct ?

For instance, let A and B be two accounts. What prevents a node from randomly saying "B gave n bitcoins to A", and that information being completely false ? B would obviously benefit from doing that.

Maybe I don't understand how consensus is enforced in nodes themselves as well... is everybody running the same "program" ? Is it something in the protocol itself ? Does the consensus "know" when a transaction cannot be made for some reason ?

Thanks for your help

**Tags:** blockchain, fraud


---

## 2 answers

### Answer by username_1 on 2017-12-08. Score: 1 | Accepted answer

> Does the consensus "know" when a transaction cannot be made for some reason ?

Yes, this is done by utilizing [public key cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography) to cryptographically sign transactions in a way that proves ownership of an unspent output.

Nodes keep a copy of the blockchain, which they know to be an accurate account of what addresses all the bitcoins in existence currently reside in. When a node hears about a new transaction, they will check to make sure the signature is valid. Public key cryptography allows a node to check that a signature is created using the right private key, without actually learning what that private key is (which is pretty neat). This is done by cryptographically verifying that the public address and the transaction signature were created by the same private key.

So if you tried to make a false transaction, to move coins you don't own, or don't exist, then network nodes would easily identify your tx as invalid, and not accept it, or relay it on.

The 'consensus layer' of the protocol strictly defines these sort of rules. All clients must adhere to the consensus layer rules in order to be a part of the network.

> **Comments:**
> **username_0**: Thanks ! It makes sense now, the whole assymetric encryption  

---

### Answer by username_2 on 2017-12-08. Score: 2

You can think of a bitcoin address like a machine that produces locks and a bitcoin wallet like a machine that produces unforgeable, labeled keys.

Say Alice received 1 bitcoin from Bob and wants to send it to Charlie. If Alice has 1 bitcoin to send, that means there is 1 bitcoin that is locked with a lock from her lock-making machine.

When Alice wants to send that 1 bitcoin to Charlie, she must have his address. She uses his address as a lock-making machine and makes a lock that only Charlie can unlock. She feeds this to her key-making machine and makes a key to the lock that only she can make a key to but labels it with the lock she got from Charlie's lock making machine.

This new key only opens the 1 bitcoin Alice will send to Charlie, and only Alice could make it. The attached new lock can only be opened by Charlie, since only he has the matching key-making machine.

You consider someone to have "sent you a bitcoin" if they locked it with a lock that only you can open.

So, a block that contains invalid transactions is itself invalid and ignored. You can only form valid transactions that transfer bitcoins with the appropriate keys or the transactions are invalid.

This might make you wonder what you need consensus for at all. And the problem is that Alice could maliciously make multiple keys that open the same lock, transferring the same 1 bitcoin to both Charlie and Dave. We need consensus to agree which of a set of conflicting transaction, each individually valid, we can rely on.

> **Comments:**
> **username_3**: Thanks for the explanation. But where does the PoW comes in (for those systems that rely on it)? Would it be fair to say that it is to "slow" things down a little, to at least not make it free for malicious agents to submit blocks?  

---

