#ifndef CONSTANTS_H_
#define CONSTANTS_H_

#include <math.h>

// Modify PRIME_FIELD_BINARY_BIT_LENGTH at will
#define PRIME_FIELD_BINARY_BIT_LENGTH (131)

// Do not modify anything below
#define LIMB_SIZE_IN_BITS (64)
#define LIMB_SIZE_IN_BYTES (LIMB_SIZE_IN_BITS / 8)
#define LIMB_SIZE_IN_HEX (LIMB_SIZE_IN_BITS / 4)
#define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH)/ ((double) LIMB_SIZE_IN_BITS)))
#define PRIME_FIELD_FULL_HEX_LENGTH (NUM_LIMBS * LIMB_SIZE_IN_HEX)

#if (PRIME_FIELD_BINARY_BIT_LENGTH % LIMB_SIZE_IN_BITS) == 0
#error "PRIME_FIELD_BINARY_BIT_LENGTH must not be a multiple of LIMB_SIZE_IN_BITS"
#endif

#endif

#ifndef CONSTANTS_H_
#define CONSTANTS_H_

#include <math.h>

#define PRIME_FIELD_BINARY_BIT_LENGTH (64)

#define LIMB_SIZE_IN_BITS (64)
#define LIMB_SIZE_IN_BYTES (LIMB_SIZE_IN_BITS / 8)
#define LIMB_SIZE_IN_HEX (LIMB_SIZE_IN_BITS / 4)
// +1 is important for basic operations like addition that may overflow to the
// next limb
#define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH + 1)/ ((double) LIMB_SIZE_IN_BITS)))
#define PRIME_FIELD_FULL_HEX_LENGTH (NUM_LIMBS * LIMB_SIZE_IN_HEX)

#endif

--- 
+++ 
@@ -3,14 +3,18 @@
 
 #include <math.h>
 
-#define PRIME_FIELD_BINARY_BIT_LENGTH (64)
+// Modify PRIME_FIELD_BINARY_BIT_LENGTH at will
+#define PRIME_FIELD_BINARY_BIT_LENGTH (131)
 
+// Do not modify anything below
 #define LIMB_SIZE_IN_BITS (64)
 #define LIMB_SIZE_IN_BYTES (LIMB_SIZE_IN_BITS / 8)
 #define LIMB_SIZE_IN_HEX (LIMB_SIZE_IN_BITS / 4)
-// +1 is important for basic operations like addition that may overflow to the
-// next limb
-#define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH + 1)/ ((double) LIMB_SIZE_IN_BITS)))
+#define NUM_LIMBS ((unsigned int) ceil((PRIME_FIELD_BINARY_BIT_LENGTH)/ ((double) LIMB_SIZE_IN_BITS)))
 #define PRIME_FIELD_FULL_HEX_LENGTH (NUM_LIMBS * LIMB_SIZE_IN_HEX)
 
+#if (PRIME_FIELD_BINARY_BIT_LENGTH % LIMB_SIZE_IN_BITS) == 0
+#error "PRIME_FIELD_BINARY_BIT_LENGTH must not be a multiple of LIMB_SIZE_IN_BITS"
 #endif
+
+#endif
Add compile-time check for bit length of prime field
