#!/usr/bin/python3
import ecdsa
import os, sys
import hashlib


# check if the private key was provided as a command-line argument
if len(sys.argv) < 2:
    print("Error: Private key not provided")
    sys.exit(1)

# generate a random byte string
random_bytes = os.urandom(32)

# compute the SHA-512 hash of the random bytes
#sha512 = hashlib.sha512(random_bytes).hexdigest()
sha512 = 'http://localhost:5000/get/1'

# read in the first argument that should be ecdsa key in hex form
private_key_hex = sys.argv[1]

# Convert the private key from hexadecimal to an integer
private_key_int = int(private_key_hex, 16)

# Generate SK from the private key
sk = ecdsa.SigningKey.from_secret_exponent(private_key_int, curve=ecdsa.SECP256k1)

# sign the message
signature = sk.sign(sha512.encode())

# print the signature
print(signature)

