[Cryptographic_Clang] Fix lost borrow in bignum_subtract when a limb is 0xFFFFFFFF
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 79/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- cryptography
Research direction
Read Security_Algorithms/Cryptographic_Clang/bignum.c, focusing on bignum_subtract and how it computes each limb’s difference and borrow. Reproduce the failure with operands whose limbs include 0xFFFFFFFF, then run the random identity and Python differential checks described in the issue. Done means both checks pass with no incorrect subtractions.
Written by the indexing model from the issue text.
Description
Summary
bignum_subtract computes the borrow from temp = carry + b2->data[i] in 32 bits. When the incoming borrow is 1 and the limb of b2 is 0xFFFFFFFF, temp wraps to 0, the limb difference is computed against 0 and the borrow is lost. RSA key generation uses subtraction (p - 1, q - 1), so wrong results can propagate into phi.
Location
Security_Algorithms/Cryptographic_Clang/bignum.c(bignum_subtract)
Evidence
Differential test against Python integers, 3,000 random operands biased towards 0xFFFFFFFF limbs: 379 subtractions wrong. Found while fixing #136 and #137.
Expected
(a + b) - b == a for all operands with a >= b.
Proposed fix
Accumulate the subtrahend limb plus borrow in 64 bits and derive the borrow from that comparison.
Acceptance criteria
- Random identity test
(a + b) - b == apasses for 20,000 operands - Differential test against Python reports no wrong subtraction
Found while fixing the bignum issues · Phase 3 · Build & correctness
Generated by Claude Code
- Dominant language
- C++
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ibra-kdbra/Math-Problems
-
area: math-chaos priority: P3 size: S type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ibra-kdbra/Math-Problems#397 ·
-
area: docs-site good first issue priority: P3 size: XS type: chore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ibra-kdbra/Math-Problems#379 ·
-
area: docs-site good first issue priority: P3 size: XS type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ibra-kdbra/Math-Problems#378 ·
-
area: docs-site good first issue priority: P2 size: XS type: chore
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ibra-kdbra/Math-Problems#367 ·
-
area: docs-site good first issue priority: P2 size: XS type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ibra-kdbra/Math-Problems#366 ·
All issues in ibra-kdbra/Math-Problems
Similar issues
-
c++ easy first-contributor first-contributors good first issue help wanted up-for-grabs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
fork-commit-merge/fork-commit-merge#8709 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
ClickHouse/clickhouse-odbc#680 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ionut-mihalache/aqua#31 · 1 comment ·