1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

tools: make sure that passed Base58 string uses valid alphabet

This commit is contained in:
matejcik 2019-01-23 11:34:41 +01:00
parent d668954a3b
commit 7d14018f99

View File

@ -107,6 +107,10 @@ def b58decode(v, length=None):
if isinstance(v, bytes):
v = v.decode()
for c in v:
if c not in __b58chars:
raise ValueError("invalid Base58 string")
long_value = 0
for (i, c) in enumerate(v[::-1]):
long_value += __b58chars.find(c) * (__b58base ** i)