tecies: don't drop sign of ephemeral key - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit eed37c41b51f99e1fa6e532a20fe879d6388729d DIR parent 03e420b1c04aa9b245406d5361c41b4f648b848c HTML Author: ThomasV <thomasv@gitorious> Date: Mon, 1 Sep 2014 13:15:15 +0200 ecies: don't drop sign of ephemeral key Diffstat: M lib/bitcoin.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- DIR diff --git a/lib/bitcoin.py b/lib/bitcoin.py t@@ -522,8 +522,7 @@ class EC_KEY(object): ephemeral_exponent = number_to_string(ecdsa.util.randrange(pow(2,256)), generator_secp256k1.order()) ephemeral = EC_KEY(ephemeral_exponent) - ecdh_key = (pk * ephemeral.privkey.secret_multiplier).x() - ecdh_key = ('%064x' % ecdh_key).decode('hex') + ecdh_key = point_to_ser(pk * ephemeral.privkey.secret_multiplier) key = hashlib.sha512(ecdh_key).digest() key_e, key_m = key[:32], key[32:] t@@ -559,8 +558,7 @@ class EC_KEY(object): if not ecdsa.ecdsa.point_is_valid(generator_secp256k1, ephemeral_pubkey.x(), ephemeral_pubkey.y()): raise Exception('invalid ciphertext: invalid ephemeral pubkey') - ecdh_key = (ephemeral_pubkey * self.privkey.secret_multiplier).x() - ecdh_key = ('%064x' % ecdh_key).decode('hex') + ecdh_key = point_to_ser(ephemeral_pubkey * self.privkey.secret_multiplier) key = hashlib.sha512(ecdh_key).digest() key_e, key_m = key[:32], key[32:] if mac != hmac.new(key_m, encrypted[:-32], hashlib.sha256).digest():