Skip to main content

Timeline for Genesis TX varint

Current License: CC BY-SA 4.0

10 events
when toggle format what by license comment
Jun 18, 2020 at 8:26 history edited CommunityBot
Commonmark migration
Jan 6, 2020 at 5:42 comment added jtgrassie I'm also ignoring the other type of varints you can find in Monero code! EPEE has another type it uses in its binary serialization. Not relevant to this question however.
Jan 6, 2020 at 5:03 comment added jtgrassie A normal, max 8 bytes number is 2^64-1. With a varint you would have to remove 7 bits from your 64 bits because the most significant bit of each byte is used to signify another byte is needed. Thus (N-1) as in 8 bytes minus the last byte is 7. 7 bits used in the encoding. 64-7 = 57. Max 57 bit number is 2^57-1 - as I stated in previous comment. Checking the Monero source, it treats the last byte just as the others, so only 7 bits can be used from that also. If the 8th bit of that bytes is set, it's considered an overflow. So yes, in fact the max number would be 2^56-1.
Jan 6, 2020 at 3:51 comment added koe If I'm understanding right, is it 2^57 instead of 2^56 because the MSB of the 8th byte is, unlike the previous 7 bytes, an information bit?
Jan 6, 2020 at 3:23 comment added jtgrassie "Am I correct in thinking varints occupy up to 9 bytes of space, and can contain up to 63 bits of information?" <- No you are incorrect. Varints can be as small as 1 byte and in theory, any size as a maximum. It even states this in the part I quoted from the spec. In Monero the range used is 1 byte to 8 bytes, because they are typically decoded to unsigned 64 bit integers. As you lose N-1 bits due to the encoding, for an 8 byte varint the maximum decoded value would be 2^57-1
Jan 6, 2020 at 3:17 comment added koe Am I correct in thinking varints occupy up to 9 bytes of space, and can contain up to 63 bits of information? based on section 1.2 here tukaani.org/xz/xz-file-format.txt
Jun 25, 2018 at 22:29 vote accept W. Kadou
Jun 25, 2018 at 22:29 comment added W. Kadou Thanks a million, this did help me. Sorry for responding late
Jun 15, 2018 at 12:00 history edited jtgrassie CC BY-SA 4.0
Added link to spec and quoted. And added breakdown.
Jun 14, 2018 at 22:59 history answered jtgrassie CC BY-SA 4.0