SiaFoundation / core

Core packages for the Sia project
MIT License
51 stars 8 forks source link

types: Fix PolicyTypeUnlockConditions validation #176

Closed lukechampine closed 2 months ago

lukechampine commented 3 months ago

The old implementation was broken, as evidenced by the test cases I added. Specifically, we were implementing this policy in terms of PolicyThreshold, but PolicyThreshold requires you to mask any unused public keys with PolicyOpaque, which PolicyTypeUnlockConditions can't do. We also now handle algorithms other than SpecifierEd25519 correctly. Overall, this brings validation into agreement with consensus.validateSignatures. We can't match its behavior exactly (because v1 transactions contain a list signatures that target specific inputs, while v2 transaction inputs carry their signatures with them), but that's fine; we just need to ensure that any UnlockConditions that were satisfiable in v1 are also satisfiable in v2.