Skip to content

Objective 11a - Naughty/Nice List with Blockchain Investigation Part 1

Objective

Objective 11


Link: tools


Tinsel Upatree tells you the following:

Howdy Santa! Just guarding the Naughty/Nice list on your desk. Santa, I don't know if you've heard, but something is very, very wrong... We tabulated the latest score of the Naughty/Nice Blockchain. Jack Frost is the nicest being in the world! Jack Frost!?! As you know, we only really start checking the Naughty/Nice totals as we get closer to the holidays. Out of nowhere, Jack Frost has this crazy score... positive 4,294,935,958 nice points! No one has EVER gotten a score that high! No one knows how it happened. Most of us recall Jack having a NEGATIVE score only a few days ago... Worse still, his huge positive score seems to have happened way back in March. Our first thought was that he somehow changed the blockchain - but, as you know, that isn't possible. We ran a validation of the blockchain and it all checks out. Even the smallest change to any block should make it invalid. Blockchains are huge, so we cut a one minute chunk from when Jack's big score registered back in March. You can get a slice of the Naughty/Nice blockchain on your desk. You can get some tools to help you here. Tangle Coalbox, in the Speaker UNPreparedness room. has been talking with attendees about the issue.

For this objective, you need to be Santa. Go to Santa's office and click on the Naughty/Nice List on the table next to Tinsel Upatree. This will download the blockchain that you need for this objective.


Objective 11


Walk-through

The terminal challenge for this objective is the "Snowball fight" that is offered by Tangle Coalbox in the UNPreparedness room.

Solving this terminal challenge provide additional hints for this objective. To view the hints or the walk-through for this terminal challenge, use the menu on the left.

To start this objective go to the Santa's Office and Download the blockchain data, OfficialNaughtyNiceBlockchainEducationPack.zip and mt19937.py.

There is a talk that may be helpful for this challenge.

To solve this challenge you need to read the blocks in blockchain.dat and extract the Nonces from each block. You will then need to feed the first 624 Nonces to the Mersenne Twister predictor (ex. mt19937.py). This will allow you to predict nonces. You then need to step through the Nonces until you reach the 130000th Nonce.

To do this, extract OfficialNaughtyNiceBlockchainEducationPack.zip. Add mt19937.py to the naughty_nice.py script.

Add the following functions to naughty_nice.py:

def SplitNonces(hexNonce):
     LSB = hexNonce[8:]
     MSB = hexNonce[:8]
     return MSB,LSB

def MergeNonces(a,b):
    return (b+""+a)

def ToDec(hexNonce):
    return int(hexNonce, 16)

def ToHex(dec):
    return hex(dec).split('x')[-1]

Update the main of naughty_nice.py as follow:

if __name__ == '__main__':

    with open('official_public.pem', 'rb') as fh:
        official_public_key = RSA.importKey(fh.read())
    c2 = Chain(load=True, filename='blockchain.dat')
    print('C2: Block chain verify: %s' % (c2.verify_chain(official_public_key)))
    print (len(c2.blocks))

    # create our own version of an MT19937 PRNG.
    myprng = mt19937(0)

    y=0
    #feed 624 Nonces to the Mersenne Twister predictor
    for i in range(0,mt19937.n,2):
        hexNonce=hex(c2.blocks[y].nonce).split('x')[-1]
        MSB,LSB = SplitNonces(hexNonce)
        myprng.MT[i] = untemper(ToDec(LSB))
        myprng.MT[i+1] = untemper(ToDec(MSB))
        y=y+1;

    #generate the Nonces for the existing blocks
    for i in range(y,len(c2.blocks)):
        hexNonce=hex(c2.blocks[i].nonce).split('x')[-1]     
        MSB,LSB = SplitNonces(hexNonce)
        myprng.extract_number()
        myprng.extract_number()
        #print(c2.blocks[i].nonce, hexNonce,MSB,LSB, ToDec(MSB), ToDec(LSB), "pred:",myprng.extract_number(),myprng.extract_number())

    #predict the next 8 Nonces
    for i in range(129997,130001):
        PredictNonce= MergeNonces(ToHex(myprng.extract_number()),ToHex(myprng.extract_number()))
        print ("Predicted Nonce:", i, PredictNonce)

Running the updated naughty_nice.py gives you the following results:


Objective 10


The updated naughty_nice.py code can be downloaded here.

Answer

The 130000 Nonce is

57066318f32f729d