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

[psbt saga part 4/4]: Multisig demo #796

Merged
merged 5 commits into from
Mar 21, 2024
Merged

[psbt saga part 4/4]: Multisig demo #796

merged 5 commits into from
Mar 21, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Feb 9, 2024

Depends on #787.

This PR adds an integration test that demonstrates how multi signatures can be used on both the BTC and asset level.
In the demo we use the following Tapscript to encumber the BTC level anchor output:

<key_1> OP_CHECKSIG <key_2> OP_CHECKSIGADD 2 OP_EQUAL

This is basically a 2-of-2 multi signature. To make sure the key spend path cannot be taken, we use the NUMS public key as the internal key.

On the asset level, we use a script key that is the MuSig2 combined key of two script keys.

This means that the 1000 units of assets sent to the constructed TAP address will be co-owned by both tapd instances, on the asset and BTC level.

We then spend from that address again, just to demonstrate how the witnesses for such transfers would be created.


This change is Reviewable

@guggero guggero changed the base branch from main to commit-virtual-psbts February 14, 2024 08:38
@guggero guggero force-pushed the commit-virtual-psbts branch 2 times, most recently from 1d9c31a to 132290e Compare February 19, 2024 15:26
@guggero guggero force-pushed the commit-virtual-psbts branch from 132290e to 783fa63 Compare February 19, 2024 15:49
@guggero guggero force-pushed the multisig-demo branch 2 times, most recently from fd7e5d4 to 0867183 Compare February 19, 2024 16:03
@guggero guggero force-pushed the commit-virtual-psbts branch from 783fa63 to 4795a21 Compare February 19, 2024 16:03
@guggero guggero force-pushed the commit-virtual-psbts branch from 4795a21 to 5cc1a74 Compare February 19, 2024 17:26
@guggero guggero force-pushed the commit-virtual-psbts branch 2 times, most recently from 0125496 to d89a35e Compare February 20, 2024 15:42
@dstadulis dstadulis added this to the v0.4 milestone Feb 20, 2024
@guggero guggero force-pushed the commit-virtual-psbts branch 2 times, most recently from b1da2c3 to e4db665 Compare February 21, 2024 17:21
@guggero guggero force-pushed the multisig-demo branch 2 times, most recently from ba82a98 to ba4fdbd Compare February 21, 2024 17:38
@guggero guggero force-pushed the commit-virtual-psbts branch from e4db665 to 9c48df2 Compare February 21, 2024 17:38
@guggero guggero force-pushed the commit-virtual-psbts branch from 9c48df2 to 3e986cf Compare February 22, 2024 09:15
@guggero guggero force-pushed the commit-virtual-psbts branch from 3e986cf to 0170a6c Compare February 22, 2024 13:09
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

:lgtm: 🌙

Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 10 of 10 files at r4, 11 of 11 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @GeorgeTsagk and @guggero)


tapdb/sqlc/queries/assets.sql line 296 at r4 (raw file):

WHERE spent = FALSE
GROUP BY assets.genesis_id, genesis_info_view.asset_id,
         version, genesis_info_view.asset_tag, genesis_info_view.meta_hash,

Hmm, trying to remember why we also wanted to group by version in the first place 🤔

@guggero guggero force-pushed the commit-virtual-psbts branch from 0e136b7 to d1c663c Compare March 5, 2024 08:56
@guggero guggero force-pushed the commit-virtual-psbts branch from d1c663c to 21253a7 Compare March 5, 2024 11:46
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Looks good! 👌

@guggero guggero force-pushed the commit-virtual-psbts branch from 21253a7 to f51c888 Compare March 5, 2024 17:03
guggero added 5 commits March 11, 2024 08:29
Because of the versions field being in the GROUP BY clause of the query,
we would get two distinct rows returned for the same asset ID if we had
asset UTXOs with different versions.
But because we use the asset ID as the map key of the data structure we
return, only one of those two entries would be returned, causing the
total amount to be incorrect.

But since the genesis doesn't really have a version in the database
anyway and we're just interested by the sum of asset balances by asset
ID, we remove the version field from the genesis entry which causes the
problem in the first place.
@lukegao209
Copy link
Contributor

Hi @guggero I saw the video about Multisig.
I have one question : Alice (tapd) + Bob(tapd) + Third party(tapd) Multisig.

for David(no tapd with) :

  1. is it possible for alice to send an asset to Bob,and the target is multisig by (Bob,David,Third Party)?
  2. can David and Bob transfer the asset by their Multisig?

@guggero
Copy link
Member Author

guggero commented Mar 13, 2024

  1. is it possible for alice to send an asset to Bob,and the target is multisig by (Bob,David,Third Party)?

Yes, definitely. Both on the BTC level (internal_key and tapscript_sibling of the NewAddrRequest message) as well as on the asset level (custom script_key). Of course Alice would need to know all the public keys involved, so she can construct the outputs. Alice would then send the proof to Bob as usual and Bob can import it to show the asset in ListAssets. I think the only caveat is that the script_key_is_local field in the ListAssets response would be false, because the tadp wallet wouldn't be able to spend the asset without externally produced signatures.

  1. can David and Bob transfer the asset by their Multisig?

Yes, if they use the correct RPCs to create the correct signatures.

@lukegao209
Copy link
Contributor

  1. is it possible for alice to send an asset to Bob,and the target is multisig by (Bob,David,Third Party)?

Yes, definitely. Both on the BTC level (internal_key and tapscript_sibling of the NewAddrRequest message) as well as on the asset level (custom script_key). Of course Alice would need to know all the public keys involved, so she can construct the outputs. Alice would then send the proof to Bob as usual and Bob can import it to show the asset in ListAssets. I think the only caveat is that the script_key_is_local field in the ListAssets response would be false, because the tadp wallet wouldn't be able to spend the asset without externally produced signatures.

  1. can David and Bob transfer the asset by their Multisig?

Yes, if they use the correct RPCs to create the correct signatures.

Its a great feature. its possible for btccoin address to receive taproot assets without tapd.

Base automatically changed from commit-virtual-psbts to main March 21, 2024 06:46
@guggero guggero added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit 5cac1e4 Mar 21, 2024
28 checks passed
@guggero guggero deleted the multisig-demo branch March 21, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants