Post
Topic
Board Bitcoin Discussion
Merits 8 from 3 users
Re: Please steal my bitcoins
by
NotATether
on 30/03/2021, 12:01:31 UTC
⭐ Merited by LoyceV (4) ,DdmrDdmr (2) ,xandry (2)
Who is going to be tying this will do it out of boredom rather than for the reward

Yeah  Lips sealed

Some multithreaded script I was working on the last few hours:

Code:
from bitcoin import *
import threading
import time
import math
import sys

pub = "bc1qq2rnv02hjzv5h0lwa03um43afwcfcpf0qg56ca"
randprv = "LP5U3KWRLvPwDefz4FVMrAJVFtU4u8pj15w8VSpZF2aaPeY5QIx8"
_1M=1024**2
nthreads = 48

def index2permarray(k, size):
  if size <= 1:
    return [0]
  arr = []
  while size > 1:
    multiplier = math.factorial(size-1)
    digit = math.floor(k/multiplier)
    arr += [digit]
    k = k % multiplier
    size = size-1
  return arr

fact52array = []
for i in range(0,53):
  fact52array += [math.factorial(i)]

def index2permutation(i,n,p):
  arr=""
  for k in range(1, n + 1): # k goes from 1 to n
    f = fact52array[n - k]  # compute factorial once per iteration
    d = i // f            # use integer division (like division + floor)
    arr = arr + str(p[d])          # print permuted number with trailing space
    p = p[:d] + p[d+1:]        # delete p[d] from p
    i = i % f             # reduce i to its remainder
  return arr

class checkKey (threading.Thread):
   def __init__(self, threadID, low, high):
      threading.Thread.__init__(self)
      self.threadID = threadID
      self.low = low
      self.high = high
   def run(self):
     for i in range(self.low, self.high+1):
        if (self.high-self.low+1 - i) % 100 == 0:
          print("Thread {}: {}%".format(self.threadID, i/(self.high-self.low+1)))
        prv = index2permutation(i,52,randprv)
        try:
          testpub = prvtopub(prv)
          if testpub == pub:
             printf("Match: " + prv)
             sys.exit(0)
        except Exception as s:
          pass

fact52 = math.factorial(52)
def main():
  threadcount=0
  k=0
  while _1M*k<fact52:
    while (threading.activeCount() <= nthreads):
      checkKey(threading.activeCount(), _1M*k, _1M*(k+1)).start()
      threadcount += 1
      k += 1
    time.sleep(0.01)
    #print(str(_1M*k/fact52*100) + "% ", end="", flush=True)

main()

Basically what it does is that it spawns a couple of threads and maps a specific number to a permutation, then takes hundreds of thousands of those permutations in one shot. The first batch of 48 threads don't even finish their work in a reasonable amount of time  Undecided

Some more unrelated rubbish that I copied and pasted from the internet which some people may find useful:

Code:
# Python 3 implementation of the approach

# Given the array arr[] of N elements and a permutation array P[], the task is to permute the given array arr[] based on the permutation array P[].
# Function to permute the the given
# array based on the given conditions
def permute(A, P, n):
     
    # For each element of P
    for i in range(n):
        next = i
 
        # Check if it is already
        # considered in cycle
        while (P[next] >= 0):
             
            # Swap the current element according
            # to the permutation in P
            t = A[i]
            A[i] = A[P[next]]
            A[P[next]] = t
             
            temp = P[next]
 
            # Subtract n from an entry in P
            # to make it negative which indicates
            # the corresponding move
            # has been performed
            P[next] -= n
            next = temp

def int_from_code(code):
    """
    :type code: list
    :rtype: int
    """
    num = 0
    for i, v in enumerate(reversed(code), 1):
        num *= i
        num += v

    return num

def code_from_int(size, num):
    """
    :type size: int
    :type num: int
    :rtype: list
    """
    code = []
    for i in range(size):
        num, j = divmod(num, size - i)
        code.append(j)

    return code


def perm_from_code(base, code, pick=None):
    """
    :type base: list
    :type code: list
    :rtype: list
    """
    if pick:
        return _perm_from_code_pick(base, code)

    perm = base.copy()
    for i in range(len(base) - 1):
        j = code[i]
        perm[i], perm[i+j] = perm[i+j], perm[i]

    return perm

def perm_from_int(base, num, pick=None):
    """
    :type base: list
    :type num: int
    :rtype: list
    """
    code = code_from_int(len(base), num)
    return perm_from_code(base, code, pick=pick)

def code_from_perm(base, perm, pick=None):
    """
    :type base: list
    :type perm: list
    :rtype: list
    """
    if pick:
        _code_from_perm_pick(base, perm)

    p = base.copy()
    n = len(base)
    pos_map = {v: i for i, v in enumerate(base)}

    w = []
    for i in range(n):
        print(pos_map, perm)
        d = pos_map[perm[i]] - i
        w.append(d)

        if not d:
            continue
        t = pos_map[perm[i]]
        pos_map[p[i]], pos_map[p[t]] = pos_map[p[t]], pos_map[p[i]]
        p[i], p[t] = p[t], p[i]

    return w

def int_from_perm(base, perm, pick=None):
    """
    :type base: list
    :type perm: list
    :rtype: int
    """
    code = code_from_perm(base, perm, pick=pick)
    return int_from_code(code)



This is my private key in a randomised order relating to this address: LP5U3KWRLvPwDefz4FVMrAJVFtU4u8pj15w8VSpZF2aaPeY5QIx8

'I' on the 50th place - wrong character, not from Base58 set.

Don't tell me I just wasted my time descrambling an invalid WIF! Nooooooooooo....