I would like to store a certificate on the blockchain. I only need to store its hash and if its been verified by both parties or not.
Should I create a struct that is made up of bytes32 for the hash, and a boolean to see if its confirmed or not. And then create a mapping of this struct. Do I need some sort of ID for the mapping? to map the id with the struct?
The certificate would be aimed for person X and his public key would be known on the frontend. This person will then have to sign with his private key and if its been signed then the boolean value should be set to true.
I will be using a database to store all the data. Upon someone searching for the certificate. The data will be pulled from the database. Hash the data and then confirm that the hash is on the blockchain.
On a side note: If i require permissions for different users, should the permissions be on the blockchain, in the struct I add a variable to store all the public keys that have permission to view this certificate.
This is what I think the frontend would look like:
hashedData = web3.utils.sha3(JSON.stringify(certificate));
contracts.mycontract.deployed().then(function(result) {
return result.createCertificate(public_addresskey,hashedData,{ from: account }); //get logged in public key from metamask
}).then(function(result) {
//send post request to backend to create db entry
}).catch(function(err) {
console.error(err);
// show error to the user.
});