Post
Topic
Board Development & Technical Discussion
Re: Cuda scripts for point addition , multiplication etc
by
Valera909
on 23/05/2025, 03:49:36 UTC
This code doesn’t actually use the GPU properly — it essentially works like a regular CPU program pretending to be CUDA magic. Let’s break this down atom by atom:

💣 What's wrong here:
1. libsecp256k1 runs on the CPU
cpp
Копировать
Редактировать
secp256k1_ec_pubkey_create(nullptr, &pub, seckey);
→ nullptr is passed instead of a context because secp256k1_context isn't available on the GPU.
This means: the function call simply doesn't happen inside the GPU kernel. And even if it could — it would be invalid.

2. OpenSSL (SHA256 and RIPEMD160) are CPU-only
cpp
Копировать
Редактировать
SHA256_Init(&sha_ctx);
RIPEMD160_Init(&ripemd_ctx);
→ These functions don't compile under CUDA. If you put them inside a __device__ function, you're tricking nvcc. Most likely:

the code won't compile,

or it compiles but runs entirely on the CPU.

3. What actually runs on the GPU? Basically… nothing.
→ The CUDA kernel:

cpp
Копировать
Редактировать
__global__ void kernel_scan(...) { ... }
calls CPU-only functions (which is impossible on GPU), so what really happens is:

either nothing runs at all,

or everything silently runs on the CPU,

or the compiler fakes compilation but the kernel doesn’t execute meaningfully.

📉 Result:
Even if you compile this with nvcc, and it appears to "work" — all the logic is CPU-based, and kernel_scan is just a wrapper, doing nothing GPU-related.

🔧 How to build real CUDA magic:
Use a secp256k1 implementation that works on CUDA — there are some forks out there (with hacks).

Replace OpenSSL with CUDA-native SHA256/RIPEMD160, such as:

cuSHA256 (available as ready-to-use kernels),

your own implementation of H160 (a bit painful, but doable).

Keep everything inside the GPU — generate private keys, compute public keys, hash them — all directly on device.