From 850562e3f16e3a1c7eafa78e0be1eb4c21e9c154 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Wed, 12 Nov 2014 13:48:46 -0800 Subject: [PATCH] Avoid unsigned comparison in scalar arith. --- src/scalar_4x64_impl.h | 2 +- src/scalar_8x32_impl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scalar_4x64_impl.h b/src/scalar_4x64_impl.h index b36e20d..760367c 100644 --- a/src/scalar_4x64_impl.h +++ b/src/scalar_4x64_impl.h @@ -179,7 +179,7 @@ static int secp256k1_scalar_is_high(const secp256k1_scalar_t *a) { /** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ #define sumadd(a) { \ c0 += (a); /* overflow is handled on the next line */ \ - int over = (c0 < (a)) ? 1 : 0; \ + unsigned int over = (c0 < (a)) ? 1 : 0; \ c1 += over; /* overflow is handled on the next line */ \ c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ } diff --git a/src/scalar_8x32_impl.h b/src/scalar_8x32_impl.h index 28a6cee..dc148d7 100644 --- a/src/scalar_8x32_impl.h +++ b/src/scalar_8x32_impl.h @@ -235,7 +235,7 @@ static int secp256k1_scalar_is_high(const secp256k1_scalar_t *a) { /** Add a to the number defined by (c0,c1,c2). c2 must never overflow. */ #define sumadd(a) { \ c0 += (a); /* overflow is handled on the next line */ \ - int over = (c0 < (a)) ? 1 : 0; \ + unsigned int over = (c0 < (a)) ? 1 : 0; \ c1 += over; /* overflow is handled on the next line */ \ c2 += (c1 < over) ? 1 : 0; /* never overflows by contract */ \ }