diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-03-15 05:07:20 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-03-15 05:07:20 +0800 |
commit | d085930d574264ae30c1091a9948c21b3160feb8 (patch) | |
tree | ce192c0cd0bcc7e3e9a8402a3147409392159277 /src/bls.cpp | |
parent | a148e716c06551b5ac143477c919548c9a682a03 (diff) | |
download | dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.gz dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.bz2 dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.lz dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.xz dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.zst dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.zip |
add UNIT option to select bn256 or bn384
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; } |