Over the past while I've been coding libraries that will help me get Bitwasp ready to implement multisig and bip32. Finally I've achieved just that. The libraries are currently on Github, in a repository I use for testing multisignature transactions.
https://github.com/Bit-Wasp/multisigBIP32https://github.com/Bit-Wasp/multisig/blob/master/application/libraries/BIP32.phpThe main interesting one is the BIP32 library - there hasn't been an implementation of this in PHP before, so I hope this is useful for others. It has functions for master key creation, and the child derivation, along with other helper functions, such as a build_key function to make dealing with the CKD function much easier, build_address which sits on top of this, and to convert from extended private to public keys.
Writing this was pretty fun, the CKD is a recursive function which, when it realizes that a generated key is invalid, will call itself again with (child number+1) to generate a valid key. This has what, 1 : 10^127 chances of occuring? but it's all taken care of anyway, and once the recursive function is done, it returns the extended key, and a human readable string describing the address (in case it DID hit an invalid key)
Out of sheer novelty it supports both bitcoin and dogecoin (magic bytes for dogecoin extended key were taken from bip32.org), although if someone wants to post litecoin's testnet/mainnet public/private key bytes, as well as the pay-to-pubkey-hash address version bytes, please do and I'll add these.
MultisigThis part requires bitcoind, but the repository can be pulled and pointed to a running bitcoind to facilitate multisig transactions. The code is pretty much ready to go with processing escrow transactions (2 of 2 wallets with autosigned spending transactions, or 2of3 signature escrow transactions). If you're setting up a 2of3 site you should really generate the 'trusted 3rd party' keys using electrum or bip32 and sign them elsewhere, as by default it imports the key so it can sign the transaction immediately for testing purposes.
Bitcoin Libraryhttps://github.com/Bit-Wasp/multisig/blob/master/application/libraries/BitcoinLib.phpA while ago I was playing with theymos' library, and have over time recoded most of it. I've added a few functions to handle compression/decompression of public keys, and other bits and pieces which should help handling these.
Electrumhttps://github.com/Bit-Wasp/multisig/blob/master/application/libraries/Electrum.phpI've written a library that handles creation of electrum seeds, generating the master public key, and derivation of private keys/public keys. Not much to see here, but maybe it'll help someone.
Update 1:
There's a new example script showing how addresses should be derived when doing multisig when you have 3 extended keys. Later on I'm going to set up the tests so they can be called through the web browser, and also then will have the multi signature address generation.
I have also started adding support for passing a tuple containing (base58_extended_key, definition like "m/0'/1") around, instead of just the extended key. This is so the functions can be used several times while accurately keeping track of the sequence numbers of the key, so if you do build_key, and subsequently to build_key, you aren't just left with the definition that was performed in the CKD.
Or maybe i'll work on refactoring the Bitcoin API library.