joschua011 (OP)
Member
Offline
Activity: 86
Merit: 10
|
|
July 30, 2014, 07:17:30 PM Last edit: July 30, 2014, 08:16:49 PM by joschua011 |
|
Not sure if this is the right place to ask this but i guess quite some people here are familliar with sipa's version of secp256k1 https://github.com/bitcoin/secp256k1when i try to run this code: unsigned char privateKeyBytes[33]; // some code to fill privateKeyBytes[] unsigned char publicKeyBytes[33];
int length; int* l; l = &length;
unsigned char* pubkeyptr; unsigned char* privkeyptr; pubkeyptr = &publicKeyBytes[0]; privkeyptr = &privateKeyBytes[0];
secp256k1_ecdsa_pubkey_create(pubkeyptr, l, privkeyptr, 1);
I get Segmentation fault (core dumped) stuck at this for some time now....any ideas?
|
|
|
|
|
|
|
|
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
Sophokles
|
|
July 30, 2014, 08:23:54 PM |
|
Not sure if this is the right place to ask this but i guess quite some people here are familliar with sipa's version of secp256k1 https://github.com/bitcoin/secp256k1when i try to run this code: unsigned char privateKeyBytes[33]; // some code to fill privateKeyBytes[] unsigned char publicKeyBytes[33];
int length; int* l; l = &length;
unsigned char* pubkeyptr; unsigned char* privkeyptr; pubkeyptr = &publicKeyBytes[0]; privkeyptr = &privateKeyBytes[0];
secp256k1_ecdsa_pubkey_create(pubkeyptr, l, privkeyptr, 1);
I get Segmentation fault (core dumped) stuck at this for some time now....any ideas? Did you just change the code? I was going to look it up, could swear it looked different a few minutes ago. Anyway, the definition of the pointers is screwed up.
|
▄▄████████▄▄ ▄▄████████████████▄▄ ▄██████████████████████▄ ▄█████████████████████████▄ ▄███████████████████████████▄
| ███████████████████▄████▄ █████████████████▄███████ ████████████████▄███████▀ ██████████▄▄███▄██████▀ ████████▄████▄█████▀▀ ██████▄██████████▀ ███▄▄████████████▄ ██▄███████████████ ░▄██████████████▀ ▄█████████████▀ █████████████ ███████████▀ ███████▀▀ | | | .
| | ▄▄███████▄▄ ▄███████████████▄ ▄███████████████████▄ ▄█████████████████████▄ ▄███████████████████████▄ █████████████████████████ █████████████████████████ █████████████████████████ ▀███████████████████████▀ ▀█████████████████████▀ ▀███████████████████▀ ▀███████████████▀ ▀▀███████▀▀ | . ElonCoin.org | │ | | .
| │ | ████████▄▄███████▄▄ ███████▄████████████▌ ██████▐██▀███████▀▀██ ███████████████████▐█▌ ████▄▄▄▄▄▄▄▄▄▄██▄▄▄▄▄ ███▀░▐███▀▄█▄█▀▀█▄█▄▀ ██████████████▄██████▌ █████▐██▄██████▄████▐ █████████▀░▄▄▄▄▄ ███████▄█▄░▀█▄▄░▀ ███▄██▄▀███▄█████▄▀ ▄██████▄▀███████▀ ████████▄▀████▀█████▄▄ | . "I could either watch it happen or be a part of it" ▬▬▬▬▬ |
|
|
|
joschua011 (OP)
Member
Offline
Activity: 86
Merit: 10
|
|
July 30, 2014, 08:44:51 PM |
|
Did you just change the code? I was going to look it up, could swear it looked different a few minutes ago. Anyway, the definition of the pointers is screwed up.
Actually i did, added pubkeyptr and privkeyptr, but its still not working...
|
|
|
|
Sophokles
|
|
July 30, 2014, 09:06:52 PM |
|
/** * In: compressed: whether the computed public key should be compressed
* seckey: pointer to a 32-byte private key.
* Out: pubkey: pointer to a 33-byte (if compressed) or 65-byte (if uncompressed)
* area to store the public key.
* pubkeylen: pointer to int that will be updated to contains the pubkey's
* length.
* Returns: 1: secret was valid, public key stores
* 0: secret was invalid, try again.
*/
int secp256k1_ecdsa_pubkey_create(unsigned char *pubkey, int *pubkeylen, const unsigned char *seckey, int compressed);
The function returns an int. Have the return value assigned to a variable.
|
▄▄████████▄▄ ▄▄████████████████▄▄ ▄██████████████████████▄ ▄█████████████████████████▄ ▄███████████████████████████▄
| ███████████████████▄████▄ █████████████████▄███████ ████████████████▄███████▀ ██████████▄▄███▄██████▀ ████████▄████▄█████▀▀ ██████▄██████████▀ ███▄▄████████████▄ ██▄███████████████ ░▄██████████████▀ ▄█████████████▀ █████████████ ███████████▀ ███████▀▀ | | | .
| | ▄▄███████▄▄ ▄███████████████▄ ▄███████████████████▄ ▄█████████████████████▄ ▄███████████████████████▄ █████████████████████████ █████████████████████████ █████████████████████████ ▀███████████████████████▀ ▀█████████████████████▀ ▀███████████████████▀ ▀███████████████▀ ▀▀███████▀▀ | . ElonCoin.org | │ | | .
| │ | ████████▄▄███████▄▄ ███████▄████████████▌ ██████▐██▀███████▀▀██ ███████████████████▐█▌ ████▄▄▄▄▄▄▄▄▄▄██▄▄▄▄▄ ███▀░▐███▀▄█▄█▀▀█▄█▄▀ ██████████████▄██████▌ █████▐██▄██████▄████▐ █████████▀░▄▄▄▄▄ ███████▄█▄░▀█▄▄░▀ ███▄██▄▀███▄█████▄▀ ▄██████▄▀███████▀ ████████▄▀████▀█████▄▄ | . "I could either watch it happen or be a part of it" ▬▬▬▬▬ |
|
|
|
joschua011 (OP)
Member
Offline
Activity: 86
Merit: 10
|
|
July 30, 2014, 09:12:19 PM |
|
The function returns an int. Have the return value assigned to a variable.
I tried: int result; result = secp256k1_ecdsa_pubkey_create(pubkeyptr, l, privkeyptr, compressed);
But still segfault :/
|
|
|
|
joschua011 (OP)
Member
Offline
Activity: 86
Merit: 10
|
|
July 30, 2014, 09:43:55 PM |
|
I forgot to call secp256k1_start();
works now, anyway thanks for your help!
|
|
|
|
Sophokles
|
|
July 30, 2014, 10:10:39 PM |
|
Cool. Will fiddle with this library a little later as well. Looks really interesting. Just today completely wrapped my mind around ECDSA signatures, fascinating stuff.
|
▄▄████████▄▄ ▄▄████████████████▄▄ ▄██████████████████████▄ ▄█████████████████████████▄ ▄███████████████████████████▄
| ███████████████████▄████▄ █████████████████▄███████ ████████████████▄███████▀ ██████████▄▄███▄██████▀ ████████▄████▄█████▀▀ ██████▄██████████▀ ███▄▄████████████▄ ██▄███████████████ ░▄██████████████▀ ▄█████████████▀ █████████████ ███████████▀ ███████▀▀ | | | .
| | ▄▄███████▄▄ ▄███████████████▄ ▄███████████████████▄ ▄█████████████████████▄ ▄███████████████████████▄ █████████████████████████ █████████████████████████ █████████████████████████ ▀███████████████████████▀ ▀█████████████████████▀ ▀███████████████████▀ ▀███████████████▀ ▀▀███████▀▀ | . ElonCoin.org | │ | | .
| │ | ████████▄▄███████▄▄ ███████▄████████████▌ ██████▐██▀███████▀▀██ ███████████████████▐█▌ ████▄▄▄▄▄▄▄▄▄▄██▄▄▄▄▄ ███▀░▐███▀▄█▄█▀▀█▄█▄▀ ██████████████▄██████▌ █████▐██▄██████▄████▐ █████████▀░▄▄▄▄▄ ███████▄█▄░▀█▄▄░▀ ███▄██▄▀███▄█████▄▀ ▄██████▄▀███████▀ ████████▄▀████▀█████▄▄ | . "I could either watch it happen or be a part of it" ▬▬▬▬▬ |
|
|
|
Remember remember the 5th of November
Legendary
Offline
Activity: 1862
Merit: 1011
Reverse engineer from time to time
|
|
July 30, 2014, 10:35:40 PM |
|
/** * In: compressed: whether the computed public key should be compressed
* seckey: pointer to a 32-byte private key.
* Out: pubkey: pointer to a 33-byte (if compressed) or 65-byte (if uncompressed)
* area to store the public key.
* pubkeylen: pointer to int that will be updated to contains the pubkey's
* length.
* Returns: 1: secret was valid, public key stores
* 0: secret was invalid, try again.
*/
int secp256k1_ecdsa_pubkey_create(unsigned char *pubkey, int *pubkeylen, const unsigned char *seckey, int compressed);
The function returns an int. Have the return value assigned to a variable. Just wanted to let you know, that in C or C++ and in many languages in fact, you are not forced to store the return value of a function. It means that, that wasn't what was causing the issue
|
BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
|
|
|
|