コード例 #1
0
 def test_encrypt(self):
     self.assertEqual([format(encrypt(PrivateKey("5HqUkGuo62BfcJU5vNhTXKJRXuUi9QSE6jp8C3uBJ2BVHtB8WSd"), "TestingOneTwoThree"), "encwif"),
                       format(encrypt(PrivateKey("5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR"), "TestingOneTwoThree"), "encwif"),
                       format(encrypt(PrivateKey("5HtasZ6ofTHP6HCwTqTkLDuLQisYPah7aUnSKfC7h4hMUVw2gi5"), "Satoshi"), "encwif")],
                      ["6PRN5mjUTtud6fUXbJXezfn6oABoSr6GSLjMbrGXRZxSUcxThxsUW8epQi",
                       "6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg",
                       "6PRNFFkZc2NZ6dJqFfhRoFNMR9Lnyj7dYGrzdgXXVMXcxoKTePPX1dWByq"])
コード例 #2
0
ファイル: wallet.py プロジェクト: bue-twitter/piston
 def encrypt_wif(self, wif):
     """ Encrypt a wif key
     """
     self.unlock()
     if self.masterpassword == "":
         return wif
     else:
         return format(bip38.encrypt(PrivateKey(wif), self.masterpassword), "encwif")
コード例 #3
0
    def encrypt(self, wif):
        """ Encrypt the content according to BIP38

            :param str wif: Unencrypted key
        """
        if not self.unlocked():
            raise WalletLocked
        return format(bip38.encrypt(str(wif), self.masterkey), "encwif")
コード例 #4
0
ファイル: wallet.py プロジェクト: Someguy123/piston
 def encrypt_wif(self, wif):
     """ Encrypt a wif key
     """
     self.unlock()
     if self.masterpassword == "":
         return wif
     else:
         return format(bip38.encrypt(PrivateKey(wif), self.masterpassword),
                       "encwif")
コード例 #5
0
 def test_encrypt(self):
     self.assertEqual([
         format(
             encrypt(
                 PrivateKey(
                     "5HqUkGuo62BfcJU5vNhTXKJRXuUi9QSE6jp8C3uBJ2BVHtB8WSd"),
                 "TestingOneTwoThree"), "encwif"),
         format(
             encrypt(
                 PrivateKey(
                     "5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR"),
                 "TestingOneTwoThree"), "encwif"),
         format(
             encrypt(
                 PrivateKey(
                     "5HtasZ6ofTHP6HCwTqTkLDuLQisYPah7aUnSKfC7h4hMUVw2gi5"),
                 "Satoshi"), "encwif")
     ], [
         "6PRN5mjUTtud6fUXbJXezfn6oABoSr6GSLjMbrGXRZxSUcxThxsUW8epQi",
         "6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg",
         "6PRNFFkZc2NZ6dJqFfhRoFNMR9Lnyj7dYGrzdgXXVMXcxoKTePPX1dWByq"
     ])
コード例 #6
0
def main() :
    parser = argparse.ArgumentParser(description='Generate CSV table with brain key, pub key and private key')
    parser.add_argument('--number', type=int, help='Number of brain keys to generate')
    parser.add_argument('--filename', type=str, help='filename to store CSV file in')
    parser.add_argument('-encrypt', help='Encrypt private key with BIP38!', action='store_true')
    parser.set_defaults(number=10)
    args = parser.parse_args()

    '''
    Optionally encrypt with BIP38
    '''
    pw = ""
    if args.encrypt :
        import getpass
        while True :
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if(pw == pwck) :
                break
            else :
                print("Given Passphrases do not match!")

    t = PrettyTable(["wif", "pub", "sequence"])
    b = BrainKey()
    for i in range(0, args.number) :
        wif = b.get_private()
        pub = format(b.get_private().pubkey, prefix)
        if args.encrypt :  # (optionally) encrypt paper wallet
            try :
                wif = format(bip38.encrypt(wif, pw), "encwif")
            except :
                raise Exception("Error encoding the privkey for pubkey %s.  Already encrypted?" % pub)
            assert format(b.get_private(), 'wif') == format(bip38.decrypt(wif, pw), 'wif')

        t.add_row([wif, pub, b.sequence])
        b.next_sequence()

    print("This is your (unencrypted) Brainkey. Make sure to store it savely:")
    print("\n\n\t%s\n\n" % b.get_brainkey())
    print(t.get_string())

    if args.filename :
        with open(args.filename, 'w') as file:
            file.write("# This is your (unencrypted) Brainkey. Make sure to store it savely:\n")
            file.write("#\n#\t%s\n#\n" % b.get_brainkey())
        with open(args.filename, 'a') as csvfile:
            spamwriter = csv.writer(csvfile, delimiter=';')
            spamwriter.writerow(t.field_names)
            for r in t._rows :
                spamwriter.writerow(r)
