Skip to content

multi: merge staging branch into main #542

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

Merged
merged 40 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b45e558
commitment: avoid shadowing package name
guggero Aug 15, 2023
7d1e06f
asset: update AssetID ser/de-ser + optional TLV
jharveyb Aug 15, 2023
c0e901a
proof: add Genesis and GroupKey reveals + TLVs
jharveyb Aug 15, 2023
1bc71bc
asset: reject unsupported versions
jharveyb Aug 15, 2023
a875bf8
proof: reject unsupported versions
jharveyb Aug 15, 2023
bc587d1
tapdb: add group witness and tapscript root, rename table
jharveyb Aug 15, 2023
5a69b8f
tapdb+asset: handle group sigs as a witness stack
jharveyb Aug 15, 2023
525e4a9
taprpc: rename group sig to witness
jharveyb Aug 15, 2023
41c7040
multi: update test vectors to omit group witness
jharveyb Aug 15, 2023
8a3a8ab
proof: reject unsupported transition versions
guggero Aug 15, 2023
ec7337a
rpcserver: fix asset meta type marshaling
guggero Aug 18, 2023
6331027
tapgarden: fix typo
guggero Aug 18, 2023
606954b
proof: add genesis and group key reveal
guggero Aug 18, 2023
9d962e3
rpc: add Reveal fields for proof objects
jharveyb Aug 25, 2023
6c3827b
proof: verify genesis reveal for genesis assets
halseth Aug 11, 2023
0aae52c
asset/asset: add ToPubKey method for SerializedKey
halseth Aug 11, 2023
cbcfdd7
proof: verify group key reveal for genesis proofs
halseth Aug 11, 2023
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
8899ca4
Merge pull request #490 from lightninglabs/group-key-witness-support
Roasbeef Oct 3, 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
23 changes: 2 additions & 21 deletions address/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ type Tap struct {
// asset to be made possible.
GroupKey *btcec.PublicKey

// groupSig is the signature of the asset genesis with the group key
// that is used to verify asset membership in a group.
groupSig *schnorr.Signature

// ScriptKey represents a tweaked Taproot output key encumbering the
// different ways an asset can be spent.
ScriptKey btcec.PublicKey
Expand Down Expand Up @@ -130,7 +126,7 @@ type Tap struct {
// TODO(ffranr): This function takes many arguments. Add a struct to better
// organise its arguments.
func New(version Version, genesis asset.Genesis, groupKey *btcec.PublicKey,
groupSig *schnorr.Signature, scriptKey btcec.PublicKey,
groupWitness wire.TxWitness, scriptKey btcec.PublicKey,
internalKey btcec.PublicKey, amt uint64,
tapscriptSibling *commitment.TapscriptPreimage,
net *ChainParams, proofCourierAddr url.URL) (*Tap, error) {
Expand Down Expand Up @@ -171,7 +167,7 @@ func New(version Version, genesis asset.Genesis, groupKey *btcec.PublicKey,
}
}

if groupKey != nil && groupSig == nil {
if groupKey != nil && len(groupWitness) == 0 {
return nil, fmt.Errorf("address: missing group signature")
}

Expand All @@ -181,7 +177,6 @@ func New(version Version, genesis asset.Genesis, groupKey *btcec.PublicKey,
AssetVersion: asset.V0,
AssetID: genesis.ID(),
GroupKey: groupKey,
groupSig: groupSig,
ScriptKey: scriptKey,
InternalKey: internalKey,
TapscriptSibling: tapscriptSibling,
Expand All @@ -200,10 +195,6 @@ func (a *Tap) Copy() *Tap {
groupPubKey := *a.GroupKey
addressCopy.GroupKey = &groupPubKey
}
if a.groupSig != nil {
groupSig := *a.groupSig
addressCopy.groupSig = &groupSig
}

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

// AttachGroupSig attaches the asset's group signature to the address.
func (a *Tap) AttachGroupSig(sig schnorr.Signature) {
a.groupSig = &sig
}

// 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 @@ -257,13 +243,8 @@ func (a *Tap) TapCommitment() (*commitment.TapCommitment, error) {
// it in the TLV leaf.
var groupKey *asset.GroupKey
if a.GroupKey != nil {
if a.groupSig == nil {
return nil, fmt.Errorf("missing group signature")
}

groupKey = &asset.GroupKey{
GroupPubKey: *a.GroupKey,
Sig: *a.groupSig,
}
}
newAsset, err := asset.New(
Expand Down
19 changes: 12 additions & 7 deletions address/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/commitment"
"github.com/lightninglabs/taproot-assets/internal/test"
Expand Down Expand Up @@ -52,26 +53,30 @@ func randAddress(t *testing.T, net *ChainParams, v Version, groupPubKey,
)
}

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

genesis := asset.RandGenesis(t, assetType)

var (
groupKey *btcec.PublicKey
groupSig *schnorr.Signature
groupKey *btcec.PublicKey
groupWitness wire.TxWitness
)

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
groupSig = &groupInfo.Sig
groupWitness = groupInfo.Witness
}

proofCourierAddr := RandProofCourierAddr(t)

return New(
v, genesis, groupKey, groupSig, pubKeyCopy1, pubKeyCopy2,
v, genesis, groupKey, groupWitness, scriptKey, internalKey,
amount, tapscriptSibling, net, proofCourierAddr,
)
}
Expand Down
9 changes: 4 additions & 5 deletions address/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/taproot-assets/asset"
Expand Down Expand Up @@ -222,17 +221,17 @@ func (b *Book) NewAddressWithKeys(ctx context.Context, assetID asset.ID,
}

var (
groupKey *btcec.PublicKey
groupSig *schnorr.Signature
groupKey *btcec.PublicKey
groupWitness wire.TxWitness
)

if assetGroup.GroupKey != nil {
groupKey = &assetGroup.GroupPubKey
groupSig = &assetGroup.Sig
groupWitness = assetGroup.Witness
}

baseAddr, err := New(
V0, *assetGroup.Genesis, groupKey, groupSig,
V0, *assetGroup.Genesis, groupKey, groupWitness,
*scriptKey.PubKey, *internalKeyDesc.PubKey, amount,
tapscriptSibling, &b.cfg.Chain, proofCourierAddr,
)
Expand Down
28 changes: 15 additions & 13 deletions address/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/commitment"
"github.com/lightninglabs/taproot-assets/internal/test"
Expand All @@ -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 @@ -45,29 +52,24 @@ func RandAddr(t testing.TB, params *ChainParams,
var (
groupInfo *asset.GroupKey
groupPubKey *btcec.PublicKey
groupSig *schnorr.Signature
groupWitness wire.TxWitness
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
groupSig = &groupInfo.Sig
groupWitness = groupInfo.Witness

tapscriptSibling = commitment.NewPreimageFromLeaf(
txscript.NewBaseTapLeaf([]byte("not a valid script")),
)
}

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, groupSig, *scriptKey.PubKey,
V0, genesis, groupPubKey, groupWitness, *scriptKey.PubKey,
*internalKey.PubKey(), amount, tapscriptSibling, params,
proofCourierAddr,
)
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