Bitcoin Forum

Other => Off-topic => Topic started by: Ean on January 09, 2012, 11:08:20 PM



Title: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: Ean on January 09, 2012, 11:08:20 PM
When I tried to solve the last puzzle (https://bitcointalk.org/index.php?topic=57220.0) I got some ideas. Therefore I decided to give away the prize.

The new riddle:
t+3HVMPwe1rr96QryQdZtZt1LWfcXnEFSG9rKiRuv8ewxwvUmZMH1zwn/Xi4

(Address: 1QE6bWhqizxUVuq55GjL1SErVKH9YCHb7e (http://blockchain.info/address/fec4f895895c6779c30c04b47a5c72dfd4f2e171))


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: scintill on January 10, 2012, 02:03:56 AM
Awesome!  It's like a new brand of "capture the flag"

So, same rules as last time?


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 10, 2012, 06:35:54 AM
So, same rules as last time?
More or less. You get 7 days, but I don't think I can give any hints without give it away.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 11, 2012, 08:47:46 PM
Okay, I'll give you a clue:
It's not base64.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: scintill on January 12, 2012, 07:11:43 AM
Okay, I'll give you a clue:
It's not base64.

Ahh, I hit dead ends investigating that angle with the last one, so I didn't think much of it this time, especially since it looks the same!

I had some ideas for non-base64, but they don't seem to be working out.  If you feel like giving another hint, maybe you can answer this: Is there significant extraneous or missing information?  (I guess the last one had a few extra bits, but for purposes of a hint I wouldn't consider them extra.)


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 12, 2012, 08:41:42 AM
Is there significant extraneous or missing information?
Nothing is missing.
In a way, you could say it's not encoded at all ...


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: mb300sd on January 12, 2012, 06:30:44 PM
I can't figure it out.. If thats not base64, I have no idea where to start. I assume you're also using 7-bit since its the same length.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 12, 2012, 06:58:05 PM
It's actually closer to the answer than you think.
In a way, you don't even need to decode.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: MelMan2002 on January 13, 2012, 10:13:29 PM
Read the + and / as mathematical operators.  The rest is in base58Check.

private key: 5KEzAJbyWBoJdjiDAMatvGTjUTurFsyweGknk8r29tUGSS7k5o9


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 13, 2012, 10:36:57 PM
Read the + and / as mathematical operators.  The rest is in base58Check.

private key: 5KEzAJbyWBoJdjiDAMatvGTjUTurFsyweGknk8r29tUGSS7k5o9
Congratulations!
Now you just have to take the coins.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: MelMan2002 on January 13, 2012, 10:59:01 PM
Thought I did - have I not?  :o


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 13, 2012, 11:06:01 PM
Thought I did - have I not?  :o
I suppose.
But I can still see them in Electrum ...


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: xzion on January 13, 2012, 11:24:33 PM
can you give a bit more details on how to get the right result?
i still can't get it to work  :(

EDIT: nevermind, got it. good challenge!


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: MelMan2002 on January 13, 2012, 11:45:58 PM
can you give a bit more details on how to get the right result?
i still can't get it to work  :(

Details on Base58Check can be found here:
https://en.bitcoin.it/wiki/Base58Check_encoding

Either you find a calculator that can handle a custom number system (my searches were fruitless but I'm sure that they exist) or you convert it to a number system that you can use to do the divide and addition operations.

To convert "Xi4" to base 10, for example, you would have (30*58^2)+(41*58^1)+(3*58^0)=103301


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: MelMan2002 on January 13, 2012, 11:50:05 PM
I suppose that the other option is to do the division by hand in Base58Check but...that can be rather tricky.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 14, 2012, 12:00:54 AM
I used these python functions for the conversion to and from integer numbers:

Code:
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)

def b58encode(v):
    result = []
    while v > 0:
        v, mod = divmod(v, __b58base)
        result.append(__b58chars[mod])
    return ''.join(result[::-1])

def b58decode(v):
    return sum(__b58chars.find(c) * __b58base ** i for i, c in enumerate(v[::-1]))


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: scintill on January 14, 2012, 12:29:52 AM
Good job, MelMan2002!

If anyone else is wondering, here's how I replicated the result in PHP:

Code:
<?php

// adapted from
// http://darklaunch.com/2009/08/07/base58-encode-and-decode-using-php-with-example-base58-encode-base58-decode
function base58_decode($num) {
    
$alphabet '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
    
$len strlen($num);
    
$decoded 0;
    
$multi 1;
 
    for (
$i $len 1$i >= 0$i--) {
        
$decoded bcadd($decodedbcmul($multistrpos($alphabet$num[$i])));
        
$multi bcmul($multistrlen($alphabet));
    }
 
    return 
$decoded;
}

function 
base58_encode($num) {
    
$alphabet '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
    
$base_count strlen($alphabet);
    
$encoded '';
 
    while (
bccomp($num$base_count) >= 0) {
        
$div bcdiv($num$base_count0);
        
$mod bcsub($numbcmul($base_count$div));
        
$encoded $alphabet[$mod] . $encoded;
        
$num $div;
    }
 
    if (
$num) {
        
$encoded $alphabet[(int)$num] . $encoded;
    }
 
    return 
$encoded;
}

// http://us2.php.net/manual/en/ref.bc.php#99130
function bcdechex($dec) {
    
$last bcmod($dec16);
    
$remain bcdiv(bcsub($dec$last), 16);

    if(
$remain == 0) {
        return 
dechex($last);
    } else {
        return 
bcdechex($remain).dechex($last);
    }
}

$num base58_decode('3HVMPwe1rr96QryQdZtZt1LWfcXnEFSG9rKiRuv8ewxwvUmZMH1zwn');

$num bcdiv($numbase58_decode('Xi4'));
$key bcadd(base58_decode('t'), $num);
echo 
base58_encode($num), "\n";
echo 
substr(bcdechex($num), 264), "\n";

(No warranty or anything on this code ;))

If I paste the base58 output into the WIF field on Casascius' address utility (https://github.com/casascius/Bitcoin-Address-Utility), appending "?", it calculates the correct private address and adjusts the WIF to match the correct answer.  I'm not sure if this adjustment is because of a bug in my program, or if it's part of the checksum stuff.

The hex goes in fine, although I'll have to read about base58check to see why the substr is necessary.

I'm curious Ean, did you purposely camouflage this to look like base64, even the same length as the last one?  If so it seems to have been effective! :)


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: Ean on January 14, 2012, 12:35:59 AM
I'm curious Ean, did you purposely camouflage this to look like base64, even the same length as the last one?
Of course.


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: MelMan2002 on January 14, 2012, 01:00:58 AM
I'm curious Ean, did you purposely camouflage this to look like base64, even the same length as the last one?
Of course.

Yes, very clever Ean - I enjoyed the challenge. :)  Thank you!


