How to create ECDSA keypair (256bit) for bitcoin curve (secp256k1) using spongy castle?

后端 未结 2 827
长情又很酷
长情又很酷 2021-01-18 02:42

Currently, I am creating keyPair using this method

private  KeyPair getKeyPair() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmPa         


        
2条回答
  •  礼貌的吻别
    2021-01-18 02:54

    Your code is already sufficient, and specifying "secp256k1" already sets the correct size. The initialize(int, SecureRandom) method is an alternative to initialize(AlgorithmParameterSpec, SecureRandom); you call one or the other, not both. If you call the one specifying the keysize (say, 256), the BC provider will try to choose a default curve of the right size (for 256, it will be "prime256v1" a.k.a. "P-256" or "secp256r1").

提交回复
热议问题