public bool IsValidChain(string prevBlockHash, bool verbose) { bool isValid = true; BuildMerkleTree(); string newBlockHash = HashFun.GetSha256(Nonce + CalculateBlockHash(prevBlockHash)); bool validSignature = KeyStore.VerifyBlock(newBlockHash, BlockSignature); if (newBlockHash != BlockHash) { isValid = false; } else { isValid |= PreviousBlockHash == prevBlockHash; } PrintVerificationMessage(verbose, isValid, validSignature); if (NextBlock != null) { return(NextBlock.IsValidChain(newBlockHash, true)); } return(isValid); }
public string CalculateBlockHash(string previousBlockHash) { string txnHash = ClaimNumber + SettlementAmount + SettlementDate + CarRegistration + Mileage + ClaimType; string blockHeader = BlockNumber + CreatedDate.ToString() + previousBlockHash; string combined = txnHash + blockHeader; return(HashFun.GetSha256(combined)); }
public string CalculateBlockHash(string previousBlockHash) { string blockheader = BlockNumber + CreatedDate.ToString() + previousBlockHash; string combined = merkleTree.RootNode + blockheader; if (KeyStore == null) { return(HashFun.GetSha256(combined)); } else { return(HashFun.GetHMACHash(combined, KeyStore.AuthenticatedHashKey)); } }
public string CalculateTransactionHash() { string txnHash = ClaimNumber + SettlementAmount + SettlementDate + CarRegistration + Mileage + ClaimType; return(HashFun.GetSha256(txnHash)); }