コード例 #7
0
 def encrypt_wif(self, wif):
     """ Encrypt a wif key
     """
     assert not self.locked()
     return format(bip38.encrypt(PrivateKey(wif), self.masterpassword),
                   "encwif")
コード例 #8
0
###CONVERTIR EL PRIVATE KEY WALLET IMPORT FORMAT WIFC
private_key_hexc = '80' + ecdsaPrivateKey.to_string().hex()+'01'
first_sha256 = hashlib.sha256(binascii.unhexlify(private_key_hexc)).hexdigest()
second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()
final_key = private_key_hexc+second_sha256[:8]
WIFC = base58.b58encode(binascii.unhexlify(final_key))


##http://docs.pygraphenelib.com/en/latest/bip38.html
##https://github.com/xeroc/python-graphenelib
###COLOCAR A LA LLAVE PRIVADA WIF UNA CONTRASENA O PASSWORD BIP0038
print()
password = input("Colocar Password Llave Privada: ")
print()
WIFPASS = format(encrypt(PrivateKey(WIF.decode('utf-8')),password), "encwif")

print("--------------------------------------------------------------")
print("DIRECCION PUBLICA 1: ", bitcoinAddress.decode('utf8'))
print()
print("LLAVE PRIVADA HEX: ", ecdsaPrivateKey.to_string().hex())
print("LLAVE PRIVADA WIF Encrypted Key (BIP0038) CON CONTRASEÑÁ:  ", WIFPASS)
print("LLAVE PRIVADA WIF:  ", WIF.decode('utf-8'))
print("LLAVE PRIVADA WIF COMPRESS: ", WIFC.decode('utf-8'))

print("--------------------------------------------------------------")

generarcodigoqr(WIF,"PrivateAddress.eps",WIF)
generarcodigoqr(WIFPASS,"PrivateAddressPassword.eps",WIFPASS)
generarcodigoqr(bitcoinAddress.decode('utf-8'),"PublicAddress.eps",bitcoinAddress.decode('utf-8'))
コード例 #9
0
def main() :
    parser = argparse.ArgumentParser(description='Generate CSV table with brain key, pub key and private key')
    parser.add_argument('--number', type=int, help='Number of brain keys to generate')
    parser.add_argument('--filename', type=str, help='filename to store CSV file in')
    parser.add_argument('-encrypt', help='Encrypt private key with BIP38!', action='store_true')
    parser.set_defaults(number=10)
    args = parser.parse_args()

    '''
    Optionally encrypt with BIP38
    '''
    pw = ""
    if args.encrypt :
        import getpass
        while True :
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if(pw == pwck) :
                break
            else :
                print("Given Passphrases do not match!")

    t = PrettyTable(["wif", "pub", "sequence"])
    b = BrainKey()
    for i in range(0, args.number) :
        wif = b.get_private()
        pub = format(b.get_private().pubkey, prefix)
        if args.encrypt :  # (optionally) encrypt paper wallet
            try :
                wif = format(bip38.encrypt(wif, pw), "encwif")
            except :
                raise Exception("Error encoding the privkey for pubkey %s.  Already encrypted?" % pub)
            assert format(b.get_private(), 'wif') == format(bip38.decrypt(wif, pw), 'wif')

        qrwif = StringIO()
        qr = qrcode.QRCode(error_correction=qrcode.ERROR_CORRECT_H)
        qr.add_data(wif)
        qr.print_ascii(out=qrwif, tty=False, invert=False)

        qrpub = StringIO()
        qr = qrcode.QRCode(error_correction=qrcode.ERROR_CORRECT_H)
        qr.add_data(pub)
        qr.print_ascii(out=qrpub, tty=False, invert=False)

        t.add_row(["%s%s" % (qrwif.getvalue(), wif),
                   "%s%s" % (qrpub.getvalue(), pub),
                   b.sequence])
        b.next_sequence()

    print("This is your (unencrypted) Brainkey. Make sure to store it savely:")
    print("\n\n\t%s\n\n" % b.get_brainkey())

    t.hrules = 1
    t.vrules = 1
    t.padding_width = 1
    t.header = False
    data = t.get_string()
    print(data)

    if args.filename :
        with open(args.filename, 'w') as file:
            file.write("# This is your (unencrypted) Brainkey. Make sure to store it savely:\n")
            file.write("#\n#\t%s\n#\n" % b.get_brainkey())
        with open(args.filename, 'a') as csvfile:
            spamwriter = csv.writer(csvfile, delimiter=';')
            spamwriter.writerow(t.field_names)
            for r in t._rows :
                spamwriter.writerow(r)