aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-05-08 04:27:31 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-05-08 04:27:31 +0800
commitb9c7e507d4946f08280873899cbeb87838d7c6b6 (patch)
treea89cf391dd1fdc520caced20fed96fafa7a1c929
parent69e8196eac7609bac3e7dc09e730bc602112edf5 (diff)
downloaddexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar.gz
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar.bz2
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar.lz
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar.xz
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.tar.zst
dexon-bls-b9c7e507d4946f08280873899cbeb87838d7c6b6.zip
add macro for vc-dll
-rw-r--r--include/bls_if.h109
-rw-r--r--mklib.bat2
-rwxr-xr-xsetvar.bat5
3 files changed, 65 insertions, 51 deletions
diff --git a/include/bls_if.h b/include/bls_if.h
index 313e78a..5b718f0 100644
--- a/include/bls_if.h
+++ b/include/bls_if.h
@@ -14,8 +14,17 @@
#include <stdlib.h> // for size_t
#ifdef _MSC_VER
+#ifdef BLS256_DLL_EXPORT
+#define BLS256_DLL_API __declspec(dllexport)
+#else
+#define BLS256_DLL_API __declspec(dllimport)
+#ifndef MCL_NO_AUTOLINK
#pragma comment(lib, "bls_if.lib")
#endif
+#endif
+#else
+#define BLS256_DLL_API
+#endif
#ifdef __cplusplus
extern "C" {
@@ -56,94 +65,94 @@ typedef struct {
call this once before using the other method
@note init() is not thread safe
*/
-void blsInit(int curve, int maxUnitSize);
-size_t blsGetOpUnitSize(void);
+BLS256_DLL_API void blsInit(int curve, int maxUnitSize);
+BLS256_DLL_API size_t blsGetOpUnitSize(void);
// return strlen(buf) if success else 0
-int blsGetCurveOrder(char *buf, size_t maxBufSize);
-int blsGetFieldOrder(char *buf, size_t maxBufSize);
+BLS256_DLL_API int blsGetCurveOrder(char *buf, size_t maxBufSize);
+BLS256_DLL_API int blsGetFieldOrder(char *buf, size_t maxBufSize);
-blsId *blsIdCreate(void);
-void blsIdDestroy(blsId *id);
+BLS256_DLL_API blsId *blsIdCreate(void);
+BLS256_DLL_API void blsIdDestroy(blsId *id);
// return 1 if same else 0
-int blsIdIsSame(const blsId *lhs, const blsId *rhs);
-void blsIdPut(const blsId *id);
-void blsIdCopy(blsId *dst, const blsId *src);
+BLS256_DLL_API int blsIdIsSame(const blsId *lhs, const blsId *rhs);
+BLS256_DLL_API void blsIdPut(const blsId *id);
+BLS256_DLL_API void blsIdCopy(blsId *dst, const blsId *src);
// return 0 if success
-int blsIdSetStr(blsId *id, const char *buf, size_t bufSize, int ioMode);
+BLS256_DLL_API int blsIdSetStr(blsId *id, const char *buf, size_t bufSize, int ioMode);
/*
return written byte size if ioMode = BlsIoComp
return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1
return 0 otherwise
*/
-size_t blsIdGetStr(const blsId *id, char *buf, size_t maxBufSize, int ioMode);
+BLS256_DLL_API size_t blsIdGetStr(const blsId *id, char *buf, size_t maxBufSize, int ioMode);
/*
access p[0], ..., p[3] if 256-bit curve
access p[0], ..., p[5] if 384-bit curve
*/
-void blsIdSet(blsId *id, const uint64_t *p);
+BLS256_DLL_API void blsIdSet(blsId *id, const uint64_t *p);
-blsSecretKey* blsSecretKeyCreate(void);
-void blsSecretKeyDestroy(blsSecretKey *sec);
+BLS256_DLL_API blsSecretKey* blsSecretKeyCreate(void);
+BLS256_DLL_API void blsSecretKeyDestroy(blsSecretKey *sec);
// return 1 if same else 0
-int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs);
+BLS256_DLL_API int blsSecretKeyIsSame(const blsSecretKey *lhs, const blsSecretKey *rhs);
-void blsSecretKeyPut(const blsSecretKey *sec);
-void blsSecretKeyCopy(blsSecretKey *dst, const blsSecretKey *src);
-void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p);
-int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize, int ioMode);
+BLS256_DLL_API void blsSecretKeyPut(const blsSecretKey *sec);
+BLS256_DLL_API void blsSecretKeyCopy(blsSecretKey *dst, const blsSecretKey *src);
+BLS256_DLL_API void blsSecretKeySetArray(blsSecretKey *sec, const uint64_t *p);
+BLS256_DLL_API int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize, int ioMode);
/*
return written byte size if ioMode = BlsIoComp
return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1
return 0 otherwise
*/
-size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize, int ioMode);
-void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs);
-
-void blsSecretKeyInit(blsSecretKey *sec);
-void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub);
-void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size);
-void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id);
-void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n);
-void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign);
-
-blsPublicKey *blsPublicKeyCreate(void);
-void blsPublicKeyDestroy(blsPublicKey *pub);
+BLS256_DLL_API size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize, int ioMode);
+BLS256_DLL_API void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs);
+
+BLS256_DLL_API void blsSecretKeyInit(blsSecretKey *sec);
+BLS256_DLL_API void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub);
+BLS256_DLL_API void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size);
+BLS256_DLL_API void blsSecretKeySet(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id);
+BLS256_DLL_API void blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n);
+BLS256_DLL_API void blsSecretKeyGetPop(const blsSecretKey *sec, blsSign *sign);
+
+BLS256_DLL_API blsPublicKey *blsPublicKeyCreate(void);
+BLS256_DLL_API void blsPublicKeyDestroy(blsPublicKey *pub);
// return 1 if same else 0
-int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs);
-void blsPublicKeyPut(const blsPublicKey *pub);
-void blsPublicKeyCopy(blsPublicKey *dst, const blsPublicKey *src);
-int blsPublicKeySetStr(blsPublicKey *pub, const char *buf, size_t bufSize, int ioMode);
+BLS256_DLL_API int blsPublicKeyIsSame(const blsPublicKey *lhs, const blsPublicKey *rhs);
+BLS256_DLL_API void blsPublicKeyPut(const blsPublicKey *pub);
+BLS256_DLL_API void blsPublicKeyCopy(blsPublicKey *dst, const blsPublicKey *src);
+BLS256_DLL_API int blsPublicKeySetStr(blsPublicKey *pub, const char *buf, size_t bufSize, int ioMode);
/*
return written byte size if ioMode = BlsIoComp
return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1
return 0 otherwise
*/
-size_t blsPublicKeyGetStr(const blsPublicKey *pub, char *buf, size_t maxBufSize, int ioMode);
-void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs);
-void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id);
-void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n);
+BLS256_DLL_API size_t blsPublicKeyGetStr(const blsPublicKey *pub, char *buf, size_t maxBufSize, int ioMode);
+BLS256_DLL_API void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs);
+BLS256_DLL_API void blsPublicKeySet(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id);
+BLS256_DLL_API void blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n);
-blsSign *blsSignCreate(void);
-void blsSignDestroy(blsSign *sign);
+BLS256_DLL_API blsSign *blsSignCreate(void);
+BLS256_DLL_API void blsSignDestroy(blsSign *sign);
// return 1 if same else 0
-int blsSignIsSame(const blsSign *lhs, const blsSign *rhs);
-void blsSignPut(const blsSign *sign);
-void blsSignCopy(blsSign *dst, const blsSign *src);
-int blsSignSetStr(blsSign *sign, const char *buf, size_t bufSize, int ioMode);
+BLS256_DLL_API int blsSignIsSame(const blsSign *lhs, const blsSign *rhs);
+BLS256_DLL_API void blsSignPut(const blsSign *sign);
+BLS256_DLL_API void blsSignCopy(blsSign *dst, const blsSign *src);
+BLS256_DLL_API int blsSignSetStr(blsSign *sign, const char *buf, size_t bufSize, int ioMode);
/*
return written byte size if ioMode = BlsIoComp
return strlen(buf) if ioMode = 2, 10, 16 ; written byte size = strlen(buf) + 1
return 0 otherwise
*/
-size_t blsSignGetStr(const blsSign *sign, char *buf, size_t maxBufSize, int ioMode);
-void blsSignAdd(blsSign *sign, const blsSign *rhs);
-void blsSignRecover(blsSign *sign, const blsSign *signVec, const blsId *idVec, size_t n);
+BLS256_DLL_API size_t blsSignGetStr(const blsSign *sign, char *buf, size_t maxBufSize, int ioMode);
+BLS256_DLL_API void blsSignAdd(blsSign *sign, const blsSign *rhs);
+BLS256_DLL_API void blsSignRecover(blsSign *sign, const blsSign *signVec, const blsId *idVec, size_t n);
-int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size);
+BLS256_DLL_API int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size);
-int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub);
+BLS256_DLL_API int blsSignVerifyPop(const blsSign *sign, const blsPublicKey *pub);
#ifdef __cplusplus
}
diff --git a/mklib.bat b/mklib.bat
index 52b61d9..ff7494a 100644
--- a/mklib.bat
+++ b/mklib.bat
@@ -6,3 +6,5 @@ lib /OUT:lib\bls.lib /nodefaultlib bls.obj %LDFLAGS%
echo make lib_if.lib
cl /c %CFLAGS% src\bls_if.cpp
lib /OUT:lib\bls_if.lib /nodefaultlib bls_if.obj %LDFLAGS%
+echo make bls256.dll
+link /nologo /DLL /OUT:bin\bls256.dll bls.obj bls_if.obj %LDFLAGS% /implib:lib\mcl256.lib
diff --git a/setvar.bat b/setvar.bat
index ccaf5bc..92b75d8 100755
--- a/setvar.bat
+++ b/setvar.bat
@@ -1,3 +1,6 @@
+@echo off
+set BLS_MAX_OP_UNIT_SIZE=4
+echo BLS_MAX_OP_UNIT_SIZE=%BLS_MAX_OP_UNIT_SIZE%
set CFLAGS=/MT /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc /nologo -I ./include -I../cybozulib/include -I../cybozulib_ext/include -I../mcl/include
-set CFLAGS=%CFLAGS% -DBLS_MAX_OP_UNIT_SIZE=6
+set CFLAGS=%CFLAGS% -DBLS_MAX_OP_UNIT_SIZE=%BLS_MAX_OP_UNIT_SIZE%
set LDFLAGS=/LIBPATH:..\cybozulib_ext\lib /LIBPATH:.\lib /LIBPATH:..\mcl\lib