Skip to content

Conversation

@odudex
Copy link
Collaborator

@odudex odudex commented Jan 29, 2025

While developing tests for Embit's taproot miniscript capabilities in Krux, I noticed that final signed tap tree PSBTs could vary in content randomly, particularly when the same key was present in more than one leaf script. Investigating this with @jdlcdl, we found that the order of taproot_script_path_sigs could change unpredictably when running Embit on standard python.

Although these PSBTs would load and parse normally—both in coordinators and via bitcoin-cli—we wanted reproducible signed PSBTs for consistent tests and standardization across platforms.

Further investigation revealed that two variables within the sign_with function in psbt.py—bip32_derivations and derived_keypairs—were of type set, which does not preserve order. This led to random ordering in the final PSBT data whenever these set variables were read and written.

By replacing these set variables with OrderedDict, we ensured a stable ordering. This change should resolve the variability and achieves reproducible signed PSBTs across both MicroPython devices and standard PCs.

@odudex odudex changed the title Reproducible Signatures Reproducible Signed PSBTs Jan 30, 2025
@odudex
Copy link
Collaborator Author

odudex commented Mar 26, 2025

The commits from this pull request have now been merged into Embit's develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant