diff options
-rw-r--r-- | include/bls/bls.hpp | 9 | ||||
-rw-r--r-- | src/bls.cpp | 11 | ||||
-rw-r--r-- | src/bls_c.cpp | 10 | ||||
-rw-r--r-- | test/bls_test.cpp | 4 |
4 files changed, 29 insertions, 5 deletions
diff --git a/include/bls/bls.hpp b/include/bls/bls.hpp index 914cedf..ca4d0ca 100644 --- a/include/bls/bls.hpp +++ b/include/bls/bls.hpp @@ -6,15 +6,16 @@ @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause */ -#include <mcl/bn.h> #include <bls/bls.h> #include <vector> #include <string> #include <iosfwd> #include <stdint.h> -#ifdef _MSC_VER - #pragma comment(lib, "bls.lib") +#ifndef BLS_NO_AUTOLINK + #ifdef _MSC_VER + #pragma comment(lib, "bls.lib") + #endif #endif namespace bls { @@ -58,6 +59,8 @@ void init(int curve = mclBn_CurveFp254BNb, int maxUnitSize = MCLBN_FP_UNIT_SIZE) size_t getOpUnitSize(); void getCurveOrder(std::string& str); void getFieldOrder(std::string& str); +int getG1ByteSize(); +int getFrByteSize(); class SecretKey; class PublicKey; diff --git a/src/bls.cpp b/src/bls.cpp index 5bfb744..d83b259 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -7,6 +7,7 @@ #include <cybozu/crypto.hpp> #include <vector> #include <string> +#define MCLBN_NO_AUTOLINK #include <bls/bls.hpp> #if MCLBN_FP_UNIT_SIZE == 4 #include <mcl/bn256.hpp> @@ -206,6 +207,16 @@ void getFieldOrder(std::string& str) Fp::getModulo(str); } +int getG1ByteSize() +{ + return (int)Fp::getByteSize(); +} + +int getFrByteSize() +{ + return (int)Fr::getByteSize(); +} + Id::Id(unsigned int id) { getInner().v = id; diff --git a/src/bls_c.cpp b/src/bls_c.cpp index d983ff2..5ea665c 100644 --- a/src/bls_c.cpp +++ b/src/bls_c.cpp @@ -240,6 +240,16 @@ int blsGetFieldOrder(char *buf, mclSize maxBufSize) return (int)Fp::getModulo(buf, maxBufSize); } +int blsGetG1ByteSize() +{ + return mclBn_getG1ByteSize(); +} + +int blsGetFrByteSize() +{ + return mclBn_getFrByteSize(); +} + void blsGetGeneratorOfG2(blsPublicKey *pub) { *(G2*)pub = getQ(); diff --git a/test/bls_test.cpp b/test/bls_test.cpp index f97d9a7..b2a7860 100644 --- a/test/bls_test.cpp +++ b/test/bls_test.cpp @@ -367,8 +367,8 @@ void aggregateTest() void dataTest() { - const size_t FrSize = mclBn_getFrByteSize(); - const size_t FpSize = mclBn_getG1ByteSize(); + const size_t FrSize = bls::getFrByteSize(); + const size_t FpSize = bls::getG1ByteSize(); bls::SecretKey sec; sec.init(); std::string str; |