If you want a vanity address then use the project here:
Source:
https://github.com/samr7/vanitygenANN:
https://bitcointalk.org/index.php?topic=25804.0It is fast and tested.
If you want to create your own code then I'm afraid you have to write it from scratch if you want it to be fast. NBitcoin has a lot of bottlenecks that is slowing the process down. That library was not meant to be used for speed.
I can't understand parts of your code. For instance what is
currentAddress in part 1, is it public key? And why perform double sha256 on it?
Also try
Buffer.BlockCopy it is slightly faster.
In your part 2 the base58 encoding is entirely unnecessary since BitcoinSecret constructor will decode it again!
https://github.com/MetacoSA/NBitcoin/blob/master/NBitcoin/Base58Data.cs#L63Create a new instance of Key and pass that in the ctor instead:
https://github.com/MetacoSA/NBitcoin/blob/d21f31311180041a15524588b443767cf95951ec/NBitcoin/Key.cs#L48-L62Your part 3 has multiple cases where it slows down. The ECC which is unavoidable to convert private to public key (although some methods of scalar multiplications are way faster than others, I believe NBitcoin uses bouncy castle for that which will most probably use a fixed time method. This can be improved if you care to rewrite ECC but I wouldn't recommend it), then another base58
decode and check of the input which can be avoided if you code it from scratch yourself and another base58 encode which may be avoided but I am not sure, have to really check how vanity address creation works under the hood.
P.S. All the Base58 encode/decode functions are slow because they are all using BigInteger which will slow things down drastically (specifically 6 times slower based on my tests)