Sort:  

Hi, there are several popular implementations of secp256k1:

The fastest implementation is https://github.com/bitcoin-core/secp256k1/. This is achieved by the fact that the low-level library written on C using inline Assembly, Boolean logic, with minimum of method calls and memory allocate.

How can we use C code in C#:

  • use mechanism P/Invoke in order to connect C assembly, but this mechanism has several drawbacks including lowering of the performance, as well as inconvenience when connecting to different solutions and architectures (like Android, iOS). Of the benefits - when you change the C source code you just need to replace the old assembly with a new one.
  • translate the C code to C#. In view of the affinity of these languages the task of translation is relatively simple (depends of code size and there are still small differences to consider). This method has one drawback - when you change the original library, you must manually correct the C# code (which in this case plays no role, because the source library is already tested and is almost constant). In this case we get the winnings in speed (since there is no P/Invoke), receive managed code that can assemble universal cross-platform build and collect in nuget package.