beemgraphenebase.account¶
-
class
beemgraphenebase.account.Address(address, prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixAddress class
This class serves as an address representation for Public Keys.
Parameters: - address (str) – Base58 encoded address (defaults to
None) - prefix (str) – Network prefix (defaults to
STM)
Example:
Address("STMFN9r6VYzBK8EKtMewfNbfiGCr56pHDBFi")
-
classmethod
derivesha256address(pubkey, compressed=True, prefix=None)¶ Derive address using
RIPEMD160(SHA256(x))
-
classmethod
derivesha512address(pubkey, compressed=True, prefix=None)¶ Derive address using
RIPEMD160(SHA512(x))
-
classmethod
from_pubkey(pubkey, compressed=True, version=56, prefix=None)¶ Load an address provided by the public key. Version: 56 => PTS
- address (str) – Base58 encoded address (defaults to
-
class
beemgraphenebase.account.BitcoinAddress(address, prefix=None)¶ Bases:
beemgraphenebase.account.Address-
classmethod
from_pubkey(pubkey, compressed=False, version=56, prefix=None)¶ Load an address provided by the public key. Version: 56 => PTS
-
classmethod
-
class
beemgraphenebase.account.BitcoinPublicKey(pk, prefix=None)¶ Bases:
beemgraphenebase.account.PublicKey-
address¶ Obtain a GrapheneAddress from a public key
-
-
class
beemgraphenebase.account.BrainKey(brainkey=None, sequence=0, prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixBrainkey implementation similar to the graphene-ui web-wallet.
Parameters: - brainkey (str) – Brain Key
- sequence (int) – Sequence number for consecutive keys
Keys in Graphene are derived from a seed brain key which is a string of 16 words out of a predefined dictionary with 49744 words. It is a simple single-chain key derivation scheme that is not compatible with BIP44 but easy to use.
Given the brain key, a private key is derived as:
privkey = SHA256(SHA512(brainkey + " " + sequence))
Incrementing the sequence number yields a new key that can be regenerated given the brain key.
-
get_blind_private()¶ Derive private key from the brain key (and no sequence number)
-
get_brainkey()¶ Return brain key of this instance
-
get_private()¶ Derive private key from the brain key and the current sequence number
-
get_private_key()¶
-
get_public()¶
-
get_public_key()¶
-
next_sequence()¶ Increment the sequence number by 1
-
normalize(brainkey)¶ Correct formating with single whitespace syntax and no trailing space
-
suggest(word_count=16)¶ Suggest a new random brain key. Randomness is provided by the operating system using
os.urandom().
-
class
beemgraphenebase.account.GrapheneAddress(address, prefix=None)¶ Bases:
beemgraphenebase.account.AddressGraphene Addresses are different. Hence we have a different class
-
classmethod
from_pubkey(pubkey, compressed=True, version=56, prefix=None)¶ Load an address provided by the public key. Version: 56 => PTS
-
classmethod
-
class
beemgraphenebase.account.Mnemonic¶ Bases:
objectBIP39 mnemoric implementation
-
check(mnemonic)¶ Checks the mnemonic word list is valid :param list mnemonic: mnemonic word list with lenght of 12, 15, 18, 21, 24 :returns: True, when valid
-
check_word(word)¶
-
expand(mnemonic)¶ Expands all words given in a list
-
expand_word(prefix)¶ Expands a word when sufficient chars are given
Parameters: prefix (str) – first chars of a valid dict word
-
generate(strength=128)¶ Generates a word list based on the given strength
Parameters: strength (int) – initial entropy strength, must be one of [128, 160, 192, 224, 256]
-
classmethod
normalize_string(txt)¶ Normalizes strings
-
to_entropy(words)¶
-
to_mnemonic(data)¶
-
classmethod
to_seed(mnemonic, passphrase='')¶ Returns a seed based on bip39
Parameters: - mnemonic (str) – string containing a valid mnemonic word list
- passphrase (str) – optional, passphrase can be set to modify the returned seed.
-
-
class
beemgraphenebase.account.MnemonicKey(word_list=None, passphrase='', account_sequence=0, key_sequence=0, prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixThis class derives a private key from a BIP39 mnemoric implementation
-
generate_mnemonic(passphrase='', strength=256)¶
-
get_path()¶
-
get_private()¶ Derive private key from the account_sequence, the role and the key_sequence
-
get_private_key()¶
-
get_public()¶
-
get_public_key()¶
-
next_account_sequence()¶ Increment the account sequence number by 1
-
next_sequence()¶ Increment the key sequence number by 1
-
set_mnemonic(word_list, passphrase='')¶
-
set_path(path)¶
-
set_path_BIP32(path)¶
-
set_path_BIP44(account_sequence=0, chain_sequence=0, key_sequence=0, hardened_address=True)¶
-
set_path_BIP48(network_index=13, role='owner', account_sequence=0, key_sequence=0)¶
-
-
class
beemgraphenebase.account.PasswordKey(account, password, role='active', prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixThis class derives a private key given the account name, the role and a password. It leverages the technology of Brainkeys and allows people to have a secure private key by providing a passphrase only.
-
get_private()¶ Derive private key from the account, the role and the password
-
get_private_key()¶
-
get_public()¶
-
get_public_key()¶
-
normalize(seed)¶ Correct formating with single whitespace syntax and no trailing space
-
-
class
beemgraphenebase.account.PrivateKey(wif=None, prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixDerives the compressed and uncompressed public keys and constructs two instances of
PublicKey:Parameters: - wif (str) – Base58check-encoded wif key
- prefix (str) – Network prefix (defaults to
STM)
Example:
PrivateKey("5HqUkGuo62BfcJU5vNhTXKJRXuUi9QSE6jp8C3uBJ2BVHtB8WSd")
Compressed vs. Uncompressed:
PrivateKey("w-i-f").pubkey:- Instance of
PublicKeyusing compressed key.
PrivateKey("w-i-f").pubkey.address:- Instance of
Addressusing compressed key.
PrivateKey("w-i-f").uncompressed:- Instance of
PublicKeyusing uncompressed key.
PrivateKey("w-i-f").uncompressed.address:- Instance of
Addressusing uncompressed key.
-
address¶
-
bitcoin¶
-
child(offset256)¶ Derive new private key from this key and a sha256 “offset”
-
compressed¶
-
derive_from_seed(offset)¶ Derive private key using “generate_from_seed” method. Here, the key itself serves as a seed, and offset is expected to be a sha256 digest.
-
derive_private_key(sequence)¶ Derive new private key from this private key and an arbitrary sequence number
-
get_public_key()¶ Legacy: Returns the pubkey
-
get_secret()¶ Get sha256 digest of the wif key.
-
pubkey¶
-
uncompressed¶
-
class
beemgraphenebase.account.PublicKey(pk, prefix=None)¶ Bases:
beemgraphenebase.prefix.PrefixThis class deals with Public Keys and inherits
Address.Parameters: - pk (str) – Base58 encoded public key
- prefix (str) – Network prefix (defaults to
STM)
Example:
PublicKey("STM6UtYWWs3rkZGV8JA86qrgkG6tyFksgECefKE1MiH4HkLD8PFGL")
Note
By default, graphene-based networks deal with compressed public keys. If an uncompressed key is required, the method
unCompressed()can be used:PublicKey("xxxxx").unCompressed()
-
add(digest256)¶ Derive new public key from this key and a sha256 “digest”
-
address¶ Obtain a GrapheneAddress from a public key
-
child(offset256)¶ Derive new public key from this key and a sha256 “offset”
-
compressed()¶ Derive compressed public key
-
compressed_key¶
-
classmethod
from_privkey(privkey, prefix=None)¶ Derive uncompressed public key
-
get_public_key()¶ Returns the pubkey
-
point()¶ Return the point for the public key
-
pubkey¶
-
unCompressed()¶ Alias for self.uncompressed() - LEGACY
-
uncompressed()¶ Derive uncompressed key
-
beemgraphenebase.account.binary_search(a, x, lo=0, hi=None)¶