Skip to content

Commit

Permalink
proof: tappsbt: update BIP test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
jharveyb authored and guggero committed Dec 12, 2024
1 parent 9f1483f commit a7e34d5
Show file tree
Hide file tree
Showing 8 changed files with 1,383 additions and 589 deletions.
26 changes: 26 additions & 0 deletions proof/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,24 @@ func NewTestFromProof(t testing.TB, p *Proof) *TestProof {
)
}

if len(p.AltLeaves) > 0 {
// Assert that the concrete type of AltLeaf is supported.
require.IsTypef(
t, &asset.Asset{}, p.AltLeaves[0],
"AltLeaves must be of type *asset.Asset",
)

tp.AltLeaves = make([]*asset.TestAsset, 0, len(p.AltLeaves))
for idx := range p.AltLeaves {
// We also need a type assertion on each leaf.
leaf := asset.InnerAltLeaf(p.AltLeaves[idx])
tp.AltLeaves = append(
tp.AltLeaves,
asset.NewTestFromAsset(t, leaf),
)
}
}

return tp
}

Expand All @@ -639,6 +657,7 @@ type TestProof struct {
ChallengeWitness []string `json:"challenge_witness"`
GenesisReveal *asset.TestGenesisReveal `json:"genesis_reveal"`
GroupKeyReveal *asset.TestGroupKeyReveal `json:"group_key_reveal"`
AltLeaves []*asset.TestAsset `json:"alt_leaves"`
UnknownOddTypes tlv.TypeMap `json:"unknown_odd_types"`
}

Expand Down Expand Up @@ -697,6 +716,13 @@ func (tp *TestProof) ToProof(t testing.TB) *Proof {
p.GroupKeyReveal = tp.GroupKeyReveal.ToGroupKeyReveal(t)
}

if len(tp.AltLeaves) > 0 {
p.AltLeaves = make([]asset.AltLeafAsset, len(tp.AltLeaves))
for idx, leaf := range tp.AltLeaves {
p.AltLeaves[idx] = leaf.ToAsset(t)
}
}

return p
}

