Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: C# or C/C++ code to convert Bitcoin brainwallet to public address
by
pooya87
on 15/06/2023, 04:51:47 UTC
⭐ Merited by ETFbitcoin (1)
You just define the data structure as array of bytes (byte[]), with known length and operate on it as it is.
FWIW Using bytes (ie. 8-bit unsigned integers) is the least efficient way of storing bits and also for performing arithmetic since after all you are performing them on 8 bits at a time whereas bigger primitive types exist that can be used to perform arithmetic on more bits like 32-bit integers (Int32) and 64-bit integers (Int64).

Of course in terms of performance many depends on the CPU architecture and not always using 64 bit type could be faster than using 32 bit type - could be opposite if machine is 32bit.
Regardless of the architecture, using 64-bit types may not always be the best option considering that you have to handle overflow and specifically the multiplication is going to be tough if you are using a 64-bit chunks.
This is why in libsecp256k1 something like the field element is implemented using 64-bit integers but only 52 bits of each chunk is used, the remaining 12 bits are there to handle overflow.