From a01ddfd438caaee17820e9975cd195130de88fa2 Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Sat, 17 Oct 2020 12:25:03 +0200
Subject: [PATCH] [mod] #176: Use base58 module

Not added as a direct dependency, since it is a DuniterPy dependency
And Silkaj won't get away from DuniterPy, nor DuniterPy will stop using
base58.
---
 silkaj/crypto_tools.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/silkaj/crypto_tools.py b/silkaj/crypto_tools.py
index 13e9b126..88ce3fea 100644
--- a/silkaj/crypto_tools.py
+++ b/silkaj/crypto_tools.py
@@ -17,6 +17,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
 
 import re
 import hashlib
+
+import base58
 from nacl import encoding
 
 from silkaj.constants import PUBKEY_PATTERN
@@ -77,9 +79,9 @@ def gen_checksum(pubkey):
     """
     Returns the checksum of the input pubkey (encoded in b58)
     """
-    pubkey_byte = b58_decode(pubkey)
+    pubkey_byte = base58.b58decode(pubkey)
     hash = hashlib.sha256(hashlib.sha256(pubkey_byte).digest()).digest()
-    return b58_encode(hash)[:3]
+    return base58.b58encode(hash)[:3].decode("utf-8")
 
 
 b58_digits = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
-- 
GitLab