I am using the Coinbase Multisig Vault and would like to build something similar that is able to replicate the entire HDM wallet using bitcore instead of bitcoinjs. The idea is: input xpubs, output addresses. I would eventually like to do this for the Copay wallet as well.
But I don’t think I am deriving the public keys correctly. This is how I do it: on the bitcore playground I input each xpub into http://bitcore.io/playground/#/hdkeys and then copy and paste the m/0 derived public key into http://bitcore.io/playground/#/multisig. When I do this for
I get derived public keys
And then I paste that into the multisig page with “2-of-3” selected and out comes address
which does not match the
in the Coinbase tool
Am I doing this correctly? It worked on Coinkite.
I believe the difference lies in that coinbase is using uncompressed pubkeys. If you use the uncompressed versions of your 3 pubkeys:
Then it gives the address you are asking for.
Most services (e.g. bitgo, bip32.org etc) use the compressed pubkey to create a multisig redeem script because you can pack more pubkeys into the script (limit 500 bytes iirc)
Ah thank you so much. There’s no way I would have figured that out unless I knew the bitcoin scripting language and what arguments it accepted for public keys.
For anyone who runs into this problem into the future, here is a quick way to generate uncompressed public keys using bitcore!
var pub = new bitcore.HDPublicKey('xpub661MyMwAqRbcEk2YrSM37a5skePAXy1CDyyKKBbVBvu6BxKqGb4C7WMFzrwEFHV3b9gQHy9oQVAf19Uw3SG5by68bM22HsHgC7zEZCr1EsC');
var derivedHdPublicKey = pub.derive('m/0');
var derivedPublicKey = derivedHdPublicKey.publicKey;
/* Derive bitcoin uncompressed public key from compressed public key */
'04' + derivedPublicKey.point.x.toString('hex') + derivedPublicKey.point.y.toString('hex')