Skip to content

Commit

Permalink
signtocontract: assert that points round-trip uniquely when hashing them
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Apr 13, 2018
1 parent bbe30af commit 6de546f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opentimestamps/core/secp256k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def _do_op_call(self, msg):
raise MsgValueError("Missing secp256k1 point")

pt = Point.decode(msg[0:33])
assert(pt.encode() == msg[0:33])

hasher = hashlib.sha256()
hasher.update(pt.encode())
hasher.update(msg[0:33])
hasher.update(msg[33:])
tweak = int.from_bytes(hasher.digest(), 'big')
tweak_pt = SECP256K1_GEN.scalar_mul(tweak)
Expand Down

0 comments on commit 6de546f

Please sign in to comment.