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

Group key witness support #490

Merged
merged 22 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a663052
tapscript: unify mock signing with asset package
jharveyb Sep 14, 2023
a4cae87
asset+tapdb: make group tapscriptRoot optional
jharveyb Sep 28, 2023
1aa9b46
tapscript+asset: virtual TXs for genesis assets
jharveyb Sep 14, 2023
a309d63
tapscript+asset: introduce GenesisTxBuilder
jharveyb Sep 14, 2023
8a103a9
vm: remove early exit for genesis grouped assets
jharveyb Sep 14, 2023
9d1b761
asset: produce group witnesses over virtual TXs
jharveyb Sep 14, 2023
afc499b
commitment+tapdb: update DeriveGroupKey usage
jharveyb Sep 14, 2023
8bd0aab
tapgarden+tapcfg: add new interfaces to garden cfg
jharveyb Sep 14, 2023
32960c0
tapgarden+asset: verify and copy group witnesses
jharveyb Sep 14, 2023
254dffc
tapgarden+proof: add Group + GroupAnchor Verifier
jharveyb Sep 26, 2023
6d85804
proof+tapdb: utilize + propogate group verifiers
jharveyb Sep 26, 2023
670b380
tapfreighter+tapscript: propogate group verifiers
jharveyb Sep 26, 2023
228bdea
rpserver+tapcfg: propogate group verifiers
jharveyb Sep 26, 2023
492f26d
tapgarden+tapdb: store group anchors early
jharveyb Sep 26, 2023
659111e
universe+tapdb: store group anchors early
jharveyb Sep 26, 2023
46d2ed7
proof: update genesis asset definition
jharveyb Sep 14, 2023
4cdaa4e
commitment: remove group witness verification
jharveyb Sep 15, 2023
308e30e
address+rpcserver: drop group witness from address
jharveyb Sep 21, 2023
7bb3bda
address+tapscript+vm: Update test setup + helpers
jharveyb Sep 19, 2023
40100f8
itest: update test helpers
jharveyb Sep 21, 2023
401f91d
multi: update test vectors to include new reveals
jharveyb Sep 28, 2023
6686744
tapfreighter+tapdb: fix some loop memory aliasing
jharveyb Sep 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions address/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/commitment"
"github.com/lightninglabs/taproot-assets/fn"
"github.com/lightningnetwork/lnd/tlv"
)

