Hello All,

I hope you can help me with understanding how primecoin works. So far the actual knowledge I’m looking for is not on the wiki, the original white paper, or asked anywhere else, and this is pretty much my last stop before I start digging though the source code and trying to understand what is going on.

In my interest in understanding how primecoin works, I want to write my own miner. This will most likely start with a CPU affair, and be slower than the official, but hopefully it will help me understand how the whole thing works.

So, based on my understanding (and please, correct me if I am wrong), the primecoin algorithm works something like this:

- You get a range of numbers, say 1-100
- You then find out which ones in that range are prime numbers
- Then you see which ones fulfill the requirements to be classed as a Cunningham chain (sequence of primes, that follow 2p+1)
- The length of the chain is your difficulty (so e.g. if the difficulty is 5, you have to find a Cunningham chain of 5 primes).
- This chain (once it meets the difficulty) is what is submitted to the network as proof of work.

Is the above correct? If it is, then to discover such a chain, I need two inputs:

- The range of numbers within which to search for primes
- The target chain length (difficulty)

However when I connect to the primecoin server, and issue a getwork command, I get this:

bitcoinrpc.data.WorkItem(

hash1=u’00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000’,

data=u’00000002f70dac11a77280011f3072fbd4a2a689f6103ab1e8ff7f1e158ab1acd5cc55815bb8d71f254092c155bb6feb3bbda2031f60388d33ef026d1fd3b9c00dcd91a552dd0e300a7011e200000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000’,

midstate=u’fa9784fcfc8f08f597b65164a4d4a1b75c0d51ebd904ab7e19b29c23119fa1fd’,

target=u’00000000000000e2117000000000000000000000000000000000000000000000’)

Which is the same format as the original BTC network. Now, out the above, what does it mean? Is there a protocol description somewhere? What is the range I need to search in, and what it the chain length I need to find? What is midstate and target in this context?

Or have I just misunderstood the algorithm completely?

Any helps/tips/pointers are appreciated