Author

Topic: PPC uses the same SHA256 hash algorithm as bitcoin? (Read 2486 times)

legendary
Activity: 1078
Merit: 1005
Do you have a good reference to read up on the issue/implementation? Information on the exact workings of merged mining is sparse. There is some explanation, e.g. http://bitcoin.stackexchange.com/questions/273/how-does-merged-mining-work
Only the source, sorry.

Quote
If a miner solves the hash at the Namecoin difficulty level, the Namecoin block is assembled. It includes the Namecoin transaction set, the Namecoin block header, the Bitcoin block header, and the hash of the rest of the transactions in the Bitcoin block.

That implies that if the bitcoin block header becomes invalid, due to a chain reorg, any namecoin blocks, which incorporate the bitcoin block header in question, become stale.
The namecoin data contains a copy of the bitcoin block header, not a reference to the header in the bitcoin chain. Imagine that namecoin is being merge mined and a block is found on the bitcoin chain, resulting in a block found in the namecoin chain. Now imagine all future blocks on the namecoin chain are mined by solo namecoin miners. These miners don't use merge mining and don't connect to bitcoin at all. Then the bitcoin chain reorgs invalidating the original bitcoin block. The solo miners will not know about this and continue mining, no affect on the chain.

Another reason a 'reorg' won't affect namecoin is that the the hash that solved the namecoin block is still a valid namecoin hash. The fact that someone built on a different bitcoin block in the primary chain, and invalidating the original block, does not stop the fact that the namecoin block had a valid namecoin hash and that miners are building on that namecoin block. Merge miners can start working on the new re-orged bitcoin main chain, but continue building on the existing valid namecoin block that was solved previously.

It is possible that a merge miner could cause a reorg on both chains though. That miner could be mining a bitcoin chain that becomes the main chain and they could be mining a namecoin chain that becomes a new chain too. It's possible that the same reason they created a fork on bitcoin causes a fork on namecoin. For example a large miner mining offline for a short period.
donator
Activity: 994
Merit: 1000
Also, from what I understand, a reorg in the mainchain invalidates some blocks in the siblings and forces it to recalculate, which means that the network security of the two blockchains are not independent...
A reorg in the mainchain does not affect the auxiliary chains. They are entirely separate.
Do you have a good reference to read up on the issue/implementation? Information on the exact workings of merged mining is sparse. There is some explanation, e.g. http://bitcoin.stackexchange.com/questions/273/how-does-merged-mining-work

In particular I'd like to verify the following statement:
Quote
If a miner solves the hash at the Namecoin difficulty level, the Namecoin block is assembled. It includes the Namecoin transaction set, the Namecoin block header, the Bitcoin block header, and the hash of the rest of the transactions in the Bitcoin block.

That implies that if the bitcoin block header becomes invalid, due to a chain reorg, any namecoin blocks, which incorporate the bitcoin block header in question, become stale.
legendary
Activity: 1078
Merit: 1005
Also, from what I understand, a reorg in the mainchain invalidates some blocks in the siblings and forces it to recalculate, which means that the network security of the two blockchains are not independent...
A reorg in the mainchain does not affect the auxiliary chains. They are entirely separate.
legendary
Activity: 1205
Merit: 1010
Merge mining also makes a few implicit assumptions, e.g. that the parent chain always has a higher difficulty than the siblings. Also, from what I understand, a reorg in the mainchain invalidates some blocks in the siblings and forces it to recalculate, which means that the network security of the two blockchains are not independent...

Hmm haven't realized about this. If that's true it would be a serious flaw of merge-mining.
donator
Activity: 994
Merit: 1000
That's correct, ppcoin uses the same hash algorithm as bitcoin.

Those who argue for merge-mining often miss some important points:

1) Merge-mining does not necessarily make 51% attack harder, CLC was so easily attacked exactly because it was merge-minable from the start. Also ppcoin uses different mechanisms to discourage 51% attack so merge-mining does not offer much additional value regarding security.

