Bitcoin Forum
May 14, 2024, 04:46:07 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why the end of signatures is 0x01  (Read 704 times)
zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 10, 2014, 03:37:09 PM
Last edit: March 10, 2014, 04:01:38 PM by zzkjliu
 #1

Hello all!

If you look at this transaction(http://blockexplorer.com/rawtx/d2b04f28dfe36bbd7f6228519725f4560b6d7eef0eb9c1b1d4c718f2ba4548f5) you can see that one of the signatures is:

Code:
3045 0220
316eb3cad8b66fcf1494a6e6f9542c3555addbf337f04b62bf4758483fdc881d          this is r
022100
bf46d26cef45d998a2cb5d2d0b8342d70973fa7c3c37ae72234696524b2bc812      this is s
01


"scriptSig":"30450220316eb3cad8b66fcf1494a6e6f9542c3555addbf337f04b62bf4758483fdc881d022100bf46d26cef45d998a2cb5d2d0b8342d70973fa7c3c37ae72234696524b2bc81201"




Why the end of the character is 0x01?

1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
1715661967
Hero Member
*
Offline Offline

Posts: 1715661967

View Profile Personal Message (Offline)

Ignore
1715661967
Reply with quote  #2

1715661967
Report to moderator
btchip
Hero Member
*****
Offline Offline

Activity: 623
Merit: 500

CTO, Ledger


View Profile WWW
March 10, 2014, 03:44:03 PM
 #2

It's the hashtype, which is not part of the signature - check https://en.bitcoin.it/wiki/OP_CHECKSIG

zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 10, 2014, 04:07:48 PM
 #3

It's the hashtype, which is not part of the signature - check https://en.bitcoin.it/wiki/OP_CHECKSIG

You are wrong? hashtype is 4 bytes, and in the TxOut.  But the 0x01 is in the scriptSig in TxIn

Code:
Hashtype Values (from script.h):
Name Value
SIGHASH_ALL 0x00000001
SIGHASH_NONE 0x00000002
SIGHASH_SINGLE 0x00000003
SIGHASH_ANYONECANPAY 0x00000080
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 10, 2014, 08:44:50 PM
 #4

It's the hashtype, which is not part of the signature - check https://en.bitcoin.it/wiki/OP_CHECKSIG

You are wrong? hashtype is 4 bytes, and in the TxOut.  But the 0x01 is in the scriptSig in TxIn

Code:
Hashtype Values (from script.h):
Name Value
SIGHASH_ALL 0x00000001
SIGHASH_NONE 0x00000002
SIGHASH_SINGLE 0x00000003
SIGHASH_ANYONECANPAY 0x00000080

Does step 5 here answer your question?
https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png
zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 11, 2014, 12:24:00 AM
 #5


Thanks
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
March 11, 2014, 11:50:17 AM
Last edit: March 11, 2014, 02:30:58 PM by kjj
 #6

It is a varint.  For values between 0 and 253, a varint has a single byte representation.

It will probably be many, many years before we see a three byte hashtype.


Edit (2014-03-11): Totally wrong, see next post

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Peter Todd
Legendary
*
expert
Offline Offline

Activity: 1120
Merit: 1150


View Profile
March 11, 2014, 12:51:59 PM
 #7

It is a varint.  For values between 0 and 253, a varint has a single byte representation.

It will probably be many, many years before we see a three byte hashtype.

That's incorrect; from CheckSig():

Code:
    if (nHashType == 0)
        nHashType = vchSig.back();
    else if (nHashType != vchSig.back())
        return false;
    vchSig.pop_back();

vchSig is a vector of 8-bit unsigned char's, so it really is just a single byte and encoding a varint would cause the signature to fail. In particular, changing to that in the future would not be a backwards compatible change.

kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
March 11, 2014, 02:29:44 PM
 #8

Shit, you're right.  I should have checked the source instead of my notes.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
zzkjliu (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 11, 2014, 03:49:02 PM
Last edit: March 11, 2014, 04:01:09 PM by zzkjliu
 #9

Look at this:https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623
Code:
https://en.bitcoin.it/wiki/OP_CHECKSIG
Hashtype Values (from script.h):
Name Value
SIGHASH_ALL               0x00000001
SIGHASH_NONE               0x00000002
SIGHASH_SINGLE            0x00000003
SIGHASH_ANYONECANPAY 0x00000080


https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623
Enochian said "......,
A signature is a pair of bignum integers, (r,s), so it consists of 0x30,
which indicates a sequence of one or more things, an octet count of
what follows, followed by two encoded integers.  In addition, bitcoin
appends the hashtype, which is always "1", to the end.
 ......"


which is always "1", is this right?


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!