plebble
|
Classes | |
class | AddressFormatException |
Static Public Member Functions | |
static String | encode (byte[] input_) |
static byte[] | copyOfRange (byte[] src, int start, int end) |
static byte[] | decode (String input) |
static String | encode (byte[] input) |
static String | decode_string (String input) |
static byte[] | decode (String input) throws AddressFormatException |
Static Public Attributes | |
static readonly char[] | ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".ToCharArray() |
static final char[] | ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray() |
Static Package Functions | |
[static initializer] | |
Static Private Member Functions | |
static | base58 () |
static byte | divmod (byte[] number, int firstDigit, int based, int divisor) |
static byte | divmod (byte[] number, int firstDigit, int base, int divisor) |
Static Private Attributes | |
static readonly char | ENCODED_ZERO = ALPHABET[0] |
static readonly int[] | INDEXES = new int[128] |
static final char | ENCODED_ZERO = ALPHABET[0] |
static final int[] | INDEXES = new int[128] |
Base58 is a way to encode Bitcoin addresses (or arbitrary data) as alphanumeric strings.
Note that this is not the same base58 as used by Flickr, which you may find referenced around the Internet.
You may want to consider working with PrefixedChecksummedBytes instead, which adds support for testing the prefix and suffix bytes commonly found in addresses.
Satoshi explains: why base-58 instead of standard base-64 encoding?
However, note that the encoding/decoding runs in O(n²) time, so it is not useful for large data.
The basic idea of the encoding is to treat the data bytes as a large number represented using base-256 digits, convert the number to be represented using base-58 digits, preserve the exact number of leading zeros (which are otherwise lost during the mathematical operations on the numbers), and finally represent the resulting base-58 digits as alphanumeric ASCII characters.
|
inlinestaticprivate |
References us.gov.crypto.base58.ALPHABET, and us.gov.crypto.base58.INDEXES.
|
inlinestaticpackage |
|
inlinestatic |
|
inlinestatic |
Decodes the given base58 string into the original data bytes.
input | the base58-encoded string to decode |
AddressFormatException | if the given string is not a valid base58 string |
References us.gov.crypto.base58.copyOfRange(), us.gov.crypto.base58.divmod(), and us.gov.crypto.base58.INDEXES.
Referenced by us.gov.crypto.ripemd160.hash_t.decode(), us.gov.crypto.base58.decode_string(), us.wallet.cli.hmi.exec(), us::gov::io::cfg1.load_sk(), us::gov::io::shell_args.next_priv(), us::gov::io::shell_args.next_priv_raw(), us::gov::io::shell_args.next_pub(), us::gov::io::shell_args.next_pub_raw(), us::gov::id::peer_t.process_challenge_response(), us::gov::id::peer_t.process_peer_challenge(), us.gov.crypto.test.ec.test_shared_secret_raw_keys(), and us::gov::crypto::ec.verify().
|
inlinestatic |
Decodes the given base58 string into the original data bytes.
input | the base58-encoded string to decode |
AddressFormatException | if the given string is not a valid base58 string |
References us.gov.crypto.base58.divmod(), and us.gov.crypto.base58.INDEXES.
|
inlinestatic |
|
inlinestaticprivate |
Divides a number, represented as an array of bytes each containing a single digit in the specified base, by the given divisor. The given number is modified in-place to contain the quotient, and the return value is the remainder.
number | the number to divide |
firstDigit | the index within the array of the first non-zero digit (this is used for optimization by skipping the leading zeros) |
base | the base in which the number's digits are represented (up to 256) |
divisor | the number to divide by (up to 256) |
|
inlinestaticprivate |
Divides a number, represented as an array of bytes each containing a single digit in the specified base, by the given divisor. The given number is modified in-place to contain the quotient, and the return value is the remainder.
number | the number to divide |
firstDigit | the index within the array of the first non-zero digit (this is used for optimization by skipping the leading zeros) |
base | the base in which the number's digits are represented (up to 256) |
divisor | the number to divide by (up to 256) |
Referenced by us.gov.crypto.base58.decode(), and us.gov.crypto.base58.encode().
|
inlinestatic |
Encodes the given bytes as a base58 string (no checksum is appended).
input | the bytes to encode |
References us.gov.crypto.base58.ALPHABET, us.gov.crypto.base58.divmod(), and us.gov.crypto.base58.ENCODED_ZERO.
|
inlinestatic |
Encodes the given bytes as a base58 string (no checksum is appended).
input | the bytes to encode |
References us.gov.crypto.base58.ALPHABET, us.gov.crypto.base58.divmod(), and us.gov.crypto.base58.ENCODED_ZERO.
Referenced by us.gov.crypto.sha256.hash_t.b58(), us.gov.crypto.ripemd160.hash_t.encode(), us::gov::id::peer_t.get_random_message(), us::gov::id::peer_t.short_version(), us::gov::crypto::ec.sign_encode(), us.gov.crypto.test.ec.test_shared_secret_raw_keys(), us::gov::crypto::ec.to_b58(), us.wallet.pairing_rpc_api.to_string(), and us.wallet.wallet_rpc_api.to_string().
|
static |
Referenced by us.gov.crypto.base58.base58(), and us.gov.crypto.base58.encode().
|
static |
|
staticprivate |
Referenced by us.gov.crypto.base58.encode().
|
staticprivate |
|
staticprivate |
Referenced by us.gov.crypto.base58.base58(), and us.gov.crypto.base58.decode().
|
staticprivate |