本文整理汇总了Java中org.spongycastle.crypto.params.ECKeyGenerationParameters类的典型用法代码示例。如果您正苦于以下问题:Java ECKeyGenerationParameters类的具体用法?Java ECKeyGenerationParameters怎么用?Java ECKeyGenerationParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECKeyGenerationParameters类属于org.spongycastle.crypto.params包,在下文中一共展示了ECKeyGenerationParameters类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ECKey
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair. Point compression is used so the resulting public key will be 33 bytes
* (32 for the co-ordinate and 1 byte to represent the y bit).
*/
public ECKey() {
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(ecParams, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
priv = privParams.getD();
// Unfortunately Bouncy Castle does not let us explicitly change a point to be compressed, even though it
// could easily do so. We must re-build it here so the ECPoints withCompression flag can be set to true.
ECPoint uncompressed = pubParams.getQ();
ECPoint compressed = compressPoint(uncompressed);
pub = compressed.getEncoded();
creationTimeSeconds = Utils.now().getTime() / 1000;
}
示例2: CryptoComponentImpl
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
@Inject
CryptoComponentImpl(SeedProvider r) {
if(!FortunaSecureRandom.selfTest()) throw new RuntimeException();
SecureRandom secureRandom1 = new SecureRandom();
if(LOG.isLoggable(INFO)) {
String provider = secureRandom1.getProvider().getName();
String algorithm = secureRandom1.getAlgorithm();
LOG.info("Default SecureRandom: " + provider + " " + algorithm);
}
SecureRandom secureRandom2 = new FortunaSecureRandom(r.getSeed());
secureRandom = new CombinedSecureRandom(secureRandom1, secureRandom2);
ECKeyGenerationParameters params = new ECKeyGenerationParameters(
PARAMETERS, secureRandom);
agreementKeyPairGenerator = new ECKeyPairGenerator();
agreementKeyPairGenerator.init(params);
signatureKeyPairGenerator = new ECKeyPairGenerator();
signatureKeyPairGenerator.init(params);
agreementKeyParser = new Sec1KeyParser(PARAMETERS, P,
AGREEMENT_KEY_PAIR_BITS);
signatureKeyParser = new Sec1KeyParser(PARAMETERS, P,
SIGNATURE_KEY_PAIR_BITS);
}
示例3: MessageEncrypter
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
MessageEncrypter(SecureRandom random) {
generator = new ECKeyPairGenerator();
generator.init(new ECKeyGenerationParameters(PARAMETERS, random));
parser = new Sec1KeyParser(PARAMETERS, MESSAGE_KEY_BITS);
KeyEncoder encoder = new PublicKeyEncoder();
ephemeralGenerator = new EphemeralKeyPairGenerator(generator, encoder);
ephemeralParser = new PublicKeyParser(PARAMETERS);
}
示例4: ECKey
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair with the given {@link SecureRandom}
* object. Point compression is used so the resulting public key will be 33
* bytes (32 for the co-ordinate and 1 byte to represent the y bit).
*/
public ECKey(SecureRandom secureRandom) {
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(CURVE, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
priv = privParams.getD();
pub = new LazyECPoint(CURVE.getCurve(), pubParams.getQ().getEncoded(true));
creationTimeSeconds = CryptoUtils.currentTimeSeconds();
}
示例5: generateECKey
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair. Point compression is used so the resulting public key will be 33 bytes
* (32 for the co-ordinate and 1 byte to represent the y bit).
*/
public static ECKey generateECKey(SecureRandom secureRandom) {
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(CURVE, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
BigInteger priv = privParams.getD();
boolean compressed = true;
ECKey ecKey = new ECKey(priv, pubParams.getQ().getEncoded(compressed));
// ecKey.setCreationTimeSeconds(Utils.currentTimeSeconds());
return ecKey;
}
示例6: generateECKey
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair. Point compression is used so the resulting public key will be 33 bytes
* (32 for the co-ordinate and 1 byte to represent the y bit).
*/
public static ECKey generateECKey(SecureRandom secureRandom) {
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(CURVE, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
BigInteger priv = privParams.getD();
boolean compressed = true;
ECKey ecKey = new ECKey(priv, pubParams.getQ().getEncoded(compressed));
ecKey.setCreationTimeSeconds(Utils.currentTimeSeconds());
return ecKey;
}
示例7: ECKey
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair with the given {@link SecureRandom} object. Point compression is used so the
* resulting public key will be 33 bytes (32 for the co-ordinate and 1 byte to represent the y bit).
*/
public ECKey(SecureRandom secureRandom) {
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(CURVE, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
priv = privParams.getD();
pub = CURVE.getCurve().decodePoint(pubParams.getQ().getEncoded(true));
}
示例8: ECKeyPair
import org.spongycastle.crypto.params.ECKeyGenerationParameters; //导入依赖的package包/类
/**
* Generates an entirely new keypair.
* */
public ECKeyPair()
{
ECKeyPairGenerator generator = new ECKeyPairGenerator();
ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(ecParams, secureRandom);
generator.init(keygenParams);
AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
priv = privParams.getD();
pub = pubParams.getQ().getEncoded();// The public key is an encoded point on the elliptic curve. It has no meaning independent of the curve.
}