CfB,
How many mistakes did I make with the following?
*****
In order to understand Transparent Forging, we must first understand the forging process itself. The goal of NXT forging is to give a chance to each account proportional to the amount of NXT in the account. A small amount of randomness is required to eliminate the possibility of attacks based on knowing the far future forgers, but the near future should be as close to deterministic as possible to allow significant reduction in network bandwidth usage. These apparently contradictory requirements are satisfied by the following code from the Jan 3rd, 2014 source code release:
Account account = unlockedAccountEntry.getKey();
User user = unlockedAccountEntry.getValue();
Block lastBlock = Block.getLastBlock();
if ( lastBlocks.get(account) != lastBlock )
{
byte[] generationSignature = Crypto.sign(lastBlock.generationSignature, user.secretPhrase);
byte[] generationSignatureHash = MessageDigest.getInstance("SHA-256").digest(generationSignature);
BigInteger hit = new BigInteger(1, new byte[] {generationSignatureHash[7], generationSignatureHash[6], generationSignatureHash[5], generationSignatureHash[4], generationSignatureHash[3], generationSignatureHash[2], generationSignatureHash[1], generationSignatureHash[0]});
lastBlocks.put(account, lastBlock);
hits.put(account, hit); // jl777: hit now contains a deterministic but pseudo-random number
JSONObject response = new JSONObject();
response.put("response", "setBlockGenerationDeadline");
response.put("deadline", hit.divide(BigInteger.valueOf(Block.getBaseTarget()).multiply(BigInteger.valueOf(account.getEffectiveBalance()))).longValue() - (getEpochTime(System.currentTimeMillis()) - lastBlock.timestamp));
user.send(response);
}
int elapsedTime = getEpochTime(System.currentTimeMillis()) - lastBlock.timestamp;
if ( elapsedTime > 0 )
{
BigInteger target = BigInteger.valueOf(Block.getBaseTarget()).multiply(BigInteger.valueOf(account.getEffectiveBalance())).multiply(BigInteger.valueOf(elapsedTime)); // jl777: chance proportional to effective balance
if ( hits.get(account).compareTo(target) < 0 ) { // jl777: as time elapses the target gets larger, eventually triggering the acct closest to target.
account.generateBlock(user.secretPhrase);
}
}
Due to the deterministic way the chances are calculated, it is possible to predict which acct will forge the next block and also when it will be forged. Since the hit value is deterministic, a person with multiple accounts can calculate which one has the best chance of forging the next block and transfer all the NXT to that acct. This is why the effective balance is used instead of the actual balance. A time delay from when an account is funded and also a time delay from when funds are transferred reduces the effective amount to eliminate NXT shuffling attacks.
By storing all of the hit values from all the accounts, if each node also knew which accounts are also actively forging, it will be possible for all nodes to predict which acct will forge the near future blocks. Due to variations in clocks and changing of active forging accts, it is not 100% accurate, but this is by design. There needs to be some error factor to prevent an attacker from calculating who will forge blocks in the far future to avoid the NXT shuffling attacks. As long as the prediction rate is close to 100%, the network traffic is reduced dramatically allowing for near realtime processing of thousands of transactions.
Transparent forging allows for a centralized action in a decentralized network. This is the fundamental breakthrough that NXT incorporates.
******
James
I marked with
red an incorrect statement. Also u should add that network topology is a major factor that makes far predictions impossible.