/**
 * AsyncCrypto is a module for doing cryptography with an asynchronous
 * interface with web workers or child process forks. It does not actually
 * support web workers or child process forks yet, but it is designed so that
 * we can start putting the cryptography behind a common, asynchronous
 * interface that can be updated to use web workers and child process forks at
 * a later date.
 *
 * TODO: The way to integrate web workers is as follows. Declare a separate
 * "worker" class that manages the workers, i.e., it can spawn new workers, and
 * respawn them if they crash, and shut them down if necessary. If this worker
 * class has not already been initialized, then we initialize it. Otherwise,
 * use the already initialized worker class.
 */
var Workers = require('./workers')

var workers = false

function AsyncCrypto () {
  if (!(this instanceof AsyncCrypto)) {
    return new AsyncCrypto()
  }
  if (!workers) {
    workers = Workers()
    this.workers = workers
  }
  this.workers = workers
}

AsyncCrypto.prototype.sha256 = function sha256 (databuf) {
  return workers.sha256(databuf)
}

AsyncCrypto.prototype.PublicKeyFromPrivateKey = function (privateKey) {
  return workers.publicKeyFromPrivateKey(privateKey)
}

AsyncCrypto.prototype.AddressFromPublicKey = function (publicKey) {
  return workers.addressFromPublicKey(publicKey)
}

AsyncCrypto.prototype.sign = function (hash, privateKey, endian) {
  return workers.sign(hash, privateKey, endian)
}

module.exports = AsyncCrypto

@@ -102,407 +102,105 @@
 ers 
-or child process forks. It does not actually%0A * support web workers or child process forks yet, but it is designed so that%0A * we can start putting the cryptography behind a common, asynchronous%0A * interface that can be updated to use web workers and child process forks at%0A * a later date.%0A *%0A * TODO: The way to integrate web workers is as follows. Declare a separate%0A * %22worker%22 class that
+(browser) or child process forks (node). It uses%0A * the workerpool module to automatically
  manage
-s
  the
@@ -211,245 +211,92 @@
 kers
-, i.e., it can spawn new workers, and%0A * respawn them if they crash, and shut them down if necessary. If this worker%0A * class has not already been initialized, then we initialize it. Otherwise,%0A * use the already initialized worker class
+ with an interface%0A * isomorphic between node and a browser (i.e., it works in both)
 .%0A *

update comment to reflect working workers