kokke / kokke/tiny-bignum-c

bignum_to_string

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
474
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Have been working with your neat library today but struggling with simplest of things. Want to work with larger 64 byte hex ecdsa but not even having luck with simple conversions to/from small strings and back. I see a note in one test script to force even number strings

file ec.c excerpt
struct bn bn1,bn2,gX;
bignum_init(&bn1);
bignum_init(&bn2);
bignum_init(&gX);

char s1[8];
bignum_from_string(&bn1,"01",2);
bignum_from_int(&bn2, 2);
bignum_to_string(&bn1,s1,8);
printf("tostr %s",s1);

I have set my WORD size in bn.h to 1,2,and 4 hoping to figure it out
building as gcc ec.c bn.c -g -o ec

on small size strings as above I'm not getting any output. On larger strings such as below the conversion back
to string is much shorter and all wrong
bignum_from_string(&gX, "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798",64);

Any help much appreciated. C is very problematic for me, so hoping am missing something easy

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the reported conversions using the ec.c excerpt, bn.h WORD sizes, and the gcc ec.c bn.c -g -o ec command. Inspect bignum_from_string and bignum_to_string in bn.c, then verify why the small value produces no output and the 64-character value is shortened; done means the cause and expected correction are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.