bitpay/bitcore — pull request #409 by ryanxcharles (2014-07-06 01:48:09+00:00)
Title: WIP: Replace bignumber.js+cryptojs with bn.js+elliptic+hash.js

I've replaced all of the bignum and elliptic curve crypto in the browser with @indutny's bn.js and elliptic, and also replaced our ripemd160 implementation with his hash.js. The result is much faster and much smaller code.

The mocha browser tests on master take about 45s on my computer. With this PR, they take 17s.

The Copay mocha browser tests, which heavily use bitcore, take 85s with bitcore master. With this PR, they take 22s.

Furthermore, the browser bundle is much smaller with this PR. On master, it is 350kb. With this PR, it is a mere 115kb.

So this PR, roughly speaking, makes bitcore 2.5 times faster and 3 times smaller. And that is actually an underestimate, since that speed test is on all tests, much of which have nothing to do with the changes. On sensitive parts of the code:

HierarchicalKey tests on master take 3.85s, and on this PR take 0.77s. So they are 5 times faster.

TransactionBuilder tests take 25s on master, and 8s on this PR. So they are 3 times faster.

Grepping for "Key" results in a bunch of sensitive tests that take 8s on master and 1.5s on this PR. So they are 4 times faster.