...by Daniel Szego
quote
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Wednesday, January 11, 2017

Communicating with external datasource on the Ethereum Blockchain

Calling external API from a Solidity smart contract is basically not possible. However there is an indirect way to communicate with external data sources via internal variables, functions and events. Let we assume that we want to call an external API with three string parameters, parameter_1, parameter_2 and parameter_3 and expecting returning a ReturnValue string.  The only way to do it is to raise an event, implement and event handler on the client side to make the necessary call for the event and write the resulting variable back to the smart contract. 

A simple smart contract for the implementation can be seen int the followings:
 Certainly the template realizes efficiently only one call. If several calls are executed paralleled than further considerations are required.  

Several considerations have to be done however regarding security. One of the main idea behind Solidity is that everything is controlled by a decentralized consensus. If external data is used by a Blockchain application it is something that is not part of the decentralized consensus, implying a way for cheating or hacking the whole application. As a consequence extensive use of external data is surely not proposed for a Blockchain application. 

Creating a simple task for an approvement workflow on the Ethereum Blockchain

Let we assume that we want to implement a simple approvement workflow, practically containing one user task with a responsible person to be approved and there are three possible outcome of the task: approves, declined or delegated. For the sake of completeness, we assume that functionalities for logging and access method control are already available, as we described them in the previous blog, The approvement process has one special information field in our example ApprovementInformation that is the information to be approved. In real case scenarios this information is best realized by an explicit smart contract. 


The implementation is pretty much straightforward. The state is stored in the workflowState variable and modified by the Approve and Reject functions. Responsible person of the workflow is stored in the WorkflowResponsible variable; in current implementation only responsible person of the task can accept or decline, however everyone with a write access is allowed to delegate the task for someone else.   


Tuesday, January 10, 2017

Combining data governance and permissions on the Ethereum Blockchain - a basic approach

As we have seen in the previous couple of blogs, there is a possibility both creating permissions on the Ethereum Blockchain and implementing basic data governance protocolls as well. Now we try to combine the two approaches into an inheritance hierarchy to cover both approaches. 

The simplest way is to define an inheritance hierarchy starting with the basic logging - governance functionalities. 
As a second smart contract let we define a descendant of the Governance smart that implements only the access modifiers. 
As the next descendant we define the administrative functions for giving access to a user. It is important to note that this functionality must already be set by the modifiers making sure that only accounts with the necessary right can set further rights. Considering governance, there is the possibility to monitor both the attempts of access and the succeed of access. It is realized by the AdminAccessRole input parameter in our example. 

Last but not least, custom functions can be set by the necessary modifiers, both ensuring that only the account with a necessary right can access to the functionality and to make sure that both the access attempts and the successfully attempts are logged. 


Notes on paper based business cards

Paper based business cards must extinct. 
They do not have any function, they do not have any usage. 
After getting the card you usually get the contact on LinkedIn and throw away the card.   
People meet, they have mobile phones they should be able to exchange business information simply by two clicking on the mobile phone. 
Paper is not required.
It is only a waste of resources,     

Monday, January 9, 2017

Basic data governance on the Ethereum Blockchain

Let we assume that we have several information on the Ethereum Blockchain and we want to realize some kind of a governance. For the first run, we want to collect and monitor the information who had access to some of the critical data and when. The easiest way is to implement an event type for logging. It provides both the possibility to log into a specific storage area and the possibility that the event is raised online on the client side (for instance in a javascript UI).
Triggering the events can be done the best by modifiers, like one for read and one for write.

Lat but not least, the functions that are critical, like access to the critical variable in this example can be extended by the modifiers. 

Certainly, the pattern works much better with inheritance, like implementing the modifiers in an ancestor smart contract and simply using them in a descendant contract. It is important to note that Ethereum is a public Blockchain. As a consequence, in this example even if getVariable is explicitly logged, there is a little bit hacking way to read out the information from the ledger itself without using getVariable.   


An attempt to define the field: Machine Assisted Human Intelligence

At the beginning of the second machine age, life has become increasingly complicated especially if someone works usually online. The reason for that is simple, the amount of knowledge and information that can be easily accessed online has been being boomed in the last couple of years on the one hand because of more and more people getting online and sharing directly or indirectly information. On the other hand, we are at the age of an IoT revolution as well, where not only people, but billions of intelligent devices are getting online, implying a huge wave of device generated data. 

From an evolutionary and biologically perspective this situation is something that is pretty new. We have been aware of the limit our physical body and human perception for thousands of years and we have been making contiguously attempts to overcome these limitations. Examples ranging from the tools of the prehistoric age via the steam engine to the industrial revolution. As an example, let we consider the capability of the human body to be able to lift at most around 100 kg. That is known to be too little already several thousands of years, implying inventions to overcome the limit from different lifting devices to different crane tools. Another well known example is the limitation of the human perception not to see in the dark. Attempts were made to overcome this limit from simply lighting a fire in the prehistory age to the nowadays night-vision systems. However information overload is something that is from an evolutionary point of view totally new. The amount of information throughout the world was something that one could overview even hundred years ago. Nowadays, the existing information is being doubled in each three years, everything is online, everything is real time and in certain fields you need pretty much of it to work or to make decisions. The human brain is simply not capable to work with such a huge amount information and well as the requirements are pretty new, we are simply not sure where exactly are our limits.     

