Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pooler committed Sep 27, 2017
2 parents 121bcde + 088b1e6 commit 4520157
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ To create binaries, create the 'packages' directory::

This directory contains the python dependencies used by Electrum.

Mac OS X
Mac OS X / macOS
--------

::

# On MacPorts installs:
sudo python setup-release.py py2app
sudo python3 setup-release.py py2app
# On Homebrew installs:
ARCHFLAGS="-arch i386 -arch x86_64" sudo python setup-release.py py2app --includes sip
ARCHFLAGS="-arch i386 -arch x86_64" sudo python3 setup-release.py py2app --includes sip
sudo hdiutil create -fs HFS+ -volname "Electrum-LTC" -srcfolder dist/Electrum-LTC.app dist/electrum-ltc-VERSION-macosx.dmg

Expand Down
8 changes: 7 additions & 1 deletion contrib/build-wine/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
These scripts can be used for cross-compilation of Windows Electrum executables from Linux/Wine.

Usage:
1. Install Wine (tested with wine-1.7.18)
1. Install wine (development version)

$ sudo apt-get install wine-development
$ sudo ln -sf /usr/bin/wine-development /usr/local/bin/wine
$ wine --version
wine-2.0 (Debian 2.0-3+b2)

2. Run "./prepare-wine.sh", it will download all dependencies. When you'll be asked, always leave default settings and press "Next >".
3. Run "./prepare-hw.sh" to build support for hardware wallets (TREZOR)
4. Run "./build-electrum-git.sh". Sources will be packed into three separate versions to dist/ directory:
Expand Down
9 changes: 6 additions & 3 deletions lib/bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ def minikey_to_private_key(text):


def msg_magic(message):
varint = var_int(len(message))
encoded_varint = varint.encode('ascii')
return b"\x19Litecoin Signed Message:\n" + encoded_varint + message
length = bfh(var_int(len(message)))
return b"\x19Litecoin Signed Message:\n" + length + message


def verify_message(address, sig, message):
Expand All @@ -587,6 +586,10 @@ def verify_message(address, sig, message):
print_error("Verification error: {0}".format(e))
return False

def sign_message_with_wif_privkey(sec, message):
key = regenerate_key(sec)
compressed = is_compressed(sec)
return key.sign_message(message, compressed)

def encrypt_message(message, pubkey):
return EC_KEY.encrypt_message(message, bfh(pubkey))
Expand Down
4 changes: 1 addition & 3 deletions lib/keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def may_have_password(self):

def sign_message(self, sequence, message, password):
sec = self.get_private_key(sequence, password)
key = regenerate_key(sec)
compressed = is_compressed(sec)
return key.sign_message(message, compressed)
return sign_message_with_wif_privkey(sec, message)

def decrypt_message(self, sequence, message, password):
sec = self.get_private_key(sequence, password)
Expand Down
22 changes: 21 additions & 1 deletion lib/tests/test_bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function
from __future__ import unicode_literals

import base64
import six
import unittest
import sys
Expand All @@ -13,7 +14,8 @@
bip32_root, bip32_public_derivation, bip32_private_derivation, pw_encode,
pw_decode, Hash, public_key_from_private_key, address_from_private_key,
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed,
var_int, op_push, address_to_script)
var_int, op_push, address_to_script, sign_message_with_wif_privkey,
verify_message)
from lib.util import bfh

try:
Expand Down Expand Up @@ -55,6 +57,24 @@ def _do_test_crypto(self, message):
#print signature
EC_KEY.verify_message(eck, signature, message)

def test_msg_signing(self):
msg1 = b'Chancellor on brink of second bailout for banks'
msg2 = b'Electrum'

sig1 = sign_message_with_wif_privkey(
'T7J3unHmmx9S8e8Zdi9r98A7wTW386HkxvMbUKEMsAY9JRWfbSe6', msg1)
sig2 = sign_message_with_wif_privkey(
'T6oaa3RpobKE2jFtkUyBJHcvCBKQJsBoSoAqZnzUQ3oexiXW7rWq', msg2)

sig1_b64 = base64.b64encode(sig1)
sig2_b64 = base64.b64encode(sig2)

self.assertEqual(sig1_b64, b'IHGAMaPxjrn3CD19S7J5KAq4xF6mdLznsSL8SrqhNwficUHlK5wSth6/JiZ/pEyo92nkUoA+kL9VJpjLnKJKTmM=')
self.assertEqual(sig2_b64, b'IIYiI5SslM+9hBEedDjl03V51vuDgjbJ493Ygb3DfDzaHBp/AkCWeJ7EL8s6IHvTsb2CHF/y8MlVQJTs5fXCOvs=')

self.assertTrue(verify_message('LPvBisC3rGmpGa3E3NeQk3PHQN4VS237y2', sig1, msg1))
self.assertTrue(verify_message('LeqUvj52PSAtwcwUPKR11zRod4N3fEg2Lx', sig2, msg2))

def test_bip32(self):
# see https://en.bitcoin.it/wiki/BIP_0032_TestVectors
xpub, xprv = self._do_test_bip32("000102030405060708090a0b0c0d0e0f", "m/0'/1/2'/2/1000000000")
Expand Down

0 comments on commit 4520157

Please sign in to comment.