kokke / kokke/tiny-bignum-c

Doing multiplication into the result directly.

Open
#17 3 comments 0 reactions 0 assignees View on GitHub
good first issue help wanted
Dominant language
C
Stars
474
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Sorry for not submitting a pull request, I'm working on a bignum library and I saw your implementation of multiplication so I just want to point out that you can simplify it by doing the multiply and the add in one loop into the result bn as follow:

```cpp
typedef unsigned int u32;
typedef unsigned long long int u64;
void _bn_add_mul_u32(u32 *out, u32 *a, size_t a_len, u32 b)
{
u64 c = 0;
size_t i;
for(i=0; i> 32;
out[i] = o & 0xffffffff;
}
for(; c; i++)
{
u64 o = out[i] + c;
c = o >> 32;
out[i] = o & 0xffffffff;
}
}
void _bn_mul(u32 *out, u32 *a, size_t a_len, u32 *b, size_t b_len)
{
for(size_t i=0; i

Contributor guide

No contributing guide indexed for this repository

Research direction

No file or test is named. Locate the current multiplication implementation, then compare its behavior with the proposed _bn_add_mul_u32 and _bn_mul entry points. Done means the multiplication remains correct while the multiply-and-add work is combined as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.