Expand Down
10 changes: 3 additions & 7 deletions proof/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,11 @@ func genRandomGenesisWithProof(t testing.TB, assetType asset.Type,
require.NoError(t, err)

// Include 1 or more alt leaves in the anchor output Tap commitment.
innerAltLeaves := asset.RandAltLeaves(t, true)

altCommitment, err := commitment.NewAssetCommitment(innerAltLeaves...)
require.NoError(t, err)

err = tapCommitment.Upsert(altCommitment)
innerAltLeaves := asset.RandAltLeaves(t, false)
altLeaves := asset.ToAltLeaves(innerAltLeaves)
err = tapCommitment.MergeAltLeaves(altLeaves)
require.NoError(t, err)

altLeaves := asset.ToAltLeaves(innerAltLeaves)
genesisAsset := assets[0]
_, commitmentProof, err := tapCommitment.Proof(
genesisAsset.TapCommitmentKey(),
Expand Down
2 changes: 1 addition & 1 deletion proof/testdata/ownership-proof.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5441505000040000000002244e562f2ee1dd0ffba93586a40f9644ed1c262b34f23072982b59c10659185b2000000001045000004020519e4f58ef90f20c03981167268969f5f912258c9e241ebb3f072d4acaf433641a5b5deb3eb9840b3455592f861134f754dc1d7a053c93fb1d10535586b535e914cf6966ffff7f200000000006fd018c020000000001024e562f2ee1dd0ffba93586a40f9644ed1c262b34f23072982b59c10659185b2001000000000000000000a1bf3e166c4ff2bc66a96d790faeabea483253f567d3443aca0f180543c6db00000000000000000003e80300000000000022512075131c90f4b84779e2de16cbcb7f330d1bd7ba27fc6027989f1ba565979d6e0ae803000000000000225120d368a69b3afee1d309c119524dc32720f00ed4eef8683236f8a8b8f57a51f557a9d0f505000000002251206cc80644acf5c9238d1beb9a693a621d042be142970c5b1d83b17294983ba631014012c896ab0645874d1f8c4686d7f3d2a5147ac80e0f38d059d465d71fac8bc0fc23f2963ac25c3e04cb1042034a3401c1163d86844b2f178ae679953433db68f40247304402205d59efe6a78355126c9c507fdd6fa608bed41760f922ae68be60ad201c11025a02200222aee2e48102a25a8581e91a6c6298a64f8efffbc6a319a0e263129f1305f90121037b23df1197e5e8a5745ad17f6f155b495c62009c1ada247533758895f31d19b50000000008220159c2fcdcefc8e854f71f1175f68687baa8f2aec6c7f916fec95c03fcf23e571d000afd02b40001000259003b7aca09198e864e3a81c8d8c8e688f3d1b052fe783850c7596d9b3c2adbc9000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd02580bfd022301fd021f0165000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fd01b44a00011f24c5895600bc6d8b0f0460f4ffc37d35d39530c8aca99449ecfaa5765fd18e0000000000000258ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffd01660001000259003b7aca09198e864e3a81c8d8c8e688f3d1b052fe783850c7596d9b3c2adbc9000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd02580bad01ab01654e562f2ee1dd0ffba93586a40f9644ed1c262b34f23072982b59c10659185b20000000013a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba02e8d229608c099e4bfea9e9861d3e2f4e4d43e9a4750b09458f26ff8953360c1903420140d64b676bfd4acbac4be655fe2e5aa00308b5b28f0eb249f42ccf738ed60f3d84067f048a0ba782d2bd35d1503af8959ae5ef8b822da04b25444e60f022674e190d283ffad0e49b5b7d302f18c8a97cdf265df22c0b648630a5642f8a04103cf36a7a00000000000004b00e0200001021024ad828457a32c78c4a3d4bb2fe0fe4d6f885bb2dc42919b6a7c7d811d82006680e020000102102599267c0f1f9c3c3824aced092d97fb56dc255a40580137d4924ca3376c29a1e0c9f0004000000010221037285f36ae2e1e52d9337ec496aaf9a56386251fcf8b40457d3e0735e484d17970374014900010002203a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0df802c7000400000000022102c25aac41f462f4cbfb5e0617df241967d3c74ca5d0bd6ce7fc79a21ed1412c14039c017100010002203a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba044a000188690bb0b1cffaa13b6b29bf686defe11ddc3e9798aff36eeb9509af3dc31fc30000000000000258ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e00040000000202210265f90d4a24fd1d2c66d2da48b1da96d3b21222c41b1bb08b08b2a1fa2d03a29005030401010f9f000400000000022102c25aac41f462f4cbfb5e0617df241967d3c74ca5d0bd6ce7fc79a21ed1412c140374014900010002203a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff15420140c23141fb15d0ce13e08e36951834d90bf86defbbd6e5145f503560cd21af42b2586419075f4700413336712ca87a3c376bb4bbf78646979921d84a6859d2e1f01604000001bc
5441505000040000000002244146fded5052d4d6666f2e3aad153de175f0300335eeef1d1796ddf8771b8e9b00000001045000004020f8b7cdd6f9d28ace33ce0a4065f92d7de9f4b73be10818d27f116530d316326ea8cbe7ba88ec8404872776918c153ee13d777c05c8b3da03cf4be76d8a56b12748725367ffff7f200000000006fd018c020000000001024146fded5052d4d6666f2e3aad153de175f0300335eeef1d1796ddf8771b8e9b0100000000000000007a6aed31fe675df9f3cbb30ec93c6aa64c0357ee95e041b68209dd0405126ea100000000000000000003e803000000000000225120b39d40166eab936be97ba489bd3e0b804fbd3c405b6b4dd853a7ecd645c7b8c9e803000000000000225120c439941c12ce99347f4a629a938835f2cdd7cc2646da97f18c52b4f17a18b0f4a9d0f505000000002251208ea64fa1adc917b9a9f7b6f4d671faa71a3ce538e4d22f2bc7696b2228448a2801400a89ab38452e2851d9b8a8faa24078d5517588fa2c857a2b4be65c0ac56631771139a245721a0b70e75e0c33a6eec16ee1d540c00489c8321569edc4e0d3e57f02473044022053b3677ee4a83b5b64d25f6c9f6d03a6678f2daeecad0966b7f1bfcb43f86b6a022041be57f3ca6ce364e28ae4991633ba9a4198f2a8ecd4489e4e1998cd447d8ff3012102dd95677d998373268ea2e0fd1a9bdd62e74eaee0db36ae080957c8f4732448c400000000082201568673ad5cad10893ce5f16f5943297a3a5d3d0e669ea3a337a32654c7533125000afd02b400010002590028ff502c98283a6008d6883a1e634a5a55c10b7927b6e60a3c90de95053e47000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd02580bfd022301fd021f0165000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fd01b44a000171eba4c1f1a64d5342c68cfcfce96a3332c936824f676cc047db8c79bf24f8ba0000000000000258ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffd016600010002590028ff502c98283a6008d6883a1e634a5a55c10b7927b6e60a3c90de95053e47000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd02580bad01ab01654146fded5052d4d6666f2e3aad153de175f0300335eeef1d1796ddf8771b8e9b00000001898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd002e2356b87d6435363aaa7a763eeeb3818000527783c0c4ed72999a4853ef2a23b0342014062f411bf03948cb3ca8a887a6449b1b99f93458e1c2f837ec20c7759461ad433bdeb43fc3abf29cde2cb2680e3f1c7a5ac60dc5833042ed31067f80c57b285370d2894c638977dfebc6426564611a74aedddb57c7664e9278213cfcce97de38733f000000000000004b00e02000010210273567b487064507c8bb16c912e8ec608bf09f2d461a89bfe63c37a7b3fdd21fa0e020000102102550807e261f1add28272dd1dc99979f7bb0e87982c296d52d7b58fba2c1a68e40c9f0004000000010221026f8944cb3cc0e077dedfbe312cbe6071861bec5cdc055ff6fe7fe26f5a5b8357037401490001000220898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd004220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0df802c70004000000000221028d87ba784f1639cb7d85f0d1f79e3a0f36a32b745aa84ef5e175aee24ab4631f039c01710001000220898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd0044a00014c598c9376185fd1dfb86659a5c3675bab19595cf1abf5a1cc7b7dc887d607cf0000000000000258fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020221027e12e36f36b1b39f15cf888cc4ec443dea1f07082fb35ea2f2d170c782687e7305030401010f9f0004000000000221028d87ba784f1639cb7d85f0d1f79e3a0f36a32b745aa84ef5e175aee24ab4631f037401490001000220898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd004220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff154201405a9d3325ceddab77bbb43583930ab428d76c89b11b3af6fe4e97daee4c4eb34422c1d8e9e67bfde1d3b1a8bfeb8ec7e458ffe0e4f8b9f2faf1ad946e43b6a9ec1604000001be
2 changes: 1 addition & 1 deletion proof/testdata/proof-file.hex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion proof/testdata/proof.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5441505000040000000002245d7abffab6c8450470a153e2193756d00f771d9a5af2d081e091d65ba44298bc000000000450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000006fd018c020000000001025d7abffab6c8450470a153e2193756d00f771d9a5af2d081e091d65ba44298bc00000000000000000002ea532b7f6f10d7ef5878d4bdae9c96a8c966fbefa0efc5dfd4034c59791f5b00000000000000000003e80300000000000022512080f7611a166819aab42e0b797b236863212bf398af3be7849294d4552d415005e803000000000000225120f0f9a8294653152502b69b2cc9ca54bf673a54ea03e4c9c778b5f984d7d8afdca9d0f505000000002251207e1c0ef01b3c3f9eb31c48f50d93de832127a2ef9c4e3088a9815da1d2e11e780140ebda6810d4ca9d220f567fe311fee267c4ed4fb1d7557e0267adb464a20eb4d01a41d9b20cb5a3f3e16065868f4139b9a682b9fcc52d64395166549e12308aa902473044022078d102f8005037362c1979c10e7c3e26b4190f4e2fda4eb596ef812be9798a00022059033397057c166563ef31eb2020eef0db9a371f8184c153e15411cfd7a1f817012102aa22f29c13156c03e4dfba265716673c69942b866b50641e3268c58067eba7ec000000000801000afd01660001000259003b7aca09198e864e3a81c8d8c8e688f3d1b052fe783850c7596d9b3c2adbc9000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd012c0bad01ab01655d7abffab6c8450470a153e2193756d00f771d9a5af2d081e091d65ba44298bc000000003a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba027aa5eed021fe1571a6f9930596bf1f4d6973730b47eb93356436ebe6463d63d303420140f40bdbc3d79e080ba95d04f8bdb785a28e8801705bb332dd5914ba683c401a9c25aa8851e4487e7f4b6d57e782542183b6622e1ee3d5953bbcb6d99e34ebb3e50d286f81441e4f801c3886d26f242f2c73ead3f5a3793b3d6fe25611e0fad4ff2d7000000000000005dc0e0200001021025bb648c78867c438cc7e8ce4793f74faf242fcbf668bf337fe04c637f60d50750cc70004000000000221037fff46adefe0450dce0205b812bac42323eaf7f441e2871cac90d8724564f1da039c014900010002203a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba04220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff024f000102024a000185064b96baa8c9686b6f5619f0beb4d5638201980f16eadf6e1144791fd219c700000000000007d0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f0df802c7000400000001022102559473084f585d68da4381097d03c017d4dbf20de346d5afc3922f30529f64bf039c017100010002203a4c9732ab1fbe44f625811d12fcf8a7a834312f8ab7bd7b0fa5643d8fc87aba044a0001d095e70612084951016728e9ebaddfd4e3765281640f57b313603e91672af73500000000000004b0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020221022fd7f0a1c0f430c25bd80f5b4a8b6046aa3c2a903568f766c8b0f503306fe0790503040101160400000000
5441505000040000000002244cd8f1e992034416b45c969e89316eaaa700daf02f15147e8816bc31d339e22b000000000450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e88000000000000000006fd018c020000000001024cd8f1e992034416b45c969e89316eaaa700daf02f15147e8816bc31d339e22b000000000000000000062736a1f2dbc0332040eafe375e4922ace3da94f88ada2ce397e7914014a32500000000000000000003e8030000000000002251203efafc563c1ffb16afc844abe35e48ea0303bf8b03753c640da1924f81b79408e8030000000000002251208eb3db333954f26aa1eacd5f057b60a32c59987e0226b58dc8debb033bdee3e6a9d0f50500000000225120f09fc5609b3c82f778d27fe3f8e9b88a10edcebc7c35864940049991bf4445650140b4622c62287ae87d96fffa7fd34f58708b0d1e6f4ae5a85fc6705781dd92711129d9cd0e3774fdb0fa048d3bbc559dd3d8d76b84d56928025ef24ba0b1940a7d02473044022006229b6e9c59a1c5d68ced672808f075382b3b5c5bf44eb1c9e993593d4807c102206667b3a902f71aab2ddbaafe2cef32f1bde17da6522444e87fe1fd50d5aa90f20121025d3b26142dcb90504cbfbbbf70d92fc7579198ffe9bf497a3bf2c55df8925126000000000801000afd016600010002590028ff502c98283a6008d6883a1e634a5a55c10b7927b6e60a3c90de95053e47000000000f66697273742d6974657374627578788d3b306cb9fc3bc5478adccf848583d8952d793747c31dddfd486d7d5d84efea00000000000401000603fd012c0bad01ab01654cd8f1e992034416b45c969e89316eaaa700daf02f15147e8816bc31d339e22b00000000898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd0025a5db7890fdd454db5d189d06880286b0d132c4709f1baee470a558276e3af5c03420140db1a68629f9408fd95e5dbd819380435bbad52c66746baabcc037ef6076cf215ecab264159bbbd922ae57a4890599f657dacc5a09d56785f08f7adad54e974d10d28c96ba1c3534f04149b2480923fc13d0e55e5251c01610317d48e1f0e7b9d219500000000000005dc0e020000102102adc1cf482226b3c4d0fac399e97302f4d7260f4ba782cd9cfbdb3c7ce94cd1e40cc7000400000000022103f8a796072d4b2f087f67973504600feafc628eaf76359d319470b186d8ccea0a039c01490001000220898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd004220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff024f000102024a0001464f6165e2b5fc1660dcecb3c02aabbae36fa0426457c5d976fd6d073328e49400000000000007d0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf0df802c7000400000001022103687c05eb0dade4141769314d1fe89ac712b1c6de66a228110189bd3b278f0fe9039c01710001000220898e84dbe0f54e8c551fa7f45e8299c57239a4cdd9d5641da75eaf83a577fdd0044a0001b44d27361609c463ec20dfa02d1fd2c489254ad82c6385ea29521553f1754b4600000000000004b0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf022700010202220000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e0004000000020221026019f70d187fdb882da16113e08014f667d05980997df3abd39bb322801b834b0503040101160400000000
Loading

0 comments on commit a7e34d5

Please sign in to comment.