示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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));
            }
        }
示例#4
0
        public string CalculateTransactionHash()
        {
            string txnHash = ClaimNumber + SettlementAmount + SettlementDate + CarRegistration + Mileage + ClaimType;

            return(HashFun.GetSha256(txnHash));
        }