Closed waigel closed 6 years ago
Yes, you are doing something wrong, almost all, actually. mp_set
accepts small integers only, not big integers, you need to read them in as strings with mp_read_radix()
. To compute 2^level
you need to use either mp_exp_d()
or, much better here, just a shift with mp_mul_2d()
. The function mp_sqr(a,b)
does b = a^2
which is not what you want to do. The function mp_toint()
is not able to do what you want, you need to use e.g. mp_toradix ()
.
LibTomMath has a lot of good documentation, please read it.
I constantly in awe and impressed that this long after I (sadly) gave up working on the projects people still are working on them and improving them. :-) Thanks to all who support free open source software.
(quick note, In case people are wondering I actually do open source at AMD on the graphics side. So I'm still fighting the good fight, just have a family to feed now :-)).
I would like to calculate the following in C ++ with libtommath:
x ^ (2 ^ level) % n
So I try it ...
It just doesn't calculate the big numbers correct ... or I'm doing something wrong ...