Q:

Document verification Smart Contract (Ethereum)

I'm new in developing of smart contracts in Ethereum. And I have a principle question:
I want to build a document verification contract. The idea would be that using smart contract(s) a document hash and additional parameters could be send to a smart contract and could be stored there forever.
Later this contract should also be used to verify the document by its hash and providing the additional parameters.
I also would like to store the document forever in a distributed store line ipfs or swarm and bind the hash-address of the store to the smart contract.
My Question to this is, I'm not really sure. If I have one smart contract where all elements (documents) are stored. Or if it would be one smart contract per document which must be deployed.
If the second is a solution how could all smart contracts which belong to this service be collected? Must there be another smart contract to hold this information?
It would be great if someone can give me some tipps how to start.
Programming language should be solidity.
Thanks for your help.

A:

I think you can manage it with one smart contract. Without knowing your exact requirements, my approach to the scenario you have described would be as follow.
There should be an id to uniquely identify a document. Set it to an integer. And document hash can be stored as a string value. A mapping defined like, mapping(uint => string) documents can be used to store the hashes.
To use to store a hash define  storeDocument and to verify define  verifyDocument functions as follow.
pragma solidity ^0.4.0;

contract Example {

    mapping(uint => string) documents;

    function storeDocument(uint id, string docHash) {

        storeDocument[id] = docHash;
    }

    function verifyDocument(uint id, string hashToVerify) returns (bool){
        if(storeDocument[id] == hashToVerify ) {
            return true;
        }
        else{
            return false;
        }
     }
} 

Now you can store and verify the documents calling the contract's functions.
NOTE: This is a very basic example and you may need to design the contract according to your requirements. Like you may need to avoid replacing the document hashes if there's  already a hash, or you may need to check who's storing the hash etc.
Hope this helps!

