Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def encode_base58(self):
"""
Returns a string representation of this seed as an XRPL base58 encoded
string such as 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'.
"""
return base58.b58encode_check(XRPL_SEED_PREFIX + self.bytes).decode()
def encode_ed25519_public_base58(self):
"""
Return the base58-encoded version of the Ed25519 public key.
"""
# Unlike secp256k1, Ed25519 public keys are the same for
# accounts and for validators.
prefix = XRPL_ACCT_PUBKEY_PREFIX
return base58.b58encode_check(prefix +
self.ed25519_public_key).decode()
def encode_secp256k1_public_base58(self, validator=False):
"""
Return the base58-encoded version of the secp256k1 public key.
"""
if validator:
# Validators use the "root" public key
key = self.secp256k1_root_public_key
prefix = XRPL_VALIDATOR_PUBKEY_PREFIX
else:
# Accounts use the derived "master" public key
key = self.secp256k1_public_key
prefix = XRPL_ACCT_PUBKEY_PREFIX
return base58.b58encode_check(prefix + key).decode()