Bitcoin::Crypto - Bitcoin cryptography in Perl
use Bitcoin::Crypto qw(btc_extprv); use Bitcoin::Crypto::Util qw(generate_mnemonic to_format); use Bitcoin::Crypto::Constants; # extended keys are used for mnemonic generation and key derivation my $mnemonic = generate_mnemonic; say "your mnemonic code is: $mnemonic"; my $master_key = btc_extprv->from_mnemonic($mnemonic); my $derived_key = $master_key->derive_key_bip44( purpose => Bitcoin::Crypto::Constants::bip44_segwit_purpose, index => 0, ); # basic keys can be used for signatures and addresses my $priv = $derived_key->get_basic_key; my $pub = $priv->get_public_key; say 'private key: ' . $priv->to_wif; say 'public key: ' . to_format [hex => $pub->to_serialized]; say 'address: ' . $pub->get_address;
This is a cryptographic module for common Bitcoin-related tasks. It enables low-level manipulation of Bitcoin keys, transactions and encodings. See Bitcoin::Crypto::Manual for an overview of the module.
This package exports the following functions when asked for them. These are shourtcut functions and will load needed packages and return their names. You can then use names of loaded packages to instantiate them however you want. It's also possible to load all of them with the :all tag in import. They functions can be used as follows:
use Bitcoin::Crypto qw(btc_pub); # loads Bitcoin::Crypto::Key::Public and returns package name # we can now use it to run its methods my $public_key = btc_pub->from_serialized([hex => $hex_data]);
Loads Bitcoin::Crypto::Key::ExtPrivate
Loads Bitcoin::Crypto::Key::Private
Loads Bitcoin::Crypto::Key::ExtPublic
Loads Bitcoin::Crypto::Key::Public
Loads Bitcoin::Crypto::Script
Loads Bitcoin::Crypto::Transaction
Loads Bitcoin::Crypto::Transaction::UTXO
Loads Bitcoin::Crypto::Block
Bitcoin::RPC::Client
https://github.com/bitcoin/bips
Bartosz Jarzyna <bbrtj.pro@gmail.com>
Consider supporting my effort: https://bbrtj.eu/support
Copyright (C) 2018 - 2024 by Bartosz Jarzyna
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Bitcoin::Crypto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bitcoin::Crypto
CPAN shell
perl -MCPAN -e shell install Bitcoin::Crypto
For more information on module installation, please visit the detailed CPAN module installation guide.