Create a primecoin hash


#1

Hello!, So I’m trying to create a primecoin hash. For example, for the first block on testnet;

version: 2
“previousblockhash” : “221156cf301bc3585e72de34fe1efdb6fbd703bc27cfc468faa1cdd889d0efa0”
“merkleroot” : “ec89e34f446bab9d7bbe0c14bea9a01a45c9eafbd383c3c7bfdc3e3c91433d81”
“time” : 1373071487,
“nonce” : 141,
“bits” : “05000000”,
bnPrimeChainMultiplier “969371”,

And the hash is here;

https://github.com/BTCPrime/BitcoinPrime/blob/7804466fc0cb70125ccba93ed9e1fdac9374ee83/src/main.h#L1276

I’m taking each field, converting it to hex if neccesary, reversing the bytes so its in little endian format, concatenating all that together, and doing a double sha256 hash on it. I would expect to arrive at the block hash of;
“hash” : “faba12d46bef122f04929195b29cd0d1cc1ecc0b66d6b35967f3f9c4d8c28fe3”,

But I’m not. What am I missing?

Here’s my workings;

Version: 02000000

echo 221156cf301bc3585e72de34fe1efdb6fbd703bc27cfc468faa1cdd889d0efa0 | grep -o … | tac | paste -sd ‘’ -
PreviousBlockHash: a0efd089d8cda1fa68c4cf27bc03d7fbb6fd1efe34de725e58c31b30cf561122

echo ec89e34f446bab9d7bbe0c14bea9a01a45c9eafbd383c3c7bfdc3e3c91433d81 | grep -o … | tac | paste -sd ‘’ -
MerkleRoot: 813d43913c3edcbfc7c383d3fbeac9451aa0a9be140cbe7b9dab6b444fe389ec

echo “obase=16; 1373071487” | bc
echo 51D7687F | grep -o … | tac | paste -sd ‘’ -
Timestamp: 7F68D751

echo 05000000 | grep -o … | tac | paste -sd ‘’ -
Bits: 00000005

echo “obase=16; 141” | bc
echo 8D | grep -o … | tac | paste -sd ‘’ -
Nonce: 8D
2s; 8D00

echo “obase=16; 969371” | bc
ECA9B
echo ECA9B | grep -o … | tac | paste -sd ‘’ -
Multiplier: A9EC
2s; 9BCA0E00

Concatenated;
02000000a0efd089d8cda1fa68c4cf27bc03d7fbb6fd1efe34de725e58c31b30cf561122813d43913c3edcbfc7c383d3fbeac9451aa0a9be140cbe7b9dab6b444fe389ec7F68D751000000058D009BCA0E00

Double 256 Hash: cfbef7bb528e767a5de9295befaa1a14be0c2dca6bc89fcd1d99cb46d4a96aba

EDIT:

Now solved.

Byte 81 gives the length of bnPrimeChainMultiplier followed by the multiplier.