use of com.github.zhenwei.core.crypto.params.CramerShoupParameters in project LinLong-Java by zhenwei1108.
the class CramerShoupKeyPairGenerator method generateKeyPair.
public AsymmetricCipherKeyPair generateKeyPair() {
CramerShoupParameters csParams = param.getParameters();
CramerShoupPrivateKeyParameters sk = generatePrivateKey(param.getRandom(), csParams);
CramerShoupPublicKeyParameters pk = calculatePublicKey(csParams, sk);
sk.setPk(pk);
return new AsymmetricCipherKeyPair(pk, sk);
}
use of com.github.zhenwei.core.crypto.params.CramerShoupParameters in project LinLong-Java by zhenwei1108.
the class CramerShoupParametersGenerator method generateParameters.
/**
* which generates the p and g values from the given parameters, returning the
* CramerShoupParameters object.
* <p>
* Note: can take a while...
* </p>
*
* @return a generated CramerShoupParameters object.
*/
public CramerShoupParameters generateParameters() {
//
// find a safe prime p where p = 2*q + 1, where p and q are prime.
//
BigInteger[] safePrimes = ParametersHelper.generateSafePrimes(size, certainty, random);
// BigInteger p = safePrimes[0];
BigInteger q = safePrimes[1];
BigInteger g1 = ParametersHelper.selectGenerator(q, random);
BigInteger g2 = ParametersHelper.selectGenerator(q, random);
while (g1.equals(g2)) {
g2 = ParametersHelper.selectGenerator(q, random);
}
return new CramerShoupParameters(q, g1, g2, new SHA256Digest());
}
use of com.github.zhenwei.core.crypto.params.CramerShoupParameters in project LinLong-Java by zhenwei1108.
the class CramerShoupParametersGenerator method generateParameters.
public CramerShoupParameters generateParameters(DHParameters dhParams) {
BigInteger p = dhParams.getP();
BigInteger g1 = dhParams.getG();
// now we just need a second generator
BigInteger g2 = ParametersHelper.selectGenerator(p, random);
while (g1.equals(g2)) {
g2 = ParametersHelper.selectGenerator(p, random);
}
return new CramerShoupParameters(p, g1, g2, new SHA256Digest());
}
Aggregations