Author

Topic: Segfault using secp256k1 (Read 1004 times)

legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
July 30, 2014, 05:35:40 PM
#8
Code:
/** * 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 Wink
hero member
Activity: 1232
Merit: 516
July 30, 2014, 05:10:39 PM
#7
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.
member
Activity: 86
Merit: 10
July 30, 2014, 04:43:55 PM
#6
I forgot to call secp256k1_start();

works now, anyway thanks for your help!
member
Activity: 86
Merit: 10
July 30, 2014, 04:12:19 PM
#5
The function returns an int. Have the return value assigned to a variable.

I tried:

Code:
    int result;
    result = secp256k1_ecdsa_pubkey_create(pubkeyptr, l, privkeyptr, compressed);

But still segfault :/
hero member
Activity: 1232
Merit: 516
July 30, 2014, 04:06:52 PM
#4
Code:
/** * 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.
member
Activity: 86
Merit: 10
July 30, 2014, 03:44:51 PM
#3
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...
hero member
Activity: 1232
Merit: 516
July 30, 2014, 03:23:54 PM
#2
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/secp256k1

when i try to run this code:

Quote

    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)  Huh

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.
member
Activity: 86
Merit: 10
July 30, 2014, 02:17:30 PM
#1
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/secp256k1

when i try to run this code:

Quote

    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)  Huh

stuck at this for some time now....any ideas?
Jump to: