Skip to content

Merge feature/shamir-secret-sharing-o2a into main - #16

Open
bakaxbaka wants to merge 10 commits into
mainfrom
feature/shamir-secret-sharing-o2a
Open

Merge feature/shamir-secret-sharing-o2a into main#16
bakaxbaka wants to merge 10 commits into
mainfrom
feature/shamir-secret-sharing-o2a

Conversation

@bakaxbaka

@bakaxbaka bakaxbaka commented Nov 4, 2025

Copy link
Copy Markdown
Owner

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_helper was always returning None because the Blockstream /block/{hash} endpoint only returns block metadata (no tx field). Added the missing /block/{hash}/txids request 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 in main.py. Without this fix, /test_manual_recovery always returned the "Could not fetch suitable test transaction data" error.
  • main.py:2107int(r_hex, 16) TypeError. Already fixed in the prior commit b2b0919 on this branch (kept verified).

Codex review

  • nonce_reuse_analysis.py (and the three sister scripts find_nonce_collision.py, bitcoin_nonce_attack.py, bitcoin_nonce_advanced.py) — parse_transaction / extract_signatures_from_raw_tx / extract_all_signatures read 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

  • Removed ten accidentally-committed zero/near-zero-byte files at the repo root (=0.15.0, =0.17.0, ..., =6.0). Those were the result of an earlier session running pip install <pkg>>=... unquoted, which the shell parsed as a stderr redirection into a file literally named =.... The branch's existing .gitignore already excludes the =* pattern, so these were stale artifacts.

Not addressed (yet)

Review & Testing Checklist for Human

  • Hit /test_manual_recovery against 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.
  • Run any of the standalone analyzers (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).
  • Sanity-check that the deletion of the =* files does not break any tooling — they were empty (or in one case a bit of pip stderr) and were not referenced anywhere in the repo.

Notes

  • CodeQL checks (Analyze python/javascript-typescript/java-kotlin) were already failing on b2b0919 for setup-related reasons (no Python source detected, etc.); this commit doesn't change that and the failures are unrelated to the bugs above.
  • The int(r_hex, 16) TypeError fix from b2b0919 is left in place, since it correctly turns the resulting r lookup into an int-keyed dict.

Link to Devin session: https://app.devin.ai/sessions/d7a8f4ccb9424d6e89a5891fe764ad1f
Requested by: @bakaxbaka

BLACKBOX Agent and others added 3 commits November 4, 2025 01:34
Add a security policy document outlining supported versions and vulnerability reporting.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread nonce_reuse_analysis.py
Comment on lines +50 to +60
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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...
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

- 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>
@bakaxbaka
bakaxbaka enabled auto-merge (rebase) May 3, 2026 03:16
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

Successfully merging this pull request may close these issues.

1 participant