2) Implementing merge-mining violates implicit contract between the designer and the users regarding the value and the foundation of the currency, that is, it's a significant change of the monetary design. For this reason alone merge-mining would not be introduced for ppcoin as it may undermine trust in the currency.

Merge mining also makes a few implicit assumptions, e.g. that the parent chain always has a higher difficulty than the siblings. Also, from what I understand, a reorg in the mainchain invalidates some blocks in the siblings and forces it to recalculate, which means that the network security of the two blockchains are not independent...
legendary
Activity: 1205
Merit: 1010
That's correct, ppcoin uses the same hash algorithm as bitcoin.

Those who argue for merge-mining often miss some important points:

1) Merge-mining does not necessarily make 51% attack harder, CLC was so easily attacked exactly because it was merge-minable from the start. Also ppcoin uses different mechanisms to discourage 51% attack so merge-mining does not offer much additional value regarding security.

2) Implementing merge-mining violates implicit contract between the designer and the users regarding the value and the foundation of the currency, that is, it's a significant change of the monetary design. For this reason alone merge-mining would not be introduced for ppcoin as it may undermine trust in the currency.

legendary
Activity: 2492
Merit: 1473
LEALANA Bitcoin Grim Reaper
So unless the same happens, which I doubt, MM will not happen.

Stake blocks keep the difficulty from falling. So that is interesting.
legendary
Activity: 1484
Merit: 1005
Quote
namecoind
For namecoind grab the latest version from vinceds repo and follow the instructions found in the doc directory for your platform or just use the latest version from dot-bit main page. The current implementation starts merged mining on block 19200 on production blockchain and on block 0 if you have configured testnet blockchain.
http://dot-bit.org/Merged_Mining#namecoind

Ah, okay...  Does that mean someone with a large proof of stake can now enable merge mining on the chain and then attack it using someone's BTC pool?  So the chain is pretty much able to be held hostage by anyone with a large proof of stake?
legendary
Activity: 2492
Merit: 1473
LEALANA Bitcoin Grim Reaper
Namecoin has a different genesis block and chain and is still able to be merge mined with bitcoin.

Namecoin was set to mergemine at block XXXXX and everyone downloaded the new client to MM.
legendary
Activity: 1484
Merit: 1005
Namecoin has a different genesis block and chain and is still able to be merge mined with bitcoin.
legendary
Activity: 2492
Merit: 1473
LEALANA Bitcoin Grim Reaper
Quote
Oh really? How would they 51% the stake blocks?
Mine tons of PPC and hold them as stake?

Wait,

Quote
"Merged mining works like this, you have two totally separate block chains, they are not related in any way nor does either contain any data from the other. When you mine you generate hashes that may be the solution to the current block, this is very very improbable per hash, its like a lottery where everyone generates tickets until someone finds the winning one. Normally you make tickets and check them against the Bitcoin block chain to see if they are the solution. With merged mining you create a ticket and check it against both the Bitcoin block chain and the Namecoin block chain, Bitcoin and Namecoin know nothing about each other, they are two totally different lotteries with different winning numbers, you just sent a copy of your ticket to both. Since you are sending the same ticket to two lotteries you increase your chances of winning one or the other. No Bitcoin data goes into Namecoin no Namecoin data into Bitcoin they remain totally separate, you simply run both the Namecoin and Bitcoin clients on the same machine and submit hashes to both networks, if your hash is the solution to the Namecoin block you get Namecoins if you hash is the solution to the Bitcoin block you get Bitcoins, its exactly like if you where mining on just one network, except you submit the same work twice."

I don't understand how the checkpoints prevent merge mining if you just submit the share against both chains...?

From what I understand the blocks that we are looking for hashes to are different in each chain. So you can't just submit them into another chain because you are looking for a hash for a different block.

Well i guess if someone held 51% of all PPC then perhaps I see your point? lol

Perhaps DOUBLEC can clarify. I already asked this question in PM before I got involved in PPC.

I did my research he he he.
legendary
Activity: 1484
Merit: 1005
Quote
Oh really? How would they 51% the stake blocks?
Mine tons of PPC and hold them as stake?

Wait,

