From: Matt Corallo Date: Mon, 15 Apr 2013 18:18:29 +0000 (-0400) Subject: tweak, build.sh X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=421e5acbd6f375ca9f2f16d260fe9c5505fb42f4;p=shamirs tweak, build.sh --- diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b473a52 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/sh +gcc shamirssecret.c -O2 -std=c99 -DTEST -o shamirssecret && ./shamirssecret && +gcc shamirssecret.c -O2 -std=c99 -o shamirssecret diff --git a/shamirssecret.c b/shamirssecret.c index cc3e713..be6eed3 100644 --- a/shamirssecret.c +++ b/shamirssecret.c @@ -102,6 +102,11 @@ static uint8_t field_pow_ret(uint8_t calc, uint8_t a, uint8_t e) { return ret; } static uint8_t field_pow(uint8_t a, uint8_t e) { +#ifndef TEST + // Although this function works for a==0, its not trivially obvious why, + // and since we never call with a==0, we just assert a != 0 (except when testing) + assert(a != 0); +#endif return field_pow_ret(exp[(log[a] * e) % 255], a, e); }