<p>Signing requires the private key, and commits the signature hash of the transaction to the signature. Altering the transaction will change the sighash, and thereby render the signature void.</p>

<p>The public key is required for signature validation. Only the public key hash is shared with the public in form of the address, from which the private key cannot be derived.</p>

<p>P2PKH and P2SH are both standard output scripts in Bitcoin.</p>

<ul>
<li>A P2PKH(address) output is spendable by the private key associated with the address.</li>
<li>A P2SH(embedded_script) output is spendable by the embedded script and the unlocking script thereof. The P2SH output script acts as a "wrapper" for other output scripts.</li>
</ul>

CC BY-SA 4.0
2019-02-11T20:40:41.923Z
Really thank you for your answer, I want to ask one more question: say that the user wrong using the private key sign the output, whether an attacker can steal bitcoin from the input address?
slylljyq
CC BY-SA 4.0
2019-02-11T20:42:15.453Z
No, because the input contains the signature, which is only valid for the specific tx.
James C.
CC BY-SA 4.0
2019-02-11T05:15:48.370Z
2019-02-11T05:15:48.370Z
James C.
<p>I know that the signing should use public key, what if the private key is used in signing the <strong>output</strong>? Does that mean anybody can use the money in your wallet? And is there any difference between P2PKH and P2SH?</p>

CC BY-SA 4.0
2019-02-11T06:26:08.087Z
There are three (not two) questions here
amaclin
<output>
Two question about bitcoin transaction signing
slylljyq
# Two question about bitcoin transaction signing

(Asked by: username_0 on 2019-02-11)

I know that the signing should use public key, what if the private key is used in signing the **output**? Does that mean anybody can use the money in your wallet? And is there any difference between P2PKH and P2SH?

**Tags:** output

> **Comments:**
> **username_1**: There are three (not two) questions here  

---

## 1 answers

### Answer by username_2 on 2019-02-11. Score: 1

Signing requires the private key, and commits the signature hash of the transaction to the signature. Altering the transaction will change the sighash, and thereby render the signature void.

The public key is required for signature validation. Only the public key hash is shared with the public in form of the address, from which the private key cannot be derived.

P2PKH and P2SH are both standard output scripts in Bitcoin.

* A P2PKH(address) output is spendable by the private key associated with the address.
* A P2SH(embedded\_script) output is spendable by the embedded script and the unlocking script thereof. The P2SH output script acts as a "wrapper" for other output scripts.

> **Comments:**
> **username_0**: Really thank you for your answer, I want to ask one more question: say that the user wrong using the private key sign the output, whether an attacker can steal bitcoin from the input address?  
> **username_2**: No, because the input contains the signature, which is only valid for the specific tx.  

---

