本文整理汇总了Java中org.bouncycastle.crypto.ec.ECNewPublicKeyTransform类的典型用法代码示例。如果您正苦于以下问题:Java ECNewPublicKeyTransform类的具体用法?Java ECNewPublicKeyTransform怎么用?Java ECNewPublicKeyTransform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECNewPublicKeyTransform类属于org.bouncycastle.crypto.ec包,在下文中一共展示了ECNewPublicKeyTransform类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import org.bouncycastle.crypto.ec.ECNewPublicKeyTransform; //导入依赖的package包/类
private void doTest(ECPrivateKeyParameters priKey, ParametersWithRandom pRandom, BigInteger value)
{
ECPoint data = priKey.getParameters().getG().multiply(value);
ECEncryptor encryptor = new ECElGamalEncryptor();
encryptor.init(pRandom);
ECPair pair = encryptor.encrypt(data);
ECKeyPairGenerator ecGen = new ECKeyPairGenerator();
ecGen.init(new ECKeyGenerationParameters(priKey.getParameters(), new SecureRandom()));
AsymmetricCipherKeyPair reEncKP = ecGen.generateKeyPair();
ECPairTransform ecr = new ECNewPublicKeyTransform();
ecr.init(reEncKP.getPublic());
ECPair srcPair = pair;
// re-encrypt the message portion
pair = ecr.transform(srcPair);
ECDecryptor decryptor = new ECElGamalDecryptor();
decryptor.init(priKey);
// decrypt out the original private key
ECPoint p = decryptor.decrypt(new ECPair(srcPair.getX(), pair.getY()));
decryptor.init(reEncKP.getPrivate());
// decrypt the fully transformed point.
ECPoint result = decryptor.decrypt(new ECPair(pair.getX(), p));
if (!data.equals(result))
{
fail("point pair failed to decrypt back to original");
}
}