diff options
Diffstat (limited to 'src/bls.cpp')
-rw-r--r-- | src/bls.cpp | 18 |
1 files changed, 14 insertions, 4 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; } |