New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace bignumber.js+cryptojs with bn.js+elliptic+hash.js #409
Conversation
Wow. Nice work Ryan. Congrats. |
Wow. Fantastic!!! On Saturday, July 5, 2014, Coveralls notifications@github.com wrote:
Matías Alejo Garcia |
Woooow! |
:o awesome work both @ryanxcharles and @indutny!!! On Sat, Jul 5, 2014 at 10:48 PM, Ryan X. Charles notifications@github.com
|
We should starting testing copay with this PR. I am really excited about this work! |
...use hash.js, which is already required by elliptic
...and all vendor bundle files.
- fix cmp, mul, div, add, mod, sub functions to take numbers and strings - fix Point class to use common folder correctly
what is happening with Coveralls? On Thu, Jul 10, 2014 at 11:17 PM, Coveralls notifications@github.com
Matías Alejo Garcia |
I keep adding more commits, so it keeps recalculating the coverage. |
...i.e., bignums, numbers, and strings. Also, ensure that if you try to multiply a buffer, it should be exactly 32 bytes. Eventually this "multiply" function will be replaced with a more conventional "mul" function, but not yet.
Replace bignumber.js+cryptojs with bn.js+elliptic+hash.js
I pulled this in. Here's some code you can run to do a performance comparison:
5000 signatures:
So the new crypto is about 20 times faster at performing signatures in the browser. And the browser code now is only about 4 times slower than node/openssl. |
fix link next block if you are on the last block
Handle invalid xpub on wallet join
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.
This replaces the previous PR where I only replaced the bignum code: #406