An algorithm for reaching a consensus amongst different parties where none of the parties can be trusted. It is based on examining the messages that each party gets from the other ones and see what the majority of the messages contain. The system will then perform the action which represents the majority consensus. It is tolerant to error or sabotage only if no more than 1/3 of the parties are wrong. It is used in distributed systems networks and distributed P2P networks, such as those used for Bitcoin.