private BigInteger RandomPrimeMSBSet(int bits) { if (bits <= 1) { throw new ArithmeticException("No primes with this bitcount"); } BigInteger limit = ((BigInteger)1) << bits; while (true) { var p = this.NextProbablePrime(BigIntegerHelper.SetBit(BigIntegerHelper.RandomIntBits(bits - 1), bits - 1)); if (p < limit) { return(p); } } }
/* * Re-randomization. */ BigInteger reRandomize(BigInteger cipher) { BigInteger r = BigIntegerHelper.RandomIntBits(DGK_BLINDING_T); return(cipherAdd(cipher, cipherMul(h, r))); }