Bithoven: Formal Safety for Expressive Bitcoin Smart Contracts
Hyunhum Cho, Ik Rae Jeong
TL;DR
Bithoven addresses the gap between Bitcoin Script’s security and developer usability by delivering a high-level, imperative language that compiles to native Script. It pairs a formal syntax and operational semantics with a multi-stage static analyzer (type system, liveness, semantic control-flow) to guarantee compile-time safety, preventing attacker-spendable and never-spendable defects before deployment. The compiler, implemented in Rust, achieves on-chain costs comparable to hand-optimized Script while enabling expressive constructs like general arithmetic, imperative control flow, and per-path input stacks for complex contracts (e.g., HTLCs). Empirical evaluations compare Bithoven to Miniscript and BSHunter, showing broader defect coverage, zero-overhead for most logic, and a favorable safety-efficiency trade-off, demonstrating practical viability for secure, expressive Bitcoin contracts. Overall, Bithoven demonstrates that formal safety can be delivered without consensus changes, unlocking safer, more usable on-chain contracts within the Bitcoin ecosystem.
Abstract
The rigorous security model of Bitcoin's UTXO architecture often comes at the cost of developer usability, forcing a reliance on manual stack manipulation that leads to critical financial vulnerabilities like signature malleability, unspendable states and unconstrained execution paths. Industry standards such as Miniscript provide necessary abstractions for policy verification but do not model the full imperative logic required for complex contracts, leaving gaps in state management and resource liveness. This paper introduces Bithoven, a high-level language designed to bridge the gap between expressiveness and formal safety. By integrating a strict type checker and a resource liveness analyzer with a semantic control-flow analyzer, Bithoven eliminates major categories of consensus and logic defects defined in our fault model prior to deployment. Our results indicate that this safety comes at modest cost: Bithoven compiles to Bitcoin Script with efficiency comparable to hand-optimized code, demonstrating that type-safe, developer-friendly abstractions are viable even within the strict byte-size constraints of the Bitcoin blockchain.
