tweak, build.sh
authorMatt Corallo <git@bluematt.me>
Mon, 15 Apr 2013 18:18:29 +0000 (14:18 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 15 Apr 2013 18:18:29 +0000 (14:18 -0400)
build.sh [new file with mode: 0755]
shamirssecret.c

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
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
index cc3e71334a1277367c2beae82bd05f9496945287..be6eed3f9d0c4247dc09a6a7d27fa0f775a32396 100644 (file)
@@ -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) {
        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);
 }
 
        return field_pow_ret(exp[(log[a] * e) % 255], a, e);
 }