Title: Re: Game 2: First person to crack this gets 5 BTC
Post by: xzion on January 14, 2012, 01:43:47 AM
wasn't using the correct order of operations. doh!


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: dani147624 on January 14, 2012, 12:01:05 PM
Damn it!  :-[

Doing the operations was my first idea... I managed to force pywallet to output something in hex, which I beleived, were the numbers:

33 + caea7cc3f8b198101e0f7ffb0eeb2e8c85ce9e72cc628990f30f41183aa6eba58761c239d03ded / 019385 (all in hex)

Doing these operations in gcalctool I ended up with this solution: 80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C

However, when this was imported into my wallet.dat, I didn't get the bitcoins (bitcoin was restarted with -rescan). What did I screw up?


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: Remember remember the 5th of November on January 14, 2012, 07:08:37 PM
Dani, a private key begins with a 5. That is quite different from a privkey.


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: altuin on January 14, 2012, 07:11:21 PM
Congratz Melman


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: Ean on January 14, 2012, 07:19:24 PM
Damn it!  :-[

Doing the operations was my first idea... I managed to force pywallet to output something in hex, which I beleived, were the numbers:

33 + caea7cc3f8b198101e0f7ffb0eeb2e8c85ce9e72cc628990f30f41183aa6eba58761c239d03ded / 019385 (all in hex)

Doing these operations in gcalctool I ended up with this solution: 80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C

However, when this was imported into my wallet.dat, I didn't get the bitcoins (bitcoin was restarted with -rescan). What did I screw up?

The base58-key kontains 5 additional bytes that the hex-version do not. The blue part is the actual key:
80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: scintill on January 14, 2012, 08:49:40 PM
Damn it!  :-[

Doing the operations was my first idea... I managed to force pywallet to output something in hex, which I beleived, were the numbers:

33 + caea7cc3f8b198101e0f7ffb0eeb2e8c85ce9e72cc628990f30f41183aa6eba58761c239d03ded / 019385 (all in hex)

Doing these operations in gcalctool I ended up with this solution: 80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C

However, when this was imported into my wallet.dat, I didn't get the bitcoins (bitcoin was restarted with -rescan). What did I screw up?

Ouch, bummer man. :(

Dani, a private key begins with a 5. That is quite different from a privkey.

A Wallet Import Format key does, but what he posted does indeed contain the hex private key, as Ean explains.


Title: Re: Game 2: First person to crack this gets 5 BTC [SOLVED]
Post by: dani147624 on January 14, 2012, 09:56:46 PM
Damn it!  :-[

Doing the operations was my first idea... I managed to force pywallet to output something in hex, which I beleived, were the numbers:

33 + caea7cc3f8b198101e0f7ffb0eeb2e8c85ce9e72cc628990f30f41183aa6eba58761c239d03ded / 019385 (all in hex)

Doing these operations in gcalctool I ended up with this solution: 80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C

However, when this was imported into my wallet.dat, I didn't get the bitcoins (bitcoin was restarted with -rescan). What did I screw up?

The base58-key kontains 5 additional bytes that the hex-version do not. The blue part is the actual key:
80BBC798A19A21A8BCEAA022375B1B73C73EF466CBE5B48D1DB1C195B26CC4603DDC2F897C


Now that I think about it, pywallet probably didn't allow me to import the long key, so I deleted the last 5 bytes... Turns out I should have deleted the first byte and the last 4 bytes instead... Well, anyway, thanks for pointing that out.