A Formal Framework for Designing Verifiable Protocols