From df235f6c2012ebdc904b4d591a7762ee12ee3159 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Sun, 7 Aug 2022 19:00:19 +0300 Subject: [PATCH] Rewrite highlevelcrypto.makeCryptor() to reuse pyelliptic.ECC._set_keys() --- src/highlevelcrypto.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index 7037bfab..ec43d3f8 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -18,16 +18,13 @@ from bmconfigparser import config __all__ = ['encrypt', 'makeCryptor', 'pointMult', 'privToPub', 'sign', 'verify'] -def makeCryptor(privkey): +def makeCryptor(privkey, curve='secp256k1'): """Return a private `.pyelliptic.ECC` instance""" private_key = a.changebase(privkey, 16, 256, minlen=32) public_key = pointMult(private_key) - privkey_bin = b'\x02\xca\x00\x20' + private_key - pubkey_bin = ( - b'\x02\xca\x00\x20' + public_key[1:-32] + b'\x00\x20' + public_key[-32:] - ) cryptor = pyelliptic.ECC( - curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin) + pubkey_x=public_key[1:-32], pubkey_y=public_key[-32:], + raw_privkey=private_key, curve=curve) return cryptor