Bitcoin Forum
May 28, 2024, 04:14:46 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: scriptSig  (Read 116 times)
AlexR12 (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile
December 16, 2017, 05:58:12 AM
Last edit: December 16, 2017, 05:25:40 PM by AlexR12
 #1

Hello!
Could someone explain how <signature> and <public key> come out of scriptSig script? Of course, scriptSig in not equal concatenate(<signature>,<public key>). How is this information incorporated into scriptSig?
Thank you!
AlexR12 (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile
December 19, 2017, 05:06:48 AM
 #2

In this input of a transaction

scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

where is the public key?
odolvlobo
Legendary
*
Offline Offline

Activity: 4326
Merit: 3247



View Profile
December 19, 2017, 05:58:18 AM
Last edit: December 19, 2017, 06:35:07 AM by odolvlobo
 #3

Hello!
Could someone explain how <signature> and <public key> come out of scriptSig script? Of course, scriptSig in not equal concatenate(<signature>,<public key>). How is this information incorporated into scriptSig?
Thank you!

It's a script.

PUSHDATA opcode
Signature data
PUSHDATA opcode
Public key data

In this input of a transaction

scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

where is the public key?

That is just the signature. The output that it spends is from doesn't require a pubkey because the output script includes the pubkey:
Quote
PUSHDATA(65)
04283338ffd784c1 ... 8af332fe4d8cde20
CHECKSIG

Here is a typical raw scriptsig (https://blockchain.info/tx/f1f1ce5a0411d890ee3c543df2302c2691129e700bb72fed9eac0fff9cc5a0d0):
Quote
48
3045022100b028b2 ... 9f49ad32a3b53e01
21
027ca78d2199b4fb6 ... 929e18f3276062e7

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
AlexR12 (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile
December 19, 2017, 10:53:46 PM
 #4

Thank you very much for answering! As I see it:

1. scriptSig is an input of the "redeeming" transaction (the one where I want to spend previously earned bitcoins) and scriptPubKey is an output specified in the "referenced" transaction (the one where I earned those bitcoins that I'm trying to spend now).

2. To see if I'm allowed to spend those bitcoins, a miner will concatenate scriptSig and scriptPubKey and run the resulting script.

3. From scriptSig signature and public key come out. This public key is then hashed and compared with the hash of the public key specified in scriptPubKey. This is the first check for validity of the transaction. The second check if for the signature.

Question: in step 3, how to get the public key from scriptSig? In simple terms, I give you scriptSig, will you be able to tell the public key?
odolvlobo
Legendary
*
Offline Offline

Activity: 4326
Merit: 3247



View Profile
December 20, 2017, 12:36:23 AM
 #5


Question: in step 3, how to get the public key from scriptSig? In simple terms, I give you scriptSig, will you be able to tell the public key?


Probably. There is nothing in the script that identifies data as a public key, but you can probably deduce it.

The typical P2PKH scriptsig is:

PUSHDATA(72)
<signature>
PUSHDATA(33)
<public key>

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
AlexR12 (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile
December 20, 2017, 01:39:52 AM
 #6

Thank you!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!