def __init__(this): this.handshake_done = False this.key = None this.privkey = randrange(2, EC.order) this.pubkey = EC.ec_scalar(EC.E, this.privkey, EC.G) this.hash_privkey = hashlib.sha1(str( this.privkey).encode("utf-8")).hexdigest()
exit() try: if ('x' not in spub.keys()) or ('y' not in spub.keys()): print("ERROR: need x,y keys in json") exit() except Exception as e: print(e.args[0] + ": JSON Error II - quitting") exit() if (type(spub['x']) != int) or (type(spub['y']) != int): print("ERROR: x and y should be ints") exit() spub_point = EC.ec_point(EC.E, spub['x'], spub['y']) shared_point = EC.ec_scalar(EC.E, S.privkey, spub_point) S.key = kdf(shared_point) S.handshake_done = True continue #Get Super Cool Fact! if cmd == "2": if S.handshake_done == False: print("Need to perform handshake first!") continue cf = choice(cool_facts) cipher = encrypt_message(cf.encode("utf-8"), S.key)