Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile on OSX #7

Closed
ghost opened this issue Feb 4, 2021 · 16 comments
Closed

Cannot compile on OSX #7

ghost opened this issue Feb 4, 2021 · 16 comments
Assignees

Comments

@ghost
Copy link

ghost commented Feb 4, 2021

After running make gives me this output:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:145:9: error: conflicting types for 'memset'
errno_t memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
        ^
<command line>:1:29: note: expanded from here
#define memset_s(W,WL,V,OL) memset(W,V,OL)
                            ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:74:7: note: previous declaration is here
void    *memset(void *__b, int __c, size_t __len);
         ^
1 error generated.
make: *** [default] Error 1
@ghost
Copy link
Author

ghost commented Feb 6, 2021

I fixed it by renaming the function in a different way, by the way now if gives me this problem, even after having installed gmp through brew.

Any idea?

MacBook-Pro keyhunt % make
gcc -O3 -c bloom/bloom.c -o bloom.o -I./bloom/murmur2
gcc -O3 -c bloom/murmur2/MurmurHash2.c -o murmurhash2.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 keccak/keccak-tiny.c -o keccak.o -D"memset_b(W,WL,V,OL)=memset(W,V,OL)"
gcc -O3 -c tiny_sha3/sha3.c -o sha3.o
gcc -O3 -c keyhunt.c -o keyhunt.o -lm
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
keyhunt.c:10:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
         ^~~~~~~
1 error generated.
make: *** [default] Error 1

@albertobsd
Copy link
Owner

Sorry to no anwser before, a was a little busy,

can you add the -lgmp at the en of this line?

gcc -O3 -c keyhunt.c -o keyhunt.o -lm -lgmp

I think that is some issue with configuration of you headers directory,

best regards!

@ghost
Copy link
Author

ghost commented Feb 6, 2021

Hi @albertobsd, Thank you for your reply,
Unfortunately didn't change, I read it on stackoverflow that had something to do with the headers and xcode,
I tried to add that flag but nothing..

MacBook-Pro keyhunt % make
gcc -O3 -c bloom/bloom.c -o bloom.o -I./bloom/murmur2
gcc -O3 -c bloom/murmur2/MurmurHash2.c -o murmurhash2.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 keccak/keccak-tiny.c -o keccak.o -D"memset_b(W,WL,V,OL)=memset(W,V,OL)"
gcc -O3 -c tiny_sha3/sha3.c -o sha3.o
gcc -O3 -c keyhunt.c -o keyhunt.o -lm -lgmp
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lgmp: 'linker' input unused [-Wunused-command-line-argument]
keyhunt.c:10:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
         ^~~~~~~
1 error generated.
make: *** [default] Error 1

@albertobsd
Copy link
Owner

Did you install libgmp-dev ?

@ghost
Copy link
Author

ghost commented Feb 6, 2021

Yes, in mac the equivalent is: brew install gmp

@albertobsd
Copy link
Owner

OK, can you see if the file gmp.h exist in this folder?

/usr/local/include

In that case include the next line in the Makefile

-I/usr/local/include -L/usr/local/lib

gcc -O3 -c keyhunt.c -o keyhunt.o -lm -I/usr/local/include -L/usr/local/lib

@ghost
Copy link
Author

ghost commented Feb 6, 2021

It's inside opt

MacBook-Pro include % find /usr /opt -name "gmp.h"

find: /usr/sbin/authserver: Permission denied
/opt/homebrew/include/gmp.h
/opt/homebrew/Cellar/gmp/6.2.1/include/gmp.h

@albertobsd
Copy link
Owner

OK, then change the directory in the -I param and -L param

gcc -O3 -c keyhunt.c -o keyhunt.o -lm -I/opt/homebrew/Cellar/gmp/6.2.1/include/ -L/opt/homebrew/Cellar/gmp/6.2.1/lib/

@ghost
Copy link
Author

ghost commented Feb 6, 2021

We're doing progress but still nothing..

