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

Check that each UTXO references a type script only once #164

Open
Sword-Smith opened this issue Jul 10, 2024 · 2 comments
Open

Check that each UTXO references a type script only once #164

Sword-Smith opened this issue Jul 10, 2024 · 2 comments

Comments

@Sword-Smith
Copy link
Member

I don't think this check is in place, and I think it would be a good idea to add it. However, if ordering is well-defined, then maybe we can just consider the 1st Coin if multiple coins reference the same typescript?

@aszepieniec
Copy link
Contributor

I can't think of anything that could go wrong in terms of consensus when a UTXO is allowed to have more than one coin of the same type script. However, I do see pitfalls regarding serialization and equality testing of UTXOs. You could have the "same" UTXO that serializes to something different and therefore yields a different hash. I can imagine this being used in an attack to exact payment for a UTXO which the receiver then cannot spend.

To fix it, I propose the following solution. Except for (potentially) genesis UTXOs, all coins in the UTXO's coins dictionary are sorted by type script hash. The CollectTypeScripts script checks that for all output UTXOs, no consecutive pair of coins have the same type script hash.

@Sword-Smith
Copy link
Member Author

Sword-Smith commented Jul 11, 2024

I added an lt for Digest in tasm-lib, so now we can use that to enforce that coins are sorted by type_script_hash, and that there are no repeated type_script_hash values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants