Author

Topic: Transaction id hashing and var_ints (Read 1300 times)

legendary
Activity: 1232
Merit: 1094
November 16, 2014, 01: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.
jr. member
Activity: 50
Merit: 54
November 16, 2014, 10:17:32 AM
#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
legendary
Activity: 1232
Merit: 1094
November 14, 2014, 04: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?
Jump to: