Author

Topic: ecctools - a small collection of tools written in C (Read 714 times)

copper member
Activity: 1330
Merit: 899
🖤😏
Many examples are written in the repository ecctools.

Alberto already provided couple of examples for each program Wink
I just read WP's page, there was only 1 example, since Alberto and WP  share the same topic, I had to ask it here, you could have said that when I asked you via PM. Thanks though, let the never ending division begin! 😉
member
Activity: 194
Merit: 14
Many examples are written in the repository ecctools.

Alberto already provided couple of examples for each program Wink
copper member
Activity: 1330
Merit: 899
🖤😏
Is there any example command to use modmath, keydivision etc for windows? Appreciate a reply.
full member
Activity: 1162
Merit: 237
Shooters Shoot...
Hi WanderingPhilospher,

I just noticed that you only compiled 2 tools out of 9 tools that Alberto developed in his ecctools

Could you please help us compile others tools for us windows users?

Thank you, and Goodluck hunting for #130!

I could not get them all to compile.

https://github.com/WanderingPhilosopher/Windows-ECC-Tools/releases/tag/v2.0
member
Activity: 194
Merit: 14
Hi WanderingPhilospher,

I just noticed that you only compiled 2 tools out of 9 tools that Alberto developed in his ecctools

Could you please help us compile others tools for us windows users?

Thank you, and Goodluck hunting for #130!
hero member
Activity: 862
Merit: 662
I just add verifymsg to the reposity

This is a tool to help to vefiry the signatature of a bitcoin message :

Code:
./verifymsg -m 1E9YwDtYf9R29ekNAfbV7MvB4LNv7v3fGa -a 1NChfewU45oy7Dgn51HwkBFSixaTnyakfj -s "HCsBcgB+Wcm8kOGMH8IpNeg0H4gjCrlqwDf/GlSXphZGBYxm0QkKEPhh9DTJRp2IDNUhVr0FhP9qCqo2W0recNM="

The signature match with the address and it is valid

-----BEGIN BITCOIN SIGNED MESSAGE-----
1E9YwDtYf9R29ekNAfbV7MvB4LNv7v3fGa
-----BEGIN BITCOIN SIGNATURE-----
1NChfewU45oy7Dgn51HwkBFSixaTnyakfj
HCsBcgB+Wcm8kOGMH8IpNeg0H4gjCrlqwDf/GlSXphZGBYxm0QkKEPhh9DTJRp2IDNUhVr0FhP9qCqo2W0recNM=
-----END BITCOIN SIGNATURE-----


Also it have some VERBOSE mode -v it give you the calculated publickey of the address, also the values RSZ for this signature.

Code:
./verifymsg -m 1E9YwDtYf9R29ekNAfbV7MvB4LNv7v3fGa -a 1NChfewU45oy7Dgn51HwkBFSixaTnyakfj -s "HCsBcgB+Wcm8kOGMH8IpNeg0H4gjCrlqwDf/GlSXphZGBYxm0QkKEPhh9DTJRp2IDNUhVr0FhP9qCqo2W0recNM=" -v
Final X, Y : 2b0172007e59c9bc90e18c1fc22935e8341f88230ab96ac037ff1a5497a61646 105ecd499fa11dffe894dead6759ab732baf593b6a4da4b7a7294d5afffa02b7
Final R: 2b0172007e59c9bc90e18c1fc22935e8341f88230ab96ac037ff1a5497a61646
Final S: 058c66d1090a10f861f434c9469d880cd52156bd0584ff6a0aaa365b4ade70d3
Final Z: d6a75acdff18b0a8103f867c6cab8c12ec8ac250dfa8dcdb4f89d8e553270115
Calculated address: 1NChfewU45oy7Dgn51HwkBFSixaTnyakfj
Calculated publickey uncompressed: 044e01f16fe203dbfd8110fd636f42e69bd2fa9e0fef913f00554e4412cb1cae070296f95c6b64f3fdcb7ee9dc838f20b992077e839703b3c2c5427e90e5afd0d1
Calculated publickey compressed: 034e01f16fe203dbfd8110fd636f42e69bd2fa9e0fef913f00554e4412cb1cae07

The signature match with the address and it is valid

-----BEGIN BITCOIN SIGNED MESSAGE-----
1E9YwDtYf9R29ekNAfbV7MvB4LNv7v3fGa
-----BEGIN BITCOIN SIGNATURE-----
1NChfewU45oy7Dgn51HwkBFSixaTnyakfj
HCsBcgB+Wcm8kOGMH8IpNeg0H4gjCrlqwDf/GlSXphZGBYxm0QkKEPhh9DTJRp2IDNUhVr0FhP9qCqo2W0recNM=
-----END BITCOIN SIGNATURE-----
member
Activity: 406
Merit: 47
still have some errors when compiling (make)

Code:
keygen.c: In function ‘main’:
keygen.c:152:38: warning: unknown conversion type character ‘\x0a’ in format [-Wformat=]
     fprintf(stderr,"OpenSSL error: %l\n",err);
                                      ^~
keygen.c:152:20: warning: too many arguments for format [-Wformat-extra-args]
     fprintf(stderr,"OpenSSL error: %l\n",err);
                    ^~~~~~~~~~~~~~~~~~~~~
keygen.c:135:4: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
    fread(buffer_key,1,bytes,fd);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
keygen.c:145:4: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
    fread(buffer_key,1,bytes,fd);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
keygen.c:158:4: warning: ignoring return value of ‘getrandom’, declared with attribute warn_unused_result [-Wunused-result]
    getrandom(buffer_key,bytes,GRND_NONBLOCK);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -o sharedsecret sharedsecret.c gmpecc.c util.o sha256.o base58.o rmd160.o -lgmp `libgcrypt-config --cflags --libs`
sharedsecret.c: In function ‘main’:
sharedsecret.c:82:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
  fgets(buffer,1022,stdin);
  ^~~~~~~~~~~~~~~~~~~~~~~~
sharedsecret.c:90:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
  fgets(buffer,1022,stdin);
  ^~~~~~~~~~~~~~~~~~~~~~~~


some I try to fix problems not found file and require file "gmp.h" and file "openssl/rand.h
just random fix

sudo apt-get install  libgmp3-dev
sudo apt install libgcrypt
sudo apt install libgcrypt20-dev
sudo apt install openssl
sudo apt-get install libssl-dev

member
Activity: 406
Merit: 47
I have a problem with compiled all tools on WSL2 ubuntu
can compile success only one is rehashaddress other code is error

Did this tools have a python code version that can be used
keydivision
keymath
modmath
hero member
Activity: 862
Merit: 662
O right the privatekey in WIF format, I will add it later
legendary
Activity: 3346
Merit: 3130
...
I already have a tool for that in the repossitory it is rehashaddress this tool can generate a Endless addresses from a passphrase check the readme for more details.

Basic example:

Code:
$ ./rehashaddress -p bitcointalk -n 1 -m 0
[I] Password: bitcointalk
[I] n: 1
[I] m: 0
Privatekey: 75959c5b70c912201868c26256115fd330ef389dcf93468d33a13a0716ca55e7
Compress publickey: 036c36c67862ee2ff9aac1df60c7a45da6dfdf0dd2ded2acb5a23dec86cdd1ea73
Compress address: 1JrxYDDPLSeocamJCXTPQTQvn2u5Uhgnw5
Uncompress publickey: 046c36c67862ee2ff9aac1df60c7a45da6dfdf0dd2ded2acb5a23dec86cdd1ea73bc4219906bf6c3a676b9151f5841dff2150654801ae1ed5f65665370f8db90f9
Uncompress address: 15Ds7MtbSx8hxC73dojDzMj2WE6jTJHR67

I see mate, you are right, there is the tool but I get confused with the name, but it's what I was looking for.

Now, what you have as Privatekey output is the Secret Exponent, and I don't see the privatekey in the output:

For that same example:
Secret Exponent: 75959c5b70c912201868c26256115fd330ef389dcf93468d33a13a0716ca55e7
Privatekey: 5Ji57mxMqPCo5jKuaQxTv9HYnkjVMYrh2ZieRhMyesiJQeVz2Du

And I think this is important because if we want to import the address to any wallet the right format is the one starting with 5J...
hero member
Activity: 862
Merit: 662
Code:
~/ecctools$ ./addr2rmd
-bash: ./addr2rmd: No such file or directory

Sorry for that I just forget to add the compilation line in the Makefile.

I already update that repository.

It would be nice if you add the passphrase (BrainWallet) option, that way people we can recover or create addresses from words or phrases. A good example of this is:

I already have a tool for that in the repossitory it is rehashaddress this tool can generate a Endless addresses from a passphrase check the readme for more details.

Basic example:

Code:
$ ./rehashaddress -p bitcointalk -n 1 -m 0
[I] Password: bitcointalk
[I] n: 1
[I] m: 0
Privatekey: 75959c5b70c912201868c26256115fd330ef389dcf93468d33a13a0716ca55e7
Compress publickey: 036c36c67862ee2ff9aac1df60c7a45da6dfdf0dd2ded2acb5a23dec86cdd1ea73
Compress address: 1JrxYDDPLSeocamJCXTPQTQvn2u5Uhgnw5
Uncompress publickey: 046c36c67862ee2ff9aac1df60c7a45da6dfdf0dd2ded2acb5a23dec86cdd1ea73bc4219906bf6c3a676b9151f5841dff2150654801ae1ed5f65665370f8db90f9
Uncompress address: 15Ds7MtbSx8hxC73dojDzMj2WE6jTJHR67
legendary
Activity: 3346
Merit: 3130
Great tool mate thanks for sharing it. I would like to request a feature if it's possible.

It would be nice if you add the passphrase (BrainWallet) option, that way people we can recover or create addresses from words or phrases. A good example of this is:

https://brainwalletx.github.io/

On that site we can input the phrase 'bitcointalk', and get the address: 15Ds7MtbSx8hxC73dojDzMj2WE6jTJHR67


That is why I think this would be a great tool for your collection. If you need some help I have a script on bash and python for passphrase and I could share them with you for the C code translation.
member
Activity: 174
Merit: 12
Code:
~/ecctools$ ./addr2rmd
-bash: ./addr2rmd: No such file or directory

Code:
~/ecctools$ make
gcc -O3 -c bloom/bloom.c -o bloom.o
gcc -O3 -c sha256/sha256.c -o sha256.o
gcc -O3 -c base58/base58.c -o base58.o
gcc -O3 -c rmd160/rmd160.c -o rmd160.o
gcc -O3 -c xxhash/xxhash.c -o xxhash.o
#gcc -O3 -c gmpecc.c -o gmpecc.o
gcc -O3 -c util.c -o util.o
gcc -O3 -o rehashaddress rehashaddress.c gmpecc.c util.o sha256.o base58.o rmd160.o -lgmp
gcc -O3 -o calculatefromkey calculatefromkey.c gmpecc.c util.o base58.o sha256.o rmd160.o -lgmp `libgcrypt-config --cflags --libs`
gcc -O3 -o calculatefrompublickey calculatefrompublickey.c util.o base58.o sha256.o rmd160.o -lgmp
gcc -O3 -o keydivision keydivision.c gmpecc.c util.o base58.o sha256.o rmd160.o -lgmp
gcc -O3 -o keymath keymath.c gmpecc.c util.o  base58.o sha256.o rmd160.o -lgmp
gcc -O3 -o modmath  modmath.c gmpecc.c util.o  base58.o sha256.o rmd160.o -lgmp
gcc -O3 -o keygen keygen.c gmpecc.c util.o sha256.o base58.o rmd160.o -lgmp -lcrypto `libgcrypt-config --cflags --libs`
keygen.c: In function ‘main’:
keygen.c:152:38: warning: unknown conversion type character ‘\x0a’ in format [-Wformat=]
  152 |     fprintf(stderr,"OpenSSL error: %l\n",err);
      |                                      ^~
keygen.c:152:20: warning: too many arguments for format [-Wformat-extra-args]
  152 |     fprintf(stderr,"OpenSSL error: %l\n",err);
      |                    ^~~~~~~~~~~~~~~~~~~~~
keygen.c:135:4: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  135 |    fread(buffer_key,1,bytes,fd);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
keygen.c:145:4: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  145 |    fread(buffer_key,1,bytes,fd);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
keygen.c:158:4: warning: ignoring return value of ‘getrandom’, declared with attribute warn_unused_result [-Wunused-result]
  158 |    getrandom(buffer_key,bytes,GRND_NONBLOCK);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -o sharedsecret sharedsecret.c gmpecc.c util.o sha256.o base58.o rmd160.o -lgmp `libgcrypt-config --cflags --libs`
