bn_lcm incorrect result with negative zero input
guidovranken opened this issue · comments
Guido Vranken commented
The following should print 0
but it prints 123
.
#include <relic_conf.h>
#include <relic.h>
static void print(const bn_t bn) {
const size_t size = bn_size_str(bn, 10);
char* s = malloc(size);
bn_write_str(s, size, bn, 10);
printf("%s\n", s);
free(s);
}
int main(void)
{
if ( core_init() != RLC_OK ) abort();
bn_t A, B, R;
bn_null(A); bn_new(A);
bn_null(B); bn_new(B);
bn_null(R); bn_new(R);
const char* s1 = "123";
const char* s2 = "-0";
bn_read_str(A, s1, strlen(s1), 10);
bn_read_str(B, s2, strlen(s2), 10);
bn_lcm(R, A, B);
print(R);
bn_free(A);
bn_free(B);
bn_free(R);
return 0;
}