# -*- coding: utf-8 -*- from lightecc import LightECC from lightecc import EllipticCurvePoint import secrets from hashlib import sha256 ec = LightECC(curve_name = "p256") G = ec.G def sha256int(s): return int.from_bytes(sha256(s.encode()).digest(), byteorder = "big") def gen(): d = secrets.randbits(256) % ec.n Q = d*G return d, Q def sig2(m, d): k = sha256int(m + str(d)) % ec.n R = k*G r = sha256int(m + str(R.x)) % ec.n s = (k + r + d) % ec.n return R.x, s d, Q = gen() m = "hello" rx, s = sig2(m, d)