 # @param {number} nbits The number of bits in the prime
 # @param {number} iters The number of time to run Miller-Rabin
 # @param {callback} Callback with the {BigInteger} result
-#
-random_prime = (nbits, iters, cb) ->
+# @param {function} progress_hook A hook to call to update progress
+#
+random_prime = (nbits, iters, cb, progress_hook) ->
   srf = new StrongRandomFountain()
   sieve = [1,2]
   go = true

  recharge : (cb) ->
    await prng.generate Math.floor(7000/8), defer tmp
    @buf = tmp.to_buffer()
    console.log "Generate ->"
    console.log @buf
    cb()
  nextBytes : (v) ->
    throw new Error "need a recharge!" unless @buf?

    for sp,i in small_primes
      while (@mods[i] + @inc >= sp)
        @mods[i] -= sp
        if (@mods[i] + @inc) is 0
          return true 
    return false

  #-----------------------
