From d085930d574264ae30c1091a9948c21b3160feb8 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 15 Mar 2017 06:07:20 +0900 Subject: add UNIT option to select bn256 or bn384 --- src/bls.cpp | 18 ++++++++++++++---- src/bls_if.cpp | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') 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 -#include #include #include #include #include - +#include +#if BLS_MAX_OP_UNIT_SIZE == 4 +#include +using namespace mcl::bn256; +#elif BLS_MAX_OP_UNIT_SIZE == 6 +#include using namespace mcl::bn384; +#else + #error "define BLS_MAX_OP_UNIT_SIZE 4(or 6)" +#endif + typedef std::vector 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() -- cgit v1.2.3