Post
Topic
Board Development & Technical Discussion
Re: Need help reversing bitcoinutils "tagged_hash" to generate Taproot addresses
by
BTCW
on 16/01/2024, 13:08:45 UTC
Code:
A tagged hash is: SHA256( SHA256("TapTweak") ||
                              SHA256("F") ||
                              data
                            )
You posted this correctly in OP but changed it here. The second hash is also SHA256 of "TapTweak" (not F).
Code:
SHA256("TapTweak")=e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e9

tagged_hash = SHA256(e80f...c5e9 | e80f...c5e9 | 79be...1798)
| is byte concatenation and 79be...1798 is the pubkey.

Gotcha, the only problem is that

Code:
hashlib.sha256(bytes.fromhex('e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e9' + 'e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e9' + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')).hexdigest()

does not give

Code:
da4710964f7852695de2da025290e24af6d8c281de5a0b902b7135fd9fd74d21

In other words, we cannot yet reproduce the bitcoinutils' method. (Not only bitcoinutils; several libraries give the same result.)