SP fixes#133
Closed
notTanveer wants to merge 2 commits into
Closed
Conversation
Four targeted fixes from the post-implementation code audit: - SPOutputScope.write_to: add `if version == 2` guard so sp_data / sp_label are never written into a PSBTv0 (or version=None) stream. Without it the round-trip raises PSBTError on parse. - _sign_with_sp: remove silent `except SPFieldError: continue`. We only reach share computation when we've already resolved the private key for that input; swallowing the error hides RNG or key-op failures and returns success with an incomplete PSBT. - create_outputs: replace signing_keys list + sum() with a running accumulator, eliminating the O(n) bigint allocation before the sum. - derive_silent_payment_outputs: drop the dead `shared_secret` parameter (no caller ever passed it; body always fell through to `= ecdh_share`).
NUMS_PUBKEY is already defined in ec.py. NUMS_H was a redundant copy of the same 32-byte value, with its own unhexlify import. Replace both with a module-level _NUMS_XONLY = ec.NUMS_PUBKEY.xonly() so the canonical definition lives in one place.
odudex
approved these changes
Jun 3, 2026
Collaborator
|
This PR is now covered by #134 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four targeted fixes from the post-implementation code audit:
SPOutputScope.write_to: add
if version == 2guard so sp_data /sp_label are never written into a PSBTv0 (or version=None) stream.
Without it the round-trip raises PSBTError on parse.
_sign_with_sp: remove silent
except SPFieldError: continue. We onlyreach share computation when we've already resolved the private key for
that input; swallowing the error hides RNG or key-op failures and
returns success with an incomplete PSBT.
create_outputs: replace signing_keys list + sum() with a running
accumulator, eliminating the O(n) bigint allocation before the sum.
derive_silent_payment_outputs: drop the dead
shared_secretparameter(no caller ever passed it; body always fell through to
= ecdh_share).use the already present NUMS_VALUE.