see other projects

Bitcoin::Crypto module

Manipulation of Bitcoin keypairs and cryptocurrency-related operations

The first native Perl Bitcoin library on CPAN

Bitcoin::Crypto is a cryptographic toolkit focused on Bitcoin-related operations. It closely follows many Bitcoin Improvement Proposal (BIP) documents and keeps track of the most impactful additions to the Bitcoin protocol. It works with any cryptocurrency sharing same fundamentals as Bitcoin (given the right configuration).

Example code

use v5.12;
use Bitcoin::Crypto qw(btc_prv);

say 'Enter your WIF (Wallet Import Format)';
my $wif = <STDIN>;

my $private_key = btc_prv->from_wif($wif);
my $public_key = $private_key->get_public_key;

say 'The cryptocurrency network is ' . $private_key->network->name;
say 'Hex representation of public key is ' . $public_key->to_hex;
say 'Legacy address is ' . $public_key->get_legacy_address;
say 'Compatibility Segregated Witness address is ' . $public_key->get_compat_address;
say 'Native Segregated Witness address is ' . $public_key->get_segwit_address;

Example output

Enter your WIF (Wallet Import Format)
cRhK6p6UJxGYwoNytLL2yqbdJHX5vzS3qvnnpzPLhQMw6hAmuYA2
The cryptocurrency network is Bitcoin Testnet
Hex representation of public key is 0285579b79659fd147435902f412212f1d389b05b93e6f6e91a42bef656f9a4065
Legacy address is mpMttyA9szKDH7BN9xDuDjZx2eN9yWShNB
Compatibility Segregated Witness address is 2N3Dw1aa7d6dnwGKxzYrWfWgN5RV8qZtqM2
Native Segregated Witness address is tb1qvypg637xyj3vw4vedlc0s5ga5gszspklaqzq87