Пример #1
0
def ecssa_commit_and_sign(m, prv, c, eph_prv=None, hasher=sha256):
    prv = int_from_prvkey(prv)
    eph_prv = rfc6979(prv, m,
                      hasher) if eph_prv is None else int_from_prvkey(eph_prv)
    R, eph_prv = tweak(eph_prv, c, hasher)
    sig = ecssa_sign_raw(m, prv, eph_prv, hasher)
    receipt = (sig[0], R)
    return sig, receipt
Пример #2
0
def det_wallet2(key, r, i):
  r_bytes = r.to_bytes(32, 'big')
  i_bytes = i.to_bytes(32, 'big')
  h_hex = sha256(i_bytes+r_bytes).hexdigest()
  h_int = int(h_hex, 16)

  try:
    prvkey = int_from_prvkey(key)
    return (prvkey + h_int) % ec.order
  except:
    pubkey = ec.tuple_from_point(key)
    return ec.pointAdd(pubkey, ec.pointMultiply(h_int))
  raise ValueError("Invalid key")
Пример #3
0
def ecssa_sign(m, prv, eph_prv=None, hasher=sha256) -> Tuple[int, int]:
    if type(m) == str: m = hasher(m.encode()).digest()
    prv = int_from_prvkey(prv)
    eph_prv = rfc6979(prv, m,
                      hasher) if eph_prv is None else int_from_prvkey(eph_prv)
    return ecssa_sign_raw(m, prv, eph_prv, hasher)