bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
92 stars 55 forks source link

use bn/elliptic for JS binding #11

Closed dcousens closed 6 years ago

dcousens commented 6 years ago

The question remains whether I add another commit to use the .sign and .verify as provided by elliptic. AFAIK, the verify employs gmaxwell's trick, so that would be nice to have.

For .sign though, we'd have to rely on a non-readable form (IMHO) of RFC6979... or provide it as is with a nonceFn. I'll measure it for comparison.

The fact this dropped in 1 to 1 is an absolutely amazing feat for readability/documentation.

dcousens commented 6 years ago

10.18x speed-up

This PR

1..100108
# tests 100108
# pass  100108

# ok

real    0m36.988s
user    0m37.879s
sys     0m0.746s

Master

1..100108
# tests 100108
# pass  100108

# ok

real    6m16.218s
user    6m15.566s
sys     0m1.619s
dcousens commented 6 years ago

@jprichardson

dcousens commented 6 years ago

@junderw browserify/web is easy enough, but what about React... know any libs that can emulate that env?

dcousens commented 6 years ago

Quantitatively, the use of Maxwells trick gave less than 1% speedup in my tests (may even be noise). I'll leave that to another PR if necessary, but, I'm happy with this as-is.

dcousens commented 6 years ago

Released as v0.2.0