I thought about this when I first heard about bitcoin. Haven't found a solution to the problem of memory providers stealing private keys though.
A lot can be done by means of code obfuscation. For example, it has taken many manhours to analyze Stuxnet, and I believe they still do not completely understand Duqu.