Skip to content

Implementation to manage hash value of file data in block chain

License

Notifications You must be signed in to change notification settings

PLUSPLUS-JP/file-identity-verification

Repository files navigation

Implementation that manages hash value of file data by block chain

Read this in other languages: English, 日本語.

Overview

Use a smart contract to manage the hash value of data of a file in a block chain, and implement a mechanism to confirm that the file certainly existed at a certain point in time

Main point

  • Three types of hash value (MD5 SHA-2 (SHA256 / SHA512)) of file information are generated and registered by block chain.
  • Hash value calculation is performed outside the block chain.
  • Information that can identify a file is not registered in the block chain. The registered information can not be deleted.

Information managed by block chain

  • Three hash values of file information (MD5 SHA-2 (SHA256 / SHA512))
  • File ID generated by combining three types of hash values
  • Registered user's ETH address
  • Time stamp when the information was taken into the blockchain

What can be achieved by this Dapps

As file information is recorded, there is no concern such as falsification of the record

Task

  • File registrant needs to pay GAS
  • Are registered files still present in the future? Can not be managed (do not manage)

specification

Calculation of file ID

argument

  • string _md5 : MD5 hash value
  • string _sha256 : SHA256 hash value
  • string _sha512 : SHA512 hash value

Return value

  • byte32: Calculated file ID
return keccak256(abi.encodePacked(bytes(_md5), bytes(_sha256), bytes(_sha512)));

function

function getFileId(string memory _md5, string memory _sha256, string memory _sha512) public pure returns (bytes32);

File registration

argument

  • string _md5 : MD5 hash value
  • string _sha256 : SHA256 hash value
  • string _sha512 : SHA512 hash value

function

function registerFileHash(string memory _md5, string memory _sha256, string memory _sha512);

ファイルの登録

Erase file

Do not implement the erasure process

Is the file registered?

The file ID is acquired by the above-mentioned "calculation of file ID".

argument

  • string fileId : File ID

Return value

  • bool: true: Registered false: Not registered

function

function isExist(bytes32 fileId) public view returns (bool);

ファイルの検証

Display file information

The file ID is acquired by the above-mentioned "calculation of file ID".

argument

  • string fileId : File ID

Return value

  • bytes32 _fileId File ID
  • bytes _md5 : MD5 hash value
  • bytes _sha256 : SHA256 hash value
  • bytes _sha512 : SHA512 hash value
  • address _registrant : Registrant EOA
  • uint _timestamp : Time stamp of captured block
  • uint _isExist : Always 1 if registered

function

function getFileIdentity(bytes32 fileId) public view
returns (bytes32 _fileId, bytes memory _md5, bytes memory _sha256, bytes memory _sha512, address _registrant, uint _timestamp, uint _isExist)

Implementation

Implementation will be released on GitHub.

https://github.com/PLUSPLUS-JP/file-identity-verification

About

Implementation to manage hash value of file data in block chain

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published