Bitcoin full node and query server

Apr 7, 2024

View in context in the libbitcoin Slack #general mirror.

pmienk16:59
Naively, can this be recast as a tail subset duplication detection?
46 replies · evoskuil, pmienk · last Apr 07, 2024
evoskuil17:00
That sounds right. But to be accurate it’s only certain subsets (by length).
evoskuil17:01
Any duplication presents the possibility. But the actuality is more specific.
pmienk17:02
Restricted to repetition of 2^i for some nonnegative i
(edited)
pmienk17:04
Presumably capable at something. Certainly 1/2 the size of the set. But probably less
evoskuil17:04
Yes, but further restricted such that at depth “i” the set has been collapsed to an odd length.
evoskuil17:05
And not before
pmienk17:11
Not sure the sizing constraints to be applied. But a linear walk of the TX set can detect the duplicate match. And if there's a first duplicate without subsequent match its already invalid and we can bail.
pmienk17:11
If a subset is found, then we need a size relation to validate against.
pmienk17:15
Some invariant between size of set s, size of nonrepeating elements p, and the length of the repeated Txs r such that r itself would require duplication to merge relative to p. So s = p + 2r or s = 2^p + 2^(r-1) is valid and s = 2^p + 2^r is the mallied block
pmienk17:16
Note that the two forms define p and r differently, not sure which is more convenient for teasing out the relation
pmienk17:17
In fact, the exponent version is necessarily incorrect or overly restrictive
(edited)
pmienk17:18
I'll keep thinking about it. Trying to catch any bad fall right now
20240407_101805.jpg
👍🏻 1
pmienk17:22
s = v + 2r where v = 2^a + 2^b and 2r = 2^b and r is odd?
evoskuil17:30
Re your earlier comments. Detection of the possibility is trivial. A duplicated tx is necessary for the possibility and also invalidates the block. That’s not the problem however. We need to be able to know that the cause of the invalidation is malleation, since that alone precludes caching the invalidity.
evoskuil17:31
Also detecting duplication is expensive relative to a function of set size.
pmienk17:42
Yes, the comment was that the first failure to match the repetition point after first duplicate is an ejection from detection of the subset. There is no, we'll maybe it has a smaller repeating duplicate later on if scanned from the front. If scanned from the tail I suppose there's no gain
pmienk17:42
Was intended anyway
evoskuil17:43
K
pmienk17:44
But even that is wrong I suppose, as the repeating subset could be performed more than once
pmienk17:45
Or no, that can't be can it due to the size limitations to produce the tree
pmienk17:46
Lot of thinking in text here, sorry
evoskuil17:46
The exponent of the repeated set length must match the depth of the first odd row in the binary reduction.
evoskuil17:47
Otherwise the merkle duplication either doesn’t occur or occurs too early or late to match the repetition (ie at the necessary depth).
(edited)
evoskuil17:47
That’s the purpose of the inner loop in the algorithm above.
pmienk17:49
So repetition of a TX can occur as many times as the padding attempts up the Merkle tree
evoskuil17:50
So if the repetition is 4 hashes (2^2) then the third (0..1..2) reduction must be an odd length set, and the first and second must not be.
evoskuil17:50
Yes, but not a given tx hash, since as you move up the tree you are duplicating a peer leaf node that is a combined hash.
pmienk17:51
Well, as many times as 2^d where d is the number of duplication points
evoskuil17:51
Merkle is a simple iteration until 1 hash remains, where pairs of leave are hashed into a new row. If the row is odd the last pair is a duplicate.
(edited)
pmienk17:52
The mallied TXs could maximally contain a single hash 2^d times
evoskuil17:53
No, because it would not match the hash of the valid block.
evoskuil17:53
When the duplicates are dropped.
evoskuil17:54
The ambiguity results only from a single automatic substitution by Merkle.
evoskuil17:54
So the dups in the original set target that “odd depth” by their width.
evoskuil17:55
A single hash dup implies a valid set with one less node and must be odd length.
evoskuil17:55
So that dup gets applied on the first iteration.
evoskuil17:56
But a 2 hash dup (as in the doc) will only work at an odd depth 2 (second iteration).
evoskuil17:57
So depths must be all even until the target depth, which must be odd. Where the target depth is determined by the dup set length base 2 exponent.
(edited)
pmienk17:58
Sounds like you're telling me that the only mallied set can contain a single duplicate sequence of hashes, cool
evoskuil17:59
Yes
evoskuil17:59
The writeups on it are sparse on details, I’ve had to work out the general case rules.
evoskuil18:01
Core scans each entire row for duplicated peers. That would create false positives. In other words, failure to invalidate a hash that has no valid variant.
evoskuil18:01
And it’s inefficient.
evoskuil18:01
The simplest specification I can think of is the iterative algorithm, which I don’t like :/.
evoskuil18:04
Also, there can be more than one mallied set for a malleable valid block. But only one dup set per mallied block is feasible.
(edited)
evoskuil18:04
Unless of course I’ve missed something.