Bitcoin Forum
May 05, 2024, 11:59:48 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Questions about multisig  (Read 193 times)
BlackHatCoiner (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 7351


Farewell, Leo


View Profile
April 25, 2021, 12:30:44 PM
 #1

I'm reading the way multisig works (p2sh), but I haven't totally understood how you end up with this:
Code:
tb1q7zdkfcze59yz4ca9clslznd297xq68yvypkhz33ph34g62g0yxrqxd00gc

Correct me if I'm somewhere wrong:

The scriptPubKey is the hash of my script hash surrounded with HASH160 and EQUAL opcodes. According with an example of learnmeabitcoin, a scriptPubKey looks like that:

_OP_HASH160_ _script hash_ _OP_EQUAL_

or in hexadecimal:
Code:
a914748284390f9e263a4b766a75d0633c50426eb87587

Question #1: Why is the address above longer than a usual native segwit? Since we no longer pay to multisig (using P2MS) and we're locking the funds to a scriptPubKey that has a script hash of the N public keys, shouldn't the address length be the same whether the script hash was hashed requiring 1-of-1 or 15-of-15?

Question #2: How is the script hash come of? I haven't read that anywhere. On a simple address (that requires 1-of-1) it could be a hash of the compressed public key. Once you wanted to spend from that address you could reveal that public key along with a signature, the nodes could hash it to verify that it's the correct public key and validate the signature. What do you hash in this case?

HASH160(M, public keys (ascending order), N) ?

Isn't N unnecessary that way?

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
1714910388
Hero Member
*
Offline Offline

Posts: 1714910388

View Profile Personal Message (Offline)

Ignore
1714910388
Reply with quote  #2

1714910388
Report to moderator
1714910388
Hero Member
*
Offline Offline

Posts: 1714910388

View Profile Personal Message (Offline)

Ignore
1714910388
Reply with quote  #2

1714910388
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714910388
Hero Member
*
Offline Offline

Posts: 1714910388

View Profile Personal Message (Offline)

Ignore
1714910388
Reply with quote  #2

1714910388
Report to moderator
1714910388
Hero Member
*
Offline Offline

Posts: 1714910388

View Profile Personal Message (Offline)

Ignore
1714910388
Reply with quote  #2

1714910388
Report to moderator
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
April 25, 2021, 01:05:05 PM
Merited by ABCbits (1)
 #2

The scriptPubKey is the hash of my script hash surrounded with HASH160 and EQUAL opcodes. According with an example of learnmeabitcoin, a scriptPubKey looks like that:
-snip-

Question #1: Why is the address above longer than a usual native segwit? Since we no longer pay to multisig (using P2MS) and we're locking the funds to a scriptPubKey that has a script hash of the N public keys, shouldn't the address length be the same whether the script hash was hashed requiring 1-of-1 or 15-of-15?
-snip-
P2SH, P2WPKH/P2WSH are all different from each other, as defined in BIP141[1]. The link should answer your queries, scroll up to look at P2WPKH as well. P2WPKH and P2WSH have 20 bytes and 32 bytes of data being pushed onto the stack respectively.

Question #2: How is the script hash come of? I haven't read that anywhere. On a simple address (that requires 1-of-1) it could be a hash of the compressed public key. Once you wanted to spend from that address you could reveal that public key along with a signature, the nodes could hash it to verify that it's the correct public key and validate the signature. What do you hash in this case?
The OP codes are defined in the script hash. Hashing the redeem script allows the nodes to correctly hash the redeem script defined in the spending transaction to your address, together with the conditions and thus verifying that your transaction meets the requirements.

[1] https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WSH



Multisig is not the only use of P2SH. There are OP_CLTV, anyone can spend and this[2].

[2] https://bitcointalk.org/index.php?topic=293382.0

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
BrewMaster
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


There is trouble abrewing


View Profile
April 25, 2021, 03:24:32 PM
Merited by ABCbits (1), NotATether (1)
 #3

1) P2WSH addresses are longer compared to P2WPKH (and P2SH) because unlike those scripts that use HASH160 here SHA256 hash is used which is longer.

2) in script hashes we are computing a hash of script as the name suggests. that means the hash found in the P2WSH address is hash of a redeem script that could be anything and only usually is a multisig script.
there is no HASH160 anymore instead it is SHA256(redeemscript). in multisig that is SHA256(m + n*pubkeys + n + OP_CHECKMULTISIG)

There is a FOMO brewing...
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
April 25, 2021, 05:09:30 PM
 #4

Question #2: How is the script hash come of?

