Hyperledger Fabric - How to Decode data_hash to return the actual data?












0















I have been involved in developing Blockchain application using hyperledger fabric.



I made use of fabric-node-sdk to interact with blockchain layer.



Right now I have few data that were inserted into blocks & we are able to see them in CouchDB & query the same to retrieve data.



When channel.queryBlock(1) is called we get data_hash as its response, Is there a way to decode data_hash to get the actual data ?



The data_hash would look like this : 0dafabc38a7d216426b9a9ab71057fe6c8b984c9e44f92b7265fbd3e2785e26c



Any suggestion would be a helpful.



Thank You!










share|improve this question



























    0















    I have been involved in developing Blockchain application using hyperledger fabric.



    I made use of fabric-node-sdk to interact with blockchain layer.



    Right now I have few data that were inserted into blocks & we are able to see them in CouchDB & query the same to retrieve data.



    When channel.queryBlock(1) is called we get data_hash as its response, Is there a way to decode data_hash to get the actual data ?



    The data_hash would look like this : 0dafabc38a7d216426b9a9ab71057fe6c8b984c9e44f92b7265fbd3e2785e26c



    Any suggestion would be a helpful.



    Thank You!










    share|improve this question

























      0












      0








      0








      I have been involved in developing Blockchain application using hyperledger fabric.



      I made use of fabric-node-sdk to interact with blockchain layer.



      Right now I have few data that were inserted into blocks & we are able to see them in CouchDB & query the same to retrieve data.



      When channel.queryBlock(1) is called we get data_hash as its response, Is there a way to decode data_hash to get the actual data ?



      The data_hash would look like this : 0dafabc38a7d216426b9a9ab71057fe6c8b984c9e44f92b7265fbd3e2785e26c



      Any suggestion would be a helpful.



      Thank You!










      share|improve this question














      I have been involved in developing Blockchain application using hyperledger fabric.



      I made use of fabric-node-sdk to interact with blockchain layer.



      Right now I have few data that were inserted into blocks & we are able to see them in CouchDB & query the same to retrieve data.



      When channel.queryBlock(1) is called we get data_hash as its response, Is there a way to decode data_hash to get the actual data ?



      The data_hash would look like this : 0dafabc38a7d216426b9a9ab71057fe6c8b984c9e44f92b7265fbd3e2785e26c



      Any suggestion would be a helpful.



      Thank You!







      hyperledger-fabric hyperledger hyperledger-fabric-ca






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '18 at 11:20









      Faizul HassanFaizul Hassan

      33




      33
























          1 Answer
          1






          active

          oldest

          votes


















          0














          As per the Fabric SDK docs, Channel.queryBlock returns a Promise for a Block. The Block object returned can be interrogated to extract various fields, e.g.



          channel = client.getChannel(channelName);
          return channel.queryBlock(blockNumber);
          }).then((block) => {
          console.log('Block Number: ' + block.header.number);
          console.log('Previous Hash: ' + block.header.previous_hash);
          console.log('Data Hash: ' + block.header.data_hash);
          console.log('Transactions: ' + block.data.data.length);
          block.data.data.forEach(transaction => {
          console.log('Transaction ID: ' + transaction.payload.header.channel_header.tx_id);
          console.log('Creator ID: ' + transaction.payload.header.signature_header.creator.Mspid);
          console.log('Data: ');
          console.log(JSON.stringify(transaction.payload.data));
          });
          });


          Some sample output:



          Block Number: 4
          Previous Hash: b794ee910514f989c0bcb54c2d26d907fca65eb9dd60e86047b3c3c78b96cb96
          Data Hash: 1e267340a5f57ea687bfd6b57aec51b5e16420921fb50f980d08f1302bd289be
          Transactions: 1
          Transaction ID: 49c1333402977a53ec2532a4d425ef8bd6e3efa546358d3d2e3be645ee32b6c0
          Creator ID: Org1MSP
          Data:
          {"actions":[{"header":{"creator":{"Mspid":"Org1MSP","IdBytes":"-----BEGIN CERTIFICATE-----...


          The structure of the Block object is fully documented here.






          share|improve this answer
























          • Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

            – Faizul Hassan
            Nov 29 '18 at 9:57











          • No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

            – Paul Russell
            Nov 29 '18 at 10:09











          • Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

            – Paul Russell
            Nov 29 '18 at 10:18











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53518276%2fhyperledger-fabric-how-to-decode-data-hash-to-return-the-actual-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          As per the Fabric SDK docs, Channel.queryBlock returns a Promise for a Block. The Block object returned can be interrogated to extract various fields, e.g.



          channel = client.getChannel(channelName);
          return channel.queryBlock(blockNumber);
          }).then((block) => {
          console.log('Block Number: ' + block.header.number);
          console.log('Previous Hash: ' + block.header.previous_hash);
          console.log('Data Hash: ' + block.header.data_hash);
          console.log('Transactions: ' + block.data.data.length);
          block.data.data.forEach(transaction => {
          console.log('Transaction ID: ' + transaction.payload.header.channel_header.tx_id);
          console.log('Creator ID: ' + transaction.payload.header.signature_header.creator.Mspid);
          console.log('Data: ');
          console.log(JSON.stringify(transaction.payload.data));
          });
          });


          Some sample output:



          Block Number: 4
          Previous Hash: b794ee910514f989c0bcb54c2d26d907fca65eb9dd60e86047b3c3c78b96cb96
          Data Hash: 1e267340a5f57ea687bfd6b57aec51b5e16420921fb50f980d08f1302bd289be
          Transactions: 1
          Transaction ID: 49c1333402977a53ec2532a4d425ef8bd6e3efa546358d3d2e3be645ee32b6c0
          Creator ID: Org1MSP
          Data:
          {"actions":[{"header":{"creator":{"Mspid":"Org1MSP","IdBytes":"-----BEGIN CERTIFICATE-----...


          The structure of the Block object is fully documented here.






          share|improve this answer
























          • Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

            – Faizul Hassan
            Nov 29 '18 at 9:57











          • No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

            – Paul Russell
            Nov 29 '18 at 10:09











          • Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

            – Paul Russell
            Nov 29 '18 at 10:18
















          0














          As per the Fabric SDK docs, Channel.queryBlock returns a Promise for a Block. The Block object returned can be interrogated to extract various fields, e.g.



          channel = client.getChannel(channelName);
          return channel.queryBlock(blockNumber);
          }).then((block) => {
          console.log('Block Number: ' + block.header.number);
          console.log('Previous Hash: ' + block.header.previous_hash);
          console.log('Data Hash: ' + block.header.data_hash);
          console.log('Transactions: ' + block.data.data.length);
          block.data.data.forEach(transaction => {
          console.log('Transaction ID: ' + transaction.payload.header.channel_header.tx_id);
          console.log('Creator ID: ' + transaction.payload.header.signature_header.creator.Mspid);
          console.log('Data: ');
          console.log(JSON.stringify(transaction.payload.data));
          });
          });


          Some sample output:



          Block Number: 4
          Previous Hash: b794ee910514f989c0bcb54c2d26d907fca65eb9dd60e86047b3c3c78b96cb96
          Data Hash: 1e267340a5f57ea687bfd6b57aec51b5e16420921fb50f980d08f1302bd289be
          Transactions: 1
          Transaction ID: 49c1333402977a53ec2532a4d425ef8bd6e3efa546358d3d2e3be645ee32b6c0
          Creator ID: Org1MSP
          Data:
          {"actions":[{"header":{"creator":{"Mspid":"Org1MSP","IdBytes":"-----BEGIN CERTIFICATE-----...


          The structure of the Block object is fully documented here.






          share|improve this answer
























          • Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

            – Faizul Hassan
            Nov 29 '18 at 9:57











          • No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

            – Paul Russell
            Nov 29 '18 at 10:09











          • Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

            – Paul Russell
            Nov 29 '18 at 10:18














          0












          0








          0







          As per the Fabric SDK docs, Channel.queryBlock returns a Promise for a Block. The Block object returned can be interrogated to extract various fields, e.g.



          channel = client.getChannel(channelName);
          return channel.queryBlock(blockNumber);
          }).then((block) => {
          console.log('Block Number: ' + block.header.number);
          console.log('Previous Hash: ' + block.header.previous_hash);
          console.log('Data Hash: ' + block.header.data_hash);
          console.log('Transactions: ' + block.data.data.length);
          block.data.data.forEach(transaction => {
          console.log('Transaction ID: ' + transaction.payload.header.channel_header.tx_id);
          console.log('Creator ID: ' + transaction.payload.header.signature_header.creator.Mspid);
          console.log('Data: ');
          console.log(JSON.stringify(transaction.payload.data));
          });
          });


          Some sample output:



          Block Number: 4
          Previous Hash: b794ee910514f989c0bcb54c2d26d907fca65eb9dd60e86047b3c3c78b96cb96
          Data Hash: 1e267340a5f57ea687bfd6b57aec51b5e16420921fb50f980d08f1302bd289be
          Transactions: 1
          Transaction ID: 49c1333402977a53ec2532a4d425ef8bd6e3efa546358d3d2e3be645ee32b6c0
          Creator ID: Org1MSP
          Data:
          {"actions":[{"header":{"creator":{"Mspid":"Org1MSP","IdBytes":"-----BEGIN CERTIFICATE-----...


          The structure of the Block object is fully documented here.






          share|improve this answer













          As per the Fabric SDK docs, Channel.queryBlock returns a Promise for a Block. The Block object returned can be interrogated to extract various fields, e.g.



          channel = client.getChannel(channelName);
          return channel.queryBlock(blockNumber);
          }).then((block) => {
          console.log('Block Number: ' + block.header.number);
          console.log('Previous Hash: ' + block.header.previous_hash);
          console.log('Data Hash: ' + block.header.data_hash);
          console.log('Transactions: ' + block.data.data.length);
          block.data.data.forEach(transaction => {
          console.log('Transaction ID: ' + transaction.payload.header.channel_header.tx_id);
          console.log('Creator ID: ' + transaction.payload.header.signature_header.creator.Mspid);
          console.log('Data: ');
          console.log(JSON.stringify(transaction.payload.data));
          });
          });


          Some sample output:



          Block Number: 4
          Previous Hash: b794ee910514f989c0bcb54c2d26d907fca65eb9dd60e86047b3c3c78b96cb96
          Data Hash: 1e267340a5f57ea687bfd6b57aec51b5e16420921fb50f980d08f1302bd289be
          Transactions: 1
          Transaction ID: 49c1333402977a53ec2532a4d425ef8bd6e3efa546358d3d2e3be645ee32b6c0
          Creator ID: Org1MSP
          Data:
          {"actions":[{"header":{"creator":{"Mspid":"Org1MSP","IdBytes":"-----BEGIN CERTIFICATE-----...


          The structure of the Block object is fully documented here.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 29 '18 at 9:44









          Paul RussellPaul Russell

          39028




          39028













          • Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

            – Faizul Hassan
            Nov 29 '18 at 9:57











          • No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

            – Paul Russell
            Nov 29 '18 at 10:09











          • Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

            – Paul Russell
            Nov 29 '18 at 10:18



















          • Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

            – Faizul Hassan
            Nov 29 '18 at 9:57











          • No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

            – Paul Russell
            Nov 29 '18 at 10:09











          • Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

            – Paul Russell
            Nov 29 '18 at 10:18

















          Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

          – Faizul Hassan
          Nov 29 '18 at 9:57





          Thanks much for taking time to write @PaulRussel :) yes have gone through this and I want that particular data_hash value to be decoded to form the actual data. Is there a way to do so ?

          – Faizul Hassan
          Nov 29 '18 at 9:57













          No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

          – Paul Russell
          Nov 29 '18 at 10:09





          No. This is a cryptographic hash, which is a one-way function used to convert data of an arbitrary size to a hash value of a fixed size. You cannot reconstruct the original data from the hash value.

          – Paul Russell
          Nov 29 '18 at 10:09













          Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

          – Paul Russell
          Nov 29 '18 at 10:18





          Just to be completely correct, if you know that no bits have been discarded (i.e. the number of bits in the original data is small enough), it is theoretically possible (given sufficient time and computing power) to reconstruct the original data from the hash. However, in the case of a Hyperledger block, I doubt this would ever be the case.

          – Paul Russell
          Nov 29 '18 at 10:18




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53518276%2fhyperledger-fabric-how-to-decode-data-hash-to-return-the-actual-data%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks