[Bitcoin-development] var_int ambiguous serialization consequences

Tamas Blummer tamas at bitsofproof.com
Sun Feb 1 11:42:05 UTC 2015


Thanks for the clarification. Yes, I referred to CompactSize using the lingo of https://en.bitcoin.it/wiki/Protocol_documentation

I am not sure if it is current concern. Apparently an exception is thrown if non-canonical CompactSize in a transaction s parsed.
Is it ensured that transactions are always parsed before computing their hash?

Tamas Blummer

On Feb 1, 2015, at 11:44 AM, Wladimir <laanwj at gmail.com> wrote:

> 
> On Sun, 1 Feb 2015, Tamas Blummer wrote:
> 
>> I wonder of consequences if var_int is used in its longer than necessary forms (e.g encoding 1 as 0xfd0100 instead of 0x01)
> 
> In serialize.h lingo you are talking about CompactSize, not VarInt.
> 
> CompactSizes indeed have redundancy in their representation, i.e. the same number can be represented as up to four different byte sequences.
> 
> VARINTs have a different format that (AFAIK) isn't used anywhere in the block chain. See WriteVarInt / ReadVarInt. These were designed to not have any redundancy in their representation.
> 
>> This is already of interest if applying size limit to a block, since transaction count is var_int but is not part of the hashed header or the
>> merkle tree.
> 
> Are you sure that this is a current concern? Non-canonical CompactSizes are forbidden - in serialize.h this is flagged in ReadCompactSize.
> 
> Wladimir
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20150201/189a978e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20150201/189a978e/attachment.sig>


More information about the bitcoin-dev mailing list