Bitcoin Forum
May 26, 2024, 05:38:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 2 3 4 5 6 7 8 9 10 11 [12] 13 14 »
221  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 06, 2023, 12:45:45 PM
Have you tried from 2000 up to 2015? You should also try 1990 to 2000, don't leave anything to chance, because for all we know he was a random guy using time and date to produce entropy. 😉


Nope. Only 2014-2015

Puzzle 65
Code:
import random
from datetime import datetime, timedelta

# Specify the start and end date and times
start_datetime_pre = datetime(2015, 1, 1, 0, 0, 0)
end_datetime_pre = datetime(2015, 1, 15, 19, 7, 14)

# Define the range of numbers
min_number = 18446744073709551615
max_number = 36893488147419103231

# Specify the target number
target_number = 30568377312064202855

# Specify the target pattern
target_pattern = '305683'

current_datetime = start_datetime_pre
time_step = timedelta(seconds=1)

while current_datetime <= end_datetime_pre:
    # Calculate the time range in seconds
    time_range_seconds = 1

    # Initialize binary search boundaries
    low_timestamp = int(current_datetime.timestamp())
    high_timestamp = int(current_datetime.timestamp())
    found_datetime = None  # Initialize found_datetime

    while low_timestamp <= high_timestamp:
        # Calculate the middle timestamp
        mid_timestamp = (low_timestamp + high_timestamp) // 2

        # Use the middle timestamp as the seed to generate a number
        random.seed(mid_timestamp)
        generated_number = random.randint(min_number, max_number)

        # Check if the generated number starts with the specified pattern
        if str(generated_number).startswith(target_pattern):
            found_datetime = datetime.fromtimestamp(mid_timestamp)
            break  # Break out of the inner loop when a match is found

        if generated_number < target_number:
            low_timestamp = mid_timestamp + 1
        else:
            high_timestamp = mid_timestamp - 1

    if found_datetime is not None:
        print("Pattern Found:", generated_number, "Found Timestamp:", found_datetime.strftime('%Y-%m-%d %H:%M:%S'))

    # Increment the current datetime by one second for the next timestamp
    current_datetime += time_step

Pattern Found: 30568335039670351430 Found Timestamp: 2015-01-01 22:52:54
Pattern Found: 30568326435315315618 Found Timestamp: 2015-01-05 02:12:12
Pattern Found: 30568385998074263793 Found Timestamp: 2015-01-12 13:05:27
Pattern Found: 30568318046551998275 Found Timestamp: 2015-01-14 07:04:04
Pattern Found: 30568367946192456402 Found Timestamp: 2015-01-14 12:26:35

2015-01-14 12:26:35 is the closest... missing many decimal places.

 if we use the same timestamp  2015-01-14 12:26:35 - puzzle 66 starts with 490151 or
49015112019902008018

This is just an assumption. Smiley
222  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 06, 2023, 11:25:24 AM

 There is no pattern here. But there is a time when a puzzle was created. I even went back in time and generating numbers from 2015. Every second of that year.


https://bitcointalk.org/index.php?topic=1306983.msg62144570#msg62144570

Almost six months ago, I undertook various tasks of a similar stuffs..

Code:
import random
from datetime import datetime, timedelta

# List of target Puzzle, each corresponding to a range
target_numbers = [
    (1, 1), (2, 3), (3, 7), (4, 8), (5, 21), (6, 49), (7, 76), (8, 224), (9, 467), (10, 514),
    (11, 1155), (12, 2683), (13, 5216), (14, 10544), (15, 26867), (16, 51510),
    (17, 95823), (18, 198669), (19, 357535), (20, 863317), (21, 1811764),
    (22, 3007503), (23, 5598802), (24, 14428676), (25, 33185509),
    (26, 54538862), (27, 111949941), (28, 227634408), (29, 400708894),
    (30, 1033162084), (31, 2102388551), (32, 3093472814), (33, 7137437912),
    (34, 14133072157), (35, 20112871792), (36, 42387769980), (37, 100251560595),
    (38, 146971536592), (39, 323724968937), (40, 1003651412950),
    (41, 1458252205147), (42, 2895374552463), (43, 7409811047825),
    (44, 15404761757071), (45, 19996463086597), (46, 51408670348612),
    (47, 119666659114170), (48, 191206974700443), (49, 409118905032525),
    (50, 611140496167764), (51, 2058769515153876), (52, 4216495639600700),
    (53, 6763683971478124), (54, 9974455244496707), (55, 30045390491869460),
    (56, 44218742292676575), (57, 138245758910846492), (58, 199976667976342049),
    (59, 525070384258266191), (60, 1135041350219496382), (61, 1425787542618654982),
    (62, 3908372542507822062), (63, 8993229949524469768),
    (64, 17799667357578236628), (65, 30568377312064202855)
]

# Sort the target_numbers list by the first element of each tuple (the range start)
target_numbers.sort(key=lambda x: x[0])

# Specify the start and end date and times for the search
start_datetime_pre = datetime(2014, 11, 1, 0, 0, 0)
end_datetime_pre = datetime(2015, 1, 15, 19, 7, 14)
current_datetime = start_datetime_pre
time_step = timedelta(seconds=1)

# Initialize a set to keep track of found target numbers
found_targets = set()

# Function to find the seed for a single target number
def find_seed_for_target(target_num, current_time):
    num, target_number = target_num
    min_number = 2 ** (num - 1)
    max_number = (2 ** num) - 1

    low_seed = int(current_time.timestamp())
    high_seed = int(end_datetime_pre.timestamp())

    found_seed = None

    while low_seed <= high_seed:
        mid_seed = (low_seed + high_seed) // 2

        random.seed(mid_seed)
        generated_number = random.randint(min_number, max_number)

        if generated_number == target_number:
            found_seed = mid_seed
            break
        elif generated_number < target_number:
            low_seed = mid_seed + 1
        else:
            high_seed = mid_seed - 1

    return found_seed

# Iterate through the time range
while current_datetime <= end_datetime_pre:
    # Find seeds for all target numbers
    found_seeds = [find_seed_for_target(target, current_datetime) for target in target_numbers]

    # Print the results for each target number if found and not already printed
    for i, (num, target_number) in enumerate(target_numbers, start=1):
        if found_seeds[i - 1] is not None and target_number not in found_targets:
            linuxtime = found_seeds[i - 1]
            timestamp = datetime.fromtimestamp(linuxtime)
            formatted_time = timestamp.strftime('%Y-%m-%d %H:%M:%S')
            print(f"Puzzle {i} : Private Key : {target_number} | Timestamp: {formatted_time}")
            found_targets.add(target_number)

    # Move to the next second
    current_datetime += time_step



You'd be surprised what this finds. You just need to guess the year and date range. Grin
It takes a long time to find Puzzle timestamps above 20...
223  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 05, 2023, 02:56:38 PM



Who knows. Maybe it's just paper and pencil. Grin
224  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 05, 2023, 02:47:59 PM
I assume the script is too. I also assume the author set the clock back or forward (from 2015) on the computer this script was running on. Grin
225  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 05, 2023, 06:47:39 AM
Maybe I'm expecting too much? Just open your laptop....


Imagine yourself living in Dubai as a btc millionaire and some bro from the internet asks you to open your laptop?

