Subject: Re: [bitcoindev] Re: SwiftSync - smarter synchronization with hints

From: Greg Maxwell <[email-masked]>
Date: Sat, 3 May 2025 08:54:20 -0700 (PDT)

Understood. My point was that this exists with the additive type too, If 
you repeat it N times it will cancel. If the salt isn't known you don't 
know the fewest repeats to achieve that. But even if you don't know the 
salt the size of the ring will do it.  So for example, this is a break of 
the passing suggestion of truncating to 32-bits (even 64-bits perhaps). You 
include the transaction with unknown accumulator impact x 2^32 times.   x * 
2^32 % 2^32 = 0.

On Saturday, May 3, 2025 at 2:56:13 PM UTC Ruben Somsen wrote:

> >I think you cannot escape the assumption that A is unique (well A and its 
> spend) thanks to TXID uniqueness
>
> A counter-example would be a chain with two transactions with the exact 
> same input A and output B. SwiftSync with XOR would basically treat these 
> two transactions as non-existent (the two A's and B's cancel each other 
> out), while a regular full node (or non-XOR SwiftSync) would reject the 
> chain.
>
> On Sat, May 3, 2025 at 3:57 PM Greg Maxwell <[email-masked]> wrote:
>
>> Hm. Fair point, but I think you cannot escape the assumption that A is 
>> unique (well A and its spend) thanks to TXID uniqueness without weakening 
>> the security argument, since A*n eventually collides.  It's essentially the 
>> same argument you make for characteristic 2, it just takes more 
>> repetitions.  Without knowing the salt you'd need 2^256 repetitions to be 
>> certain, but e.g. see the prior suggestions on truncating the hash to 32 
>> bits or whatever, a practical number of A repeats would then self cancel.
>>
>> To be clear I'm not arguing that it should be xor here, but pointing out 
>> there is structure here you might not have expected.
>>
>>
>>
>>
>>
>> On Sat, May 3, 2025 at 1:42 PM Ruben Somsen <[email-masked]> wrote:
>>
>>>   Hey all,
>>>
>>>
>>> @Saint Wenhao
>>>
>>> >if you take the sum of hashes, which should be finally zero, then by 
>>> grinding UTXOs, someone could make it zero
>>>
>>> That's what the secret salt prevents. You can't grind for a certain 
>>> number if you don't know what the number is you are trying to collide with.
>>>
>>> >maybe you can avoid hashing at all [...] And then, it is all about 
>>> mixing the salt
>>>
>>> Without a concrete solution I'm afraid that's wishful thinking. That 
>>> last part of the sentence is why we currently need the hash, as well as for 
>>> adding more data in the non-assumevalid version.
>>>
>>>
>>> @Sanket Kanjalkar
>>>
>>> >What if instead of hash we encrypt with AES
>>>
>>> I can't really evaluate whether this might work, but I can see the line 
>>> of reasoning. Conceptually, I think what we need is something that 
>>> transforms the data into fixed length blocks for which an attacker can't 
>>> know the relationship between each block (i.e. via a secret). The 
>>> transformation needs to be the same on the input and output side.
>>>
>>>
>>> @Greg Maxwell
>>>
>>> >Your reduction function could just be xor
>>>
>>> I had initially ruled XOR out. Reason for this is that XOR would lead 
>>> one to conclude that sets [A, B, C, C], [A, B], [A, B, D, D], etc. are all 
>>> equivalent because any two values cancel each other out, regardless of 
>>> whether the sets are on the input or output side. Modular add/sub doesn't 
>>> have this issue. If the speedup actually turns out to be significant then 
>>> there may be some clever way to salvage it like by counting the total 
>>> number of inputs and outputs and relying on the knowledge that every txid 
>>> must be unique, but that's a lot harder to reason about.
>>>
>>> >even if its with a quite expensive hash function that the IBD 
>>> performance will be heavily bottlenecked in network and parallelism related 
>>> issues and be far from the lowest hanging fruit for a while,  considering 
>>> that this has eliminated the big sequential part and a number of annoying 
>>> to optimize components entirely
>>>
>>> Very true, and as you said, we can easily drop-in replace the hash 
>>> function at any future point we like, without adverse consequences.
>>>
>>>
>>> Cheers,
>>> Ruben
>>>
>>> On Sat, May 3, 2025 at 2:07 PM Greg Maxwell <[email-masked]> wrote:
>>>
>>>> On Saturday, May 3, 2025 at 11:55:28 AM UTC Sanket Kanjalkar wrote:
>>>>
>>>> > hash(UTXO_A||salt) + hash(UTXO_B||salt) - hash(UTXO_C||salt) - 
>>>> hash(UTXO_D||salt) == 0 (proving (A==C && B==D) || (A==D && B==C))
>>>>
>>>> What if instead of hash we encrypt with AES and modular add/subs? I 
>>>> cannot prove it; but I also don't see a clear way this is broken. 
>>>>
>>>> 1. Sample random symmetric key `k`
>>>> 2. Instead of above; AES_k(UTXO_A) + AES_k(UTXO_B) - AES_k(UTXO_C) - 
>>>> AES(UTXO_D) == 0 =>  (proving (A==C && B==D) || (A==D && B==C))?
>>>>
>>>>
>>>> AES in CTR mode is, I'm not sure about other modes? Obviously CTR mode 
>>>> would be unsuitable! (I mean sure modular add/sub and xor are different 
>>>> operations but they are quite close).  I think that in many modes the 
>>>> collision resistance would have to at least be restricted by the birthday 
>>>> bound with the small block size. I think CMC might be needed to avoid that 
>>>> sort of issue.
>>>>
>>>>  
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Bitcoin Development Mailing List" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email-masked].
>>>> To view this discussion visit 
>>>> https://groups.google.com/d/msgid/bitcoindev/fbf06c5b-57b6-4615-99bb-3a7ea31ebf22n%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/bitcoindev/fbf06c5b-57b6-4615-99bb-3a7ea31ebf22n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/a1e589d5-1bd9-4e4b-9824-db22fda77646n%40googlegroups.com.