Merge feature/shamir-secret-sharing-o2a into main - #16
Conversation
Add a security policy document outlining supported versions and vulnerability reporting.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def parse_transaction(tx_hex): | ||
| """Parse Bitcoin transaction and extract all signatures""" | ||
| data = bytes.fromhex(tx_hex) | ||
| offset = 0 | ||
|
|
||
| # Version | ||
| version = int.from_bytes(data[offset:offset+4], 'little') | ||
| offset += 4 | ||
|
|
||
| # Number of inputs | ||
| num_inputs, offset = parse_varint(data, offset) |
There was a problem hiding this comment.
Handle SegWit marker when parsing inputs
The transaction parser assumes the byte immediately after the version is the varint-encoded input count. In SegWit transactions the version is followed by the 0x00/0x01 marker and flag before the input count, so this code interprets the marker as the input count and the whole structure becomes misaligned. For any modern SegWit transaction, parse_transaction will either return zero signatures or raise when offsets run past the buffer, so the nonce analysis silently fails. Detect the SegWit marker/flag and skip them before calling parse_varint.
Useful? React with 👍 / 👎.
…shamir-secret-sharing-o2a
…shamir-secret-sharing-o2a
commit 860fc30 Author: bakaxbaka <profesyonelceset@gmail.com> Date: Tue Nov 4 15:40:00 2025 +0300 Add Contributor Covenant Code of Conduct This document outlines the standards of behavior expected from community members and the enforcement procedures for violations.
commit b60f59e Author: bakaxbaka <bakaxbaka@users.noreply.github.com> Date: Thu Nov 20 20:27:07 2025 +0300 Squashed commit of the following: commit 9fed685 Author: bakaxbaka <profesyonelceset@gmail.com> Date: Tue Nov 4 15:36:55 2025 +0300 Create SECURITY.md for security policy Add a security policy document outlining supported versions and vulnerability reporting. commit 2a8c25e Merge: 521ee19 9827d2e Author: bakaxbaka <bakaxbaka@users.noreply.github.com> Date: Thu Nov 20 20:26:28 2025 +0300 Merge branch 'codex/replace-sighash-logic-in-main.py' into feature/manus-ai-agent-integration-n1a commit 9827d2e Merge: aae28db d3ccab5 Author: bakaxbaka <bakaxbaka@users.noreply.github.com> Date: Thu Nov 20 20:24:34 2025 +0300 Merge branch 'main' into codex/replace-sighash-logic-in-main.py commit 521ee19 Author: BLACKBOX Agent <agent@example.com> Date: Tue Nov 4 21:31:37 2025 +0000 fix the code # Claude Integration Guide **FOR CL... commit 1572f3b Author: BLACKBOX Agent <agent@example.com> Date: Tue Nov 4 21:19:44 2025 +0000 chore: add core dependencies for async web framework commit aae28db Author: bakaxbaka <profesyonelceset@gmail.com> Date: Tue Oct 28 07:59:47 2025 +0300 Implement accurate Bitcoin sighash calculation
commit 76c2517 Author: BLACKBOX Agent <agent@example.com> Date: Tue Nov 4 01:35:33 2025 +0000 020000005800bb13b1ecc77e537bd8d0bf70055bf29f133c7c...
- main.py: _fetch_test_transaction_data_helper was hitting Blockstream's
/block/{hash} endpoint (metadata only) and reading from a non-existent
'tx' field, so the helper always returned None and /test_manual_recovery
always errored. Add a separate /block/{hash}/txids fetch that matches the
iteration loop (which uses each entry as a txid string in /tx/{txid}).
- nonce_reuse_analysis.py, find_nonce_collision.py, bitcoin_nonce_attack.py,
bitcoin_nonce_advanced.py: parse_transaction (and the equivalent extract
functions) read the input-count varint immediately after the version,
silently misinterpreting the SegWit marker (0x00) as 'zero inputs' and
returning [] for any modern SegWit transaction. Detect the optional
marker (0x00) + flag (non-zero) bytes and skip them before reading the
input count.
- Remove ten zero/near-zero-byte files (=0.15.0, =0.17.0, ...) that were
accidentally committed when an earlier session ran 'pip install foo>=...'
unquoted and the shell redirected stderr into a file named '=...'.
.gitignore already excludes the pattern going forward.
Co-Authored-By: bakaxbaka <profesyonelceset@gmail.com>
Summary
Take-over of PR #16 to address the bugs flagged by Devin Review and Codex on this branch.
Devin Review (posted to GitHub)
main.py—_fetch_test_transaction_data_helperwas always returningNonebecause the Blockstream/block/{hash}endpoint only returns block metadata (notxfield). Added the missing/block/{hash}/txidsrequest that matches the existing iteration loop (each entry is then used as a txid string in/tx/{txid}). The same pattern is already used by_fetch_block_data(with/txs) elsewhere inmain.py. Without this fix,/test_manual_recoveryalways returned the "Could not fetch suitable test transaction data" error.main.py:2107—int(r_hex, 16)TypeError. Already fixed in the prior commitb2b0919on this branch (kept verified).Codex review
nonce_reuse_analysis.py(and the three sister scriptsfind_nonce_collision.py,bitcoin_nonce_attack.py,bitcoin_nonce_advanced.py) —parse_transaction/extract_signatures_from_raw_tx/extract_all_signaturesread the input-count varint immediately after the version. SegWit transactions place a 0x00 marker + 0x01 flag between the version and the input count, so the parser silently misinterpreted the marker as "zero inputs" (or, worse, fell off the end of the buffer on the next reads). Detect the optional marker/flag pair and skip it before parsing the input count. Verified against constructed legacy + SegWit fixtures locally.Cleanup
=0.15.0,=0.17.0, ...,=6.0). Those were the result of an earlier session runningpip install <pkg>>=...unquoted, which the shell parsed as a stderr redirection into a file literally named=.... The branch's existing.gitignorealready excludes the=*pattern, so these were stale artifacts.Not addressed (yet)
Review & Testing Checklist for Human
/test_manual_recoveryagainst the live Flask app and confirm it now reaches the inner loop instead of immediately returning the "could not fetch" error message. The endpoint still depends on a recent block actually containing a k-reuse signature pair, so a "no k-reuse found" response is normal — the regression was that the loop body was never executed at all.python nonce_reuse_analysis.py,python find_nonce_collision.py, etc.) against a SegWit transaction hex you care about and confirm signatures are reported (or at least that the parser no longer silently returns[]on legacy + SegWit inputs).=*files does not break any tooling — they were empty (or in one case a bit ofpipstderr) and were not referenced anywhere in the repo.Notes
b2b0919for setup-related reasons (no Python source detected, etc.); this commit doesn't change that and the failures are unrelated to the bugs above.int(r_hex, 16)TypeError fix fromb2b0919is left in place, since it correctly turns the resultingrlookup into an int-keyed dict.Link to Devin session: https://app.devin.ai/sessions/d7a8f4ccb9424d6e89a5891fe764ad1f
Requested by: @bakaxbaka