From d98057662f778564554b0972d9ce54e67b45c906 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@martin-legene.dk> Date: Mon, 1 Apr 2019 02:49:26 -0300 Subject: [PATCH] Resurrecting TimeStampAuthority.sol --- src/TimeStampAuthority.sol | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/TimeStampAuthority.sol diff --git a/src/TimeStampAuthority.sol b/src/TimeStampAuthority.sol new file mode 100644 index 0000000..2282493 --- /dev/null +++ b/src/TimeStampAuthority.sol @@ -0,0 +1,26 @@ +// 20180718 Robert Martin-Legene <robert@nic.ar> +// Time stamp authority + +pragma solidity ^0.4.24; + +contract TimeStampAuthority { + // This mapping is almost an "associative array" + mapping (uint256 => uint) private hashstore; + + // Stores hashes (256 bit uint) of a document in the mapping + function put( uint256[] hasharray ) public { + uint256 i = hasharray.length; + while (i>0) { + i--; + uint256 h = hasharray[i]; + if (hashstore[h] == 0) { + hashstore[h] = block.number; + } + } + } + + // Returns the block number in which the hash was first seen + function get( uint256 hash ) public view returns (uint) { + return hashstore[hash]; + } +} -- GitLab