Hey everyone
Does anyone know if there's a secp256k1 implementation for the CUDA API in C++? I'm trying to figure out how to set up a project in Visual Studio for this.
If anybody has a project already put together, that'd be awesome. My focus is solely on CUDA.
I found some projects like BitCrack and Kangaroo, but honestly, I don't have the C++ skills to sift through the documentation there.
All I want to do is boost the mathematical operations in parallel. So, if you know of any C++ project that works with the secp256k1 library on CUDA, please share it.
Thanks a lot!
Not one that I know of.
The fastest secp256k1 library in existence, libsecp256k1 (Pieter Wuille's brainchild), currently works only on CPU. So, what someone would do from here is find somebody who can port this to CUDA.
It's unlikely the actual operations themselves can be optimized further beyond placing them on blocks and threads, but the ideal way to create a super-fast secp256k1 CUDA implementation, or for any math library really, is to design it so that millions of these numbers can be operated on in parallel.
Someone made a start for OpenCL but it's not as fast as it could be.
Thanks NotATether for the reply
For CUDA, the number library is important for fast transactions, especially in parallel transactions, the CGBN project started in 2019. I'm not sure how useful the CGBN number library would be compared to the large number use in Bitcrack and Kangaroo projects, but there is a table for the duration of mathematical operations.
Project address: https://github.com/NVlabs/CGBN
Is it the right way to make a new secp256K1 library with the CGBN number library on Cuda?
Fastest parts of secp256k1 for CUDA I know of are in https://github.com/JeanLucPons/VanitySearch and https://github.com/JeanLucPons/Kangaroo
Slower, but easier to follow code is in https://github.com/brichard19/BitCrack
All these are heavily optimized for specific tasks, you would need to understand what it does first, and then copy/modify it for your needs.
No. We should not base a CUDA secp256k1 implementation on an arbitrary precision library like GMP or the one you just mentioned, because we don't need all of that precision and bitlength.
Dealing with arbitrary precision numbers deprives us of the opportunity to optimize the code for a specific bitlength. Instead of 4 statements of 64-bit words, now you need a loop, which doesn't optimize well on CUDA, especially when future results inside it depend on previous ones (the loop cannot be unrolled).
I strongly believe that for maximum performance the ideal library would be written from scratch. CUDA doesn't play well with C++ classes so the library would just be a series of global functions plus a type such as secp256k1_t or something.