<p>When you spend Bitcoin, you are not just using a new randomly generated keypair. You are using a specific keypair generated before. In order for you to have been sent Bitcoin, you have to give the sender a Bitcoin address. This Bitcoin address contains the hash of your public key. When you want to spend those Bitcoin, you put your public key into the transaction and verifiers will check that that public key hashes to the hash specified in the transaction that sent those Bitcoin to you. If you just put a newly generated public key there, it would not match the hash and so the spending transaction would not be valid.</p>

CC BY-SA 4.0
2021-05-27T03:24:57.870Z
If I'm understanding correctly, my Bitcoin address that I sent to the payer will be: hash(my address + my (public key that is generated from my wallet) pk)? 

Then to spend it I will put that pk into the transaction. Then verifiers will check that hash(pk) == hash(transaction sent to me before)?
Andrew Q
CC BY-SA 4.0
2021-05-27T04:28:57.723Z
Your address is just hash(pk). This is placed into the transaction sent to you. When you spend, you put pk into your transaction, and verifiers will check hash(pk) == hash from previous tx.
Ava Chow
CC BY-SA 4.0
2021-05-28T22:40:03.290Z
Oh ok I think I get it now. Then once my pk is in the transaction and verified, the verifiers will also check that my pk can verify the signed message created with my sk. And I can assume that the life span of using that sk/pk pair is done and next time I use or receive a token, it will be with a different pair?
Andrew Q
CC BY-SA 4.0
2021-05-28T23:08:32.150Z
@AndrewQ There's no expiration per se. You can reuse addresses (and thus reuse keypairs) if you want, however this is not advised because it reduces your privacy.
Ava Chow
CC BY-SA 4.0
2021-05-27T03:01:29.763Z
2021-05-27T03:01:29.763Z
Ava Chow
<p>I think I'm missing and understanding about the current process of how your wallet works and how the transactions are signed.</p>
<p>For example, if I'm user &quot;A&quot; and there exists a transaction from user &quot;B&quot; where I received 10 BTC that has been written into a block. Then for me to use it I just generate a random public/private key pair and sign the transaction with the private key.</p>
<p>What is stopping user &quot;B&quot; from generating a public/private key pair then creating and signing a transaction saying that I, user &quot;A&quot; sent them 10 BTC?</p>
<p>I've read that some wallet implementations generate a list of public/private key pairs that can somehow be associated with the wallet address? I'm not sure how this would come into play if this is the case or if I'm misunderstanding this bit of information.</p>

<transactions><wallet><signature>
What does bitcoin do that prevents someone from using your coins by just generating a key pair and saying "you" sent those coins?
Andrew Q
# What does bitcoin do that prevents someone from using your coins by just generating a key pair and saying "you" sent those coins?

(Asked by: username_0 on 2021-05-27)

I think I'm missing and understanding about the current process of how your wallet works and how the transactions are signed.

For example, if I'm user "A" and there exists a transaction from user "B" where I received 10 BTC that has been written into a block. Then for me to use it I just generate a random public/private key pair and sign the transaction with the private key.

What is stopping user "B" from generating a public/private key pair then creating and signing a transaction saying that I, user "A" sent them 10 BTC?

I've read that some wallet implementations generate a list of public/private key pairs that can somehow be associated with the wallet address? I'm not sure how this would come into play if this is the case or if I'm misunderstanding this bit of information.

**Tags:** transactions, wallet, signature


---

## 1 answers

### Answer by username_1 on 2021-05-27. Score: 2 | Accepted answer

When you spend Bitcoin, you are not just using a new randomly generated keypair. You are using a specific keypair generated before. In order for you to have been sent Bitcoin, you have to give the sender a Bitcoin address. This Bitcoin address contains the hash of your public key. When you want to spend those Bitcoin, you put your public key into the transaction and verifiers will check that that public key hashes to the hash specified in the transaction that sent those Bitcoin to you. If you just put a newly generated public key there, it would not match the hash and so the spending transaction would not be valid.

> **Comments:**
> **username_0**: If I'm understanding correctly, my Bitcoin address that I sent to the payer will be: hash(my address + my (public key that is generated from my wallet) pk)?   Then to spend it I will put that pk into the transaction. Then verifiers will check that hash(pk) == hash(transaction sent to me before)?  
> **username_1**: Your address is just hash(pk). This is placed into the transaction sent to you. When you spend, you put pk into your transaction, and verifiers will check hash(pk) == hash from previous tx.  
> **username_0**: Oh ok I think I get it now. Then once my pk is in the transaction and verified, the verifiers will also check that my pk can verify the signed message created with my sk. And I can assume that the life span of using that sk/pk pair is done and next time I use or receive a token, it will be with a different pair?  
> **username_1**: @AndrewQ There's no expiration per se. You can reuse addresses (and thus reuse keypairs) if you want, however this is not advised because it reduces your privacy.  

---

