exbtc v0.1.4 Exbtc.Core

Link to this section Summary

Types

b58checked public address string

binary encoded key: “bin”, “bin_compressed”

use charlist to represent code strings

hex encoded key: “hex”, “hex_compressed”

jacobian number as a tuple

native decoded key in big integer, or “decimal”

point on the elliptic curve as a tuple

“bin” | “bin_compressed” | “bin_electrum” | “decimal” | “hex” | “hex_compressed” | “hex_electrum” | “wif” | “wif_compressed”

“bin” | “bin_compressed” | “bin_electrum” | “decimal” | “hex” | “hex_compressed” | “hex_electrum”

“wif”, “wif_compressed”

Functions

a()

secp256k1 y^2 = x^3 + ax + b, a is 0

b()

secp256k1 y^2 = x^3 + ax + b, b is 7

Convert encoded string between different base, e.g. base-2, base-10, base-16 etc

returns “bin_compressed” or “hex_compressed” version of the public key if possible

Decode a base-N encoded string into the equivalent integer

returns the un-compressed version of the public key, i.e. “bin” or “hex”

recover the public key

anything non base 256 is encoded as a string format of the target chars (base 16, base 10 or base 2); base 256 is encoded as a list(byte)

the term bytes in Python 3 is used as charlist in naming the method and argument here

g()

secp256k1 base point (G) = (g_x, g_y)

secp256k1 base point (G) = (g_x, g_y)

secp256k1 base point (G) = (g_x, g_y)

extended Euclidean algo

n()

secp256k1 number of points

p()

secp256k1 prime

iex> C.sha256(‘784734adfids’) “ae616f5c8f6d338e4905f6170a90a231d0c89470a94b28e894a83aef90975557”

Link to this section Types

Link to this type address()
address() :: String.t()

b58checked public address string

Link to this type binary_encoded_key()
binary_encoded_key() :: [byte()]

binary encoded key: “bin”, “bin_compressed”

Link to this type binary_encoded_private_key()
binary_encoded_private_key() :: binary_encoded_key()
Link to this type binary_encoded_public_key()
binary_encoded_public_key() :: binary_encoded_key()
Link to this type code_base()
code_base() :: 2 | 10 | 16 | 32 | 58 | 256
Link to this type code_string()
code_string() :: charlist()

use charlist to represent code strings

Link to this type hex_encoded_key()
hex_encoded_key() :: String.t()

hex encoded key: “hex”, “hex_compressed”

Link to this type hex_encoded_private_key()
hex_encoded_private_key() :: hex_encoded_key()
Link to this type hex_encoded_public_key()
hex_encoded_public_key() :: hex_encoded_key()
Link to this type jacobian_number()
jacobian_number() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}

jacobian number as a tuple

Link to this type native_key()
native_key() :: non_neg_integer()

native decoded key in big integer, or “decimal”

Link to this type native_private_key()
native_private_key() :: native_key()
Link to this type native_public_key()
native_public_key() :: native_key()
Link to this type native_public_key_pair()
native_public_key_pair() :: {native_key(), native_key()}
Link to this type pair()
pair() :: {non_neg_integer(), non_neg_integer()}

point on the elliptic curve as a tuple

Link to this type private_key_format()
private_key_format() :: String.t()

“bin” | “bin_compressed” | “bin_electrum” | “decimal” | “hex” | “hex_compressed” | “hex_electrum” | “wif” | “wif_compressed”

Link to this type public_key_format()
public_key_format() :: String.t()

“bin” | “bin_compressed” | “bin_electrum” | “decimal” | “hex” | “hex_compressed” | “hex_electrum”

Link to this type wif_encoded_key()
wif_encoded_key() :: String.t()

“wif”, “wif_compressed”

Link to this type wif_encoded_private_key()
wif_encoded_private_key() :: wif_encoded_key()

Link to this section Functions

secp256k1 y^2 = x^3 + ax + b, a is 0

secp256k1 y^2 = x^3 + ax + b, b is 7

Link to this function b58check_to_bin(key)
b58check_to_bin(hex_encoded_key() | wif_encoded_key()) :: binary_encoded_key()
Link to this function bin_double_sha256(chars)
bin_double_sha256([byte()] | binary() | bitstring() | String.t()) :: [byte()]
Link to this function bin_hash160(chars)
bin_hash160([byte()]) :: [byte()]
Link to this function bin_ripemd160(chars)
bin_ripemd160([byte()] | bitstring() | binary() | String.t()) :: [byte()]
Link to this function bin_sha256(chars)
bin_sha256([byte()]) :: [byte()]
Link to this function bin_slowsha(chars)
bin_slowsha([byte()]) :: [byte()]
Link to this function bin_to_b58check(chars, magic_byte \\ 0)
bin_to_b58check(binary_encoded_key(), integer()) :: binary_encoded_key()
Link to this function bytes_to_hex_string(bin)
bytes_to_hex_string(binary()) :: String.t()
Link to this function changebase(str, from, to, minlen \\ 0)
changebase(str :: String.t() | [byte()], from :: code_base(), to :: code_base(), minlen :: integer()) ::
  String.t() |
  [byte()]

Convert encoded string between different base, e.g. base-2, base-10, base-16 etc

returns “bin_compressed” or “hex_compressed” version of the public key if possible.

Link to this function decode(val, base)
decode(String.t() | [byte()], code_base()) :: non_neg_integer()

Decode a base-N encoded string into the equivalent integer

iex> prime_70 = 4669523849932130508876392554713407521319117239637943224980015676156491
iex> assert decode("8s3gRRbpi7NyJH3sudQTtsygDHDyzzB5q3Xc6svA", 58) == prime_70
iex> assert decode("11111100101010110000110110010111001110001101001111111101010000101", 2) == prime_20
Link to this function decode_privkey(key, format \\ nil)
Link to this function decode_pubkey(pub, format \\ nil)
Link to this function decode_sig(signature)
decode_sig(String.t()) :: {integer(), integer(), integer()}

returns the un-compressed version of the public key, i.e. “bin” or “hex”

Link to this function deterministic_generate_k(msg_hash, privkey)
deterministic_generate_k(String.t(), String.t()) :: non_neg_integer()
Link to this function ecdsa_raw_recover(msg_hash, arg)
ecdsa_raw_recover(charlist(), {non_neg_integer(), non_neg_integer(), non_neg_integer()}) :: pair()

recover the public key

Link to this function ecdsa_raw_sign(msg_hash, privkey)
ecdsa_raw_sign(String.t() | charlist(), String.t() | non_neg_integer()) :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}
Link to this function ecdsa_raw_verify(msg_hash, arg, pubkey)
ecdsa_raw_verify([byte()], {non_neg_integer(), non_neg_integer(), non_neg_integer()}, String.t() | pair()) :: boolean()
Link to this function ecdsa_recover(msg, signature)
ecdsa_recover(String.t(), String.t()) :: String.t()
Link to this function ecdsa_sign(msg, privkey)
ecdsa_sign(String.t(), String.t()) :: String.t()
Link to this function ecdsa_verify(msg, sig, pub)
ecdsa_verify(String.t(), String.t(), String.t()) :: boolean()
Link to this function ecdsa_verify_address(msg, signature, address)
ecdsa_verify_address(String.t(), String.t(), String.t()) :: boolean()
Link to this function electrum_sig_hash(message)
electrum_sig_hash(String.t()) :: [byte()]
Link to this function encode(val, base, minlen \\ 0)
encode(non_neg_integer(), integer(), pos_integer()) ::
  String.t() |
  [byte()]

anything non base 256 is encoded as a string format of the target chars (base 16, base 10 or base 2); base 256 is encoded as a list(byte)

iex> prime_70 = 4669523849932130508876392554713407521319117239637943224980015676156491
iex> assert encode(prime_70, 58) == "8s3gRRbpi7NyJH3sudQTtsygDHDyzzB5q3Xc6svA"
iex> assert encode(prime_70, 32) == "cwthr5r3cy4jn6as3oouomr3ondgjigwie45geqegagy2sl"
iex> assert encode(prime_70, 256) == [173, 51, 199, 177, 216, 177, 196, 183, 192, 150, 220, 234, 57, 145, 219, 154, 51, 37, 6, 178, 9, 206, 152, 144, 33, 128, 108, 106, 75]  
Link to this function encode_privkey(key, format, vbyte \\ 0)
Link to this function encode_sig(v, r, s)
encode_sig(integer(), integer(), integer()) :: String.t()
Link to this function fast_add(a, b)
fast_add(pair(), pair()) :: pair()
Link to this function fast_multiply(a, n)
fast_multiply(pair(), non_neg_integer()) :: pair()
Link to this function from_jacobian(p)
from_jacobian(jacobian_number()) :: pair()
Link to this function from_string_to_bytes(s)

the term bytes in Python 3 is used as charlist in naming the method and argument here

secp256k1 base point (G) = (g_x, g_y)

secp256k1 base point (G) = (g_x, g_y)

secp256k1 base point (G) = (g_x, g_y)

Link to this function get_code_string(base)
get_code_string(integer()) :: code_string()
Link to this function get_privkey_format(key)
Link to this function get_pubkey_format(key)
Link to this function get_version_byte(address)
get_version_byte(String.t()) :: integer()
Link to this function hash_to_int(x)
hash_to_int(String.t() | [byte()]) :: integer()

extended Euclidean algo

Link to this function is_address(address)
is_address(address()) :: boolean()
Link to this function is_inf(p)
is_inf(pair()) :: boolean()
Link to this function is_privkey(key)
is_privkey(encoded_private_key() | native_private_key()) :: boolean()
Link to this function is_pubkey(key)
is_pubkey(encoded_public_key() | native_public_key_pair()) :: boolean()
Link to this function jacobian_add(p, q)
Link to this function jacobian_double(p)
jacobian_double(jacobian_number()) :: jacobian_number()
Link to this function jacobian_multiply(a, n)
jacobian_multiply(jacobian_number(), jacobian_number()) :: jacobian_number()
Link to this function lpad(msg, symbol, len)
Link to this function multiply_privkeys(p1, p2)
multiply_privkeys(p1 :: encoded_private_key(), p2 :: encoded_private_key()) :: encoded_private_key()

secp256k1 number of points

Link to this function num_to_var_int(x)
num_to_var_int(integer()) :: [byte()]

secp256k1 prime

Link to this function privkey_to_address(key, magicbyte \\ 0)
privkey_to_address(encoded_private_key() | native_private_key(), integer()) :: address()
Link to this function pubkey_to_address(key, magicbyte \\ 0)
pubkey_to_address(native_public_key_pair() | encoded_public_key() | native_public_key(), non_neg_integer()) :: address()
Link to this function random_electrum_seed()
random_electrum_seed() :: String.t()
Link to this function random_key()
random_key() :: String.t()
Link to this function sha256(chars)
sha256([byte()] | bitstring() | binary() | String.t()) :: String.t()

iex> C.sha256(‘784734adfids’) “ae616f5c8f6d338e4905f6170a90a231d0c89470a94b28e894a83aef90975557”

Link to this function slowsha(chars)
slowsha([byte()]) :: String.t()
Link to this function subtract_pubkeys(p1, p2)
Link to this function to_jacobian(p)
to_jacobian(pair()) :: {non_neg_integer(), non_neg_integer(), 1}