From 6d75c674ab3a33cbc4736d8899a659c80f25e1af Mon Sep 17 00:00:00 2001 From: Gottfried Herold Date: Fri, 17 Mar 2023 21:30:06 +0100 Subject: [PATCH] Check that FIELD_ELEMENTS_PER_BLOB is defined. (#225) --- src/c_kzg_4844.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/c_kzg_4844.h b/src/c_kzg_4844.h index c409dcf..6e7915b 100644 --- a/src/c_kzg_4844.h +++ b/src/c_kzg_4844.h @@ -36,6 +36,19 @@ extern "C" { // Macros /////////////////////////////////////////////////////////////////////////////// +#ifndef FIELD_ELEMENTS_PER_BLOB +#error FIELD_ELEMENTS_PER_BLOB is undefined. This value must be externally supplied. +#endif // FIELD_ELEMENTS_PER_BLOB +/** + * There are only 1<<32 2-adic roots of unity in the field, limiting the + * possible values of FIELD_ELEMENTS_PER_BLOB. The restriction to 1<<31 is a + * current implementation limitation. Notably, the size of the FFT setup would + * overflow uint32_t, which would casues issues. + */ +#if ((FIELD_ELEMENTS_PER_BLOB) <= 0) || ((FIELD_ELEMENTS_PER_BLOB) > (1 << 31)) +#error Invalid value of FIELD_ELEMENTS_PER_BLOB +#endif // FIELD_ELEMENTS_PER_BLOB + #define BYTES_PER_COMMITMENT 48 #define BYTES_PER_PROOF 48 #define BYTES_PER_FIELD_ELEMENT 32