Quote
"Merged mining works like this, you have two totally separate block chains, they are not related in any way nor does either contain any data from the other. When you mine you generate hashes that may be the solution to the current block, this is very very improbable per hash, its like a lottery where everyone generates tickets until someone finds the winning one. Normally you make tickets and check them against the Bitcoin block chain to see if they are the solution. With merged mining you create a ticket and check it against both the Bitcoin block chain and the Namecoin block chain, Bitcoin and Namecoin know nothing about each other, they are two totally different lotteries with different winning numbers, you just sent a copy of your ticket to both. Since you are sending the same ticket to two lotteries you increase your chances of winning one or the other. No Bitcoin data goes into Namecoin no Namecoin data into Bitcoin they remain totally separate, you simply run both the Namecoin and Bitcoin clients on the same machine and submit hashes to both networks, if your hash is the solution to the Namecoin block you get Namecoins if you hash is the solution to the Bitcoin block you get Bitcoins, its exactly like if you where mining on just one network, except you submit the same work twice."

I don't understand how the checkpoints prevent merge mining if you just submit the share against both chains...?
legendary
Activity: 2492
Merit: 1473
LEALANA Bitcoin Grim Reaper
Well, regardless of merge mining, the first person to get a couple of ASICs can 51% the entire currency.  Roll Eyes

Oh really? How would they 51% the stake blocks?  Cheesy

I guess the real question to Sunny King is if you can invalidate stake blocks.
legendary
Activity: 1484
Merit: 1005
Well, regardless of merge mining, the first person to get a couple of ASICs can 51% the entire currency.  Roll Eyes
legendary
Activity: 2492
Merit: 1473
LEALANA Bitcoin Grim Reaper
It can be merge mined if majority of the nodes download an updated client. Otherwise it won't happen.

From what I got from DoubleC, you have to set a checkpoint to start from and have users update their clients. Ultimately it is up to the PPC network to decide based on updating their client after it would be updated.

As of right NOW you can't merge mine PPC.

 Cheesy Cheesy Cheesy
legendary
Activity: 1484
Merit: 1005
PPC: util.h
Code:
#include

template
inline uint256 Hash(const T1 pbegin, const T1 pend)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

template
inline uint256 Hash(const T1 p1begin, const T1 p1end,
                    const T2 p2begin, const T2 p2end)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256_CTX ctx;
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
    SHA256_Final((unsigned char*)&hash1, &ctx);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

template
inline uint256 Hash(const T1 p1begin, const T1 p1end,
                    const T2 p2begin, const T2 p2end,
                    const T3 p3begin, const T3 p3end)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256_CTX ctx;
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
    SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0]));
    SHA256_Final((unsigned char*)&hash1, &ctx);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

Bitcoin: util.h
Code:
#include

template
inline uint256 Hash(const T1 pbegin, const T1 pend)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

template
inline uint256 Hash(const T1 p1begin, const T1 p1end,
                    const T2 p2begin, const T2 p2end)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256_CTX ctx;
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
    SHA256_Final((unsigned char*)&hash1, &ctx);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

template
inline uint256 Hash(const T1 p1begin, const T1 p1end,
                    const T2 p2begin, const T2 p2end,
                    const T3 p3begin, const T3 p3end)
{
    static unsigned char pblank[1];
    uint256 hash1;
    SHA256_CTX ctx;
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0]));
    SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0]));
    SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0]));
    SHA256_Final((unsigned char*)&hash1, &ctx);
    uint256 hash2;
    SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
    return hash2;
}

output of diff: no differences

PPC: script.cpp
Code:
   // Serialize and hash
    CDataStream ss(SER_GETHASH, 0);
    ss.reserve(10000);
    ss << txTmp << nHashType;
    return Hash(ss.begin(), ss.end());

Bitcoin: script.cpp (old version)
Code:
   // Serialize and hash
    CDataStream ss(SER_GETHASH, 0);
    ss.reserve(10000);
    ss << txTmp << nHashType;
    return Hash(ss.begin(), ss.end());

output of diff: no differences

Am I missing something here?  It sure looks merge minable to me.
Jump to: