relic-toolkit / relic

Code
Other
452 stars 179 forks source link

ERROR in bn_mod_basic(); #298

Closed 121TheShuDynasty closed 3 months ago

121TheShuDynasty commented 3 months ago
void hash(bn_t q, const uint8_t *input, bn_t output){

    uint8_t output_hash[RLC_MD_LEN_SH256];
    size_t input_size = sizeof(input) / sizeof(uint8_t);
    md_map_sh256(output_hash, input, input_size);

    bn_new(output);
    bn_read_bin(output, output_hash, RLC_MD_LEN_SH256);

    bn_mod_basic(output, output, q);
}

The error occurred at bn_mod_basic(output, output, q); and the error message is as follows:

ERROR in bn_grow() at /home/yang/relic-main/src/bn/relic_bn_mem.c,133: insufficient precision.
    CAUGHT in bn_sub_imp() at /home/yang/relic-main/src/bn/relic_bn_add.c,111.
dfaranha commented 3 months ago

Have you initialized q?

121TheShuDynasty commented 3 months ago

Thank you, the problem has been resolved.