Skip to content

Commit 10bfa78

Browse files
committed
chore: polishing
1 parent bb0c7fc commit 10bfa78

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

dotenvx-spring-boot/src/main/java/org/mvnsearch/dotenvx/jwt/Secp256k1KeyParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.mvnsearch.dotenvx.jwt;
22

3-
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton;
43
import org.bouncycastle.asn1.sec.SECNamedCurves;
54
import org.bouncycastle.asn1.x9.X9ECParameters;
65
import org.bouncycastle.jce.ECNamedCurveTable;
@@ -20,7 +19,7 @@
2019
public class Secp256k1KeyParser {
2120
static {
2221
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
23-
Security.addProvider(BouncyCastleProviderSingleton.getInstance());
22+
Security.addProvider(new BouncyCastleProvider());
2423
}
2524
}
2625

@@ -45,7 +44,7 @@ public static ECPublicKey parseSecp256k1CompressedPublicKey(byte[] compressedPub
4544
x9ECParameters.getH()
4645
);
4746
ECPublicKeySpec pubSpec = new ECPublicKeySpec(ecPoint, ecParameterSpec);
48-
KeyFactory keyFactory = KeyFactory.getInstance("EC", "BC");
47+
KeyFactory keyFactory = KeyFactory.getInstance("EC", BouncyCastleProvider.PROVIDER_NAME);
4948
return (ECPublicKey) keyFactory.generatePublic(pubSpec);
5049
}
5150

@@ -64,7 +63,7 @@ public static ECPrivateKey parseSecp256k1PrivateKey(byte[] privateKeyBytes) thro
6463
// Create an ECPrivateKeySpec
6564
ECPrivateKeySpec privateKeySpec = new ECPrivateKeySpec(privateKeyValue, ecSpec);
6665
// Get a KeyFactory for EC
67-
KeyFactory keyFactory = KeyFactory.getInstance("EC", "BC");
66+
KeyFactory keyFactory = KeyFactory.getInstance("EC", BouncyCastleProvider.PROVIDER_NAME);
6867
// Generate the PrivateKey object
6968
return (ECPrivateKey) keyFactory.generatePrivate(privateKeySpec);
7069
}

dotenvx-spring-boot/src/main/java/org/mvnsearch/dotenvx/jwt/Secp256k1Signer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.mvnsearch.dotenvx.jwt;
22

3-
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton;
43
import org.bouncycastle.jce.provider.BouncyCastleProvider;
54

65
import java.security.*;
@@ -12,7 +11,7 @@
1211
public class Secp256k1Signer {
1312
static {
1413
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
15-
Security.addProvider(BouncyCastleProviderSingleton.getInstance());
14+
Security.addProvider(new BouncyCastleProvider());
1615
}
1716
}
1817

@@ -25,7 +24,7 @@ public class Secp256k1Signer {
2524
*/
2625
public static byte[] signData(byte[] data, PrivateKey privateKey)
2726
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException {
28-
Signature signature = Signature.getInstance("SHA256withECDSA", "BC");
27+
Signature signature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME);
2928
signature.initSign(privateKey);
3029
signature.update(data);
3130
return signature.sign();
@@ -41,7 +40,7 @@ public static byte[] signData(byte[] data, PrivateKey privateKey)
4140
*/
4241
public static boolean verifySignature(byte[] data, byte[] signatureBytes, PublicKey publicKey)
4342
throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException {
44-
Signature signature = Signature.getInstance("SHA256withECDSA", "BC");
43+
Signature signature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME);
4544
signature.initVerify(publicKey);
4645
signature.update(data);
4746
return signature.verify(signatureBytes);

0 commit comments

Comments
 (0)