We have the witness, which is just m + n*pubkeys + n + OP_CHECKMULTISIG as BrewMaster said, and the script hash is the 32-byte SHA256 of this byte sequence. Then we have the redeem script which is composed of OP_0 (1 byte), a push byte of 0x20 (1 byte) and then the above 32-byte script hash. And the scriptPubKey is the format in your title post (OP_HASH160 redeemScript OP_EQUAL) and the witness and scriptPubKey are sent together as part of a transaction, where the witness is used in place of the empty scriptSig.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
BlackHatCoiner (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 7351


Farewell, Leo


View Profile
May 18, 2021, 08:16:51 AM
 #5

1) P2WSH addresses are longer compared to P2WPKH (and P2SH) because unlike those scripts that use HASH160 here SHA256 hash is used which is longer.
Is there any reason why we use SHA256 instead of HASH160? Why does this change only in multi-sig and not traditionally on 1-of-1 P2WSH addresses? Using 160 bits instead of 256 would make the transaction weight less.

Also, why does that happen only on P2WSH and not on P2SH? My multi-sig nested segwit addresses aren't longer than those that aren't multi-sig:

(Example of nested segwit multi-sig)



(Example of native segwit multi-sig)


We have the witness, which is just m + n*pubkeys + n + OP_CHECKMULTISIG as BrewMaster said
But what is the exact order of the public keys? Since we're hashing a message, then the public keys must be given on the same order. For example, in electrum when it asks me to enter my cosigners' keys, do I have to enter them in the same order when we made the wallet or has it a way to then sort it out in ascending order no matter the way I entered them?

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 18, 2021, 03:23:07 PM
Last edit: May 18, 2021, 03:40:52 PM by ranochigo
Merited by ABCbits (1), BrewMaster (1)
 #6

Is there any reason why we use SHA256 instead of HASH160? Why does this change only in multi-sig and not traditionally on 1-of-1 P2WSH addresses? Using 160 bits instead of 256 would make the transaction weight less.
You mean P2WPKH?

The rationale behind using SHA256 for P2WSH instead of HASH160 is stated here:
The scriptPubKey occupies 34 bytes, as opposed to 23 bytes of BIP16 P2SH. The increased size improves security against possible collision attacks, as 2^80 work is not infeasible anymore (By the end of 2015, 284 hashes have been calculated in Bitcoin mining since the creation of Bitcoin). The spending script is same as the one for an equivalent BIP16 P2SH output but is moved to witness.

Also, why does that happen only on P2WSH and not on P2SH? My multi-sig nested segwit addresses aren't longer than those that aren't multi-sig:
Nested Segwit (Multisig or not) is P2SH, not P2WSH. The standard is defined before we've decided on this and is different, there is no need to change that. There is no need for us to introduce a longer Segwit address for P2WPKH as well.

