Post
Topic
Board Proje Geliştirme
Merits 1 from 1 user
Re: Bitcoin; Algoritma Üzerine Yöntemler
by
Jupiter_01
on 15/12/2019, 11:15:20 UTC
⭐ Merited by 2run (1)
Random Private Key Üretip Adres ve compressed Adres çıktısını almak



import bitcoin
import qrcode

f = open("keyler.txt", "w")
z = open("adresler.txt", "w")
for i in range(10000000):
  valid_private_key = False
  while not valid_private_key:
    private_key = bitcoin.random_key()
    #private_key = str('siz girin')
    decoded_private_key = bitcoin.decode_privkey(private_key, 'hex')
    valid_private_key = 0 < decoded_private_key < bitcoin.N

  #print ('Private Key (hex) is: ' + private_key)
  #print ('private Key (decimal) is: ' + str(decoded_private_key))
  wif_encoded_private_key = bitcoin.encode_privkey(decoded_private_key, 'wif')
  #print('Private Key (WIF) is: ' + wif_encoded_private_key)
  compressed_private_key = private_key + '01'
  #print ('Private Key Compressed (hex) is: ' + compressed_private_key)
  wif_compressed_private_key = bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'), 'wif')
  #print ('Private Key (WIF-compressed) is: ' + wif_compressed_private_key)
  public_key = bitcoin.fast_multiply(bitcoin.G, decoded_private_key)
  #print ('Public Key (x,y) coordinates are: ' + str(public_key))
  hex_encoded_public_key = bitcoin.encode_pubkey(public_key, 'hex')
  #print ('Public Key (hex) is: ' + hex_encoded_public_key)
  (public_key_x, public_key_y) = public_key
  if public_key_y % 2 == 0:
    compressed_prefix = '02'
  else:
    compressed_prefix = '03'
  hex_compressed_public_key = compressed_prefix + bitcoin.encode(public_key_x, 16)
  #print ('Compressed Public Key is: ' + hex_compressed_public_key)
  print ('Adres ' + bitcoin.pubkey_to_address(public_key))
  print ('CAdres ' + bitcoin.pubkey_to_address(hex_compressed_public_key))
  compressed_address_base58check = bitcoin.pubkey_to_address(hex_compressed_public_key)

  f.write(bitcoin.pubkey_to_address(public_key)  + "//" + bitcoin.pubkey_to_address(hex_compressed_public_key) + "//" + private_key  + "\n")
  z.write(bitcoin.pubkey_to_address(public_key)  + "\n" + bitcoin.pubkey_to_address(hex_compressed_public_key) + "\n")