How are Bitcoin Addresses generated when using bitaddress.org?
https://github.com/pointbiz/bitaddress.org/blob/master/src/bitcoinjs-lib.eckey.js#L65 seems like a good starting point.

The functionality you are interested in has been taken from https://github.com/bitcoinjs/bitcoinjs-lib, so you might want to have a look there as well.