I recently came across the topic where exchanges have to constantly give a proof of solvency to prove that they hold enough bitcoin for it's clients. I was however intrigued by the way an exchange would give a proof of reserves. I was trying to build a script for generating the proof of reserves using the Invalid input scheme to prove the reserves of bitcoin a node holds. Are there any resources which I can refer to for the same?I have been struggling to find any. Any help would be very much appreciated.
A proof of reserve via invalid input is not necessarily constructable by regular means, due to a few reasons.
- Proving you own all utxos in a single tx may result in a tx that is too large - while this isn't a problem for the proof, any sane wallet will refuse to construct such a tx
- Using invalid inputs by definition requires you to sign an invalid tx - any sane wallet will also disallow this.
- In trivial cases, a proof via invalid inputs is unnecessary - if all your coins reside in p2pkh addresses or simple multisig addresses, a single signed message signed with all the keys involved (along with appropriate redeemscripts) is sufficient.
That said, if you really do want to use a proof of reserve with invalid inputs, you can construct a raw transaction consuming all the inputs, add an invalid inputs (a utxo that doesn't exist, or has already been spent), and then sign it with any bitcoin signing tool or library - any tool that supports offline signing should have little trouble signing it (although you may still get hit by validation issues if the resulting tx is too large).