The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bitcoin::Crypto::Util - Basic utilities for working with bitcoin

SYNOPSIS

        use Bitcoin::Crypto::Util qw(
                validate_wif
                get_key_type
                get_path_info
        );

DESCRIPTION

These are basic utilities for working with bitcoin, used by other packages.

FUNCTIONS

validate_wif

        my $bool = validate_wif($str);

Ensures Base58 encoded string looks like encoded private key in WIF format. Throws an exception if $str is not valid base58.

get_key_type

        my $is_private = get_key_type($bytestr);

Checks if the $bytestr looks like a valid ASN X9.62 format (compressed / uncompressed / hybrid public key or private key entropy up to curve size bits). Returns boolean which can be used to determine if the key is private. Returns undef if $bytestr does not look like a valid key entropy.

get_path_info

        my $path = "m/1/3'";
        my $path_data = get_path_info($path);

Tries to get derivation path data from $path. Returns undef if $path is not a valid path. Otherwise returns the structure:

        {
                private => bool, # is path derivation private (lowercase m)
                path => [
                        # derivation path with 2^31 added to every hardened child number
                        int, int, ..
                ],
        }

SEE ALSO

Bitcoin::Crypto::Key::ExtPrivate