         y = y.square().mod(n)
         return false if y.compareTo(BigInteger.ONE) is 0
 
+  progress_hook? { what : "mr", i : iter, total : iter, p : n }
   return true
 
 #=================================================================

    await srf.recharge defer()
    p = new BigInteger nbits, srf
    p = p.setBit(0).setBit(nbits-1)
    console.log "Starting from #{p.toString()}"
    p = prime_search p, nbits/2, sieve, iters
    go = (p.compareTo(BigInteger.ZERO) is 0)
    console.log "iter #{i++} -> #{go}"
  cb p

#=================================================================

# @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
# @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