But what is the exact order of the public keys? Since we're hashing a message, then the public keys must be given on the same order. For example, in electrum when it asks me to enter my cosigners' keys, do I have to enter them in the same order when we made the wallet or has it a way to then sort it out in ascending order no matter the way I entered them?
You need to do so in the exact order. As you've said, the script is hashed and changing the order also changes the hash. That is why we rely on the redeem script.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
BlackHatCoiner (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 7351


Farewell, Leo


View Profile
May 18, 2021, 05:55:51 PM
 #7

You mean P2WPKH?
Wait, P2WPKH stands for “Pay To Witness Public Key Hash” and an example is:
Code:
bc1qs9p7wkudkknd2u7p7rtmtxgpr9ca0z9wk6fl9y

P2WSH stands for “Pay To Witness Script Hash” and an example is:
Code:
bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3

Yes, my bad. P2WPKH is what I meant.

The scriptPubKey occupies 34 bytes, as opposed to 23 bytes of BIP16 P2SH. The increased size improves security against possible collision attacks, as 2^80 work is not infeasible anymore (By the end of 2015, 284 hashes have been calculated in Bitcoin mining since the creation of Bitcoin). The spending script is same as the one for an equivalent BIP16 P2SH output but is moved to witness.
So we have the witness script hash (P2WSH) and the witness public key hash (P2WPKH). This Bitcoin improvement proposal says that it will improve the security by increasing the size, from 160 bits to 256, because it'll be harder to find a collision. Isn't this a little ironic for the already existent address types? I'm trying to understand what's going on here, but it seems that I fail to.

If you increase the address size, then the transaction will also weight more, but it'll be more secure against a collision attack. But why did the developers change it to SHA256 since every other address type uses the HASH160? Making such announcement is like contending that HASH160 isn't strong enough, but it is. The fact that they did it exclusively for P2WSH seems weird to me.

Nested Segwit (Multisig or not) is P2SH, not P2WSH. The standard is defined before we've decided on this and is different, there is no need to change that. There is no need for us to introduce a longer Segwit address for P2WPKH as well.
Question: Is there a P2WPKH corresponding to P2SH? Or if I didn't place it properly: An address type that is longer than P2SH, but starts with “3”?

You need to do so in the exact order. As you've said, the script is hashed and changing the order also changes the hash. That is why we rely on the redeem script.
Oh, okay, thanks. So electrum doesn't sort them ascendingly.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 18, 2021, 06:14:02 PM
 #8

So we have the witness script hash (P2WSH) and the witness public key hash (P2WPKH). This Bitcoin improvement proposal says that it will improve the security by increasing the size, from 160 bits to 256, because it'll be harder to find a collision. Isn't this a little ironic for the already existent address types? I'm trying to understand what's going on here, but it seems that I fail to.

If you increase the address size, then the transaction will also weight more, but it'll be more secure against a collision attack. But why did the developers change it to SHA256 since every other address type uses the HASH160? Making such announcement is like contending that HASH160 isn't strong enough, but it is. The fact that they did it exclusively for P2WSH seems weird to me.
Hash160 is secure by itself. P2SH is susceptible to collision (with birthday paradox) as the complexity is 2^80. This means that in the far future, it could be feasible for someone to be able to obtain a collision for a given script hash address.

It is not that big of a deal. P2WSH is far more efficient and Taproot is coming out as well. I'm not sure whether there would be any plans to phase out P2SH but that is likely not the case.
Question: Is there a P2WPKH corresponding to P2SH? Or if I didn't place it properly: An address type that is longer than P2SH, but starts with “3”?
Nope.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
BrewMaster
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


There is trouble abrewing


View Profile
May 18, 2021, 06:31:23 PM
 #9

i don't think we can say 160 bit is not secure, just that 256 bit is more secure. we still can't find a collision for 160 bit and it also won't be enough to find the collision the message that is being hashed (which would be the redeem script for P2SH) has to be a valid spendable script for it to work.

i also don't like this "By the end of 2015, 2^84 hashes have been calculated in Bitcoin mining" since the hashes are SHA256d not RIPEMD160 of SHA256.

There is a FOMO brewing...
BlackHatCoiner (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 7351


Farewell, Leo


View Profile
May 18, 2021, 08:11:46 PM
 #10

Hash160 is secure by itself. P2SH is susceptible to collision (with birthday paradox) as the complexity is 2^80. This means that in the far future, it could be feasible for someone to be able to obtain a collision for a given script hash address.
Just googled what's the birthday paradox, but haven't understood properly how could this be used to increase your probability of finding a collision. It'd be off-topic to analyze it here, so I may create a new thread about it in the future. Anyway, thanks for the clarification.

i don't think we can say 160 bit is not secure, just that 256 bit is more secure. we still can't find a collision for 160 bit and it also won't be enough to find the collision the message that is being hashed (which would be the redeem script for P2SH) has to be a valid spendable script for it to work.
I may have misunderstood this. It wouldn't make sense to brute force invalid scripts, but valid ones. Why would someone brute force scripts that couldn't be redeemed?

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
BrewMaster
Legendary
*
Offline Offline

Activity: 2114
Merit: 1292


There is trouble abrewing


View Profile
May 19, 2021, 02:49:15 AM
 #11

I may have misunderstood this. It wouldn't make sense to brute force invalid scripts, but valid ones. Why would someone brute force scripts that couldn't be redeemed?

we are talking about finding hash collision not brute forcing scripts but the bytes you hash to find the collision in a P2SH output is the bytes that are converted to a redeem script so they also have to be a valid script.

There is a FOMO brewing...
vjudeu
Hero Member
*****
Offline Offline

Activity: 678
Merit: 1560



View Profile
May 19, 2021, 05:34:50 AM
 #12

Quote
Just googled what's the birthday paradox, but haven't understood properly how could this be used to increase your probability of finding a collision.
If you want to get any two identical addresses from scratch, then birthday paradox applies here. But if you have some 160-bit address with someone else's coins, then of course birthday paradox does not help at all. So, theoretically you can switch from mining blocks with 80 zero bits to creating addresses and hope that you find a pair of keys after checking 2^80 keys, but it has no use when guessing already used addresses. Also, as nobody took 0.64 BTC reward from the transaction puzzle, I think someone would take them before we would see any collision in addresses.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
May 19, 2021, 07:56:50 AM
 #13

You need to do so in the exact order. As you've said, the script is hashed and changing the order also changes the hash. That is why we rely on the redeem script.
Oh, okay, thanks. So electrum doesn't sort them ascendingly.
Actually... it does... and it doesn't... Tongue

Electrum uses "lexicographical ordering" as per BIP45: https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki#cosigner-index

But, because it is an HD version of Multisig... the ordering is of the "purpose keys'" of each co-signer (m/45') and is used to determine the co-signer index of each party, which then determines the order of the individual public keys when combining them to create an "address" script... this may result in individual scripts where the public keys are not ordered lexicographically.


As opposed to a "non-HD" multisig, where the combined public keys would (should?) always be lexicographically ordered.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!