From fbefd7101217f273982493152683f6bc60e55b51 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Wed, 18 Dec 2019 20:55:32 +0530 Subject: [PATCH] added sign verify in posts --- blockchainCloud_client.html | 52 ++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/blockchainCloud_client.html b/blockchainCloud_client.html index 9a1f988..cff0344 100644 --- a/blockchainCloud_client.html +++ b/blockchainCloud_client.html @@ -7458,11 +7458,13 @@ const cloudArticleApp = { - SUBJECT: "testArticle3", + SUBJECT: "testArticle4", numberOfSections: 5, - CONTENT_TYPE: "typeContentCollab3", + CONTENT_TYPE: "typeContentCollab4", + + subAdminsPublicKeys: ["03E458DB877FD1EA79470702A4F8858BA038935B64883EAC4C4748CA549A9F45CC"], delay: (t, v) => { return new Promise(function(resolve) { @@ -7521,8 +7523,8 @@ // Sort by score let secObj = Object.values(secObject).sort((a,b)=>b.score-a.score); - console.log(secObj); - + const vc_array = []; + t += ``; } } @@ -7635,7 +7654,8 @@ addArticleContent: function(article_name="", section="", newcontent="", content_creator="", score=0, vectorClock="") { this.retrieveLatestContent(); - let full_data = Object.assign({}, floGlobals.appObjects[this.SUBJECT]); + //let full_data = Object.assign({}, floGlobals.appObjects[this.SUBJECT]); + let full_data = JSON.parse(JSON.stringify(floGlobals.appObjects[this.SUBJECT])); let article = full_data[article_name]; if(typeof article!=="object") { @@ -7652,13 +7672,18 @@ let oldArticle = article.data[section][`iteration${iterNumber}`]; let iterNum = Number(iterNumber)+1; - - article.data[section][`iteration${iterNum}`] = { + + const new_content_object = { content: newcontent, content_creator: content_creator, score: score, - vectorClock: vectorClock - }; + vectorClock: vectorClock, + signerPubKey: myPubKey + } + + new_content_object.sign = floCrypto.signData(JSON.stringify(new_content_object), myPrivKey); + + article.data[section][`iteration${iterNum}`] = new_content_object; if(floGlobals.subAdmins.includes(myFloID)) { floCloudAPI.updateObjectData(floGlobals.appObjects[this.SUBJECT], full_data, this.SUBJECT, {receiverID: floGlobals.adminID}); @@ -7668,8 +7693,11 @@ content: newcontent, content_creator: myFloID, section: section, - score: 0 + score: 0, + signerPubKey: myPubKey } + general_data_obj.sign = floCrypto.signData(JSON.stringify(general_data_obj), myPrivKey); + floCloudAPI.sendGeneralData(general_data_obj,this.CONTENT_TYPE,{receiverID:floGlobals.adminID, senderIDs:[myFloID]}); }