module Bip0039::Util

Overview

A collection of utilities for Bip0039 mnemonic management, e.g., loading word lists from dictionaries, or n-bit padding operations.

Defined in:

util.cr

Class Method Summary

Class Method Detail

def self.bin_to_padded_hex(bin : String, size : Int) : String #

A generic utility to generate a padded hex string from a binary string with given size.

Parameters:

  • bin (String): the binary string to be formatted as padded hex string.
  • size (Int): the size in bits for the resulting hex string, e.g., 128.
Bip0039::Util.bin_to_padded_hex "1100101", 32
# => "00000065"

[View source]
def self.hex_to_padded_bin(hex : String, size : Int) : String #

A generic utility to generate a padded binary string from a hex string with given size.

Parameters:

  • hex (String): the hex string to be formatted as padded binary string.
  • size (Int): the size in bits for the resulting hex string, e.g., 128.
Bip0039::Util.hex_to_padded_bin "69", 32
# => "00000000000000000000000001101001"

[View source]
def self.num_to_padded_bin(num : BigInt | Int, size : Int) : String #

A generic utility to generate a padded binary string from a big number with given size.

Parameters:

  • num (BigInt | Int): the number to be formatted as padded binary string.
  • size (Int): the size in bits for the resulting hex string, e.g., 128.
Bip0039::Util.num_to_padded_bin 137, 32
# => "00000000000000000000000010001001"

[View source]
def self.num_to_padded_hex(num : BigInt | Int, size : Int) : String #

A generic utility to generate a padded hex string from a big number with given size.

Parameters:

  • num (BigInt | Int): the number to be formatted as padded hex string.
  • size (Int): the size in bits for the resulting hex string, e.g., 128.
Bip0039::Util.num_to_padded_hex 137, 32
# => "00000089"

[View source]
def self.word_list : Array(String) #

A generic utility to load the standardized english language word list from file.

Bip0039::Util.word_list
# => ["abandon", "ability", "able", "about", "above", ...

[View source]