2

I am looking to be able to calculate the public key from the transaction input. The input is from a 'pay to public key' output.
Can the public key of the input be generated from just the signature and the transaction that the input is in?

1

I can't understand your question but I will try to clarify the things for you.

A Pay-to-Pub-Key transaction is a type of transaction which is generated basically from a miner in order to send back to his own address the reward(now is 25 BT) after a suceessful creation of a Block. This transaction is called coinbase transaction and is the first located transaction of the Block which is going to be mined by him.

The structure of the script which satisfies this kind of transaction is:

• Locking Script or scriptPubKey (which located in the Output of a transaction)

< Public Key of Miner> OP_CHECKSIG

• Unlocking Script or scriptSig (which located in the Input of a transaction)

<Signature from Private Key of Miner> 

• Validation Script

<Signature from Private Key of Miner> < Public Key of Miner> OP_CHECKSIG

In order the miner to redeem the 25BT value :

His signature located in Locking script have to be created by his private key. In order to check that condition, his public key is used, which corresponds to this private key.

As a result the public Key can't create a signature. A signature is created by the private key and a message (or transaction) which is going to be signed with this private key. You can't calculate the public key from the input, because the public key is located in the output or better in the Locking Script.

1

In spending a pay-to-pubkey transaction output, just the signature is put into the scriptSig. The signature can be used to do public key recovery, but you won't be able to uniquely identify the exact public key representation that was put into the scriptPubKey. You can mathematically narrow it down to 4 possibilities using the public key recovery method, but to get the exact representation that was used, you'll need to do a lookup on the previous output.

For more on public key recovery, look at https://crypto.stackexchange.com/questions/18105/how-does-recovering-the-public-key-from-an-ecdsa-signature-work

In brief, you can determine the X coordinate of the ECC public key, and then the Y coordinate can be one of two values. And for each of those two points ((X, Y) & (X, -Y)), there are two representations, compressed and decompressed form.

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.