Author Topic: 250 PTS - BOUNTY - Import wallet.dat Private Keys via API call (2 PTS Referral)  (Read 20709 times)

0 Members and 1 Guest are viewing this topic.

Offline bytemaster

How do you want the function to respond to soft errors (corrupt data in db, decryption error etc). Should it throw an exception or ignore and continue with the remaining keys?
I'm able to import the correct private keys from a bitcoin wallet (verified it with a address utility, the public key matches the address in the client). But the public keys i import from pts wallets dont get me the right addresses with
Code: [Select]
auto test_pub = imported_keys[n].get_public_key();
bts::pts_address test_addr(test_pub);
So if the pts_address class is supposed to work i somehow don't get the right public keys from pts wallets while i get the right public keys from bitcoin wallets.

Good work.  Does this even work for wallets that are encrypted?

The pts_address class *should work* but has not been throughly tested.   Could it be a version byte is different in the wallet?

All errors should use FC_THROW_EXCEPTION( ... ) or FC_ASSERT(...) to capture proper debug information to be passed up the stack.

For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

drekrob

  • Guest
How do you want the function to respond to soft errors (corrupt data in db, decryption error etc). Should it throw an exception or ignore and continue with the remaining keys?
I'm able to import the correct private keys from a bitcoin wallet (verified it with a address utility, the public key matches the address in the client). But the public keys i import from pts wallets dont get me the right addresses with
Code: [Select]
auto test_pub = imported_keys[n].get_public_key();
bts::pts_address test_addr(test_pub);
So if the pts_address class is supposed to work i somehow don't get the right public keys from pts wallets while i get the right public keys from bitcoin wallets.

Offline bytemaster

Pts and btc wallet are the same format.

As long as everything is forward declared and OpenSSL headers are not exposed in the header. 


Sent from my iPhone using Tapatalk
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

drekrob

  • Guest
The function is called import_bitcoin_wallet but you say the unit test should check for proper PTS addresses. Can you clarify? Also i would like to change the private_key constructor so it can take an optional EC_KEY if that is ok for you.

Offline bytemaster

The unit tests should include two wallet files one with and one without a password and import multiple keys from both.  Include hidden addresses used for change. 


Sent from my iPhone using Tapatalk
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

drekrob

  • Guest
I am currently working on this bounty. Can you tell me more details about your requirements for unit tests? I've already made some good progress. The code will add libdb_cxx to the dependencies but will not depend on any of the bitcoin-qt sources.

busygin

  • Guest
Ok, I can parse wallet.dat file in C++ now with db_cxx library. Need to learn about the algorithm used for private key encryption and then I think I can handle this task.

Offline 5chdn

  • Sr. Member
  • ****
  • Posts: 487
  • i wonder how many chars i can put in this field 50
    • View Profile
    • Votesapp
  • GitHub: 5chdn

busygin

  • Guest
I am going to increase this bounty to 250 PTS as this is a high priority.

I want to try this task but I've never done any bitcoin or crypto-related development before. So, perhaps a silly noob question: do I understand correctly that wallet.dat is a Berkeley database file? What library (if any) should I use in C++ to read it without bringing something that would contradict bitshares software license?

Offline bytemaster

I am going to increase this bounty to 250 PTS as this is a high priority.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline bytemaster

I am going to increase this bounty to 150 PTS... I suspect that toast has decided to tackle the other bounties in the short term such as the Mac Keyhotee bounty.   Keep up the good work guys.

For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline toast

  • Hero Member
  • *****
  • Posts: 4001
    • View Profile
  • BitShares: nikolai
This project on github claims to be able to import private keys among other things. It is written i Python

Some code I found on the repository

Code: [Select]
def i2d_ECPrivateKey(pkey, compressed=False):#, crypted=True):
    part3='a081a53081a2020101302c06072a8648ce3d0101022100'  # for uncompressed keys
    if compressed:
        if True:#not crypted:  ## Bitcoin accepts both part3's for crypted wallets...
            part3='a08185308182020101302c06072a8648ce3d0101022100'  # for compressed keys
        key = '3081d30201010420' + \
            '%064x' % pkey.secret + \
            part3 + \
            '%064x' % _p + \
            '3006040100040107042102' + \
            '%064x' % _Gx + \
            '022100' + \
            '%064x' % _r + \
            '020101a124032200'
    else:
        key = '308201130201010420' + \
            '%064x' % pkey.secret + \
            part3 + \
            '%064x' % _p + \
            '3006040100040107044104' + \
            '%064x' % _Gx + \
            '%064x' % _Gy + \
            '022100' + \
            '%064x' % _r + \
            '020101a144034200'

    return key.decode('hex') + i2o_ECPublicKey(pkey, compressed)

