-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve the documentation #27
Conversation
r = Random.rand 57 | ||
key += Hash.base57_char r | ||
r = Random.rand 56 | ||
key += Hash.base56_char r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog: mini-private keys now use base-56 instead of base-57. that does not affect existing mini-private keys.
# Secp256k1::Bitcoin.wif_from_private_uncompressed BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16) | ||
# # => "5JTDCfWtwBsA26NcrJJdb7xvBPvJY9jKTdppXckp3SVTrBe6pg1" | ||
# ``` | ||
def self.wif_from_private_uncompressed(k : BigInt, version = "80") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: added wif_from_private_uncompressed
wrapper
# Secp256k1::Bitcoin.wif_from_private_compressed BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16) | ||
# # => "Kz2grUzxEAxNopiREbNpVbjoitAGQVXnUZY4n8pNdmWdVqub99qu" | ||
# ``` | ||
def self.wif_from_private_compressed(k : BigInt, version = "80") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: renamed wif_compressed_from_private
to wif_from_private_compressed
# Secp256k1::Bitcoin.address_from_private BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16) | ||
# # => "1Q1zbmPZtS2chwxpviqz6qHgoM8UUuviGN" | ||
# ``` | ||
def self.address_from_private(priv : BigInt, version = "00", compressed = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: private keys are handled as BigInt
instead of a String
literal wherever possible, e.g., address_from_private
# The elliptic curve domain parameters over `F_p` associated with a Koblitz curve | ||
# Secp256k1 are specified by the sextuple `T = (p, a, b, G, n, h)` where the finite | ||
# field `F_p` is defined by the prime `p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1`. | ||
EC_PRIME_P = BigInt.new "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: EC_PARAM_PRIME
was renamed to EC_PRIME_P
BASE_57 = "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" | ||
# The Base-56 alphabet for `Bitcoin` mini-private keys is a Base-58 alphabet | ||
# without `1` and `o` to additionally omit more similar-looking letters. | ||
BASE_56 = "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: replaced BASE_57
in favor of BASE_56
by removing the o
.
# Secp256k1::Hash.sha3 Bytes[183, 149, 205, 44, 92, 224, 204, 99, 44, 161, 246, 94, 146, 27, 156, 117, 27, 54, 62, 151, 252, 174, 236, 129, 192, 42, 133, 183, 99, 68, 130, 104] | ||
# # => "66bb65180108362a3e25ba8282f7b96bfe840ce34a2e5dbc421aa8a590cc5f2e" | ||
# ``` | ||
def self.sha3(b : Bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: binary hashing operations now directly operate on Bytes
instead of String
literals, e.g., sha3
, sha256
, keccak256
, ripemd160
# Secp256k1::Hash.ripemd160_string "b795cd2c5ce0cc632ca1f65e921b9c751b363e97fcaeec81c02a85b763448268" | ||
# # => "46dff6cd5666c8e67db26ac0dfaf685bf71fc5f6" | ||
# ``` | ||
def self.ripemd160_string(h : String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: added ripemd160_string
for String
hashes
# Secp256k1::Hash.base58_char 13 | ||
# # => 'E' | ||
# ``` | ||
def self.base58_char(i : Int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: added base58_char
to complement base56_char
# Returns an `EC_Point` containing the public key. | ||
# | ||
# Raises if public key format is unknown. | ||
def self.restore_public_key(pub : String, prime = EC_PRIME_P) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog: pass the prime
to restore_public_key
No description provided.