Author

Topic: M-Of-N Addressess - Can we check how many 'N's & 'M's? (Read 1359 times)

sr. member
Activity: 375
Merit: 255
the redeem script format:

the byte 50 + required Keys
pubkey1 count
pubkey1
(...)
byte 50 + pubkey count
byte ae

example (2 of 3)
52 33 035b641b667aded965c2f7c2be17c736e6d960e3316a5c2d46ccacf6ff9fa87edd 33 02b94370211403cac9378dfbc414df44842523e120e5301d3d593a370cf6b9fb38 33 0260b26aa4d0e921f322bcad0f04c1bcd475a70e4553f3bda007eb1534081ead46 53 ae

i made a mistake
the pubkey count is in hex
so is 21, not 33

52 21 035b641b667aded965c2f7c2be17c736e6d960e3316a5c2d46ccacf6ff9fa87edd 21 02b94370211403cac9378dfbc414df44842523e120e5301d3d593a370cf6b9fb38 21 0260b26aa4d0e921f322bcad0f04c1bcd475a70e4553f3bda007eb1534081ead46 53 ae
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
Thanks all! It helped me!

/thread

   -MZ
donator
Activity: 1218
Merit: 1079
Gerald Davis
Providing a proof that a P2SH is legit is a good feature which should be proposed by all multisig online wallets.
It just requires you have access to the redeem script and the hash before sending funds to the P2SH address.

Hard part. It can be faked.
Fakes can be trivially detected.   If you need to authenticate the script you should hash the redeemScript provided and compare it to the ScriptHash decoded from the P2SH address you were given.
sr. member
Activity: 375
Merit: 255
the first byte, 52, is the M (52-50=2) and the second last byte, 53, is tne N (53-50=3)
sr. member
Activity: 384
Merit: 258
A few useful resources on the subject:
- Bip16 : easy to read and contains everything required to understand P2SH.
- the wiki page about scripts.
- webbtc explorer which has a very useful script debugger (here's a page with P2SH multisig examples)

WRT to old multisig scripts: Basically they have the same structure as P2SH multisig redeem script ("2 pubkey1 pubkey2 2 OP_CHECKMULTISIG" for a 2of2 multisig) but the script is used directly in the scriptpubkey.


hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
the redeem script format:

the byte 50 + required Keys
pubkey1 count
pubkey1
(...)
byte 50 + pubkey count
byte ae

example (2 of 3)
52 33 035b641b667aded965c2f7c2be17c736e6d960e3316a5c2d46ccacf6ff9fa87edd 33 02b94370211403cac9378dfbc414df44842523e120e5301d3d593a370cf6b9fb38 33 0260b26aa4d0e921f322bcad0f04c1bcd475a70e4553f3bda007eb1534081ead46 53 ae

Thanks! How did you know that is 2-of-3 and not 1-of-3 or 3-of-3? Thank you and sorry for my stupid questions.

   -MZ
sr. member
Activity: 375
Merit: 255
the redeem script format:

the byte 50 + required Keys
pubkey1 count
pubkey1
(...)
byte 50 + pubkey count
byte ae

example (2 of 3)
52 21 035b641b667aded965c2f7c2be17c736e6d960e3316a5c2d46ccacf6ff9fa87edd 21 02b94370211403cac9378dfbc414df44842523e120e5301d3d593a370cf6b9fb38 21 0260b26aa4d0e921f322bcad0f04c1bcd475a70e4553f3bda007eb1534081ead46 53 ae
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
I make the hypothesis that you're talking about P2SH addresses (starting with a 3)*

Yes, I am.

Unfortunately, the scriptpubkey (script stored in the unspent output) of a P2SH can't be used to retrieve the M & N values.
The scriptpubkey contains a hash of the redeem script (the multisig script) and this hash can't be reversed and interpreted.
The redeem script will be provided in clear in the scriptsig when the utxo is spent. But that may be too late...

It's okay! Can you tell me how to find M & N values after UTXO is spent?

Providing a proof that a P2SH is legit is a good feature which should be proposed by all multisig online wallets.
It just requires you have access to the redeem script and the hash before sending funds to the P2SH address.

Hard part. It can be faked.

*: old multisig scripts don't have this "problem" since the multisig script can be found in clear in the scriptpubkey. 

I didn't there was two different multisig. Can you please give more info about the multisig you are talking about? Thank you!

   -MZ
sr. member
Activity: 384
Merit: 258
I make the hypothesis that you're talking about P2SH addresses (starting with a 3)*

Unfortunately, the scriptpubkey (script stored in the unspent output) of a P2SH can't be used to retrieve the M & N values.
The scriptpubkey contains a hash of the redeem script (the multisig script) and this hash can't be reversed and interpreted.
The redeem script will be provided in clear in the scriptsig when the utxo is spent. But that may be too late...

Providing a proof that a P2SH is legit is a good feature which should be proposed by all multisig online wallets.
It just requires you have access to the redeem script and the hash before sending funds to the P2SH address.

*: old multisig scripts don't have this "problem" since the multisig script can be found in clear in the scriptpubkey.  
sr. member
Activity: 375
Merit: 255
only with a redeem script...
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
Hello,

Can we check how many 'N's & 'M's are there for a multisig address? There are a few wallets which offer multisig addresses, one key with us and one in server, according to them a 2-of-2 address. But to be sure, I would like to check whether it is true? i.e., whether it is really a 2-of-2 or 2+-of-3+. Any suggestions/opinions are helpful. Smiley

Kindly,
Muhammed Zakir
Jump to: