Title: Perl Private Key -> Public Address Post by: ethought on March 19, 2015, 07:09:45 PM Does any one have a minimal / basic perl script that can generate a public addresses given a 32 byte private key?
Most of the perl code examples on Github are unmaintained / broken / years old and I am having troubles getting any of them working. Something similar to this python code: Code: import ecdsa ref: https://bitcointalk.org/index.php?topic=84238.0 Would be happy to provide a small bounty. thanks Title: Re: Perl Private Key -> Public Address Post by: dserrano5 on March 19, 2015, 07:19:40 PM I do have some Perl but in the bit privkey → pubkey I cheat via "use Inline" ;). C compiler and libssl-dev required.
Title: Re: Perl Private Key -> Public Address Post by: ethought on March 19, 2015, 07:25:38 PM I do have some Perl but in the bit privkey → pubkey I cheat via "use Inline" ;). C compiler and libssl-dev required. Interested.. :) Title: Re: Perl Private Key -> Public Address Post by: dserrano5 on March 19, 2015, 08:19:49 PM Code: #!/usr/bin/perl Title: Re: Perl Private Key -> Public Address Post by: ethought on March 20, 2015, 11:36:33 AM Thanks very much. Looks great but cannot get it working unfortunately.
I have /usr/include/openssl/bn.h but am getting the following error: Quote undefined symbol: BN_init Looking in bn.h 'BN_init' does not seem to exist... Will keep trying though. Title: Re: Perl Private Key -> Public Address Post by: dserrano5 on March 20, 2015, 07:10:45 PM Looking in bn.h 'BN_init' does not seem to exist... In my case: Code: $ grep -r BN_init /usr/include/openssl/ Code: $ dpkg -l |grep ssl.*dev Title: Re: Perl Private Key -> Public Address Post by: DryPalms on July 08, 2018, 12:48:12 AM dserrano5, great piece of code, works like a charm. The inline C code based on openssl you provided generates over 1500 pubkeys per second which is 5+ times more than any native Perl implementation of secp256k1 curve.
But it seems there might be significant improvement in speed if the code written using inline C based on libsecp256k1 (https://github.com/bitcoin-core/secp256k1) (#include <secp256k1.h>) library. Unfortunately, I am not familiar with C enough to do that. Can anyone rewrite dserrano5's code to use libsecp256k1 lib to generate compressed/uncompressed pubkeys from private key? It should be working many times faster. Thanks in advance! Would be glad to donate :) PS: This is kind of an old thread but I think it not worth opening a new one so I decided posting here as here is all the pre-history present. Sorry if I am wrong. UPD: The code seems to have a memory leak because after running it for 24 hours it takes 37% of memory on my server with 48Gb RAM. Title: Re: Perl Private Key -> Public Address Post by: DryPalms on June 04, 2021, 12:32:32 PM Anyone? I am sitting here waiting for a reply for the last three years ;D
Title: Re: Perl Private Key -> Public Address Post by: pooya87 on June 04, 2021, 12:48:05 PM Anyone? I am sitting here waiting for a reply for the last three years ;D How about finding a way to call C functions from Perl, I'm not familiar with Perl so here is a link: https://stackoverflow.com/questions/4048557/calling-c-function-from-perl-within-embedded-c-applicationThen you can use the library that bitcoin core uses known as libsec256k1: https://github.com/bitcoin-core/secp256k1 That way you don't have to worry about the library not being complete or having any bugs. |