11package org .mvnsearch .dotenvx .jwt ;
22
3- import com .nimbusds .jose .crypto .bc .BouncyCastleProviderSingleton ;
43import org .bouncycastle .jce .provider .BouncyCastleProvider ;
54
65import java .security .*;
1211public 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