NAME
Finance::Libdogecoin::FFI - Use features from libdogecoin via FFI
VERSION
version 1.20220815.1712
SYNOPSIS
To generate and verify a private/public keypair:
# call this before all key-manipulation functions
Finance::Libdogecoin::FFI::context_start();
my ($priv_key, $pub_key) = Finance::Libdogecoin::FFI::generate_key_pair();
if (Finance::Libdogecoin::FFI::verify_key_pair( $priv_key, $pub_key )) {
# ... key pair is valid
}
# call this after all key-manipulation functions
Finance::Libdogecoin::FFI::context_stop();
From this example be aware of three things:
First, call
context_start()
before andcontext_stop()
after any use of the key-manipulation functions. These start and finish the cryptographic context used in the underlying C library.Second, these function are available from the
Finance::Libdogecoin::FFI
namespace and are not exported by default.Third, these functions are minimally Perlish. A nicer interface should/will exist.
DESCRIPTION
This module provides a minimal FFI interface to libdogecoin
functions. It uses Alien::Libdogecoin to use a local installation of this library or the system version.
See https://github.com/dogecoinfoundation/libdogecoin/blob/main/doc/address.md for full documentation of the libdogecoin
library, including the principles behind the design. The API of this module follows the example of the Python bindings, though the C function calls are also available in this namespace.
FUNCTIONS
context_start()
Initializes the libdogecoin
cryptography mechanism. Call this before using any other key-management functions.
context_start()
Finishes the libdogecoin
cryptography mechanism. Call this when you no longer need to use any other key-management functions.
generate_key_pair( $is_testnet )
The boolean $is_testnet
argument is optional; the default value is false.
Generates and returns a private/public key pair for the network. The return value is two strings in base-58 encoding. Do not share the private key. Do not lose the private key.
The public key is a valid P2PKH address.
verify_key_pair( $private_key, $public_key, $is_testnet )
The boolean $is_testnet
argument is optional; the default value is false.
Given two strings in base-58 encoding, returns a boolean value to indicate whether the pair is valid for the given network.
verify_p2pkh_address( $address )
Given a public key, returns a boolean to indicate whether the address passes validation checks. This doesn't guarantee that an address is legitimate, but it can help decide whether it's worth sending to it at all.
generate_hd_master_pub_key_pair( $is_testnet )
The boolean $is_testnet
argument is optional; the default value is false.
Generates and returns a private/public key hierarchical deterministic pair for the network. The return value is two strings in base-58 encoding. Do not share the private key. Do not lose the private key.
generate_derived_hd_pub_key( $master_private_key )
Given a master key hierarchical deterministic key, derive and return a public key associated with the master.
verify_master_priv_pub_keypair( $master_private_key, $master_public_key, $is_testnet )
The boolean $is_testnet
argument is optional; the default value is false.
Given two strings representing hierarchical deterministic keys (a master public key and a master private key) in base-58 encoding, returns a boolean value to indicate whether the pair both match and are valid for the given network. In other words, for the given network, can the public key be derived from the private key?
AUTHOR, COPYRIGHT, and LICENSE
Copyright (c) 2022, chromatic. Interface based on and derived from the libdogecoin
Python bindings.
AUTHOR
chromatic <chromatic@wgz.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2022 by chromatic.
This is free software, licensed under:
The MIT (X11) License