I am going to test pywallet to see if this works.

Yo, that's awesome. I'm gonna get on IRC in 45 minutes, this looks we could finish really quick if that works.

Quote
Edit: One note of caution. I cant find a license accompanying the code on github.
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

Offline arcke

  • Full Member
  • ***
  • Posts: 115
    • View Profile
    • Diaspora
This project on github claims to be able to import private keys among other things. It is written i Python

Some code I found on the repository

Code: [Select]
def i2d_ECPrivateKey(pkey, compressed=False):#, crypted=True):
    part3='a081a53081a2020101302c06072a8648ce3d0101022100'  # for uncompressed keys
    if compressed:
        if True:#not crypted:  ## Bitcoin accepts both part3's for crypted wallets...
            part3='a08185308182020101302c06072a8648ce3d0101022100'  # for compressed keys
        key = '3081d30201010420' + \
            '%064x' % pkey.secret + \
            part3 + \
            '%064x' % _p + \
            '3006040100040107042102' + \
            '%064x' % _Gx + \
            '022100' + \
            '%064x' % _r + \
            '020101a124032200'
    else:
        key = '308201130201010420' + \
            '%064x' % pkey.secret + \
            part3 + \
            '%064x' % _p + \
            '3006040100040107044104' + \
            '%064x' % _Gx + \
            '%064x' % _Gy + \
            '022100' + \
            '%064x' % _r + \
            '020101a144034200'

    return key.decode('hex') + i2o_ECPublicKey(pkey, compressed)

I am going to test pywallet to see if this works.

Edit: One note of caution. I cant find a license accompanying the code on github.
« Last Edit: January 02, 2014, 03:27:51 am by arcke »
OpenPGP: 0x22d7e9cc35375665
PTS - PawnbhoiXhmkrKJEPAsCiwkpP81nRXJGTD
Diaspora profile - https://pod.orkz.net/u/arcke

Offline bytemaster

Just  install it with apt-get
apt-get install libboost1.54-all-dev


Ubuntu (I assume you're on 13.10) installs boost 1.53 by default, bitshares require 1.54. You can install it with apt-get or you can stay on 1.53 and just downgrade required boost version in CMakeList.txt and also remove boost_coroutine requirement from it. It compiles and runs fine with 1.53, I compiled and ran Keyhotee a few days ago.

Yes, I am running Ubuntu 13.10.

I tried to install Boost 1.55, with this sequence:
Code: [Select]
wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2
tar --bzip2 -xf /path/to/boost_1_55_0.tar.bz2
cd boost_1_55_0/
./bootstrap.sh --prefix=/usr/local/
./b2 install
./bjam
sudo ./bjam install

The same error about 1.53 still appears.
Code: [Select]
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1126 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.53.0

  Boost include path: /usr/include

  The following Boost libraries could not be found:

          boost_coroutine

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:57 (FIND_PACKAGE)


-- Boost version: 1.53.0
-- Found the following Boost libraries:
--   thread
--   date_time
--   system
--   filesystem
--   program_options
--   signals
--   serialization
--   chrono
--   unit_test_framework
--   context
CMake Warning (dev) at CMakeLists.txt:87 (set):
  Cannot set "BOOST_LIBRARIES": current scope has no parent.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
[/quote]

You need to upgrade to boost 1.54
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
Just  install it with apt-get
apt-get install libboost1.54-all-dev


Ubuntu (I assume you're on 13.10) installs boost 1.53 by default, bitshares require 1.54. You can install it with apt-get or you can stay on 1.53 and just downgrade required boost version in CMakeList.txt and also remove boost_coroutine requirement from it. It compiles and runs fine with 1.53, I compiled and ran Keyhotee a few days ago.

Yes, I am running Ubuntu 13.10.

I tried to install Boost 1.55, with this sequence:
Code: [Select]
wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2
tar --bzip2 -xf /path/to/boost_1_55_0.tar.bz2
cd boost_1_55_0/
./bootstrap.sh --prefix=/usr/local/
./b2 install
./bjam
sudo ./bjam install

The same error about 1.53 still appears.
Code: [Select]
CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1126 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.53.0

  Boost include path: /usr/include

  The following Boost libraries could not be found:

          boost_coroutine

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
Call Stack (most recent call first):
  CMakeLists.txt:57 (FIND_PACKAGE)


-- Boost version: 1.53.0
-- Found the following Boost libraries:
--   thread
--   date_time
--   system
--   filesystem
--   program_options
--   signals
--   serialization
--   chrono
--   unit_test_framework
--   context
CMake Warning (dev) at CMakeLists.txt:87 (set):
  Cannot set "BOOST_LIBRARIES": current scope has no parent.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
[/quote]