Construct hash function in C language

Job ID: 31663373

Budget: $10 – $30 USD

First, open hash.h file and read it. Create a file named hash.c and write the following functions:
• SHA_40, which takes a message of arbitrary length and generated a 40-bit hash value using the sha_40 algorithm
• digest_equal, which indicates whether or not two digests are equal
• main, which tests the functions above




• Read the blockchain.h file. Open blockchain.c and define the following functions in order:
• set_digest, which used to set the SHA_40 digest of a block
• add, which inserts a new value into the blockchain
• verify, which verifies that a blockchain has not been tempered. This function
must compute digest of the previous block and compare it against the digest value stored in the current block.
• There are three attack functions you will add to blockchain.c.
o delete, which deletes a block
o alter_block, which alters data in a block
o alter_2_blocks, which alters data in a block and sets the hash value stored in
the next block to the digest of the altered block
• More details about the functions can be found in the blockchain.h file.



o addanewattributeintnonce;tostructBlock.
o Copy-paste your add function and rename it mine_block.
o This function implements the proof of work system that Bitcoin blockchain uses in
order to control block creation time. You will need to select a nonce of the new block that makes hash digest of the block “small” enough; the first 12 bits of digest must be all zeros.
Related categories: C Programming Cryptography