0

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?

  • There are three (not two) questions here – amaclin Feb 11 at 6:26
0

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.
  • 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 Feb 11 at 20:40
  • No, because the input contains the signature, which is only valid for the specific tx. – James C. Feb 11 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.