MacBook-Pro keyhunt % make
gcc -O3 -c bloom/bloom.c -o bloom.o -I./bloom/murmur2
gcc -O3 -c bloom/murmur2/MurmurHash2.c -o murmurhash2.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 keccak/keccak-tiny.c -o keccak.o -D"memset_b(W,WL,V,OL)=memset(W,V,OL)"
gcc -O3 -c tiny_sha3/sha3.c -o sha3.o
gcc -O3 -c keyhunt.c -o keyhunt.o -lm -I/opt/homebrew/Cellar/gmp/6.2.1/include/ -L/opt/homebrew/Cellar/gmp/6.2.1/lib/
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/opt/homebrew/Cellar/gmp/6.2.1/lib/' [-Wunused-command-line-argument]
keyhunt.c:71:6: error: conflicting types for 'heapsort'
void heapsort(char  *arr, int int64_t);
     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:309:6: note: previous declaration is here
int      heapsort(void *__base, size_t __nel, size_t __width,
         ^
keyhunt.c:748:62: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                                        fprintf(stderr,"[E] error bloom_init for %u elements\n",bsgs_m);
                                                                                 ~~             ^~~~~~
                                                                                 %llu
keyhunt.c:767:62: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                printf("[+] Init bloom filter for %u elements : %.2f MB\n",bsgs_m,(float)((uint32_t)bloom_bPx.bytes/(uint32_t)1048576));
                                                  ~~                       ^~~~~~
                                                  %llu
keyhunt.c:811:49: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                                printf("[+] Precalculating %u aMP points\n",bsgs_m);
                                                           ~~               ^~~~~~
                                                           %llu
keyhunt.c:825:48: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                        printf("[+] Precalculating %u aMP points\n",bsgs_m);
                                                   ~~               ^~~~~~
                                                   %llu
keyhunt.c:865:48: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                                printf("[+] Precalculating %u bP points\n",bsgs_m);
                                                           ~~              ^~~~~~
                                                           %llu
keyhunt.c:882:47: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                        printf("[+] precalculating %u bP points\n",bsgs_m);
                                                   ~~              ^~~~~~
                                                   %llu
keyhunt.c:898:38: warning: format specifies type 'unsigned int' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                printf("[+] Sorting %u elements\n",bsgs_m);
                                    ~~             ^~~~~~
                                    %llu
keyhunt.c:1174:12: warning: passing 'char *' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between pointers to integer types with different sign
      [-Wpointer-sign]
                shake256(digest, 256,(const uint8_t* ) pkey, length);
                         ^~~~~~
./keccak/keccak-tiny.h:14:1: note: passing argument to parameter here
decshake(256)
^
./keccak/keccak-tiny.h:8:27: note: expanded from macro 'decshake'
  int shake##bits(uint8_t*, size_t, const uint8_t*, size_t);
                          ^
keyhunt.c:1452:30: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
        printf("Testing Keys %lu\n",count);
                             ~~~    ^~~~~
                             %llu
keyhunt.c:1663:30: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
        printf("Testing Keys %lu\n",count);
                             ~~~    ^~~~~
                             %llu
keyhunt.c:1689:23: error: too few arguments to function call, expected 4, have 2
        heapsort(arr,n);
        ~~~~~~~~      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:309:1: note: 'heapsort' declared here
int      heapsort(void *__base, size_t __nel, size_t __width,
^
keyhunt.c:1813:6: error: conflicting types for 'heapsort'
void heapsort(char  *arr, int n)  {
     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:309:6: note: previous declaration is here
int      heapsort(void *__base, size_t __nel, size_t __width,
         ^
keyhunt.c:2270:55: warning: passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'int64_t *' (aka 'long long *') converts between pointers to integer
      types with different sign [-Wpointer-sign]
                                                r = bsgs_searchbinary(bPtable,xpoint_raw,bsgs_m,&j);
                                                                                                ^~
keyhunt.c:1932:81: note: passing argument to parameter 'r_value' here
int bsgs_searchbinary(struct bsgs_xvalue *buffer,char *data,int64_t _N,int64_t *r_value)  {
                                                                                ^
11 warnings and 3 errors generated.
make: *** [default] Error 1

@albertobsd
Copy link
Owner

ok, this is conflic bewteen that heapsort and my custom heapsort, can you find and remplace all the coincidences of the "heapsort" to "heapsort_2" in the keyhunt.c file

Sorry i need to update all my code to solve this, if you can wait some day or two until i solve those things.

best regards!

@ghost
Copy link
Author

ghost commented Feb 6, 2021

It started but it pop out this error now:

MacBook-Pro keyhunt % ./keyhunt -m bsgs -f ../120.txt -r 800000000000000000000000000000:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -t 2
[+] Version 0.1.20210112 BSGS
[+] Setting mode BSGS
[+] Setting 2 threads
[+] Opening file ../120.txt
[+] Added 1 points from file
[+] Setting N up to 17592186044416.
[+] Init bloom filter for 4194304 elements : 7.00 MB
[+] Allocating 128.00 MB for aMP Points
[+] Precalculating 4194304 aMP points
[+] Allocating 160.00 MB for bP Points
[+] precalculating 4194304 bP points
[+] Sorting 4194304 elements
[+] Thread 1: 0000000000000000000000000000000000800000000000000000000000000000
zsh: segmentation fault  ./keyhunt -m bsgs -f ../120.txt -r  -t 2

I changed also the Makefile line btw to: gcc -o keyhunt keyhunt.o base58.o rmd160.o sha256.o bloom.o murmurhash2.o keccak.o -lgmp -lm -lpthread -I/opt/homebrew/Cellar/gmp/6.2.1/include/ -L/opt/homebrew/Cellar/gmp/6.2.1/lib/
otherwise will still prompt some other conflict errors..

Thank you so much anyway @albertobsd!
I'll wait futures updates from you, if you want to bring it also to mac users 👍

@albertobsd
Copy link
Owner

The -r option need a parameter of a range from:to example -r F0000000:FFFFFFFF

if you need a Random is with upper case R this is only -R

@ghost
Copy link
Author

ghost commented Feb 7, 2021

It's not that, something went wrong while doing make...

a@a-MacBook-Pro keyhunt % ./keyhunt -m bsgs -f ../120.txt -R 800000000000000000000000000000:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF     
[+] Version 0.1.20210112 BSGS
[+] Setting mode BSGS
[+] Setting random mode.
[+] Opening file ../120.txt
[+] Added 1 points from file
[+] Setting N up to 17592186044416.
[+] Init bloom filter for 4194304 elements : 7.00 MB
[+] Allocating 128.00 MB for aMP Points
[+] Precalculating 4194304 aMP points
[+] Allocating 160.00 MB for bP Points
[+] precalculating 4194304 bP points
[+] Sorting 4194304 elements
[+] Thread 0: af41b9d521f21b466da9d454ec6b486232f7b1f641a4c333a92d1fc3e34b19cc
keyhunt(2477,0x16dce3000) malloc: *** error for object 0x4b72c55a98a602ff: pointer being freed was not allocated
keyhunt(2477,0x16dce3000) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort      ./keyhunt -m bsgs -f ../120.txt -R 
a@a-MacBook-Pro keyhunt % ./keyhunt -m bsgs -f ../120.txt                                                                 
[+] Version 0.1.20210112 BSGS
[+] Setting mode BSGS
[+] Opening file ../120.txt
[+] Added 1 points from file
[+] Setting N up to 17592186044416.
[+] Init bloom filter for 4194304 elements : 7.00 MB
[+] Allocating 128.00 MB for aMP Points
[+] Precalculating 4194304 aMP points
[+] Allocating 160.00 MB for bP Points
[+] precalculating 4194304 bP points
[+] Sorting 4194304 elements
[+] Thread 0: 5590f388e5b3568581fa2c41ec2ca029a9863c48636887653680557c2dc95f77
zsh: segmentation fault  ./keyhunt -m bsgs -f ../120.txt
a@a-MacBook-Pro keyhunt % 

@albertobsd
Copy link
Owner

Interesting there is some error in some devices, idk why is this happening i need to debug in some of those devices.

I will notifiyou when I solve this error.

Best regards!

@albertobsd albertobsd self-assigned this Mar 12, 2021
@albertobsd
Copy link
Owner

Can you check if the new version works in Mac?

@albertobsd
Copy link
Owner

This shoulbe solved now those errors were related to an keccak librery but is not loger use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant