Understand Bitcoin from First Principles