Wladimir [ARCHIVE] on Nostr: 📅 Original date posted:2015-02-01 📝 Original message:On Sun, 1 Feb 2015, Tamas ...
📅 Original date posted:2015-02-01
📝 Original message: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
Published at
2023-06-07 15:29:13Event JSON
{
"id": "6c722543cc7a9018fe189b4839410af277c93f129e68fe5e80a234acefe0bafc",
"pubkey": "30217b018a47b99ed4c20399b44b02f70ec4f58ed77a2814a563fa28322ef722",
"created_at": 1686151753,
"kind": 1,
"tags": [
[
"e",
"fc2797f264a13f8ea77af5ba5889066dcc94b1e56a4f279f23c6bca6f2d81430",
"",
"root"
],
[
"e",
"c365127a8e0f2e6cb22b319f06fd9782c06d8a72898fe468f13b535bbd50ec96",
"",
"reply"
],
[
"p",
"c632841665fccdabf021322b1d969539c9c1f829ceed38844fea24e8512962d7"
]
],
"content": "📅 Original date posted:2015-02-01\n📝 Original message:On Sun, 1 Feb 2015, Tamas Blummer wrote:\n\n\u003e I wonder of consequences if var_int is used in its longer than necessary forms (e.g encoding 1 as 0xfd0100 instead of 0x01)\n\nIn serialize.h lingo you are talking about CompactSize, not VarInt.\n\nCompactSizes indeed have redundancy in their representation, i.e. the same \nnumber can be represented as up to four different byte sequences.\n\nVARINTs have a different format that (AFAIK) isn't used anywhere in \nthe block chain. See WriteVarInt / ReadVarInt. These were designed to \nnot have any redundancy in their representation.\n\n\u003e 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\n\u003e merkle tree.\n\nAre you sure that this is a current concern? Non-canonical CompactSizes \nare forbidden - in serialize.h this is flagged in ReadCompactSize.\n\nWladimir",
"sig": "b5d9e648fa5a13cf90fcaf80e4f62ac8b4e40d66da4929c1c9442879f268c49eb3d1be201f1941a9a1f4ddc3b0222e56b3ee0e832651ef0ec9d0be58788cebf8"
}