Homomorphic encryption allows to store data on a blockchain encrypted, but a smart contract is a program that is executed on a node on the blockchain, therefore the "source code" of the contract is not private; therefore it is desirable to build a monotone compiler that would convert an ordinary function into a set of computations that when executed on the node machine do not reveal any meaningful info, yet when its result is read back by the transaction owner, the results would be tangible to her (as she has the private key). Can this be done with a state machine rather that formal logic like here "TOWARDS" HOMOMORPHIC COMPUTATION FOR DISTRIBUTED COMPUTING
Are there existing algorithms to do that precisely?