Skip to content

Commit

Permalink
proof: test genesis, group key reveal verification
Browse files Browse the repository at this point in the history
  • Loading branch information
jharveyb committed Dec 14, 2023
1 parent 7e0e376 commit 47baba3
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions proof/mint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ func TestNewMintingBlobs(t *testing.T) {
assetGenesis := asset.RandGenesis(t, asset.Collectible)
assetGenesis.MetaHash = metaReveal.MetaHash()
assetGenesis.OutputIndex = 0
protoAsset := asset.NewAssetNoErr(
t, assetGenesis, 1, 0, 0,
asset.NewScriptKeyBip86(genesisScriptKey), nil,
)

assetGroupKey := asset.RandGroupKey(t, assetGenesis, protoAsset)
tapCommitment, _, err := commitment.Mint(
assetGenesis, assetGroupKey, &commitment.AssetDetails{
assetGenesis, nil, &commitment.AssetDetails{
Type: asset.Collectible,
ScriptKey: genesisScriptKey,
Amount: nil,
Expand All @@ -53,6 +47,23 @@ func TestNewMintingBlobs(t *testing.T) {
)
require.NoError(t, err)

// Add a group anchor with a custom tapscript root to the set of minted
// assets. We cannot make this type of asset with commitment.Mint, so
// we create it manually and then insert it into the tap commitment.
groupedGenesis := asset.RandGenesis(t, asset.Normal)
groupedGenesis.FirstPrevOut = assetGenesis.FirstPrevOut
groupedGenesis.MetaHash = metaReveal.MetaHash()
groupedGenesis.OutputIndex = 0
// Issue here with one branch of useHashLock
groupedAsset := asset.AssetCustomGroupKey(
t, test.RandBool(), false, false, true, groupedGenesis,
)

groupedAssetTree, err := commitment.NewAssetCommitment(groupedAsset)
require.NoError(t, err)
err = tapCommitment.Upsert(groupedAssetTree)
require.NoError(t, err)

internalKey := test.SchnorrPubKey(t, genesisPrivKey)
tapscriptRoot := tapCommitment.TapscriptRoot(nil)
taprootKey := txscript.ComputeTaprootOutputKey(
Expand Down Expand Up @@ -89,11 +100,10 @@ func TestNewMintingBlobs(t *testing.T) {
0, chaincfg.MainNetParams.GenesisHash, merkleRoot, 0, 0,
)

newAsset := tapCommitment.CommittedAssets()[0]
assetScriptKey := newAsset.ScriptKey

assetScriptKey := asset.NewScriptKeyBip86(genesisScriptKey)
metaReveals := map[asset.SerializedKey]*MetaReveal{
asset.ToSerialized(assetScriptKey.PubKey): metaReveal,
asset.ToSerialized(assetScriptKey.PubKey): metaReveal,
asset.ToSerialized(groupedAsset.ScriptKey.PubKey): metaReveal,
}

// The NewMintingBlobs will return an error if the generated proof is
Expand Down

0 comments on commit 47baba3

Please sign in to comment.