Multi-signature public key validation

4

In a pay 2 script hash transaction, does the redeem script get checked for valid public keys before a transaction can be signed? I have noticed that if I have a redeem script with one invalid pubkey out of 3, even if I sign with a valid private key for the multi-sig transaction, the "scriptSig" is blank and the hex returned for the signrawtransaction is small/incomplete.

Any ideas?

I saw a comment on here that led me to believe that public keys in redeem scripts could be text or 'anything'

Derek

Posted 2017-01-17T00:49:16.327

Reputation: 141

Get checked by what? What code/project are you using to sign transactions?Pieter Wuille 2017-01-17T13:21:01.017

I am using bitcoin-cliDerek 2017-01-17T16:57:15.610

Answers

1

For m of n multisig, only the last m pub keys are checked for validity, given that at least the last m pub keys are valid public keys and match to signatures in the correct order. Other pub keys are not checked and can be used to push arbitrary data.

MCCCS

Posted 2017-01-17T00:49:16.327

Reputation: 5 827

0

You are doing something wrong. (or your tool is broken)

Signing the input can not leave scriptSig blank

amaclin

Posted 2017-01-17T00:49:16.327

Reputation: 5 763

the tool is bitcoin-cli. I can reproduce steps in my question later if needed, but if you want to try - run createmultisig then modify one of the public keys that is in the redeemscript. Send btc to the multi address. Create a 3rd party and try to send to that user. Sign the "send" transaction with the modifed redeemScript, and you'll see that scriptSig is blankDerek 2017-01-17T17:00:43.513

If you modify one of the keys, the corresponding address will change. Bitcoin Core cannot even know how to sign for it without knowing that.Pieter Wuille 2017-01-17T17:28:47.380

Are you saying that the signature part re-creates the mutlisign address using the keys that are found in the "corrupt" redeemScript? I would have thought that was encoded in the transaction that was created using the real redeemScriptDerek 2017-01-17T17:30:31.547

I think what @PieterWuille means, and correct me if I'm wrong, is that if you modify one of the public keys used to create the redeemScipt, the reddemScript itself changes, that is: the address format for P2SH according to BIP13 is [one-byte version][20-byte hash][4-byte checksum], since the 20 byte hash represents the hash of the scrip you have created, lets say its a 1-3 multisig address like: address = 1 <PubKey1><PubKey2><PubKey3> 3, if you change, for example PubKey2 for a new one: address2 = 1 <PubKey1><PubKey4><PubKey3> 3, the resulting script will change (address != address2).sr-gi 2017-02-16T11:55:57.383