From b89695c0db6fd18f42ab68303f5b98da7abf84c9 Mon Sep 17 00:00:00 2001 From: "Diego F. Aranha" Date: Fri, 26 Apr 2024 15:04:59 +0200 Subject: [PATCH] Update relic_bn_mul_low.c --- src/low/x64-asm-6l/relic_bn_mul_low.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/low/x64-asm-6l/relic_bn_mul_low.c b/src/low/x64-asm-6l/relic_bn_mul_low.c index 2229b6d2e..5699d06a1 100644 --- a/src/low/x64-asm-6l/relic_bn_mul_low.c +++ b/src/low/x64-asm-6l/relic_bn_mul_low.c @@ -52,6 +52,20 @@ void bn_muln_low(dig_t *c, const dig_t *a, const dig_t *b, int size) { mpn_mul_n(c, a, b, size); } +dig_t bn_muls_low(dig_t *c, const dig_t *a, dig_t sa, dis_t digit, int size) { + dig_t carry, sign, sd = digit >> (RLC_DIG - 1); + + sa = -sa; + sign = sa ^ sd; + digit = (digit ^ sd) - sd; + + carry = mpn_mul_1(c, a, size, digit); + for (size_t i = 0; i < size; i++) { + c[i] = c[i] ^ sign; + } + return (carry ^ sign) + mpn_add_1(c, c, size, -sign); +} + void bn_muld_low(dig_t *c, const dig_t *a, int sizea, const dig_t *b, int sizeb, int low, int high) { (void)low;