Expand Down Expand Up @@ -98,12 +97,6 @@ type Tap struct {
// asset to be made possible.
GroupKey *btcec.PublicKey

// groupWitness is a stack of witness elements that authorizes the
// membership of an asset in a partiular asset group. The witness can
// be a single signature or a script from the tapscript tree committed
// to with the TapscriptRoot, and follows the witness rules in BIP-341.
groupWitness wire.TxWitness
jharveyb marked this conversation as resolved.
Show resolved Hide resolved

// ScriptKey represents a tweaked Taproot output key encumbering the
// different ways an asset can be spent.
ScriptKey btcec.PublicKey
Expand Down Expand Up @@ -184,7 +177,6 @@ func New(version Version, genesis asset.Genesis, groupKey *btcec.PublicKey,
AssetVersion: asset.V0,
AssetID: genesis.ID(),
GroupKey: groupKey,
groupWitness: groupWitness,
ScriptKey: scriptKey,
InternalKey: internalKey,
TapscriptSibling: tapscriptSibling,
Expand All @@ -203,9 +195,6 @@ func (a *Tap) Copy() *Tap {
groupPubKey := *a.GroupKey
addressCopy.GroupKey = &groupPubKey
}
if len(a.groupWitness) != 0 {
addressCopy.groupWitness = fn.CopySlice(a.groupWitness)
}

return &addressCopy
}
Expand All @@ -226,11 +215,6 @@ func (a *Tap) AttachGenesis(gen asset.Genesis) {
a.assetGen = gen
}

// AttachGroupWitness attaches the asset's group witness to the address.
func (a *Tap) AttachGroupWitness(wit wire.TxWitness) {
a.groupWitness = wit
}

// TapCommitmentKey is the key that maps to the root commitment for the asset
// group specified by a Taproot Asset address.
func (a *Tap) TapCommitmentKey() [32]byte {
Expand Down Expand Up @@ -259,13 +243,8 @@ func (a *Tap) TapCommitment() (*commitment.TapCommitment, error) {
// it in the TLV leaf.
var groupKey *asset.GroupKey
if a.GroupKey != nil {
if len(a.groupWitness) == 0 {
return nil, fmt.Errorf("missing group signature")
}

groupKey = &asset.GroupKey{
GroupPubKey: *a.GroupKey,
Witness: a.groupWitness,
}
}
newAsset, err := asset.New(
Expand Down
12 changes: 8 additions & 4 deletions address/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func randAddress(t *testing.T, net *ChainParams, v Version, groupPubKey,
)
}

pubKeyCopy1 := *pubKey
pubKeyCopy2 := *pubKey
scriptKey := *pubKey
internalKey := *pubKey

genesis := asset.RandGenesis(t, assetType)

Expand All @@ -64,15 +64,19 @@ func randAddress(t *testing.T, net *ChainParams, v Version, groupPubKey,
)

if groupPubKey {
groupInfo := asset.RandGroupKey(t, genesis)
protoAsset := asset.NewAssetNoErr(
t, genesis, amount, 0, 0,
asset.NewScriptKey(&scriptKey), nil,
)
groupInfo := asset.RandGroupKey(t, genesis, protoAsset)
groupKey = &groupInfo.GroupPubKey
groupWitness = groupInfo.Witness
}

proofCourierAddr := RandProofCourierAddr(t)

return New(
v, genesis, groupKey, groupWitness, pubKeyCopy1, pubKeyCopy2,
v, genesis, groupKey, groupWitness, scriptKey, internalKey,
amount, tapscriptSibling, net, proofCourierAddr,
)
}
Expand Down
20 changes: 11 additions & 9 deletions address/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ func RandAddr(t testing.TB, params *ChainParams,
*asset.Genesis, *asset.GroupKey) {

scriptKeyPriv := test.RandPrivKey(t)
scriptKey := asset.NewScriptKeyBip86(keychain.KeyDescriptor{
PubKey: scriptKeyPriv.PubKey(),
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(test.RandIntn(255) + 1),
Index: uint32(test.RandIntn(255)),
},
})

internalKey := test.RandPrivKey(t)

Expand All @@ -49,7 +56,10 @@ func RandAddr(t testing.TB, params *ChainParams,
tapscriptSibling *commitment.TapscriptPreimage
)
if test.RandInt[uint32]()%2 == 0 {
groupInfo = asset.RandGroupKey(t, genesis)
protoAsset := asset.NewAssetNoErr(
t, genesis, amount, 0, 0, scriptKey, nil,
)
groupInfo = asset.RandGroupKey(t, genesis, protoAsset)
groupPubKey = &groupInfo.GroupPubKey
groupWitness = groupInfo.Witness

Expand All @@ -58,14 +68,6 @@ func RandAddr(t testing.TB, params *ChainParams,
)
}

scriptKey := asset.NewScriptKeyBip86(keychain.KeyDescriptor{
PubKey: scriptKeyPriv.PubKey(),
KeyLocator: keychain.KeyLocator{
Family: keychain.KeyFamily(test.RandIntn(255) + 1),
Index: uint32(test.RandIntn(255)),
},
})

tapAddr, err := New(
V0, genesis, groupPubKey, groupWitness, *scriptKey.PubKey,
*internalKey.PubKey(), amount, tapscriptSibling, params,
Expand Down
4 changes: 2 additions & 2 deletions address/testdata/address_tlv_encoding_generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@
"chain_params_hrp": "taptb",
"asset_version": 0,
"asset_id": "7f3a94b3048ecbce4f2b1686e2df89bde52d5ead1aed011f75fa6578dcab0839",
"group_key": "03f32d239904d1addae728d1917a94bc1d20455b12b251a9222d035e5014a9f759",
"group_key": "02cd028e8899c3324c75a41f6f34b0038fa640b96b93e421c9860c52a7efa9d395",
"script_key": "02a0afeb165f0ec36880b68e0baabd9ad9c62fd1a69aa998bc30e9a346202e078f",
"internal_key": "02a0afeb165f0ec36880b68e0baabd9ad9c62fd1a69aa998bc30e9a346202e078f",
"tapscript_sibling": "",
"amount": 1,
"proof_courier_addr": "hashmail://rand.hashmail.proof.courier:443"
},
"expected": "taptb1qqqsqqspqqzzqle6jjesfrktee8jk95xut0cn00994026xhdqy0ht7n90rw2kzpeq5ss8uedywvsf5ddmtnj35v3022tc8fqg4d39vj34y3z6q672q22na6eqcss9g90avt97rkrdzqtdrst427e4kwx9lg6dx4fnz7rp6drgcszupu0pqss9g90avt97rkrdzqtdrst427e4kwx9lg6dx4fnz7rp6drgcszupu0pgqszrp2dpshx6rdv95kcw309aexzmny9e5xzumgd4skjmpwwpex7mmx9e3k7atjd9jhyw35xseskkqklz",
"expected": "taptb1qqqsqqspqqzzqle6jjesfrktee8jk95xut0cn00994026xhdqy0ht7n90rw2kzpeq5ss9ngz36yfnsejf366g8m0xjcq8raxgzukhylyy8ycvrzj5lh6n5u4qcss9g90avt97rkrdzqtdrst427e4kwx9lg6dx4fnz7rp6drgcszupu0pqss9g90avt97rkrdzqtdrst427e4kwx9lg6dx4fnz7rp6drgcszupu0pgqszrp2dpshx6rdv95kcw309aexzmny9e5xzumgd4skjmpwwpex7mmx9e3k7atjd9jhyw35xses833965",
"comment": "signet group collectible"
},
{
Expand Down
Loading