Examining the global reinsurance market for catastrophic losses, we propose a new theory of optimal risk sharing that finds its inspiration in the economic theory of the firm. Our model offers a theoretical foundation for the vertical and horizontal tranching of insurance contracts (also known respectively as proportional and excess of loss reinsurance contracts). Using a two-factor production model popular in industrial economics, we show how reinsurance should be optimally layered (with attachment and detachment points) for a given book of business. This allows us to find the minimum insurance premium necessary to cover the cost of catastrophic events. We conclude with public policy implications by showing the conditions under which government intervention in the catastrophic loss insurance industry can reduce the cost to society of bearing risk and increase its welfare.