Skip to content

Commit

Permalink
Remove registration of bouncy castle as JCE provider
Browse files Browse the repository at this point in the history
Signed-off-by: R-J Lim <[email protected]>
  • Loading branch information
R-J Lim committed Jun 15, 2024
1 parent 4aa96b5 commit 7080867
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions crypto/src/main/java/org/web3j/crypto/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.Security;
import java.security.spec.ECGenParameterSpec;
import java.util.Arrays;

Expand All @@ -40,12 +39,7 @@ public class Keys {
public static final int ADDRESS_LENGTH_IN_HEX = ADDRESS_SIZE >> 2;
static final int PUBLIC_KEY_LENGTH_IN_HEX = PUBLIC_KEY_SIZE << 1;
public static final int PRIVATE_KEY_LENGTH_IN_HEX = PRIVATE_KEY_SIZE << 1;

static {
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider(new BouncyCastleProvider());
}
}
private static final BouncyCastleProvider BC_PROVIDER = new BouncyCastleProvider();

private Keys() {}

Expand All @@ -68,7 +62,7 @@ static KeyPair createSecp256k1KeyPair(SecureRandom random)
NoSuchAlgorithmException,
InvalidAlgorithmParameterException {

KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC");
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", BC_PROVIDER);
ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1");
if (random != null) {
keyPairGenerator.initialize(ecGenParameterSpec, random);
Expand Down

0 comments on commit 7080867

Please sign in to comment.