lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
457 stars 110 forks source link

[feature]: custom Group Key API for minting #722

Closed jharveyb closed 4 months ago

jharveyb commented 9 months ago

Related to #343 .

We have support for group keys that include tapscript trees, but no way for users to actually provide a tapscript tree root during the minting process. Specifically:

For the first point, we'll need to add a new field to the Seedling and MintAssetRequest structs for custom group keys. We likely also want to mark these seedlings as using a custom group key, so that we require an external witness when finalizing the batch.

For the second point, we'll need to extend the FinalizeBatch call to accept a list of witnesses for each seedling. Otherwise we shouldn't have many changes wrt. creating the minting proofs.

The last point is being tracked in #343.

jharveyb commented 7 months ago

Depends on #768.

There are a few points in the minting flow where this feature could be exposed:

Separately, there is the option to mandate that a tapscript tree is stored with tapd before minting begins (or least, with an RPC unrelated to minting). Then the tree could be referenced by root hash in minting-related calls.

More generally, right now we don't support an externally-managed key as the internal key for an asset group key. However, we also can't create a group key without an anchor asset. So we likely want to expand the AddSeedling call to be able to specify a custom internal key.

We'll also need more validation logic around group witnesses, to fail early for incorrect user-provided witnesses, but also to reject batch finalization if tapd can't produce a group witness directly (because a group internal key is externally managed).

dstadulis commented 6 months ago

During initial implementation investigation, @jharveyb uncovered, a few areas which necessary changes will need to be implemented. An corresponding issue to describe the necessary prerequisites before this issue is started is currently being written. Roughly the prerequisite are:

Roasbeef commented 6 months ago

We'll also need more validation logic around group witnesses, to fail early for incorrect user-provided witnesses, but also to reject batch finalization if tapd can't produce a group witness directly (because a group internal key is externally managed).

IIRC, we can only actually validate the group witness once we know the true asset/ID, which right now is when we go to finalize (do the coin selection, etc) and obtain the genesis prev out. As a result, I think we're forced to either just accept all the witnesses in finalize, or accept it in AddSeedling, then only validate later on once we've done the necessary in selection. With the latter option, we could start to lock that genesis prev out sooner in the process, but need to make sure the lease is properly renwed.

jharveyb commented 6 months ago

Moved discussion on this requirement to #820.

jharveyb commented 5 months ago

From discussion in #820, user flow would be:

dstadulis commented 5 months ago

Construct the correct signing descriptor and pass that, along with the relevant script leaves, trees, and group virtual TXs, to an external signer that satisfies the lnd SignOutputRaw RPC (or equivalent).

https://github.com/lightninglabs/taproot-assets/issues/722#issuecomment-2018545094

https://github.com/lightninglabs/taproot-assets/blob/649425831ce5310ff2cca50a7ca85e5245000f4e/asset/asset.go#L1108-L1217 stipulates the properties of the fields that a user, who is creating an external group key, will need to satisfy. Previously this would have been handled by lnd but now user would need to ensure conformance.

jharveyb commented 5 months ago

Implemented in #827 , being exposed in #866 .

883 is related.