Class: MoneyTree::Key

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/money-tree/key.rb

Direct Known Subclasses

PrivateKey, PublicKey

Defined Under Namespace

Classes: InvalidBase64Format, InvalidWIFFormat, KeyFormatNotFound, KeyGenerationFailure, KeyImportFailure, KeyInvalid

Constant Summary collapse

GROUP_NAME =
"secp256k1"
ORDER =
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141".to_i(16)

Constants included from Support

Support::BASE58_CHARS, Support::INT32_MAX, Support::INT64_MAX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

#base58_to_int, #bytes_to_hex, #bytes_to_int, #convert_p2wpkh_p2sh, #custom_hash_160, #decode_base58, #decode_base64, #digestify, #encode_base58, #encode_base64, #encode_p2wpkh_p2sh, #from_serialized_base58, #hex_to_bytes, #hex_to_int, #hmac_sha512, #hmac_sha512_hex, #int_to_base58, #int_to_bytes, #int_to_hex, #ripemd160, #sha256, #to_serialized_base58, #to_serialized_bech32

Instance Attribute Details

#ec_keyObject

Returns the value of attribute ec_key.



20
21
22
# File 'lib/money-tree/key.rb', line 20

def ec_key
  @ec_key
end

#keyObject (readonly)

Returns the value of attribute key.



17
18
19
# File 'lib/money-tree/key.rb', line 17

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/money-tree/key.rb', line 16

def options
  @options
end

#raw_keyObject (readonly)

Returns the value of attribute raw_key.



18
19
20
# File 'lib/money-tree/key.rb', line 18

def raw_key
  @raw_key
end

Instance Method Details

#to_bytesObject



30
31
32
# File 'lib/money-tree/key.rb', line 30

def to_bytes
  hex_to_bytes to_hex
end

#to_iObject



34
35
36
# File 'lib/money-tree/key.rb', line 34

def to_i
  bytes_to_int to_bytes
end

#valid?(eckey = nil) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/money-tree/key.rb', line 25

def valid?(eckey = nil)
  eckey ||= ec_key
  eckey.nil? ? false : eckey.check_key
end