import ecdsa
import random
from hashlib import sha256

def privatekey():
    n = 1.158 * 10**77
    rng = random.SystemRandom()
    random_num = rng.randint(0, n)
    private_key = int(sha256(str(random_num).encode()).hexdigest(),16)

    while private_key > n:
        random_num = rng.randint(0, n)
        private_key = int(sha256(str(random_num).encode()).hexdigest(),16)

        if private_key < n: 
            print(random_num)
            print(private_key)
            return private_key
            break

    else:
        print(random_num)
        print(private_key)
        return private_key

private_key = privatekey()        

def private_to_public_key(private_key):
    signing_key = ecdsa.SigningKey.from_string(private_key,curve=ecdsa.SECP256k1)
verifying_key = signing_key.verifying_key
return verifying_key.to_string()

public_key = private_to_public_key(private_key)
print(public_key)

このコードでこんなエラー文が出ます。

assert len(string) == curve.baselen, (len(string), curve.baselen)

TypeError: object of type 'int' has no len()

どう対処すればよいのでしょうか。