Bitcoin Forum
September 27, 2018, 10:59:24 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Transaction id hashing and var_ints  (Read 1210 times)
TierNolan
Legendary
*
Offline Offline

Activity: 1190
Merit: 1001


View Profile
November 14, 2014, 09:15:00 PM
 #1

The transaction serialization contains various var_int fields.  This means that you can change those and keep the actual data in the transaction the same.

For example, a transaction with 3 inputs could encode the 3 as "03" to encode 3 (single byte version) or "FD0300" (two byte version).  

Is it defined as the most compact version?  This isn't transaction malleability exactly.

The process when a tx is received is

- tx received
- convert to CTransaction object
- store 3 in the size of the vector
- calls UpdateHash
-- re-serializes transaction
-- compute hash
- store hash

This means that no matter how the transaction receives the 3, the 3 gets converted back into the shortest form before hashing for the txid.

Is this correct?

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
1538089164
Hero Member
*
Offline Offline

Posts: 1538089164

View Profile Personal Message (Offline)

Ignore
1538089164
Reply with quote  #2

1538089164
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538089164
Hero Member
*
Offline Offline

Posts: 1538089164

View Profile Personal Message (Offline)

Ignore
1538089164
Reply with quote  #2

1538089164
Report to moderator
harding
Jr. Member
*
Offline Offline

Activity: 44
Merit: 21


View Profile WWW
November 16, 2014, 03:17:32 PM
 #2

It looks to me like CompactSize requires the smallest possible encoding.  See: https://github.com/bitcoin/bitcoin/blob/master/src/serialize.h#L218

It also looks like there are some tests to ensure non-canonical compatSize uints are forbidden in the test cases.  See: https://github.com/bitcoin/bitcoin/blob/master/src/test/serialize_tests.cpp#L81
TierNolan
Legendary
*
Offline Offline

Activity: 1190
Merit: 1001


View Profile
November 16, 2014, 06:06:35 PM
 #3

It looks to me like CompactSize requires the smallest possible encoding.  See: https://github.com/bitcoin/bitcoin/blob/master/src/serialize.h#L218

Interesting, I thought it was valid but discouraged.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!