Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: Ukigo on August 25, 2011, 02:42:39 PM



Title: Pywallet fork for SolidCoin and more
Post by: Ukigo on August 25, 2011, 02:42:39 PM
Hi all !
 Pywallet.py fork for  SolidCoin https://github.com/ukigo/pywallet_solidcoin.git

Tested for creation and import privkeys only.

EDIT: Use this "evil" fork ONLY if you wish to play with key generator below or something similar.
For other purposes please use : https://github.com/jackjack-jj/pywallet

And yet another privkey generator, but for SolidCoin only.See code below.

Code:
#!/usr/bin/python

# Copyright (c) 2011, Ukigo

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


usage = """             Usage : ./solkgn your_passphrase_here your_number_from_0_to_32

                        Example :  ./solkgn =Sezam-+-+-+-+-+-+-+ 13 """


import sys, hashlib
import pywallet_solidcoin as pyw

def gen():

    try:
        if sys.argv[1] in ("help", "-h", "-help","--help"):
            print " "
            print usage
            exit(0)

    except IndexError:
        print " "
        print usage
        exit(0)

    print " "

    hash1 = hashlib.sha512(sys.argv[1]).digest()
    hash2 = hashlib.sha512(hash1).digest()
    hash3 = hashlib.sha512(hash2).digest()
    hash4 = hashlib.sha512(hash3).digest()
    hash5 = hashlib.sha512(hash4).digest()

    cut = int(sys.argv[2])
    if cut>32 or cut<0:
        print "Number must be in range 0...32"
        return

    print " "
    print "    Input was : ", sys.argv[1]

    topsec = hash5[cut:cut+32]
#    print len(topsec)
    print "                 ................................................................"
    print "    Sec (hex) : ", topsec.encode("hex")

    
    
    print " "
    
    secret = pyw.str_to_long(topsec)
    eckey = pyw.EC_KEY(secret)
    pub = pyw.GetPubKey(eckey)
    priv = pyw.GetPrivKey(eckey)
    priv_base58 = pyw.SecretToASecret(pyw.PrivKeyToSecret(priv))
    print "    Key for import : ", priv_base58
    
    print " "
    print "                Address :  "+pyw.public_key_to_bc_address(pub)
    print " "
    exit(0)

if __name__ == '__main__':
    gen()

 


Title: Re: Pywallet fork for SolidCoin and more
Post by: Ukigo on August 25, 2011, 03:03:03 PM
How to use :
1) Install SolidCoin.
2) install pywallet_solidcoin from link in OP.
3) Save code from code block above in the same dir with pywallet_solidcoin.py
    as "solkgn".
4) chmod 700 ./solkgn
5) $ ./solkgn Good-Intentions=================Hell-Route 13
6) Note "Key for import" string from script output.
7) Be sure that SolidCoin is not running.
9) $ python pywallet_solidcoin.py  --datadir=/path/to/solidcoin_wallet \
 --importprivkey=your_key_here_from_5th_step
10) PROFIT ! Now you have deterministic key imported in your SolidCoin wallet.dat



Title: Re: Pywallet fork for SolidCoin and more
Post by: jackjack on August 25, 2011, 03:06:24 PM
Did you leave your basement during the last thousand years?

Pywallet already support all existing and future blockchains

Also, you forked the old Joric's pywallet, ie you forked a tool which is already outdated
Well done


Title: Re: Pywallet fork for SolidCoin and more
Post by: Ukigo on August 25, 2011, 03:23:31 PM
Hmm, try to import Solidcoin key with your fork.
Then we will see who is right.


Title: Re: Pywallet fork for SolidCoin and more
Post by: jackjack on August 25, 2011, 03:27:46 PM
I don't have to try I know it works
Follow my instructions (https://bitcointalk.org/index.php?topic=34028.0) with Version = 125 instead of 0
It worked for Bitcoin, Namecoin, I0coin, Ixcoin, Devcoin, Groupcoin, and all their testnets

Basically you just:
 - created a useless function
 - reintroduced 2 bugs
Code:
$ diff old_joric_pywallet this_awesome_fork
3c3
< # pywallet_solidcoin.py 1.1
---
> # pywallet.py 1.1
6c6
< # Usage: pywallet_solidcoin.py [options]
---
> # Usage: pywallet.py [options]
30,31c30,31
< max_version = 32500
< addrtype = 125
---
> max_version = 32400
> addrtype = 0
207a208
> return hex_der_key.decode('hex')
229a231,235
> # private keys are 279 bytes long (see crypto/ec/cec_asn1.c)
> # ASN1_SIMPLE(EC_PRIVATEKEY, version, LONG),
> # ASN1_SIMPLE(EC_PRIVATEKEY, privateKey, ASN1_OCTET_STRING),
> # ASN1_EXP_OPT(EC_PRIVATEKEY, parameters, ECPKPARAMETERS, 0),
> # ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1)
244a251,252
> # public keys are 65 bytes long (520 bits)
> # 0x04 + 32-byte X-coordinate + 32-byte Y-coordinate
271,279d278
< def short_hex(bytes):
< t = bytes.encode('hex_codec')
< if len(t) < 32:
< return t
< return t[0:32]+"..."+t[-32:]
<
365c364
< vchIn = chr(addrtype) + secret
---
> vchIn = chr(addrtype+128) + secret
370c369
< if vch and vch[0] == chr(addrtype):
---
> if vch and vch[0] == chr(addrtype+128):
685a685,689
> elif type == "bestblock":
> vds.write_int32(d['nVersion'])
> vds.write_compact_size(len(d['hashes']))
> for h in d['hashes']:
> vds.write(h)



Title: Re: Pywallet fork for SolidCoin and more
Post by: Ukigo on August 25, 2011, 05:26:36 PM
"short_hex" function is not mine.
Bugs ?! These are features. :)

BTW, my fork works for me just fine, i already imported ~100 keys
 and have  coins transfered to those addresses.

And yes i pretty love my basement and hate abusive strangers.
Dunno why, but they are tend to disappear.  ;D


Title: Re: Pywallet fork for SolidCoin and more
Post by: jackjack on August 25, 2011, 05:52:16 PM
Yes,
Code:
chr(addrtype+128)
instead of
Code:
chr(addrtype)
is a bug, or rather something that goes against the de facto standards

I didn't say it doesn't work
It's just like ix/i0/solidcoin: copy the code, change a value, tada I made a fork
You guys should really help Bitcoin projects instead of parasiting them (mainly when it doesn't add any value...)


Title: Re: Pywallet fork for SolidCoin and more
Post by: Ukigo on August 25, 2011, 06:04:38 PM

You guys should really help Bitcoin projects instead of parasiting them (mainly when it doesn't add any value...)
I'm helping :) See my key generator above.
Most of it shamelessly copied from my own previous analogs.