Page 1 of 1

Blockchain - Antonio

Posted: Wed Apr 04, 2018 12:42 pm
by cdmmaui
Dear Antonio,

Are there any plans to incorporate Blockchain initiatives in to FWH?

Thank you,

Re: Blockchain - Antonio

Posted: Wed Apr 04, 2018 2:30 pm
by Antonio Linares

Re: Blockchain - Antonio

Posted: Wed Apr 04, 2018 10:52 pm
by cdmmaui
Dear Antonio,

We have been invited to be part of the global supply chain and logistics platform with IBM and Maersk (one of the largest shipping companies in the world). We are looking at available platforms and moving forward. It would be great if FWH had these capabilities.

Sincerely,

Re: Blockchain - Antonio

Posted: Thu Apr 05, 2018 7:07 am
by Antonio Linares
Dear Darrell,

The key concept of the blockchain is this one:
The hash of the previous block must be found in the block to preserve the chain integrity
So you can easily apply this concept to a database table records, or to an invoice, etc. Simply select which data to control, generate its hash and store it in the next record.

If a record is modified, the hash no longer matches and the blockchain is broken and can be detected where it got broken.

A question arises: What if a record has to be modified ? In such case, all records must modify their hashes. Or modifications are not allowed.

In example: when we use GIT for source control, every change is tracked. There is no way to "modify" a change. You simply add a "new" change.

Applying these two simple ideas, you can blockchain whatever you want :-)

Re: Blockchain - Antonio

Posted: Thu Apr 05, 2018 2:40 pm
by lucasdebeltran
Antonio,

A prototype in fivewin Will be great!!.

Re: Blockchain - Antonio

Posted: Sat Apr 07, 2018 3:34 pm
by George
Antonio,
Very interesting the "FWH Blockchain initiative" proposed by Darrell.
I think the Fivewin community, as a whole, should support it, as this would introduce Fivewin into the new distributed database development environment.

Regards,

George

Re: Blockchain - Antonio

Posted: Sun Apr 08, 2018 3:43 pm
by Antonio Linares
This example shows how to create a Blockchain using an array:

The third element of each subarray contains the hash of the previous subarray. As soon as an element of a subarray is modified, we can detect
where the blockchain has been modified.

This same concept can be taken into a DBF so each record keeps a hash of the previous record. In fact we can easily modify FWH Class TDataBase to
automatically implement this on a DBF and thus provide the Blockchain security to our DBFs or SQL tables :-)

blockchain.prg (c) FiveTech Software 2018

Code: Select all

function Main()

   local aBlocks := { { 1, "first", 0 },;
                      { 2, "second", 0 },;
                      { 3, "third", 0 },;
                      { 4, "fourth", 0 },;
                      { 5, "fifth", 0 } }

   AEval( aBlocks, { | aBlock, n | If( n > 1,;
          aBlock[ 3 ] := hb_HMAC_SHA256( aBlocks[ n - 1 ][ 2 ],;
                                         aBlocks[ n - 1 ][ 3 ] ),) } )
   aBlocks[ 3 ][ 2 ] = "changed!"     

   AEval( aBlocks, { | aBlock, n | If( n > 1,;
          If( aBlock[ 3 ] != hb_HMAC_SHA256( aBlocks[ n - 1 ][ 2 ],;
                                             aBlocks[ n - 1 ][ 3 ] ),;
          MsgInfo( "blockchain modified at " + AllTrim( Str( n - 1 ) ) + ;
                   "element" ), ), ) } )   

return nil  

Re: Blockchain - Antonio

Posted: Mon Apr 09, 2018 5:53 pm
by cnavarro

Re: Blockchain - Antonio

Posted: Mon Apr 23, 2018 8:20 am
by Antonio Linares