I am trying to sign a bitcoin transaction in c#. I have 2 bits of code I am trying to complete. I can create a set of private and public keys using Bouncy castle. I can convert this to wallet import format ok.
I can also generate a bitcoin address from the ECDSA public key.
However, I want to sign a transaction and all I have is my private key. I don't want to have to import into a wallet and sign. So how can I generate the public key, given only the private key?
I have found a javascript method that does this:
ecparams.getG().multiply(this.priv).getEncoded();
The only way I've seen in Bouncy Castle is to generate a random pair.
private static AsymmetricCipherKeyPair GenerateKeys(int keySize)
{
ECKeyPairGenerator gen = new ECKeyPairGenerator();
SecureRandom secureRandom = new SecureRandom();
KeyGenerationParameters keyGenParam = new KeyGenerationParameters(secureRandom, keySize);
gen.Init(keyGenParam);
return gen.GenerateKeyPair();
}