Title: Transaction id hashing and var_ints Post by: TierNolan on November 14, 2014, 09:15:00 PM 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? Title: Re: Transaction id hashing and var_ints Post by: harding on November 16, 2014, 03:17:32 PM 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 Title: Re: Transaction id hashing and var_ints Post by: TierNolan on November 16, 2014, 06:06:35 PM 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. |