commit 8a3e5032b1b0f65dc192c2f821a9fe8b8c9aef13
parent a5d337c0cea4498ad2ee6c0a849ba1b37f890297
Author: ThomasV <electrumdev@gmail.com>
Date: Fri, 14 Aug 2015 16:48:23 +0200
Merge pull request #1389 from romanz/master
remove unused code
Diffstat:
4 files changed, 0 insertions(+), 86 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -2916,16 +2916,3 @@ class ElectrumWindow(QMainWindow):
text.setText(mpk_text)
vbox.addLayout(Buttons(CloseButton(d)))
d.exec_()
-
- @protected
- def create_csr(self, alias, challenge, password):
- from electrum import x509
- import tlslite
- xprv = self.wallet.get_master_private_key(self.wallet.root_name, password)
- _, _, _, c, k = bitcoin.deserialize_xkey(xprv)
- csr = x509.create_csr(alias, challenge, k)
- csr = tlslite.utils.pem.pem(bytearray(csr), "CERTIFICATE REQUEST")
- with open('test.csr', 'w') as f:
- f.write(csr)
- #os.system('openssl asn1parse -i -in test.csr')
- return 'test.csr'
diff --git a/lib/account.py b/lib/account.py
@@ -187,7 +187,6 @@ class OldAccount(Account):
@classmethod
def mpk_from_seed(klass, seed):
- curve = SECP256k1
secexp = klass.stretch_key(seed)
master_private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve = SECP256k1 )
master_public_key = master_private_key.get_verifying_key().to_string().encode('hex')
@@ -211,7 +210,6 @@ class OldAccount(Account):
@classmethod
def get_pubkey_from_mpk(self, mpk, for_change, n):
- curve = SECP256k1
z = self.get_sequence(mpk, for_change, n)
master_public_key = ecdsa.VerifyingKey.from_string( mpk, curve = SECP256k1 )
pubkey_point = master_public_key.pubkey.point + z*curve.generator
@@ -239,7 +237,6 @@ class OldAccount(Account):
def check_seed(self, seed):
- curve = SECP256k1
secexp = self.stretch_key(seed)
master_private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve = SECP256k1 )
master_public_key = master_private_key.get_verifying_key().to_string()
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -604,8 +604,6 @@ def CKD_priv(k, c, n):
return _CKD_priv(k, c, rev_hex(int_to_hex(n,4)).decode('hex'), is_prime)
def _CKD_priv(k, c, s, is_prime):
- import hmac
- from ecdsa.util import string_to_number, number_to_string
order = generator_secp256k1.order()
keypair = EC_KEY(k)
cK = GetPubKey(keypair.pubkey,True)
@@ -627,8 +625,6 @@ def CKD_pub(cK, c, n):
# helper function, callable with arbitrary string
def _CKD_pub(cK, c, s):
- import hmac
- from ecdsa.util import string_to_number, number_to_string
order = generator_secp256k1.order()
I = hmac.new(c, cK + s, hashlib.sha512).digest()
curve = SECP256k1
@@ -706,7 +702,6 @@ def xpub_from_xprv(xprv, testnet=False):
def bip32_root(seed, testnet=False):
- import hmac
header_pub, header_priv = _get_headers(testnet)
I = hmac.new("Bitcoin seed", seed, hashlib.sha512).digest()
master_k = I[0:32]
diff --git a/lib/x509.py b/lib/x509.py
@@ -190,68 +190,3 @@ def load_certificates(ca_path):
ca_keyID[x.get_keyID()] = fp
return ca_list, ca_keyID
-
-
-def int_to_bytestr(i):
- s = chr(i % 256)
- while i > 256:
- i >>= 8
- s = chr(i % 256) + s
- return s
-
-def create_csr(commonName, challenge, k):
- from bitcoin import point_to_ser
- private_key = ecdsa.SigningKey.from_string(k, curve = ecdsa.SECP256k1)
- public_key = private_key.get_verifying_key()
- pubkey = point_to_ser(public_key.pubkey.point, False)
- asn1_type_table = {
- 'BOOLEAN': 0x01, 'INTEGER': 0x02,
- 'BIT STRING': 0x03, 'OCTET STRING': 0x04,
- 'NULL': 0x05, 'OBJECT IDENTIFIER': 0x06,
- 'SEQUENCE': 0x30, 'SET': 0x31,
- 'PrintableString': 0x13, 'IA5String': 0x16,
- 'UTCTime': 0x17, 'ENUMERATED': 0x0A,
- 'UTF8String': 0x0C, 'PrintableString': 0x13,
- }
- def x(t, s):
- c = asn1_type_table[t] & 0x3f if type(t) == str else t
- l = len(s)
- if l < 128:
- ls = chr(l)
- else:
- n = int_to_bytestr(l)
- ls = chr(len(n) + 128) + n
- return chr(c) + ls + s
- x_int = lambda i: x('INTEGER', int_to_bytestr(i))
- x_seq = lambda *items: x('SEQUENCE', ''.join(items))
- x_bitstring = lambda s: x('BIT STRING', s)
- x_utf8 = lambda s: x('UTF8String', s)
- x_set = lambda *items: x('SET', ''.join(items))
- x_printable = lambda s: x('PrintableString', s)
- x_obj = lambda oid: x('OBJECT IDENTIFIER', encode_OID(oid))
- body = x_seq(
- x_int(0),
- x_seq(
- x_set(x_seq(x_obj('2.5.4.3'), x_utf8(commonName)))
- ),
- x_seq(
- x_seq(
- x_obj('1.2.840.10045.2.1'),
- x_obj('1.3.132.0.10')
- ),
- x_bitstring(chr(0) + pubkey)
- ),
- x(0xa0, x_seq(x_obj('1.2.840.113549.1.9.7'), x_set(x_utf8(challenge)))
- )
- )
- signature = private_key.sign_deterministic(body, hashfunc=hashlib.sha256, sigencode = ecdsa.util.sigencode_der)
- assert public_key.verify(signature, body, hashfunc=hashlib.sha256, sigdecode = ecdsa.util.sigdecode_der)
- csr = x_seq(
- body,
- x_seq(x_obj(ALGO_ECDSA_SHA256)),
- x_bitstring(chr(0) + signature)
- )
- return csr
-
-
-