World class dining and drinking?

Tons of things to do?

Lol
226  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 03, 2023, 06:09:55 AM
@nomachine what is the problem with the original code?

Quote
if a non-deterministic source (e.g. a hardware device) is not available to the implementation. In this case each std::random_device object may generate the same number sequence.


Everything is great with the code. Even std::random_device works great for me. I am experimenting with different generators and speeds. It's not even an ordinary platform. I'm currently on an ARM machine.



 There is no pattern here. But there is a time when a puzzle was created. I even went back in time and generating numbers from 2015. Every second of that year.

Code:
add = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so"
# Specify the start date and time
start_datetime = datetime(2015, 1, 13, 19, 7, 14)
current_datetime = start_datetime

# Specify the end date and time
end_datetime = datetime(2015, 1, 15, 19, 7, 14)

while current_datetime <= end_datetime:
    # Convert the current datetime to a Unix timestamp
    timestamp = int(current_datetime.timestamp())

    random.seed(timestamp)
    key = random.randint(start_range, end_range)
    public_key = private_key_to_public_key(key)
    bitcoin_address = public_key_to_address(public_key, compressed=True)
    public_key = public_key_to_hex(public_key)

    # Increment the current datetime by one second for the next timestamp
    current_datetime += timedelta(seconds=1)

you won't believe what I've tried so far.
227  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 02, 2023, 07:51:40 PM


- we run keyhunt in BSGS mode on 8 CPU threads with about 16GB RAM allocation and get about 80 PKey/s.

Is Kangaroo with multi-GPU usage more advantageous and more likely to get a hit, even though keyhunt with CPU usage in BSGS can process 80 PKey/s?



Try changing the random generator in both. Play what works best in your environment.
example

keyhunt.cpp

replace
Code:
#include <sys/random.h>
to
Code:
#include <random>
replace  seed random generator with minstd_rand rng
Code:
#if defined(_WIN64) && !defined(__CYGWIN__)
    // Any Windows secure random source goes here
    rseed(clock() + time(NULL) + rand());
#else
    std::random_device rd;
    std::minstd_rand rng(rd());
    
    // Seed the random number generator
    rseed(rng());
#endif

I have from 80  to ~177 Pkeys/s (177940438134284990 keys/s) Grin
These apps can't get better if we don't all work on them and test them.


An windows version ?

Code:
#if defined(_WIN64) && !defined(__CYGWIN__)
    // On Windows, use a combination of clock, time, and rand as the seed
    return std::minstd_rand(static_cast<unsigned>(clock() + time(nullptr) + rand()));
#else
    // On non-Windows platforms (including Linux), use std::random_device to seed
    std::random_device rd;
    return std::minstd_rand(rd());


This code should work on both Windows and Linux.
I also use -O3 flag during compilation.
Aggressive optimizations can greatly improve performance,
they may also increase compilation time, and in some cases, they can make debugging more challenging because the optimized code may differ significantly from the original source code.
228  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: October 02, 2023, 02:49:17 PM


- we run keyhunt in BSGS mode on 8 CPU threads with about 16GB RAM allocation and get about 80 PKey/s.

Is Kangaroo with multi-GPU usage more advantageous and more likely to get a hit, even though keyhunt with CPU usage in BSGS can process 80 PKey/s?



Try changing the random generator in both. Play what works best in your environment.
example

keyhunt.cpp

replace
Code:
#include <sys/random.h>
to
Code:
#include <random>
replace  seed random generator with minstd_rand rng
Code:
#if defined(_WIN64) && !defined(__CYGWIN__)
    // Any Windows secure random source goes here
    rseed(clock() + time(NULL) + rand());
#else
    std::random_device rd;
    std::minstd_rand rng(rd());
    
    // Seed the random number generator
    rseed(rng());
#endif

I have from 80  to ~177 Pkeys/s (177940438134284990 keys/s) Grin
These apps can't get better if we don't all work on them and test them.
229  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 30, 2023, 03:06:18 PM
Based on the information provided, it appears that the pattern for generating the private key (PVK) values for these Bitcoin addresses involves incrementing the PVK values by a specific sequence of integers. Let's calculate the PVK value for Address 15 and beyond based on the observed pattern:

Address 15: PVK value = Address 14's PVK value + 27
Address 15: PVK value = 10544 + 27
Address 15: PVK value = 10571

So, the PVK value for Address 15 is 10571.

You can continue this pattern to calculate the PVK values for addresses beyond Address 15 by adding the next integer in the sequence to the PVK value of the previous address.

What  is for 66 then ?  Grin

I can even help you further how to program this

import math

# Given list of numbers
numbers = [
    1, 3, 7, 8, 21, 49, 76, 224, 467, 514, 1155, 2683, 5216, 10544, 26867, 51510,
    95823, 198669, 357535, 863317, 1811764, 3007503, 5598802, 14428676, 33185509,
    54538862, 111949941, 227634408, 400708894, 1033162084, 2102388551, 3093472814,
    7137437912, 14133072157, 20112871792, 42387769980, 100251560595, 146971536592,
    323724968937, 1003651412950, 1458252205147, 2895374552463, 7409811047825,
    15404761757071, 19996463086597, 51408670348612, 119666659114170, 191206974700443,
    409118905032525, 611140496167764, 2058769515153876, 4216495639600700,
    6763683971478124, 9974455244496707, 30045390491869460, 44218742292676575,
    138245758910846492, 199976667976342049, 525070384258266191, 1135041350219496382,
    1425787542618654982, 3908372542507822062, 8993229949524469768,
    17799667357578236628, 30568377312064202855
]


Give me math formula that can calculate pattern for WIF 66 here ?
Whoever succeeds in doing this will receive a greater prize than the Nobel Prize.

p.s.
It doesn't even have to be an exact number.
That it is accurate to approximately +/- 8 decimal places.

you must be a very big joker if you think there is a pattern in the numbers you see up there

Tell  that to him.  Grin
230  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 30, 2023, 11:53:42 AM
Based on the information provided, it appears that the pattern for generating the private key (PVK) values for these Bitcoin addresses involves incrementing the PVK values by a specific sequence of integers. Let's calculate the PVK value for Address 15 and beyond based on the observed pattern:

Address 15: PVK value = Address 14's PVK value + 27
Address 15: PVK value = 10544 + 27
Address 15: PVK value = 10571

So, the PVK value for Address 15 is 10571.

You can continue this pattern to calculate the PVK values for addresses beyond Address 15 by adding the next integer in the sequence to the PVK value of the previous address.

What  is for 66 then ?  Grin

I can even help you further how to program this

import math

# Given list of numbers
numbers = [
    1, 3, 7, 8, 21, 49, 76, 224, 467, 514, 1155, 2683, 5216, 10544, 26867, 51510,
    95823, 198669, 357535, 863317, 1811764, 3007503, 5598802, 14428676, 33185509,
    54538862, 111949941, 227634408, 400708894, 1033162084, 2102388551, 3093472814,
    7137437912, 14133072157, 20112871792, 42387769980, 100251560595, 146971536592,
    323724968937, 1003651412950, 1458252205147, 2895374552463, 7409811047825,
    15404761757071, 19996463086597, 51408670348612, 119666659114170, 191206974700443,
    409118905032525, 611140496167764, 2058769515153876, 4216495639600700,
    6763683971478124, 9974455244496707, 30045390491869460, 44218742292676575,
    138245758910846492, 199976667976342049, 525070384258266191, 1135041350219496382,
    1425787542618654982, 3908372542507822062, 8993229949524469768,
    17799667357578236628, 30568377312064202855
]


Give me math formula that can calculate pattern for WIF 66 here ?
Whoever succeeds in doing this will receive a greater prize than the Nobel Prize.

p.s.
It doesn't even have to be an exact number.
That it is accurate to approximately +/- 8 decimal places.
231  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 30, 2023, 08:34:52 AM
Now will start on a small  range. Let's say
    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "30568377312063203855");
    BN_dec2bn(&maxKeyBN, "30568377312065203855");
    std::string targetAddress = "18ZMbwUFLMHoZBbfpCjUJQTCMCbktshgpe";


This is how  looks when hits

  • Fri Sep 29 18:01:54 2023
  • 18ZMbwUFLMHoZBbfpCjUJQTCMCbktshgpe
  • PUZZLE SOLVED: 2023-09-29 18:02:59
  • WIF: KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qZM21gaY8WN2CdwnTG57

You can also stretch the random key space and search for 66 and 67 at once. Something like this:

Code:
Bit 66 CPU Base Key thId 0: 2070B59CFFB6E8A6C
[i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 67 CPU Base Key thId 1: 5F69D80358D3D5461
[0.83 Mkey/s][GPU 0.00 Mkey/s][Total 2^29.06][Prob 0.0%][50% in 3.88754e+34y][Found 0]  [i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 66 CPU Base Key thId 1: 2E3C205D5E1AED2B1
[i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 66 CPU Base Key thId 0: 310A2ED5261C2A060
[0.80 Mkey/s][GPU 0.00 Mkey/s][Total 2^29.18][Prob 0.0%][50% in 4.03042e+34y][Found 0]  [i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 66 CPU Base Key thId 0: 218520C965083E2EC
[i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 67 CPU Base Key thId 1: 5BCD840005DB9C7A0
[0.79 Mkey/s][GPU 0.00 Mkey/s][Total 2^29.29][Prob 0.0%][50% in 4.04933e+34y][Found 0]  [i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 67 CPU Base Key thId 1: 670DE68F544FE981A
[i] Random Keys - Low Keys Space 2^(67-2) 0x20000000000000000

Bit 67 CPU Base Key thId 0: 52D16C4062A5F03A4
[0.82 Mkey/s][GPU 0.00 Mkey/s][Total 2^29.35][Prob 0.0%][50% in 3.89443e+34y][Found 0]

There are special requirements here...For example digaran wants to print all addresses from 1 to 10 or any range  Grin How to do that madness here?

Code:
#include "SECP256k1.h"
#include "Int.h"
#include <iostream>
#include <memory>

int main() {
    Int minKey;
    Int maxKey;
    // Configuration
    minKey.SetBase10("1");
    maxKey.SetBase10("10");

    // Initialize SECP256k1
    std::shared_ptr<Secp256K1> secp256k1 = std::make_shared<Secp256K1>();
    secp256k1->Init();

    Int privateKey = minKey;
    Point publicKey;
    std::string caddr;
    std::string wifc;

    while (!privateKey.IsGreater(&maxKey)) {
        publicKey = secp256k1->ComputePublicKey(&privateKey);
        caddr = secp256k1->GetAddress(0, true, publicKey);
        wifc = secp256k1->GetPrivAddress(true, privateKey);
       
        // Display the generated address
        std::string message = caddr +  " ------> " + wifc + "\n";
        std::cout << message;
        std::cout.flush();

        privateKey.AddOne();
    }

    return 0;
}
232  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 29, 2023, 03:55:44 PM
Hello everyone, and especially those who still remember me)
Has anyone used OpenSSL to generate keys?
Probably not..

main.cpp (*Int class require some code changes within the SECP256k1 library to support BIGNUM* directly.)


Yes... Grin

But it is still slow. Even 5M keys/s per core muscles is not enough for such a large range. Undecided

hi there nomachine, is there a compiled exe there.. or not. thanks man

I have solution for Linux now. I have no idea how this can work on Windows - I haven't had it in years. It is about 5-6 M keys/s per core brute force script.

Code:
sudo apt update && sudo apt install libssl-dev

Code:
git clone https://github.com/JeanLucPons/VanitySearch.git

Change in that folder main.cpp to be:
Code:
#include "SECP256k1.h"
#include "Int.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <thread>
#include <vector>
#include <mutex>
#include <memory>
#include <openssl/bn.h>

const int numThreads = 128; // You can adjust this number based on your CPU cores

// Function to generate a random private key using BIGNUM
BIGNUM* generateRandomPrivateKey(const BIGNUM* minKey, const BIGNUM* maxKey) {
    BIGNUM* randomPrivateKey = BN_new();
    BN_rand_range(randomPrivateKey, maxKey);

    // Ensure the generated key is within the desired range
    while (BN_cmp(randomPrivateKey, minKey) < 0) {
        BN_rand_range(randomPrivateKey, maxKey);
    }

    return randomPrivateKey;
}

// Function to convert a BIGNUM to Int
Int bignumToBigInt(const BIGNUM* bignum) {
    char* bignumStr = BN_bn2dec(bignum);
    Int bigInt;
    bigInt.SetBase10(bignumStr);
    OPENSSL_free(bignumStr);
    return bigInt;
}

// Function to generate keys and check for a specific address
void generateKeysAndCheckForAddress(BIGNUM* minKey, BIGNUM* maxKey, std::shared_ptr<Secp256K1> secp256k1, const std::string& targetAddress) {
    while (true) {
        BIGNUM* randomPrivateKey = generateRandomPrivateKey(minKey, maxKey);

        // Convert the BIGNUM private key to an Int
        Int privateKey = bignumToBigInt(randomPrivateKey);

        // Continue with the rest of the address generation and checking logic
        Point publicKey;
        std::string caddr;
        std::string wifc;

        publicKey = secp256k1->ComputePublicKey(&privateKey);
        caddr = secp256k1->GetAddress(0, true, publicKey);
        wifc = secp256k1->GetPrivAddress(true, privateKey);

        // Display the generated address
        std::string message = "\r\033[01;33m[+] " + caddr;
        std::cout << message << "\e[?25l";
        std::cout.flush();

        // Check if the generated address matches the target address
        if (caddr.find(targetAddress) != std::string::npos) {
            time_t currentTime = std::time(nullptr);

            // Format the current time into a human-readable string
            std::tm tmStruct = *std::localtime(&currentTime);
            std::stringstream timeStringStream;
            timeStringStream << std::put_time(&tmStruct, "%Y-%m-%d %H:%M:%S");
            std::string formattedTime = timeStringStream.str();

            std::cout << "\n\033[32m[+] PUZZLE SOLVED: " << formattedTime << "\033[0m" << std::endl;
            std::cout << "\033[32m[+] WIF: " << wifc << "\033[0m" << std::endl;

            // Append the private key information to a file if it matches
            std::ofstream file("KEYFOUNDKEYFOUND.txt", std::ios::app);
            if (file.is_open()) {
                file << "\nPUZZLE SOLVED " << formattedTime;
                file << "\nPublic Address Compressed: " << caddr;
                file << "\nPrivatekey (dec): " << privateKey.GetBase10();
                file << "\nPrivatekey Compressed (wif): " << wifc;
                file << "\n----------------------------------------------------------------------------------------------------------------------------------";
                file.close();
            }

            // Free the BIGNUM and break the loop
            BN_free(randomPrivateKey);
            break;
        }

        // Free the BIGNUM
        BN_free(randomPrivateKey);

        // Convert the max key to an Int
        Int maxInt;
        maxInt.SetBase10(BN_bn2dec(maxKey));

        if (privateKey.IsGreater(&maxInt)) {
            break;
        }
    }
}


int main() {
    // Clear the console
    std::system("clear");

    time_t currentTime = std::time(nullptr);
    std::cout << "\033[01;33m[+] " << std::ctime(&currentTime) << "\r";
    std::cout.flush();

    BIGNUM* minKeyBN = BN_new(); // Initialize minKeyBN
    BIGNUM* maxKeyBN = BN_new(); // Initialize maxKeyBN

    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "62079069358943824031");
    BN_dec2bn(&maxKeyBN, "67079069358943924031");
    std::string targetAddress = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so";

    // Initialize SECP256k1
    std::shared_ptr<Secp256K1> secp256k1 = std::make_shared<Secp256K1>();
    secp256k1->Init();

    // Create threads for key generation and checking
    std::vector<std::thread> threads;

    for (int i = 0; i < numThreads; ++i) {
        threads.emplace_back(generateKeysAndCheckForAddress, minKeyBN, maxKeyBN, secp256k1, targetAddress);
    }

    // Wait for all threads to finish
    for (std::thread& thread : threads) {
        thread.join();
    }

    // Cleanup BIGNUM variables
    BN_free(minKeyBN);
    BN_free(maxKeyBN);

    return 0;
}

Change Makefile to be:
Code:
SRC = Base58.cpp IntGroup.cpp main.cpp Random.cpp Timer.cpp \
      Int.cpp IntMod.cpp Point.cpp SECP256K1.cpp \
      hash/ripemd160.cpp hash/sha256.cpp hash/sha512.cpp \
      hash/ripemd160_sse.cpp hash/sha256_sse.cpp Bech32.cpp

OBJDIR = obj

OBJET = $(addprefix $(OBJDIR)/, \
        Base58.o IntGroup.o main.o Random.o Int.o Timer.o \
        IntMod.o Point.o SECP256K1.o \
        hash/ripemd160.o hash/sha256.o hash/sha512.o \
        hash/ripemd160_sse.o hash/sha256_sse.o Bech32.o)

CXX = g++
CXXFLAGS = -m64 -mssse3 -Wno-write-strings -O2 -I.

LFLAGS = -lpthread -lssl -lcrypto

$(OBJDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<



VanitySearch: $(OBJET)
@echo Making Lottery...
$(CXX) $(OBJET) $(LFLAGS) -o LOTTO.bin && chmod +x LOTTO.bin

$(OBJET): | $(OBJDIR) $(OBJDIR)/hash

$(OBJDIR):
mkdir -p $(OBJDIR)

$(OBJDIR)/hash: $(OBJDIR)
cd $(OBJDIR) && mkdir -p hash

clean:
@echo Cleaning...
@rm -f obj/*.o
@rm -f obj/hash/*.o

Code:
make

and  start
Code:
 ./LOTTO.bin

Good luck Wink

For Windows, I suppose you can try to compile it with msys2 and mingw, installing the toolchain with Pacman, or with Cygwin to avoid errors regarding Linux commands in Windows.
Probably so. I haven't done that in a long time.

I edited the script in the last post. it didn’t want to work on small ranges.
Code:
// Function to generate a random private key using BIGNUM
BIGNUM* generateRandomPrivateKey(const BIGNUM* minKey, const BIGNUM* maxKey) {
    BIGNUM* randomPrivateKey = BN_new();
    BIGNUM* range = BN_new();

    // Calculate the range (maxKey - minKey)
    BN_sub(range, maxKey, minKey);

    // Generate a random number in the range [0, range)
    BN_rand_range(randomPrivateKey, range);

    // Add the minimum value to the generated random number
    BN_add(randomPrivateKey, randomPrivateKey, minKey);

    // Cleanup the range BIGNUM
    BN_free(range);

    return randomPrivateKey;
}

Now will start on a small  range. Let's say
    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "30568377312063203855");
    BN_dec2bn(&maxKeyBN, "30568377312065203855");
    std::string targetAddress = "18ZMbwUFLMHoZBbfpCjUJQTCMCbktshgpe";


This is how  looks when hits

  • Fri Sep 29 18:01:54 2023
  • 18ZMbwUFLMHoZBbfpCjUJQTCMCbktshgpe
  • PUZZLE SOLVED: 2023-09-29 18:02:59
  • WIF: KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qZM21gaY8WN2CdwnTG57

233  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 29, 2023, 02:53:48 PM
Hello everyone, and especially those who still remember me)
Has anyone used OpenSSL to generate keys?
Probably not..

main.cpp (*Int class require some code changes within the SECP256k1 library to support BIGNUM* directly.)


Yes... Grin

But it is still slow. Even 5M keys/s per core muscles is not enough for such a large range. Undecided

hi there nomachine, is there a compiled exe there.. or not. thanks man

I have solution for Linux now. I have no idea how this can work on Windows - I haven't had it in years. It is about 5-6 M keys/s per core brute force script.

Code:
sudo apt update && sudo apt install libssl-dev

Code:
git clone https://github.com/JeanLucPons/VanitySearch.git

Change in that folder main.cpp to be:
Code:
#include "SECP256k1.h"
#include "Int.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <thread>
#include <vector>
#include <mutex>
#include <memory>
#include <openssl/bn.h>

const int numThreads = 12; // You can adjust this number based on your CPU cores

// Function to generate a random private key using BIGNUM
BIGNUM* generateRandomPrivateKey(const BIGNUM* minKey, const BIGNUM* maxKey) {
    BIGNUM* randomPrivateKey = BN_new();
    BIGNUM* range = BN_new();

    // Calculate the range (maxKey - minKey)
    BN_sub(range, maxKey, minKey);

    // Generate a random number in the range [0, range)
    BN_rand_range(randomPrivateKey, range);

    // Add the minimum value to the generated random number
    BN_add(randomPrivateKey, randomPrivateKey, minKey);

    // Cleanup the range BIGNUM
    BN_free(range);

    return randomPrivateKey;
}

// Function to convert a BIGNUM to Int
Int bignumToBigInt(const BIGNUM* bignum) {
    char* bignumStr = BN_bn2dec(bignum);
    Int bigInt;
    bigInt.SetBase10(bignumStr);
    OPENSSL_free(bignumStr);
    return bigInt;
}

// Function to generate keys and check for a specific address
void generateKeysAndCheckForAddress(BIGNUM* minKey, BIGNUM* maxKey, std::shared_ptr<Secp256K1> secp256k1, const std::string& targetAddress) {
    while (true) {
        BIGNUM* randomPrivateKey = generateRandomPrivateKey(minKey, maxKey);

        // Convert the BIGNUM private key to an Int
        Int privateKey = bignumToBigInt(randomPrivateKey);

        // Continue with the rest of the address generation and checking logic
        Point publicKey;
        std::string caddr;
        std::string wifc;

        publicKey = secp256k1->ComputePublicKey(&privateKey);
        caddr = secp256k1->GetAddress(0, true, publicKey);
        wifc = secp256k1->GetPrivAddress(true, privateKey);

        // Display the generated address
        std::string message = "\r\033[01;33m[+] " + caddr;
        std::cout << message << "\e[?25l";
        std::cout.flush();

        // Check if the generated address matches the target address
        if (caddr.find(targetAddress) != std::string::npos) {
            time_t currentTime = std::time(nullptr);

            // Format the current time into a human-readable string
            std::tm tmStruct = *std::localtime(&currentTime);
            std::stringstream timeStringStream;
            timeStringStream << std::put_time(&tmStruct, "%Y-%m-%d %H:%M:%S");
            std::string formattedTime = timeStringStream.str();

            std::cout << "\n\033[32m[+] PUZZLE SOLVED: " << formattedTime << "\033[0m" << std::endl;
            std::cout << "\033[32m[+] WIF: " << wifc << "\033[0m" << std::endl;

            // Append the private key information to a file if it matches
            std::ofstream file("KEYFOUNDKEYFOUND.txt", std::ios::app);
            if (file.is_open()) {
                file << "\nPUZZLE SOLVED " << formattedTime;
                file << "\nPublic Address Compressed: " << caddr;
                file << "\nPrivatekey (dec): " << privateKey.GetBase10();
                file << "\nPrivatekey Compressed (wif): " << wifc;
                file << "\n----------------------------------------------------------------------------------------------------------------------------------";
                file.close();
            }

            // Free the BIGNUM and break the loop
            BN_free(randomPrivateKey);
            break;
        }

        // Free the BIGNUM immediately
        BN_free(randomPrivateKey);

        // Convert the max key to an Int
        Int maxInt;
        maxInt.SetBase10(BN_bn2dec(maxKey));

        if (privateKey.IsGreater(&maxInt)) {
            break;
        }
    }
}

int main() {
    // Clear the console
    std::system("clear");

    time_t currentTime = std::time(nullptr);
    std::cout << "\033[01;33m[+] " << std::ctime(&currentTime) << "\r";
    std::cout.flush();

    BIGNUM* minKeyBN = BN_new(); // Initialize minKeyBN
    BIGNUM* maxKeyBN = BN_new(); // Initialize maxKeyBN

    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "30568377312063203855");
    BN_dec2bn(&maxKeyBN, "30568377312065203855");
    std::string targetAddress = "18ZMbwUFLMHoZBbfpCjUJQTCMCbktshgpe";

    // Initialize SECP256k1
    std::shared_ptr<Secp256K1> secp256k1 = std::make_shared<Secp256K1>();
    secp256k1->Init();

    // Create threads for key generation and checking
    std::vector<std::thread> threads;

    for (int i = 0; i < numThreads; ++i) {
        threads.emplace_back(generateKeysAndCheckForAddress, minKeyBN, maxKeyBN, secp256k1, targetAddress);
    }

    // Wait for all threads to finish
    for (std::thread& thread : threads) {
        thread.join();
    }

    // Cleanup BIGNUM variables
    BN_free(minKeyBN);
    BN_free(maxKeyBN);

    return 0;
}

Change Makefile to be:
Code:
SRC = Base58.cpp IntGroup.cpp main.cpp Random.cpp Timer.cpp \
      Int.cpp IntMod.cpp Point.cpp SECP256K1.cpp \
      hash/ripemd160.cpp hash/sha256.cpp hash/sha512.cpp \
      hash/ripemd160_sse.cpp hash/sha256_sse.cpp Bech32.cpp

OBJDIR = obj

OBJET = $(addprefix $(OBJDIR)/, \
        Base58.o IntGroup.o main.o Random.o Int.o Timer.o \
        IntMod.o Point.o SECP256K1.o \
        hash/ripemd160.o hash/sha256.o hash/sha512.o \
        hash/ripemd160_sse.o hash/sha256_sse.o Bech32.o)

CXX = g++
CXXFLAGS = -m64 -mssse3 -Wno-write-strings -O3 -I.

LFLAGS = -lpthread -lssl -lcrypto

$(OBJDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<



VanitySearch: $(OBJET)
@echo Making Lottery...
$(CXX) $(OBJET) $(LFLAGS) -o LOTTO.bin && chmod +x LOTTO.bin

$(OBJET): | $(OBJDIR) $(OBJDIR)/hash

$(OBJDIR):
mkdir -p $(OBJDIR)

$(OBJDIR)/hash: $(OBJDIR)
cd $(OBJDIR) && mkdir -p hash

clean:
@echo Cleaning...
@rm -f obj/*.o
@rm -f obj/hash/*.o

Code:
make

and  start
Code:
 ./LOTTO.bin

Good luck Wink
234  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 29, 2023, 07:36:45 AM


This would have zero relevance to secp256k1 curve, I just wanted to know if it's possible, which I assume it is, since I know no black magic, I thought to ask here.😉


Addresses with private keys and public addresses will not match. It doesn't matter if you reach 10B addresses per second if they are not in the BTC Bitcoin network.
it's certainly possible to do so, but it would be in a separate context from Bitcoin and would not be suitable for use within the Bitcoin network.  Grin

Next level of  voodoo would be be optimizing SHA-256 and RIPEMD-160 hashing more  reducing redundant operations and utilizing efficient libraries or algorithms.
Or even making specialized hardware for them with special instructions.

We're struggling more with hardware than math here.
235  Bitcoin / Development & Technical Discussion / Re: the fastest possible way to mass-generate addresses in Python on: September 28, 2023, 04:40:42 AM

I was looking only for public key generation part

Here's a simplified script that generates compressed public keys from a given range of private keys:

Code:
import hashlib, sys
import gmpy2

# Constants as mpz
Gx = gmpy2.mpz('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798', 16)
Gy = gmpy2.mpz('0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8', 16)
p = gmpy2.mpz('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F', 16)
n = gmpy2.mpz('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', 16)

def private_key_to_public_key(private_key):
    Q = point_multiply(Gx, Gy, private_key, p)
    return Q

def point_multiply(x, y, k, p):
    result = (gmpy2.mpz(0), gmpy2.mpz(0))
    addend = (x, y)
   
    while k > 0:
        if k & 1:
            result = point_add(result, addend, p)
        addend = point_double(addend, p)
        k >>= 1

    return result

def point_double(point, p):
    x, y = point
    lmbda = (3 * x * x * gmpy2.powmod(2 * y, -1, p)) % p
    x3 = (lmbda * lmbda - 2 * x) % p
    y3 = (lmbda * (x - x3) - y) % p
    return x3, y3

def point_add(point1, point2, p):
    x1, y1 = point1
    x2, y2 = point2

    if point1 == (gmpy2.mpz(0), gmpy2.mpz(0)):
        return point2
    if point2 == (gmpy2.mpz(0), gmpy2.mpz(0)):
        return point1

    if point1 != point2:
        lmbda = ((y2 - y1) * gmpy2.powmod(x2 - x1, -1, p)) % p
    else:
        lmbda = ((3 * x1 * x1) * gmpy2.powmod(2 * y1, -1, p)) % p

    x3 = (lmbda * lmbda - x1 - x2) % p
    y3 = (lmbda * (x1 - x3) - y1) % p
    return x3, y3

def encode_base58(byte_str):
    __b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
    __b58base = len(__b58chars)
    long_value = gmpy2.mpz(int.from_bytes(byte_str, byteorder='big'))
    result = ''
    while long_value >= __b58base:
        div, mod = gmpy2.f_divmod(long_value, __b58base)
        result = __b58chars[int(mod)] + result
        long_value = div
    result = __b58chars[int(long_value)] + result

    # Add leading '1's for zero bytes
    nPad = 0
    for byte in byte_str:
        if byte == 0:
            nPad += 1
        else:
            break

    return __b58chars[0] * nPad + result

def public_key_to_hex(public_key, compressed=True):
    x_hex = format(public_key[0], '064x')[2:]  # Remove '0x' prefix
    if compressed:
        # Use '02' prefix if Y coordinate is even, '03' if odd
        return ('02' if public_key[1] % 2 == 0 else '03') + x_hex

def public_key_to_address(public_key, compressed=True):
    public_key_hex = ('02' if compressed else '04') + format(public_key[0], '064x')
    sha256_hash = hashlib.sha256(bytes.fromhex(public_key_hex)).digest()
    ripemd160_hash = hashlib.new('ripemd160', sha256_hash).digest()
    versioned_hash = (b'\x00' if compressed else b'\x04') + ripemd160_hash
    checksum = hashlib.sha256(hashlib.sha256(versioned_hash).digest()).digest()[:4]
    address_bytes = versioned_hash + checksum
    return encode_base58(address_bytes)

# Define the range
start_range = gmpy2.mpz('36893488147419132058')
end_range = gmpy2.mpz('36893488149419115809')

# Iterate through the range and generate Bitcoin Addresses (Compressed) and their Public Keys
for key in range(start_range, end_range + 1):
    public_key = private_key_to_public_key(key)
    bitcoin_address = public_key_to_address(public_key, compressed=True)
    public_key = public_key_to_hex(public_key)
    sys.stdout.write("\033c")
    sys.stdout.write("\033[01;33m")
    sys.stdout.write(f"\r[+] Private Key (dec): {key}\n[+] Bitcoin Address (Compressed): {bitcoin_address}\n[+] Public Key: {public_key}" + "\n")
    sys.stdout.flush()


Mobile phones typically run Android or iOS. Python can be run on both platforms, but there are some differences in compatibility..
For Android, you can use the QPython app or Termux to run Python scripts. On iOS, you might need to use apps like Pythonista or Pyto.
It may require a lot of CPU power and memory. Make sure your mobile phone can handle the computational requirements.
You can even translate this script into a mobile app  but I don't see the purpose of it on the phone. Neither the script will work as it should nor the phone.
236  Bitcoin / Development & Technical Discussion / Re: the fastest possible way to mass-generate addresses in Python on: September 27, 2023, 07:28:01 PM

I tried using the script you posted but I can't generate millions on an android phone, I changed many things but it returned an error everytime, I'm interested in this one because  it uses no external libraries, and since iceland library doesn't support arm/mobile architecture.

What do I need to change to generate my desired range for public keys?


Maybe everything? Grin


Code:
#!/usr/bin/python3
import hashlib, sys

# Constants as regular integers
Gx = int('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798', 16)
Gy = int('0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8', 16)
p = int('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F', 16)
n = int('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', 16)

def private_key_to_public_key(private_key):
    Q = point_multiply(Gx, Gy, private_key, p)
    return Q

def point_multiply(x, y, k, p):
    result = (0, 0)
    addend = (x, y)

    while k > 0:
        if k & 1:
            result = point_add(result, addend, p)
        addend = point_double(addend, p)
        k >>= 1

    return result

def point_double(point, p):
    x, y = point
    lmbda = (3 * x * x * pow(2 * y, -1, p)) % p
    x3 = (lmbda * lmbda - 2 * x) % p
    y3 = (lmbda * (x - x3) - y) % p
    return x3, y3

def point_add(point1, point2, p):
    x1, y1 = point1
    x2, y2 = point2

    if point1 == (0, 0):
        return point2
    if point2 == (0, 0):
        return point1

    if point1 != point2:
        lmbda = ((y2 - y1) * pow(x2 - x1, -1, p)) % p
    else:
        lmbda = ((3 * x1 * x1) * pow(2 * y1, -1, p)) % p

    x3 = (lmbda * lmbda - x1 - x2) % p
    y3 = (lmbda * (x1 - x3) - y1) % p
    return x3, y3

def encode_base58(byte_str):
    __b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
    __b58base = len(__b58chars)
    long_value = int.from_bytes(byte_str, byteorder='big')
    result = ''
    while long_value >= __b58base:
        div, mod = divmod(long_value, __b58base)
        result = __b58chars[mod] + result
        long_value = div
    result = __b58chars[long_value] + result

    # Add leading '1's for zero bytes
    nPad = 0
    for byte in byte_str:
        if byte == 0:
            nPad += 1
        else:
            break

    return __b58chars[0] * nPad + result

def public_key_to_hex(public_key, compressed=True):
    x_hex = format(public_key[0], '064x')[2:]  # Remove '0x' prefix
    if compressed:
        # Use '02' prefix if Y coordinate is even, '03' if odd
        return ('02' if public_key[1] % 2 == 0 else '03') + x_hex

def public_key_to_address(public_key, compressed=True):
    public_key_hex = ('02' if compressed else '04') + format(public_key[0], '064x')
    sha256_hash = hashlib.sha256(bytes.fromhex(public_key_hex)).digest()
    ripemd160_hash = hashlib.new('ripemd160', sha256_hash).digest()
    versioned_hash = (b'\x00' if compressed else b'\x04') + ripemd160_hash
    checksum = hashlib.sha256(hashlib.sha256(versioned_hash).digest()).digest()[:4]
    address_bytes = versioned_hash + checksum
    return encode_base58(address_bytes)

# Define the range
start_range = int('36893488147419103232')
end_range = int('73786976294838206463')

# Iterate through the range and generate Bitcoin Addresses (Compressed) and their Public Keys
for key in range(start_range, end_range + 1):
    public_key = private_key_to_public_key(key)
    bitcoin_address = public_key_to_address(public_key, compressed=True)
    public_key = public_key_to_hex(public_key)
    sys.stdout.write("\033c")
    sys.stdout.write("\033[01;33m")
    sys.stdout.write(f"\r[+] Private Key (dec): {key}\n[+] Bitcoin Address (Compressed): {bitcoin_address}\n[+] Public Key: {public_key}" + "\n")
    sys.stdout.flush()

p.s.
updated as desired
237  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 27, 2023, 10:20:25 AM
I have to admit that Open SSL is very good.  Cool
To have a good probability of finding, you need a good randomness of the search. Sounds logical  Roll Eyes. I have not studied probability theory. Previously, the program included the Mersenne Twister algorithm. The Mersenne Twister is a general-purpose pseudorandom number generator (PRNG) developed in 1997 by Makoto Matsumoto.
This algorithm is predictable, and external events are seconds of time and a hashed SEED from the command line.
OpenSSL is certainly better.


when Vanity Search is cleared of statistics, calculation of results per seconds, Timer ticking, you simply get a  10% more perfomance....The more simplified the better.
238  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 26, 2023, 08:17:01 AM

Use  @alek76 github link....It is exactly the same thing  forked from Jean-Luc PONS. (I removed Printing and command line options from my binaries..)


git clone https://github.com/alek76-2/VanitySearch.git


TO make it work add in Random.cpp

#include <cstring>  (should be changed there in source)

You have in README.md how to compile exe in Windows.

p.s.
this is still in the testing phase

It's not the same! You should look carefully at the GPUEngine.cu code. Which functions were prohibited for use, and which were fixed and allowed, and why this was done.
The Y coordinate is calculated, so only the __device__ void ComputeKeys() function is used, and this is due to the prohibition of reuse of _GetHash160Comp() - to increase speed. It is better to calculate the Y coordinate once than to calculate hash160 twice (in which there are 2 functions sha256 + 1 time Ripemd160).
So what will be faster???
You need to look at someone else’s code carefully before drawing such conclusions. Is this the same thing or not?


Binary build using CUDA 10.2 Available for downloads https://github.com/alek76-2/VanitySearch/tree/main/bin

NO testing phase  Grin

Well, if you ask why I removed the endomorphism? It is only effective for 256-bit keys, because... k1 and k2 are half the length of 256 bits (this is how they get the speedup). In this case, it is useless for solving the 32 BTC Puzzle.
With endomorphism you will search in space for 128 bits for heating an apartment with a video card  Grin Grin Grin

Sorry, but I really didn't look.I don't have a GPU here (ADLINK Ampere Altra 128-core ) so I don't even care about that part (removed all CUDA code in my version). I'm only interested in the CPU how to speed up in a specific environment targeting platform specific compiler ...I have to admit that Open SSL is very good.  Cool
239  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 25, 2023, 12:38:55 PM
Hello everyone, and especially those who still remember me)
Has anyone used OpenSSL to generate keys?
Probably not..

main.cpp (*Int class require some code changes within the SECP256k1 library to support BIGNUM* directly.)
Code:
#include "SECP256k1.h"
#include "Int.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <thread>
#include <vector>
#include <mutex>
#include <memory>
#include <openssl/bn.h>

const int numThreads = 4; // You can adjust this number based on your CPU cores

// Function to generate a random private key using BIGNUM
BIGNUM* generateRandomPrivateKey(const BIGNUM* minKey, const BIGNUM* maxKey) {
    BIGNUM* randomPrivateKey = BN_new();
    BN_rand_range(randomPrivateKey, maxKey);

    // Ensure the generated key is within the desired range
    while (BN_cmp(randomPrivateKey, minKey) < 0) {
        BN_rand_range(randomPrivateKey, maxKey);
    }

    return randomPrivateKey;
}

// Function to convert a BIGNUM to Int
Int bignumToBigInt(const BIGNUM* bignum) {
    char* bignumStr = BN_bn2dec(bignum);
    Int bigInt;
    bigInt.SetBase10(bignumStr);
    OPENSSL_free(bignumStr);
    return bigInt;
}

// Function to generate keys and check for a specific address
void generateKeysAndCheckForAddress(BIGNUM* minKey, BIGNUM* maxKey, std::shared_ptr<Secp256K1> secp256k1, const std::string& targetAddress) {
    BIGNUM* randomPrivateKey = generateRandomPrivateKey(minKey, maxKey);

    while (true) {
        // Convert the BIGNUM private key to an Int
        Int privateKey = bignumToBigInt(randomPrivateKey);

        // Continue with the rest of the address generation and checking logic
        Point publicKey;
        std::string caddr;
        std::string wifc;

        publicKey = secp256k1->ComputePublicKey(&privateKey);
        caddr = secp256k1->GetAddress(0, true, publicKey);
        wifc = secp256k1->GetPrivAddress(true, privateKey);

        // Display the generated address
        std::string message = "\r\033[01;33m[+] " + caddr;
        std::cout << message << "\e[?25l";
        std::cout.flush();

        // Check if the generated address matches the target address
        if (caddr.find(targetAddress) != std::string::npos) {
            time_t currentTime = std::time(nullptr);

            // Format the current time into a human-readable string
            std::tm tmStruct = *std::localtime(&currentTime);
            std::stringstream timeStringStream;
            timeStringStream << std::put_time(&tmStruct, "%Y-%m-%d %H:%M:%S");
            std::string formattedTime = timeStringStream.str();

            std::cout << "\n\033[32m[+] PUZZLE SOLVED: " << formattedTime << "\033[0m" << std::endl;
            std::cout << "\033[32m[+] WIF: " << wifc << "\033[0m" << std::endl;

            // Append the private key information to a file if it matches
            std::ofstream file("KEYFOUNDKEYFOUND.txt", std::ios::app);
            if (file.is_open()) {
                file << "\nPUZZLE SOLVED " << formattedTime;
                file << "\nPublic Address Compressed: " << caddr;
                file << "\nPrivatekey (dec): " << privateKey.GetBase10();
                file << "\nPrivatekey Compressed (wif): " << wifc;
                file << "\n----------------------------------------------------------------------------------------------------------------------------------";
                file.close();
            }
        }

        // Cleanup the BIGNUM
        BN_free(randomPrivateKey);

        // Convert the max key to an Int
        Int maxInt;
        maxInt.SetBase10(BN_bn2dec(maxKey));

        if (privateKey.IsGreater(maxInt)) {
            break;
        }
    }
}

int main() {
    // Clear the console
    std::system("clear");

    time_t currentTime = std::time(nullptr);
    std::cout << "\033[01;33m[+] " << std::ctime(&currentTime) << "\r";
    std::cout.flush();

    BIGNUM* minKeyBN = BN_new(); // Initialize minKeyBN
    BIGNUM* maxKeyBN = BN_new(); // Initialize maxKeyBN

    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "62079069358943824031");
    BN_dec2bn(&maxKeyBN, "67079069358943924031");
    std::string targetAddress = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so";

    // Initialize SECP256k1
    std::shared_ptr<Secp256K1> secp256k1 = std::make_shared<Secp256K1>();
    secp256k1->Init();

    // Create threads for key generation and checking
    std::vector<std::thread> threads;

    for (int i = 0; i < numThreads; ++i) {
        threads.emplace_back(generateKeysAndCheckForAddress, minKeyBN, maxKeyBN, secp256k1, targetAddress);
    }

    // Wait for all threads to finish
    for (std::thread& thread : threads) {
        thread.join();
    }

    // Cleanup BIGNUM variables
    BN_free(minKeyBN);
    BN_free(maxKeyBN);

    return 0;
}


Yes... Grin

But it is still slow. Even 5M keys/s per core muscles is not enough for such a large range. Undecided

hi there nomachine, is there a compiled exe there.. or not. thanks man

Use  @alek76 github link....It is exactly the same thing  forked from Jean-Luc PONS. (I removed Printing and command line options from my binaries..)


git clone https://github.com/alek76-2/VanitySearch.git


TO make it work add in Random.cpp

#include <cstring>  (should be changed there in source)

You have in README.md how to compile exe in Windows.

p.s.
this is still in the testing phase
240  Bitcoin / Bitcoin Discussion / Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it on: September 25, 2023, 05:35:45 AM
Hello everyone, and especially those who still remember me)
Has anyone used OpenSSL to generate keys?
Probably not..

main.cpp (*Int class require some code changes within the SECP256k1 library to support BIGNUM* directly.)
Code:
#include "SECP256k1.h"
#include "Int.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <thread>
#include <vector>
#include <mutex>
#include <memory>
#include <openssl/bn.h>

const int numThreads = 4; // You can adjust this number based on your CPU cores

// Function to generate a random private key using BIGNUM
BIGNUM* generateRandomPrivateKey(const BIGNUM* minKey, const BIGNUM* maxKey) {
    BIGNUM* randomPrivateKey = BN_new();
    BN_rand_range(randomPrivateKey, maxKey);

    // Ensure the generated key is within the desired range
    while (BN_cmp(randomPrivateKey, minKey) < 0) {
        BN_rand_range(randomPrivateKey, maxKey);
    }

    return randomPrivateKey;
}

// Function to convert a BIGNUM to Int
Int bignumToBigInt(const BIGNUM* bignum) {
    char* bignumStr = BN_bn2dec(bignum);
    Int bigInt;
    bigInt.SetBase10(bignumStr);
    OPENSSL_free(bignumStr);
    return bigInt;
}

// Function to generate keys and check for a specific address
void generateKeysAndCheckForAddress(BIGNUM* minKey, BIGNUM* maxKey, std::shared_ptr<Secp256K1> secp256k1, const std::string& targetAddress) {
    while (true) {
        BIGNUM* randomPrivateKey = generateRandomPrivateKey(minKey, maxKey);

        // Convert the BIGNUM private key to an Int
        Int privateKey = bignumToBigInt(randomPrivateKey);

        // Continue with the rest of the address generation and checking logic
        Point publicKey;
        std::string caddr;
        std::string wifc;

        publicKey = secp256k1->ComputePublicKey(&privateKey);
        caddr = secp256k1->GetAddress(0, true, publicKey);
        wifc = secp256k1->GetPrivAddress(true, privateKey);

        // Display the generated address
        std::string message = "\r\033[01;33m[+] " + caddr;
        std::cout << message << "\e[?25l";
        std::cout.flush();

        // Check if the generated address matches the target address
        if (caddr.find(targetAddress) != std::string::npos) {
            time_t currentTime = std::time(nullptr);

            // Format the current time into a human-readable string
            std::tm tmStruct = *std::localtime(&currentTime);
            std::stringstream timeStringStream;
            timeStringStream << std::put_time(&tmStruct, "%Y-%m-%d %H:%M:%S");
            std::string formattedTime = timeStringStream.str();

            std::cout << "\n\033[32m[+] PUZZLE SOLVED: " << formattedTime << "\033[0m" << std::endl;
            std::cout << "\033[32m[+] WIF: " << wifc << "\033[0m" << std::endl;

            // Append the private key information to a file if it matches
            std::ofstream file("KEYFOUNDKEYFOUND.txt", std::ios::app);
            if (file.is_open()) {
                file << "\nPUZZLE SOLVED " << formattedTime;
                file << "\nPublic Address Compressed: " << caddr;
                file << "\nPrivatekey (dec): " << privateKey.GetBase10();
                file << "\nPrivatekey Compressed (wif): " << wifc;
                file << "\n----------------------------------------------------------------------------------------------------------------------------------";
                file.close();
            }

            // Free the BIGNUM and break the loop
            BN_free(randomPrivateKey);
            break;
        }

        // Free the BIGNUM
        BN_free(randomPrivateKey);

        // Convert the max key to an Int
        Int maxInt;
        maxInt.SetBase10(BN_bn2dec(maxKey));

        if (privateKey.IsGreater(&maxInt)) {
            break;
        }
    }
}


int main() {
    // Clear the console
    std::system("clear");

    time_t currentTime = std::time(nullptr);
    std::cout << "\033[01;33m[+] " << std::ctime(&currentTime) << "\r";
    std::cout.flush();

    BIGNUM* minKeyBN = BN_new(); // Initialize minKeyBN
    BIGNUM* maxKeyBN = BN_new(); // Initialize maxKeyBN

    // Configuration for the Puzzle
    // Set minKeyBN and maxKeyBN using the provided base 10 values
    BN_dec2bn(&minKeyBN, "62079069358943824031");
    BN_dec2bn(&maxKeyBN, "67079069358943924031");
    std::string targetAddress = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so";

    // Initialize SECP256k1
    std::shared_ptr<Secp256K1> secp256k1 = std::make_shared<Secp256K1>();
    secp256k1->Init();

    // Create threads for key generation and checking
    std::vector<std::thread> threads;

    for (int i = 0; i < numThreads; ++i) {
        threads.emplace_back(generateKeysAndCheckForAddress, minKeyBN, maxKeyBN, secp256k1, targetAddress);
    }

    // Wait for all threads to finish
    for (std::thread& thread : threads) {
        thread.join();
    }

    // Cleanup BIGNUM variables
    BN_free(minKeyBN);
    BN_free(maxKeyBN);

    return 0;
}

Code:
SRC = Base58.cpp IntGroup.cpp main.cpp Random.cpp Timer.cpp \
      Int.cpp IntMod.cpp Point.cpp SECP256K1.cpp \
      hash/ripemd160.cpp hash/sha256.cpp hash/sha512.cpp \
      hash/ripemd160_sse.cpp hash/sha256_sse.cpp Bech32.cpp

OBJDIR = obj

OBJET = $(addprefix $(OBJDIR)/, \
        Base58.o IntGroup.o main.o Random.o Int.o Timer.o \
        IntMod.o Point.o SECP256K1.o \
        hash/ripemd160.o hash/sha256.o hash/sha512.o \
        hash/ripemd160_sse.o hash/sha256_sse.o Bech32.o)

CXX = g++
CXXFLAGS = -m64 -mssse3 -Wno-write-strings -O2 -I.

LFLAGS = -lpthread -lssl -lcrypto

$(OBJDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<



VanitySearch: $(OBJET)
@echo Making Lottery...
$(CXX) $(OBJET) $(LFLAGS) -o LOTTO.bin && chmod +x LOTTO.bin

$(OBJET): | $(OBJDIR) $(OBJDIR)/hash

$(OBJDIR):
mkdir -p $(OBJDIR)

$(OBJDIR)/hash: $(OBJDIR)
cd $(OBJDIR) && mkdir -p hash

clean:
@echo Cleaning...
@rm -f obj/*.o
@rm -f obj/hash/*.o

Yes... Grin

But it is still slow. Even 5M keys/s per core muscles is not enough for such a large range. Undecided
Pages: « 1 2 3 4 5 6 7 8 9 10 11 [12] 13 14 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!