org.spongycastle.jcajce.provider.asymmetric.ec.BCECPublicKey Java Examples
The following examples show how to use
org.spongycastle.jcajce.provider.asymmetric.ec.BCECPublicKey.
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: ECKeySecp256k1.java From aion with MIT License | 6 votes |
/** * Generate a new keypair using the given Java Security Provider. * * <p>All private key operations will use the provider. */ public ECKeySecp256k1(Provider provider, SecureRandom secureRandom) { this.provider = provider; final KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance(provider, secureRandom); final KeyPair keyPair = keyPairGen.generateKeyPair(); this.privKey = keyPair.getPrivate(); final PublicKey pubKey = keyPair.getPublic(); if (pubKey instanceof BCECPublicKey) { pub = ((BCECPublicKey) pubKey).getQ(); } else if (pubKey instanceof ECPublicKey) { pub = extractPublicKey((ECPublicKey) pubKey); } else { throw new AssertionError( "Expected Provider " + provider.getName() + " to produce a subtype of ECPublicKey, found " + pubKey.getClass()); } }
Example #2
Source File: ECKey.java From gsc-core with GNU Lesser General Public License v3.0 | 6 votes |
/** * Generate a new keypair using the given Java Security Provider. * * <p>All private key operations will use the provider. */ public ECKey(Provider provider, SecureRandom secureRandom) { this.provider = provider; final KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance(provider, secureRandom); final KeyPair keyPair = keyPairGen.generateKeyPair(); this.privKey = keyPair.getPrivate(); final PublicKey pubKey = keyPair.getPublic(); if (pubKey instanceof BCECPublicKey) { pub = ((BCECPublicKey) pubKey).getQ(); } else if (pubKey instanceof ECPublicKey) { pub = extractPublicKey((ECPublicKey) pubKey); } else { throw new AssertionError( "Expected Provider " + provider.getName() + " to produce a subtype of ECPublicKey, found " + pubKey.getClass()); } }
Example #3
Source File: ECKey.java From wkcwallet-java with Apache License 2.0 | 6 votes |
/** * Generate a new keypair using the given Java Security Provider. * * All private key operations will use the provider. */ public ECKey(Provider provider, SecureRandom secureRandom) { this.provider = provider; final KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance(provider, secureRandom); final KeyPair keyPair = keyPairGen.generateKeyPair(); this.privKey = keyPair.getPrivate(); final PublicKey pubKey = keyPair.getPublic(); if (pubKey instanceof BCECPublicKey) { pub = ((BCECPublicKey) pubKey).getQ(); } else if (pubKey instanceof ECPublicKey) { pub = extractPublicKey((ECPublicKey) pubKey); } else { throw new AssertionError("Expected Provider " + provider.getName() + " to produce a subtype of ECPublicKey, found " + pubKey.getClass()); } }
Example #4
Source File: ECKey.java From tron-wallet-android with Apache License 2.0 | 6 votes |
/** * Generate a new keypair using the given Java Security Provider. <p> All private key operations * will use the provider. */ public ECKey(Provider provider, SecureRandom secureRandom) { this.provider = provider; final KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance (provider, secureRandom); final KeyPair keyPair = keyPairGen.generateKeyPair(); this.privKey = keyPair.getPrivate(); final PublicKey pubKey = keyPair.getPublic(); if (pubKey instanceof BCECPublicKey) { pub = ((BCECPublicKey) pubKey).getQ(); } else if (pubKey instanceof ECPublicKey) { pub = extractPublicKey((ECPublicKey) pubKey); } else { throw new AssertionError( "Expected Provider " + provider.getName() + " to produce a subtype of ECPublicKey, found " + pubKey.getClass()); } }
Example #5
Source File: ECKey.java From asf-sdk with GNU General Public License v3.0 | 6 votes |
/** * Generate a new keypair using the given Java Security Provider. * * All private key operations will use the provider. */ public ECKey(Provider provider, SecureRandom secureRandom) { this.provider = provider; KeyPairGenerator keyPairGen = ECKeyPairGenerator.getInstance(provider, secureRandom); KeyPair keyPair = keyPairGen.generateKeyPair(); this.privKey = keyPair.getPrivate(); PublicKey pubKey = keyPair.getPublic(); if (pubKey instanceof BCECPublicKey) { pub = ((BCECPublicKey) pubKey).getQ(); } else if (pubKey instanceof ECPublicKey) { pub = extractPublicKey((ECPublicKey) pubKey); } else { throw new AssertionError("Expected Provider " + provider.getName() + " to produce a subtype of ECPublicKey, found " + pubKey.getClass()); } }
Example #6
Source File: KeyCodec.java From UAF with Apache License 2.0 | 5 votes |
/** * UAF_ALG_KEY_ECC_X962_RAW 0x100 * Raw ANSI X9.62 formatted Elliptic Curve public key [SEC1]. * <p> * I.e. [0x04, X (32 bytes), Y (32 bytes)]. Where the byte 0x04 denotes the uncompressed point compression method. * * @param pub - Public Key * @return bytes * @throws IOException */ public static byte[] getPubKeyAsRawBytes(PublicKey pubKey) { try { if (pubKey instanceof java.security.interfaces.ECPublicKey) { return getJCEKeyAsRawBytes((java.security.interfaces.ECPublicKey) pubKey); } return KeyCodec.getBCKeyAsRawBytes((BCECPublicKey) pubKey); } catch(IOException e) { throw new RuntimeException(e); } }
Example #7
Source File: KeyCodec.java From UAF with Apache License 2.0 | 4 votes |
public static byte[] getBCKeyAsRawBytes(String base64EncodedPubKey) throws GeneralSecurityException, IOException { return getBCKeyAsRawBytes((BCECPublicKey) getPubKey(android.util.Base64.decode(base64EncodedPubKey, android.util.Base64.DEFAULT))); }