sharedsecret.c: In function ‘main’:
sharedsecret.c:82:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
   82 |  fgets(buffer,1022,stdin);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
sharedsecret.c:90:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
   90 |  fgets(buffer,1022,stdin);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
rm *.o
hero member
Activity: 862
Merit: 662
I know this is hobby project, but you might want to check https://keybase.io/warp as reference if you plan to improve it's security.

Interesting i saw that it use scrypt and pbkdf2.

Code:
s1	=	scrypt(key=(passphrase||0x1), salt=(salt||0x1), N=218, r=8, p=1, dkLen=32)
s2 = pbkdf2(key=(passphrase||0x2), salt=(salt||0x2), c=216, dkLen=32, prf=HMAC_SHA256)
keypair = generate_bitcoin_keypair(s1 ⊕ s2)

I will implement that, one to generate those address and another to forcebrute them.
hero member
Activity: 862
Merit: 662
add in the title something like (for Linux users only)  Wink

Well, yes i usually develop for linux, but the code can be running on windows through the ubuntu shell. Also with Mingw64.

I was able to compile under Windows using Mingw64!!  Cool

That is what i'm talking about Smiley Thanks!

1. For rehashaddress, what hash algorithm do you use?

for now only sha256, but i will add some extra options.

2. Looking at README.md, looks like this tool only support legacy address (address with prefix 1), is it true?

Yes that is true for now, i will plan to add some extra kind of address but i'm still learning and  testing it.

3. You might want to mention version of C (and other dependency/utility), so other people (and yourself in the future) could save some time.

Excellent yes, i will add it in the readme, some times I forget that most users doesn't know linux, also i forget that most user never read the readme LOL


Here is the Windows version:

https://github.com/WanderingPhilosopher/Windows-ECC-Tools
You may want to add the link in your main post so people who use Windows know they can use your program as well.

I will add it, also to the readme in github.

Thanks!
full member
Activity: 1162
Merit: 237
Shooters Shoot...
Here is the Windows version:

https://github.com/WanderingPhilosopher/Windows-ECC-Tools

albert0bsd,

You may want to add the link in your main post so people who use Windows know they can use your program as well.

WP

Edit:  If Windows users wish to compile on their own, I followed this guide  https://www.msys2.org/  to download, install, setup the mingw-w64 GCC. Follow the instructions. Once complete, you can go to the above github page that has my Windows release and download the files and unzip. Open up MSYS MinGW 64-bit, do a cd (change directory) to the folder containing the files. Once there, simply type in make.

Enjoy.
full member
Activity: 1162
Merit: 237
Shooters Shoot...
I was able to compile under Windows using Mingw64!!  Cool
full member
Activity: 1162
Merit: 237
Shooters Shoot...
I will help, but we need to figure out how Windows users can easily compile or at least have a .exe file to run on Windows.

I will try to compile on Windows - Mingw64 using make command. Will post update.

No good with Mingw64 and make command. Same errors as keysubtracter.

Code:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: gmpecc.o:gmpecc.c:(.bss+0x2020): multiple definition of `EC'; C:\msys64\tmp\ccf7PnVf.o:rehashaddress.:(.bss+0x2040): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: gmpecc.o:gmpecc.c:(.bss+0x0): multiple definition of `DoublingG'; C:\msys64\tmp\ccf7PnVf.o:rehashaddress.:(.bss+0x20): first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: gmpecc.o:gmpecc.c:(.bss+0x2000): multiple definition of `G'; C:\msys64\tmp\ccf7PnVf.o:rehashaddress.:(.bss+0x2020): first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:9: default] Error 1



But for Keyhunt, I can create/compile using Mingw64 and using make command.
legendary
Activity: 3472
Merit: 3507
Crypto Swap Exchange
add in the title something like (for Linux users only)  Wink
hero member
Activity: 862
Merit: 662
I made a new repository in github ecctools

This is a small collection of tools that i've made in the past months, most of those tools only do one or two things, those task are or were useful for me in some moments.

Tool lists:

List of tools in this repository

  • keygen
  • sharedsecret
  • rehashaddress
  • calculatefromkey
  • calculatefrompublickey
  • keydivision
  • keymath
  • modmath
  • addr2rmd

I will be updating this list when i add some new codes

I start this topic just to seek ideas, improvements, bug reports, requests.

Regards!
Jump to: