Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing proof of reserves #356

Closed

Conversation

ulrichard
Copy link
Contributor

@ulrichard ulrichard commented May 28, 2021

Description

Adding a module that allows the construction of "proof of reserves" PSBTs and the verification thereof.

Notes to the reviewers

There will be an accompanying PR in bdk-cli. I will paste the URL here, once it's created.
https://github.com/ulrichard/bdk-cli/tree/reserves
But it builds upon this one:
bitcoindevkit/bdk-cli#28

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

@notmandatory
Copy link
Member

notmandatory commented May 30, 2021

@nicolasburtey heard you on SLP and that you are looking into proof of reserve for your project. I would be interested to have your feedback on if you think this PR is in the right direction.

Cargo.toml Outdated
@@ -67,6 +71,7 @@ env_logger = "0.7"
base64 = "^0.11"
clap = "2.33"
serial_test = "0.4"
rstest = "^0.7"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of adding extra dependencies, even if they are only used during tests since they increase compilation times. Is there a different way to achieve the same result without adding this extra dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it would be possible with some macro magic. But I don't know rust macros good enough yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can leave this open for the meantime and once everything else is done I'll help you out with the macro

@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch 2 times, most recently from 62227ac to 53316ea Compare June 1, 2021 14:42
network: Network,
) -> Result<u64, Error> {
let tx = psbt.clone().extract_tx();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it would make sense to copy the outpoints into a sorted container for faster lookups here.

@nicolasburtey
Copy link

@notmandatory super cool I'll have a look. thanks.

@notmandatory
Copy link
Member

@ulrichard I have a meta question also about this PR. It seems that you don't need to access any wallet internals to create or validate a proof of reserve. So how would you feel about making this it's own repo here in the bitcoindevkit project? I think this would make it easier to iterate on the PoR concepts and release on your own schedule. And you can still have pub extern crate bdk so anyone using your crate will have full access to bdk wallet features.

@ulrichard
Copy link
Contributor Author

@ulrichard I have a meta question also about this PR. It seems that you don't need to access any wallet internals to create or validate a proof of reserve. So how would you feel about making this it's own repo here in the bitcoindevkit project? I think this would make it easier to iterate on the PoR concepts and release on your own schedule. And you can still have pub extern crate bdk so anyone using your crate will have full access to bdk wallet features.

I'm still fairly new to rust, and thus still learning how to structure projects. If you think that's better, it's fine with me.

  1. Do you have naming conventions for stuff like that? How about "bdk-reserves"?
  2. Can I just create the project, and you add it to the bitcoindevkit project, or is it better if you create it first?

@notmandatory
Copy link
Member

I'm still fairly new to rust, and thus still learning how to structure projects. If you think that's better, it's fine with me.

Thanks, we're still figuring it out too, but I think in this case since proof of reserve is still an experimental topic it makes sense for it to live in it's own repo.

1. Do you have naming conventions for stuff like that? How about "bdk-reserves"?

We don't have an official convention, the most important thing is that the name isn't taken in https://crates.io yet. The name bdk-reserves is a available.

2. Can I just create the project, and you add it to the `bitcoindevkit` project, or is it better if you create it first?

It's probably easier if you create the repo in your account and then when you have it ready to re-review you can transfer it to the bitcoindevkit project. I don't think your code will need to change much, you should still be able to implementing the ProofOfReserves trait on Wallet. And I think this could be a good dev model for how other experimental features (mixing, DLCs, stuff like that), could be built on bdk.

@rajarshimaitra
Copy link
Contributor

Hello @ulrichard , I haven't looked into the PR in detail yet, but judging from the overall objective is it something similar to BIP322? That BIP is a generic message signing protocol using specially formed Bitcoin transactions. And one of the major applications of such generic signing is "Proof of Reserve", as outlined here.

My understanding is BIP322 can be used for many things including proof of reserve, so maybe you might wanna try to include that standard in your implementation?

Unfortunately, there is no working implementation of BIP322 and rust-miniscript had a feature request open for it for some time now. As far as my understanding, nobody in Blockstream has time to write it, but they would appreciate PRs.

I have worked on a very rough sketch of it a few months ago trying to layout how basic BIP322 rust structures might look like. rust-bitcoin/rust-miniscript#240

It's not complete but it does basic BIP322 functions of signing and verifying. That might be something of your interest?

I am also happy to put in hands with you finishing BIP322 (it has been stale for some time now) and BDK can simply use that (it already has rust-miniscript dependency), if that aligns with your need.

Overall I feel this magic should reside in some upstream rust library like rust-miniscript or rust-bitcoin instead of wallet tools. Wallet tools like BDK can then simply expose simple APIs to use it.

@ulrichard
Copy link
Contributor Author

Hello @ulrichard , I haven't looked into the PR in detail yet, but judging from the overall objective is it something similar to BIP322? That BIP is a generic message signing protocol using specially formed Bitcoin transactions. And one of the major applications of such generic signing is "Proof of Reserve", as outlined here.

My understanding is BIP322 can be used for many things including proof of reserve, so maybe you might wanna try to include that standard in your implementation?

Unfortunately, there is no working implementation of BIP322 and rust-miniscript had a feature request open for it for some time now. As far as my understanding, nobody in Blockstream has time to write it, but they would appreciate PRs.

I have worked on a very rough sketch of it a few months ago trying to layout how basic BIP322 rust structures might look like. rust-bitcoin/rust-miniscript#240

It's not complete but it does basic BIP322 functions of signing and verifying. That might be something of your interest?

I am also happy to put in hands with you finishing BIP322 (it has been stale for some time now) and BDK can simply use that (it already has rust-miniscript dependency), if that aligns with your need.

Overall I feel this magic should reside in some upstream rust library like rust-miniscript or rust-bitcoin instead of wallet tools. Wallet tools like BDK can then simply expose simple APIs to use it.

Hi @rajarshimaitra, Yes BIP322 along with BIP127 were the main inspirations. Of which I followed BIP127 more closely.
I didn't realize BIP322 could be implemented in miniscript. I'll have a look at your PR.

@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch 4 times, most recently from dca18fd to 061cfbd Compare June 11, 2021 10:02
@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch from b5519c0 to 3e5bf16 Compare June 21, 2021 06:36
@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch 2 times, most recently from 4680c7d to def6089 Compare June 29, 2021 08:08
@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch from def6089 to 4120a0a Compare June 29, 2021 12:55
@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch from 4120a0a to ea9746b Compare July 8, 2021 06:39
@ulrichard ulrichard force-pushed the feature/proof_of_reserves branch from 7c50ff4 to 0379cdf Compare July 23, 2021 09:10
@notmandatory
Copy link
Member

Closing the PR and will work with @ulrichard on his https://github.com/ulrichard/bdk-reserves repo instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants