diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bls.cpp | 18 | ||||
-rw-r--r-- | src/bls_if.cpp | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/bls.cpp b/src/bls.cpp index ff747bf..a159373 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -4,14 +4,21 @@ @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause */ -#include <bls.hpp> -#include <mcl/bn384.hpp> #include <cybozu/crypto.hpp> #include <cybozu/random_generator.hpp> #include <vector> #include <string> - +#include <bls.hpp> +#if BLS_MAX_OP_UNIT_SIZE == 4 +#include <mcl/bn256.hpp> +using namespace mcl::bn256; +#elif BLS_MAX_OP_UNIT_SIZE == 6 +#include <mcl/bn384.hpp> using namespace mcl::bn384; +#else + #error "define BLS_MAX_OP_UNIT_SIZE 4(or 6)" +#endif + typedef std::vector<Fr> FrVec; #define PUT(x) std::cout << #x << "=" << x << std::endl; @@ -156,19 +163,22 @@ std::ostream& writeAsHex(std::ostream& os, const T& t) return os << str; } -void init(int curve) +void init(int curve, int maxUnitSize) { + if (maxUnitSize != BLS_MAX_OP_UNIT_SIZE) throw cybozu::Exception("bls:init:bad maxUnitSize") << maxUnitSize << BLS_MAX_OP_UNIT_SIZE; mcl::bn::CurveParam cp; switch (curve) { case bls::CurveFp254BNb: cp = mcl::bn::CurveFp254BNb; break; +#if BLS_MAX_OP_UNIT_SIZE == 6 case bls::CurveFp382_1: cp = mcl::bn::CurveFp382_1; break; case bls::CurveFp382_2: cp = mcl::bn::CurveFp382_2; break; +#endif default: throw cybozu::Exception("bls:init:bad curve") << curve; } diff --git a/src/bls_if.cpp b/src/bls_if.cpp index 091bace..05ba0e8 100644 --- a/src/bls_if.cpp +++ b/src/bls_if.cpp @@ -43,9 +43,9 @@ size_t getStrT(const Outer *p, char *buf, size_t maxBufSize) return 0; } -void blsInit(int curve) +void blsInit(int curve, int maxUnitSize) { - bls::init(curve); + bls::init(curve, maxUnitSize); } blsId *blsIdCreate() |