Author

Topic: Private Key to ripemd160 hash in perl (Read 833 times)

HCP
legendary
Activity: 2086
Merit: 4361
July 13, 2017, 10:48:25 PM
#3
I want to get from a simple hexadecimal private key to the ripemd160 hash of the bitcoin address. All this in perl.

The best would be such a simple way like ripemd160(sha256(publickey(x))) where x is a positive integer. Smiley
I assume you are wanting to do steps 1 through 4 of the "private key to bitcoin address conversion" in Perl: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses ?

Although quite old, these might give you some ideas:
https://github.com/mtve/bitcoin-pl
https://github.com/grondilu/libbitcoin-perl

parts of which appear to have been rewritten into: http://rosettacode.org/wiki/Bitcoin/public_point_to_address#Perl
legendary
Activity: 1456
Merit: 1081
I may write code in exchange for bitcoins.
July 13, 2017, 01:55:15 PM
#2
Here you go:

https://metacpan.org/pod/Crypt::RIPEMD160

And you probably want to look here for some discussion (is this you?):

https://stackoverflow.com/questions/16092584/perl-alternative-to-hash-hmacripemd160-data-key-in-php

For sha256 there's a built-in:

http://perldoc.perl.org/Digest/SHA.html

And of course you could (on GNU/Linux) do:

Code:
$hash=`echo -n $seed | sha256sum`;

because as I recall Perl supports the backtick operators and sha256sum is usually built-in on GNU/Linux.



member
Activity: 117
Merit: 250
July 13, 2017, 10:04:59 AM
#1
ripemd160(sha256(publickey(x))) where x is the private key
Jump to: