Bitcoin Forum
May 28, 2024, 12:43:56 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Re: Private Key to WIF? on: November 18, 2013, 09:50:02 PM
I'm porting it from https://github.com/bkkcoins/misc/blob/master/hexwif/hexwif

and it's pretty much the exact same code, isn't it?

Note the last line of the code at that link:

Code:
print alphabet[bn] + out

alphabet[bn] in that code is equivalent to the $alphabet[gmp_strval($divmod[0])] that is missing from your code.

Yeah I just figured out that's what you meant, lol.

Once again, thanks!
2  Bitcoin / Bitcoin Technical Support / Re: Private Key to WIF? on: November 18, 2013, 09:42:22 PM
As you exit this loop:

Code:
while (gmp_strval($divmod[0]) >= 58)
{
$divmod = divmod($divmod[0], 58);
$out = $alphabet[gmp_strval($divmod[1])] . $out;
}

$divmod[0] = 4

But you never use that value.  You exit the loop and print out the conversion that you've done so far, but you never calculate the final $alphabet[gmp_strval($divmod[0])]

Oh you're right. I don't understand why, though?

I'm porting it from https://github.com/bkkcoins/misc/blob/master/hexwif/hexwif

and it's pretty much the exact same code, isn't it?

Either way, thanks a lot!
3  Bitcoin / Bitcoin Technical Support / Re: Private Key to WIF? on: November 18, 2013, 07:48:47 PM
https://en.bitcoin.it/wiki/Wallet_import_format

Trying to follow this example here to do this in PHP, but I get stuck at step 3.

I can't seem to get the same SHA256 hash.

I take the extended key from step 2 "800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D"

and SHA256 it.

I should get "8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592" according to step 3 but I just get "E2E4146A36E9C455CF95A4F259F162C353CD419CC3FD0E69AE36D7D1B6CD2C09"

What am I doing wrong?

As with everyone who comes here asking this question (I think this is the fifth time I've answered it, and I'm sure others have answered it many times as well), you are hashing the string (an ASCII representation of a hex number) instead of the actual hex number itself.

Awesome! Thanks!

I've got it working near perfectly, now. The only issue is that it's messing up on the final character.

Do you by chance know PHP?

Code:
$keyHex = $argv[1];

$alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

$exKey = '80' . $keyHex;

$chksum = substr(strtoupper(hash('sha256', hex2bin(strtoupper(hash('sha256', hex2bin($exKey)))))), 0, 8);
echo "Checksum: " . $chksum . "\n";

$divmod = array(gmp_init($exKey . $chksum, 16), 0);

$out = "";

while (gmp_strval($divmod[0]) >= 58)
{
$divmod = divmod($divmod[0], 58);
$out = $alphabet[gmp_strval($divmod[1])] . $out;
}

echo $out . "\n";

function divmod($x, $y)
{
    $div = gmp_div($x, $y);
    $mod = gmp_mod($x, $y);

    return array($div, $mod);
}

If I plug in "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D", it outputs "HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ", but it should be outputting "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" (note the prepending 5)
4  Bitcoin / Bitcoin Technical Support / Private Key to WIF? on: November 18, 2013, 06:54:51 PM
https://en.bitcoin.it/wiki/Wallet_import_format

Trying to follow this example here to do this in PHP, but I get stuck at step 3.

I can't seem to get the same SHA256 hash.

I take the extended key from step 2 "800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D"

and SHA256 it.

I should get "8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592" according to step 3 but I just get "E2E4146A36E9C455CF95A4F259F162C353CD419CC3FD0E69AE36D7D1B6CD2C09"

What am I doing wrong?
5  Bitcoin / Bitcoin Technical Support / Re: How to calculate address? on: November 18, 2013, 04:53:27 PM
I'm using vanitygen. I supply a public key to it and a prefix. It then finds the vanity address using said public key and provides me a partial private key. Sites like bitaddress.com can take that public key and the partial private key and determine the address. The public key itself is not enough; that returns a different address.

That functionality is intended for vanity key "farms" that calculate private keys as a service. The key combination ensures the generated key is known only by the client and not the service.

I was involved in a short discussion on this a while back so I'll link the thread https://bitcointalk.org/index.php?topic=268567.0 in case its of any use to you.

...It generates a partial private key that gets converted to a public key and then added with the buyer's public key to calculate the address. Multiple sites and scripts offer this service, such as bitaddress and pybitcointools

I'd like to know the algorithm to do this so that I can do it up in PHP.
6  Bitcoin / Bitcoin Technical Support / Re: How to calculate address? on: November 18, 2013, 04:43:33 AM
In this, where would I stick the partial private key?

The private key is used to calculate the public key.

You said you already have the public key.

Not sure if this is the right section. Sorry if not.

How can I calculate the address if I have the public key and a private partial key?

Once you have the public key, that's all you need for calculating the address.

Okay let me explain the scenario.

I'm using vanitygen. I supply a public key to it and a prefix. It then finds the vanity address using said public key and provides me a partial private key. Sites like bitaddress.com can take that public key and the partial private key and determine the address. The public key itself is not enough; that returns a different address.
7  Bitcoin / Bitcoin Technical Support / Re: How to calculate address? on: November 18, 2013, 04:10:34 AM
Here:
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

Cheat sheet:


Bitcoin now supports compressed pubkeys (only contains X value, Y value is computed) the above diagram should probably be updated to reflect that.

In this, where would I stick the partial private key?
8  Bitcoin / Bitcoin Technical Support / Re: How to calculate address? on: November 18, 2013, 03:39:24 AM
bitaddress.org and navigate to the vanity wallet

Thank you. And now how can I do it offline?

Save the site, access it from an offline computer.

All the logic is in the client side javascript.  It works just as well offline.

Alright and now let's assume I want to know how it's done.
9  Bitcoin / Bitcoin Technical Support / Re: How to calculate address? on: November 18, 2013, 03:33:00 AM
bitaddress.org and navigate to the vanity wallet

Thank you. And now how can I do it offline?
10  Bitcoin / Bitcoin Technical Support / How to calculate address? on: November 18, 2013, 02:26:58 AM
Not sure if this is the right section. Sorry if not.

How can I calculate the address if I have the public key and a private partial key?
11  Bitcoin / Project Development / hexprivkey to WIF via PHP? on: November 17, 2013, 11:47:36 AM
Been Googling and looking at code for a couple of hours. I've seen a few javascript implementations but honestly I haven't the slightest idea how to port it over. The whole thing's above my head. I'd like to have this in PHP. Can anyone help?
12  Bitcoin / Project Development / Open Source Vanity Address Generator Pool? on: November 17, 2013, 06:13:12 AM
I want to start up a small private pool for generating vanity addresses for just myself and a few friends to do the generating together. Does anyone know of a free vanity address pool that I can set up it up on my server?

Sorry if this is the wrong section.
13  Other / Beginners & Help / Newbie here; are there any open source vanity pool servers? on: November 16, 2013, 01:34:06 AM
Want to start up a small private vanity pool, but I don't have the knowledge necessary to write an efficient server for this. Do any open source ones exist already?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!