2. Key points
You can use any programming environment for both custom blockchain or BTC-transactions.
E.g. NBitcoin can be used with FSharp or Microsoft .NET CSharp
Code examples: http://fssnip.net/7RT and http://fssnip.net/7RY
Blockchain is an immutable insert-only database (no deletes, no updates)
Functional programming is a good fit!
Blockchain “trust” = external computing power required.
To benefit block-chain you need untrusted 3rd parties.
3. Normal table with a hash-code
Id Column1 Column2 Hashcode
1 “Pekka” 23 9a3ffc
• This ensures that table data modifications could be detected
• Column1 and Column2 here is just some normal data…
4. Chain: Table with parent hash-code
Id Column1 Column2 Parent-Hashcode Hashcode
1 “Pekka” 23 9a3ffc
2 “Seppo” 12 9a3ffc a11c52
• Now we can ensure that the rows are in correct order
• And without extra rows or rows missing.
5. Accept only hash-codes start with zeros
Id Column1 Column2 Parent-Hashcode Seed Hashcode
1 “Pekka” 23 11212 00cff4
2 “Seppo” 12 00cff4 7223 009a56
3 “Raimo” 42 009a56 8932 0028a4
4 “asdf” 123 0028a4 6932 00fcc3
5 “Jukka” 53 00fcc3 1234 007b2f
• Add a seed and run a loop from 1 to … to find a seed where hash-code that starts with two zeros.
• Ensures creating a valid transaction chain will need computing power.
• As real hash-codes are length of 32, the leading zeros can be e.g. 8, not two.
6. Scalability: A “block” –chain
Id Parent-Hashcode Seed Hashcode
a1a35 11212 00cff4
2bcf4 00cff4 7223 009a56
3c9ff 009a56 8932 0028a4
• Not all the data need to increase the size of the block-chain.
• A block can contain multiple data rows. The merging (/attaching to chain) is the only operation that
needs the verification: can we trust the client that sent a chunk of data to us?
• Can be thought as normal relational database, a block is one to many relation
• To ensure data is not modified after attached to chain, corresponding Column1 and Column2 data is
still included to hashcode
BlockId Column1 Column2
2bcf4 “Pekka” 23
2bcf4 “Seppo” 12
3c9ff “Raimo” 42
3c9ff “asdf” 123
3c9ff “Jukka” 53
7. Immutable data tables
Data is action-log / event-loop / audit-trail style
Never delete, never update, only insert
Note: The business-logic data action sequence validation is not built-in to block-chain itself.
Did Raimo had 42 to sell?
BlockId Action Column1 Column2
2bcf4 Generated “Pekka” 23
2bcf4 Buy “Seppo” 12
3c9ff Sell “Raimo” 42
3c9ff Buy “asdf” 123
3c9ff Sell “Jukka” 53
8. Conclusions
The real verification, and also cost, is the calculation power and time.
There is no point in block-chain inside one company. You just waste your computing power.
The only benefit is in a large distributed database.
We could code this by hand, but why bother?
Existing block-chain technologies can be used as is
E.g. the Bitcoin block-chain. For Microsoft.NET, NBitcoin: https://github.com/MetacoSA/NBitcoin
Existing trackers/wallets have also features to enable easily custom validations (e.g. data action
sequence)
Creating new private keys uses advanced elliptic cryptography math which is painful to do manually
Code example: http://www.fssnip.net/7RY