Java Code Examples for org.spongycastle.crypto.AsymmetricCipherKeyPair#getPublic()
The following examples show how to use
org.spongycastle.crypto.AsymmetricCipherKeyPair#getPublic() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ECKeyPair.java From BlockchainWallet-Crypto with GNU General Public License v3.0 | 6 votes |
public static ECKeyPair createNew(boolean compressed) { ECKeyPairGenerator generator = new ECKeyPairGenerator(); ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(domain, secureRandom); generator.init(keygenParams); AsymmetricCipherKeyPair keypair = generator.generateKeyPair(); ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate(); ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic(); ECKeyPair k = new ECKeyPair(); k.priv = privParams.getD(); k.compressed = compressed; ECPoint multiply = CURVE.getG().multiply(k.priv); k.pub = multiply.getEncoded(false); k.pubComp = multiply.getEncoded(true); return k; }
Example 2
Source File: ECKey.java From bcm-android with GNU General Public License v3.0 | 5 votes |
/** * 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 = Utils.currentTimeSeconds(); }
Example 3
Source File: ECKey.java From green_android with GNU General Public License v3.0 | 5 votes |
/** * 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 = Utils.currentTimeSeconds(); }
Example 4
Source File: Cryptograph.java From SightRemote with GNU General Public License v3.0 | 5 votes |
public static KeyPair generateRSAKey() { RSAKeyPairGenerator generator = new RSAKeyPairGenerator(); generator.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537), new SecureRandom(),2048, 8)); AsymmetricCipherKeyPair ackp = generator.generateKeyPair(); KeyPair keyPair = new KeyPair(); keyPair.privateKey = (RSAPrivateCrtKeyParameters) ackp.getPrivate(); keyPair.publicKey = (RSAKeyParameters) ackp.getPublic(); return keyPair; }
Example 5
Source File: ECKey.java From nuls with MIT License | 5 votes |
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 = pubParams.getQ(); creationTimeSeconds = System.currentTimeMillis(); }
Example 6
Source File: Cryptograph.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
public static KeyPair generateRSAKey() { RSAKeyPairGenerator generator = new RSAKeyPairGenerator(); generator.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537), new SecureRandom(), 2048, 8)); AsymmetricCipherKeyPair ackp = generator.generateKeyPair(); KeyPair keyPair = new KeyPair(); keyPair.privateKey = (RSAPrivateCrtKeyParameters) ackp.getPrivate(); keyPair.publicKey = (RSAKeyParameters) ackp.getPublic(); return keyPair; }
Example 7
Source File: ECKey.java From GreenBits with GNU General Public License v3.0 | 5 votes |
/** * 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 = Utils.currentTimeSeconds(); }
Example 8
Source File: ECKey.java From bitherj with Apache License 2.0 | 5 votes |
/** * 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; }
Example 9
Source File: ECKey.java From ethereumj with MIT License | 5 votes |
/** * 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)); }
Example 10
Source File: ECKeyPair.java From bitseal with GNU General Public License v3.0 | 5 votes |
/** * 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. }