bitcoindevkit / bdk-reserves

Proof-of-reserves for bitcoin-dev-kit
Other
14 stars 9 forks source link

Possible path for removing `bitcoinconsesnus` dependency?? #7

Open rajarshimaitra opened 2 years ago

rajarshimaitra commented 2 years ago

The bitcoinconsensus crate is used to do the proof verification here https://github.com/weareseba/bdk-reserves/blob/61b5f517f4c227bdf62507d1fcc2fd79bb87db8d/src/reserves.rs#L273-L279

BDK exposes a very similar functionality in the wallet api itself with the verify feature flag and uses the same bitcoinconsensus underneath like this..

https://github.com/bitcoindevkit/bdk/blob/2283444f727b85663b19d100af86db4392ebc891/src/wallet/verify.rs#L58-L68

This api is publicly exposed via verify feature of BDK.. So may be one more opportunity to reduce external dependency on bitcoinconsensus??

But might need some restructuring of the proof verification logic in this crate..

ulrichard commented 2 years ago

I think I looked into this a while ago. Back then it didn't quite match. But maybe something has changed in the meantime, and it is worth another detailed look. If it works out, it would certainly be cool.

rajarshimaitra commented 2 years ago

I would guess nothing changed much since your last look.. This part of lib hasn't been touched much.. The API asks for a full Transaction and the database (can be taken from the wallet) and performs the same consensus verification call as in the bare code in this crate..

So it depends on weather stuffs being verified here can be a full transaction itself in the wallet db.. In that case it should be theoretically possible to use this API instead of the bare call.. All this api does, before the bare bitcoinconsensus::verify is to get the prev outputs and script pubkeys from the given transaction..

ulrichard commented 9 months ago

I just had a quick look at this again. Since the first input is the special hashed message, I would need a way to skip the first input. Adding functionality to skip some inputs might undermine the validity for normal transactions.