temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 02, 2020, 10:50:46 AM |
|
Hi, everybody. Tell me how I can generate millions of keys in hex format with output one per line without any extra characters? This should work on Linux
|
|
|
|
AdolfinWolf
Legendary
Offline
Activity: 1946
Merit: 1427
|
|
February 02, 2020, 05:12:17 PM Last edit: February 02, 2020, 05:43:25 PM by AdolfinWolf |
|
Something like https://github.com/matja/bitcoin-tool ? I'm not sure what would be the most efficient library to generate millions of keys in HEX format. But i guess you could also use https://github.com/bitcoinjs/bitcoinjs-lib (But again, for something more efficient you might want to use a more low-level language..)
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 02, 2020, 05:31:44 PM |
|
I tried the command keys=1000; openssl rand $[32*keys] | xd-pc 32 but more than 60000000 at a time does not generate I need continuous generation of random keys
|
|
|
|
LoyceV
Legendary
Offline
Activity: 3360
Merit: 16954
Thick-Skinned Gang Leader and Golden Feather 2021
|
|
February 02, 2020, 06:02:41 PM |
|
I need continuous generation of random keys Can you share what you're trying to accomplish?
|
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 03, 2020, 02:27:31 AM |
|
I need continuous generation of random keys Can you share what you're trying to accomplish? Unfortunately, I can't say what I need it for yet.
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 03, 2020, 02:51:10 AM |
|
Thanks. Tell me How to run linux in the terminal?
|
|
|
|
Abdussamad
Legendary
Offline
Activity: 3640
Merit: 1571
|
|
February 03, 2020, 04:47:06 AM |
|
for thing in {1..100}; do openssl rand -hex 32 >> privkeys; done
that'll put them in a file named privkeys. replace 100 with 1,000,000 or whatever once you are satisfied it does what you want it to. btw this may interest you
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 04, 2020, 11:58:06 AM |
|
for thing in {1..100}; do openssl rand -hex 32 >> privkeys; done
that'll put them in a file named privkeys. replace 100 with 1,000,000 or whatever once you are satisfied it does what you want it to. btw this may interest you This is what I need. Tell me how to immediately send to another program through the pipe and not save to a file?
|
|
|
|
LoyceV
Legendary
Offline
Activity: 3360
Merit: 16954
Thick-Skinned Gang Leader and Golden Feather 2021
|
|
February 04, 2020, 02:32:50 PM |
|
for thing in {1..100}; do openssl rand -hex 32 >> privkeys; done
This is what I need. Tell me how to immediately send to another program through the pipe and not save to a file? Remove the ">> privkeys" and pipe the whole thing: for thing in {1..100}; do openssl rand -hex 32; done | wc -l This sends it to "word count" as an example. This is a terribly slow method for generating private keys though.
|
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3430
Merit: 4681
|
for thing in {1..100}; do openssl rand -hex 32 >> privkeys; done
that'll put them in a file named privkeys. replace 100 with 1,000,000 or whatever once you are satisfied it does what you want it to. btw this may interest you While rare and generally unlikely, it is possible that the provided command may generate values that are out of range for a Bitcoin Private key. To be sure that you are only generating valid private keys, you'll want to check each 32 byte value and make sure it's greater than: 0000000000000000000000000000000000000000000000000000000000000000 and less than: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140
|
|
|
|
pooya87
Legendary
Offline
Activity: 3500
Merit: 10694
|
|
February 05, 2020, 04:41:47 AM |
|
and less than: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140
"less than or equal to" instead (or just add +1 to the value) since the order of sekp256k1 curve is FF....4141 and private keys are chosen in range of [1, n-1] and the quoted value is n-1 not n. for reference (page 9): https://www.secg.org/sec2-v2.pdf
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 05, 2020, 12:19:21 PM |
|
for thing in {1..100}; do openssl rand -hex 32 >> privkeys; done
This is what I need. Tell me how to immediately send to another program through the pipe and not save to a file? Remove the ">> privkeys" and pipe the whole thing: for thing in {1..100}; do openssl rand -hex 32; done | wc -l This sends it to "word count" as an example. This is a terribly slow method for generating private keys though. Unfortunately, this works very slowly and loads the computer's memory very much. If you set this command as keys=60000000; openssl rand $[32*keys] | xd-p-c32 generates 17000 keys per second. But no more than 60000000 keys at a time. And I need continuous generation of keys in hex format with their transfer through a pipe to another program.
|
|
|
|
pooya87
Legendary
Offline
Activity: 3500
Merit: 10694
|
|
February 05, 2020, 01:40:59 PM |
|
generates 17000 keys per second.
if you want speed then you shouldn't be using bash and while you're at it avoid using strings (hex) altogether. you are adding a couple of bottlenecks that slow down your process. instead write your own code and generate random keys based on what you need. you didn't say what you are using it for, so i'll guess it is nothing serious and randomness doesn't matter. for that case you can simply use a fast hash algorithm that produces 256-bit digests and hash numbers from 1 to 1 mil (or whatever message you want) and use the result as the random key. that shouldn't take any more than a seconds or so.
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
temadlyavseh (OP)
Newbie
Offline
Activity: 12
Merit: 0
|
|
February 05, 2020, 04:05:46 PM |
|
generates 17000 keys per second.
if you want speed then you shouldn't be using bash and while you're at it avoid using strings (hex) altogether. you are adding a couple of bottlenecks that slow down your process. instead write your own code and generate random keys based on what you need. you didn't say what you are using it for, so i'll guess it is nothing serious and randomness doesn't matter. for that case you can simply use a fast hash algorithm that produces 256-bit digests and hash numbers from 1 to 1 mil (or whatever message you want) and use the result as the random key. that shouldn't take any more than a seconds or so. I can't write this code. Can you help me with this?
|
|
|
|
pooya87
Legendary
Offline
Activity: 3500
Merit: 10694
|
|
February 06, 2020, 05:52:40 AM |
|
generates 17000 keys per second.
if you want speed then you shouldn't be using bash and while you're at it avoid using strings (hex) altogether. you are adding a couple of bottlenecks that slow down your process. instead write your own code and generate random keys based on what you need. you didn't say what you are using it for, so i'll guess it is nothing serious and randomness doesn't matter. for that case you can simply use a fast hash algorithm that produces 256-bit digests and hash numbers from 1 to 1 mil (or whatever message you want) and use the result as the random key. that shouldn't take any more than a seconds or so. I can't write this code. Can you help me with this? compile with .net core. it takes 1.2 seconds in debug mode to generate all these hashes. using System.Security.Cryptography;
namespace ValueGen { class Program { private static byte[] max = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 186, 174, 220, 230, 175, 72, 160, 59, 191, 210, 94, 140, 208, 54, 65, 64 };
static void Main(string[] args) { SHA256 hash = SHA256.Create(); for (int i = 0; i < 1_000_000; i++) Foo(hash.ComputeHash(new byte[4] { (byte)i, (byte)(i >> 8), (byte)(i >> 16), 0 })); } public static void Foo(byte[] key) { if (((ReadOnlySpan<byte>)key).SequenceEqual(new byte[32]) ||((ReadOnlySpan<byte>)key).SequenceEqual(max)) return;
// Do whatever with the key! } } }
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
|