3

I'm just getting a handle on multisig, so sorry about that. I don't really get how, (what operations are performed) on the inputs (3 public keys, right?) to generate a multisig address. Or is it some simple concatenation operation?

4

To better understand multisig addresses and transactions, it's useful to read BIP 0013 and create a multisig address using https://coinb.in/multisig/

If I want to create a multisig that requires signatures from 2 of the 3 following pubkeys:

04c96a8b79aff49f36766b7827308bb5d6dc031e4e9112b785201a9a61821d2a336dbb7fa69f44c2dc76dee8fa7ed8fee2958f4a86a3dbb7ebf3eeb790cd464db9
04fd6c4db8841f7370a0cdc464a58b3e2a0da5b6566e0502a9cf583360bcdd16e8453a0a8da0fba0ff26e40c1f8c55f8cd0ad61988b7d4418b504264be8a9cef59
04c41b31403f24ef79e9c7dcfb67ea0341fcb986e9555123b022258a92d2bade3674574bf3de7affe93706399d9eb76d04f05213cda8b8e8bb8541533c39f244a9

The resulting multisig script is this: (broken down by OP code)

52 OP_2, meaning you need two signatures
41 push 65 bytes
04c96a8b79aff49f36766b7827308bb5d6dc031e4e9112b785201a9a61821d2a336dbb7fa69f44c2dc76dee8fa7ed8fee2958f4a86a3dbb7ebf3eeb790cd464db9
41 push 65 bytes
04fd6c4db8841f7370a0cdc464a58b3e2a0da5b6566e0502a9cf583360bcdd16e8453a0a8da0fba0ff26e40c1f8c55f8cd0ad61988b7d4418b504264be8a9cef59
41 push 65 bytes
04c41b31403f24ef79e9c7dcfb67ea0341fcb986e9555123b022258a92d2bade3674574bf3de7affe93706399d9eb76d04f05213cda8b8e8bb8541533c39f244a9
53 OP_3, meaning there are three public keys
ae OP_CHECKMULTISIG described at https://en.bitcoin.it/wiki/Script

And the page tells me the address for it is 3K6sEDqXaSFKjcq8PUKNsGbxXjBR8QmBWr

The hash of this script, along with a version number (to make the starting character 3) and checksum (to ensure that a misentering of data is not likely to go through) is what makes up the multisig address:

base58-encode: [one-byte version][20-byte hash][4-byte checksum]

You can verify this by comparing the hash160 value shown at https://blockchain.info/address/3K6sEDqXaSFKjcq8PUKNsGbxXjBR8QmBWr and the result of the following short C# program: they are both befcdceed8cbf0d74d9d58bf8e30ce027e8a9b56

var data = new byte[] { 0x52, 0x41, 0x04, 0xc9, 0x6a, 0x8b, 0x79, 0xaf, 0xf4, 0x9f, 0x36, 0x76, 0x6b, 0x78, 0x27, 0x30, 0x8b, 0xb5, 0xd6, 0xdc, 0x03, 0x1e, 0x4e, 0x91, 0x12, 0xb7, 0x85, 0x20, 0x1a, 0x9a, 0x61, 0x82, 0x1d, 0x2a, 0x33, 0x6d, 0xbb, 0x7f, 0xa6, 0x9f, 0x44, 0xc2, 0xdc, 0x76, 0xde, 0xe8, 0xfa, 0x7e, 0xd8, 0xfe, 0xe2, 0x95, 0x8f, 0x4a, 0x86, 0xa3, 0xdb, 0xb7, 0xeb, 0xf3, 0xee, 0xb7, 0x90, 0xcd, 0x46, 0x4d, 0xb9, 0x41, 0x04, 0xfd, 0x6c, 0x4d, 0xb8, 0x84, 0x1f, 0x73, 0x70, 0xa0, 0xcd, 0xc4, 0x64, 0xa5, 0x8b, 0x3e, 0x2a, 0x0d, 0xa5, 0xb6, 0x56, 0x6e, 0x05, 0x02, 0xa9, 0xcf, 0x58, 0x33, 0x60, 0xbc, 0xdd, 0x16, 0xe8, 0x45, 0x3a, 0x0a, 0x8d, 0xa0, 0xfb, 0xa0, 0xff, 0x26, 0xe4, 0x0c, 0x1f, 0x8c, 0x55, 0xf8, 0xcd, 0x0a, 0xd6, 0x19, 0x88, 0xb7, 0xd4, 0x41, 0x8b, 0x50, 0x42, 0x64, 0xbe, 0x8a, 0x9c, 0xef, 0x59, 0x41, 0x04, 0xc4, 0x1b, 0x31, 0x40, 0x3f, 0x24, 0xef, 0x79, 0xe9, 0xc7, 0xdc, 0xfb, 0x67, 0xea, 0x03, 0x41, 0xfc, 0xb9, 0x86, 0xe9, 0x55, 0x51, 0x23, 0xb0, 0x22, 0x25, 0x8a, 0x92, 0xd2, 0xba, 0xde, 0x36, 0x74, 0x57, 0x4b, 0xf3, 0xde, 0x7a, 0xff, 0xe9, 0x37, 0x06, 0x39, 0x9d, 0x9e, 0xb7, 0x6d, 0x04, 0xf0, 0x52, 0x13, 0xcd, 0xa8, 0xb8, 0xe8, 0xbb, 0x85, 0x41, 0x53, 0x3c, 0x39, 0xf2, 0x44, 0xa9, 0x53, 0xae, };
var sha256 = System.Security.Cryptography.HashAlgorithm.Create("SHA256");
var ripe = System.Security.Cryptography.HashAlgorithm.Create("RIPEMD160");
Console.WriteLine(string.Join("", ripe.ComputeHash(sha256.ComputeHash(data)).Select(x=>x.ToString("X2"))).ToLower());

Then when you want to pay that address, you use pay-to-script-hash output instead of a pay-to-pubkey-hash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.