I'm trying to get PrivateKey Object from 32-byte raw private key that I got by useing getS() method. I used ECDSA secp256k1 algorithm at bouncy castle library to generate a key pair.
Below is the way that I got 32-byte private key in byte array, and I would like to reverse this process to get PrivateKey object from the 32-byte private key.
Can anyone please help me out with this? I'd really appreciate it.
PrivateKey prvKey;
public byte[] getPrivateKey() {
ECPrivateKey ecPrv = (ECPrivateKey) this.prvKey;
byte[] prv = ecPrv.getS().toByteArray();
if (prv[0] == 0) {
byte[] rslt = new byte[prv.length - 1];
System.arraycopy(prv, 1, rslt, 0, prv.length - 1);
return rslt;
} else {
return prv;
}
}