I am looking for a good way to create more than one P2SH address (address is based on the hash of the script) which is encumbered by the same set of private keys.
"Standard" multisig script is <OP_m> [PubKeys] <OP_n> <OP_CHECKMULTISIG>
So with the following PubKeys:
02171f8058701e94efbbca609509b858f0ef1e32923d51991eac403ade22952421
03694411c22d04a72ced42e79d584de695e322e67b9f2bafc1f2805146dda20f60
036b033de1664219216408262a9a32dfb801f09b0bfb53dd83f036fedf1a644488
The script would be:
<OP_2> <"OP_PUSH_33"> <PubKey1:02171f8058701e94efbbca609509b858f0ef1e32923d51991eac403ade22952421> <"OP_PUSH_33"> <PubKey2:03694411c22d04a72ced42e79d584de695e322e67b9f2bafc1f2805146dda20f60> <"OP_PUSH_33"> <PubKey3:036b033de1664219216408262a9a32dfb801f09b0bfb53dd83f036fedf1a644488> <OP_3> <OP_CHECKMULTISIG>
In hex:
522102171f8058701e94efbbca609509b858f0ef1e32923d51991eac403ade22952421210369441 1c22d04a72ced42e79d584de695e322e67b9f2bafc1f2805146dda20f6021036b033de166421921 6408262a9a32dfb801f09b0bfb53dd83f036fedf1a64448853ae
The base58 encoded (0x05 prefix byte) HASH-160 hash of the script above is the address 3KKVrgqN2AYAsLQoJQchT5GK2KnKQ3dAPL. The simplest way to get a new address would be to change the keys but lets say I want a set of addresses which use the same keys. I could make one of the keys bogus and use it as a counter value (obviously this requires more keys i.e. for a real 2-of-3 script would require creating a pseudo 2-of-4 script).
As an example, in the two scripts the following key the first key is invalid and just used to create a unique hash output so this is effectively a 2-of-2 script despite being 2-of-3.
script: 5221020000000000000000000000000000000000000000000000000000e0000000000012103694411c22d04a72ced42e79d584de695e322e67b9f2bafc1f2805146dda20f6021036b033de 1664219216408262a9a32dfb801f09b0bfb53dd83f036fedf1a64448853ae
address: 3DmfeKGpHVsC7HHf2GumUE31NG14f4P8SM
script: 52210200000000000000000000000000000000000000000000000000000000000000022103694411c22d04a72ced42e79d584de695e322e67b9f2bafc1f2805146dda20f6021036b033de 1664219216408262a9a32dfb801f09b0bfb53dd83f036fedf1a64448853ae
address: 3AeD9PWp4nCi5x1BKFhyX4qHVkiejfTbq8
Addresses can be created on demand by incrementing the counter value in the pseudo-key and recomputing the scriptHash. This naive approach however is rather wasteful (and cludgy). It requires 34 additional bytes when only a few bytes are needed. If we assume a 3 byte counter (>16 million sequential addresses) then this has 31 bytes of overhead.
Any ideas on a more space efficient way to accomplish the same task? I am thinking maybe pushing the nonce to the stack and then using an OP_DROP?
<"OP_PUSH_3"> <0x010000> <OP_DROP> <OP_2> <"OP_PUSH_33"> <PubKey1> <"OP_PUSH_33"> <PubKey2> <OP_2> <OP_CHECKMULTISIG>
Any other ideas? Any way to make it pass IsStandard()?