blob: cbfaaaa68d34d2c95d1d6f442977973d97d4616d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package org.spongycastle.crypto.ec;
import java.math.BigInteger;
import java.security.SecureRandom;
import org.spongycastle.math.ec.ECConstants;
class ECUtil
{
static BigInteger generateK(BigInteger n, SecureRandom random)
{
int nBitLength = n.bitLength();
BigInteger k;
do
{
k = new BigInteger(nBitLength, random);
}
while (k.equals(ECConstants.ZERO) || (k.compareTo(n) >= 0));
return k;
}
}
|