Good examples are for instance many IT fields, like cloud computing. The field did not exist 10 years ago, despite nowadays there are thousands of books of information about and it is being continuously increased. Working in a field like this requires huge amount of time to simply keep up with the information without doing anything productive. There are not many companies and business models that can support such a thing. As a consequence the need for extending information processing limits  of the brain is an always increasing and demanding field.  

On the other hand current trends of artificial intelligence and machine learning provide many intelligent tools that could be efficiently used extend the limits of the humans' recognition and information collecting process. These fields have rather the focus of creating something that is thinking - working - acting similarly as a human. However with the little refocusing the tools might be used not to copy something that already exist and slowly will not be sufficient for the modern world requirements but rather to extend the human's thinking capabilities. Certainly it should be analysed which AI tools and methodologies can be really used in this field as well: rather methods that produce at the end symbolic results in a human understandable way. With other worlds, let machines support our cognitive capabilities by gathering, analyzing, structuring and storing data.  

Fields of machine assisted human intelligence might be the followings:
- Integrated man-machine interfaces
- Integrated man-machine knowledge discovery
- Integrated man-machine learning and knowledge integration:
- Integrated man-machine memory or storage.
- Integrated man-machine decision making.
- Integrated man-machine collaboration

In this sense the field is located somewhere between cognitive science and machine intelligence, having perhaps more general elements from computer science (Figure 1).


Figure 1. The field of machine assisted human intelligence.

An example for such an ecosystem which already can be found practically in each car is the navigation system. The navigation system extends the human memory simply by storing all of the required maps. It helps with the integrated decision making by collecting online data about traffic collecting both from individuals and from automatic sensors as well, practically realizing an integrated knowledge discovery environment as well. Advanced navigation systems take into account the experience and preferences of the driver as well, providing at the everything on a human readable interface (which I would say can be further developed in the future).

Another innovative field that is emerging at the moment and can be regarded as machine assisted human intelligence is the robo-advisory trend of the fintech industry. 

Using permissions on the Ethereum Blockchain with Smart Contract Inheritance

As we have seen in the last two blogs, there is a possibility to use access for functionalities for na Blockchain on permission basis and on group and permission basis as well. One way to use the functionality efficiently is with the help of Smart Contract inheritance. The modifiers and the logic are implemented in an ancestor class, as a consequence they can be used on the exactly same way in the descendant class as well. 



Creating groups and permissions on the Ethereum Blockchain for a SmartContract

We briefly covered in the last blog how to create permissions for accessing information on the Ethereum Blockchain. Let we extend the model for administrating the access rights not on the individual user (address) basis, but with the help of groups and group membership. We are presenting only a simply version as a prototype; certainly more complex solutions can be built as well. 

As usual, let we create a smart contract, some state variables to access, some elementary access level presented by an enum and two mappings: groupAtomicRoleMapping for mapping an atomic role for a group, and groupsForMembers for mapping list of members for a group name. A constructor is also presented that creates the first Administrators group with an Admin atomic access level and puts the current user into the group. 

Secondly let we create four modifiers to check if the the account calling a function in a group having Read, Write or Admin atomic access. Additionally one modifier checks if the account is the owner of the Smart Contract. 

As a next step some functions are implemented to access to the data of the smart contract and setting access to groups or adding users to group. All functions are modified based on the right modifiers. 

Last but not least, a help function is implemented for string comparison and a destructor as well. 

First testing of the contract can be done in the browser version of solidity. As an example after creating the contract with Create (default zero constructor) we get exception for services that require Admin access. (Please note that in this example there is a type error for the AccessWithGroups constructor. In this way we make tests with or without executing the functionality in the constructor).


After calling the constructor AccesWithGroups constructor explicitly, the administrator group is created set with Admin access and the current account is put into the group. As a consequence we have access for functions like setGroupAccess. 


Certainly real life examples would require more considerations, like implementing functionality for adding or deleting groups, having the possibility for a group to have more than one atomic access level or just implementing error checking into the existing functions.  


Sunday, January 8, 2017

Creating permissions on the Ethereum Blockchain with SmartContract

Let we create a simply example for a permissioned Smart Contract on Ethereum Blockchain. Let we assume that we have the following atomic level of access:
- Read: reading information from the state of the Smart Contract.
- Write; Writing information to a Smart Contract.
- Admin: administration the roles.

Let we assume that the Smart Contract has a couple of variables in a struct for storing internal information an enum for storing atomic access information, a mapping for storing the access information for each account and and a constructor that guarantees that the creating account is registered as Admin. 
Let we create as the next step three modifiers to guarantee that certain functions can be called only by the necessary rights. 
Last but not least, we use the modifiers in the service functions to make sure that only people with the necessary right are able to reach the given service, In our example, we have three services: for reading out data, for writing data and for administrating access.

Certainly, getData functionality does not really cover the expected functionality. As Ethereum is a public Blockchain, the data can be practically read out from the Blockchain even if the getData function can not be explicitly called. 

Saturday, January 7, 2017

Notes on API Integration Frameworks and API query languages


Regarding general IT trends, hosted API solutions are getting more and more common. It implies that solutions will be built up in the future with integrating several API-s as a service. As a consequence frameworks will be more and more important to integrate API-s, to test them, to measure the availability of the individual API-s, or just simply query data efficiently.