bitcoinjs/bitcoinjs-lib — pull request #26 by xnova (2014-02-27 01:21:21+00:00)
Title: Address some shortcomings with wallet.js

I've made two commits that enhance Bitcoin.Wallet in two ways:

#1 - The Wallet constructor now takes a "network" parameter, which can be "Bitcoin" or "BitcoinTest". This allows the wallet to generate addresses for testnet, for instance.

#2 - the Wallet constructor also takes a "derivationMethod" parameter, which allows one to specify whether they want public key child derivation, or private key child derivation (https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-functions).

This is important, because (to quote: https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254): "One weakness that may not be immediately obvious, is that knowledge of the extended public key + a private key descending from it is equivalent to knowing the extended private key (i.e., every private and public key) in case public derivation is used. This means that extended public keys must be treated more carefully than regular public keys. This is the reason why accounts at the first level of the default wallet layout use private derivation, so a leak of account-specific (or below) private key never risks compromising the master."

Because of the above, a default of 'private' was chosen. Also, I put this on the constructor (instead of a param on generateAddress) because it didn't seem to make sense to allow the setting to change on a per-address basis, for a given wallet.

Comments on either of these commits welcome. I can tweak something if need be.