Optimizing CounterTools Vanity Generator

@rubensayshi’s excellent cp-vanitygen loops around 3000x per second.
CounterTools’ browser/javascript implementation only makes ~5 loops/sec.

I’m looking for ways to improve CT’s performance, and I’ve found the bottlenecks.

A full loop that lasted 208 ms

  • spent 52 ms on line 181; var HDPrivateKey = bitcore.HDPrivateKey.fromSeed(res, bitcore.Networks.livenet);
  • spent 152 ms on line 183; var derived = HDPrivateKey.derive("m/0'/0/0");
  • spent only 4 ms on everything else

Does someone know a more efficient way?