make bn256_if.dll

dev
MITSUNARI Shigeo 8 years ago
parent ebc006b7ab
commit 47767251a1
  1. 134
      include/mcl/bn256_if.h
  2. 2
      mk.bat
  3. 12
      mklib.bat
  4. 1
      src/bn256_if.cpp

@ -39,128 +39,138 @@ typedef struct BN256_GT BN256_GT;
#endif #endif
#ifdef _MSC_VER
#ifdef BN256_DLL_EXPORT
#define BN256_DLL_API __declspec(dllexport)
#else
#define BN256_DLL_API __declspec(dllimport)
#endif
#else
#define BN256_DLL_API
#endif
/* /*
set errlog file name set errlog file name
use stderr if name == "stderr" use stderr if name == "stderr"
close if name == "" close if name == ""
return 0 if success return 0 if success
*/ */
int BN256_setErrFile(const char *name); BN256_DLL_API int BN256_setErrFile(const char *name);
int BN256_init(void); BN256_DLL_API int BN256_init(void);
//////////////////////////////////////////////// ////////////////////////////////////////////////
// set zero // set zero
void BN256_Fr_clear(BN256_Fr *x); BN256_DLL_API void BN256_Fr_clear(BN256_Fr *x);
// set x to y // set x to y
void BN256_Fr_setInt(BN256_Fr *y, int x); BN256_DLL_API void BN256_Fr_setInt(BN256_Fr *y, int x);
void BN256_Fr_copy(BN256_Fr *y, const BN256_Fr *x); BN256_DLL_API void BN256_Fr_copy(BN256_Fr *y, const BN256_Fr *x);
// return 0 if success // return 0 if success
int BN256_Fr_setStr(BN256_Fr *x, const char *str); BN256_DLL_API int BN256_Fr_setStr(BN256_Fr *x, const char *str);
// return 1 if true and 0 otherwise // return 1 if true and 0 otherwise
int BN256_Fr_isValid(const BN256_Fr *x); BN256_DLL_API int BN256_Fr_isValid(const BN256_Fr *x);
int BN256_Fr_isSame(const BN256_Fr *x, const BN256_Fr *y); BN256_DLL_API int BN256_Fr_isSame(const BN256_Fr *x, const BN256_Fr *y);
int BN256_Fr_isZero(const BN256_Fr *x); BN256_DLL_API int BN256_Fr_isZero(const BN256_Fr *x);
int BN256_Fr_isOne(const BN256_Fr *x); BN256_DLL_API int BN256_Fr_isOne(const BN256_Fr *x);
void BN256_Fr_setRand(BN256_Fr *x); BN256_DLL_API void BN256_Fr_setRand(BN256_Fr *x);
// hash(str) and set x // hash(str) and set x
void BN256_Fr_setMsg(BN256_Fr *x, const char *str); BN256_DLL_API void BN256_Fr_setMsg(BN256_Fr *x, const char *str);
// return 0 if success // return 0 if success
int BN256_Fr_getStr(char *buf, size_t maxBufSize, const BN256_Fr *x); BN256_DLL_API int BN256_Fr_getStr(char *buf, size_t maxBufSize, const BN256_Fr *x);
void BN256_Fr_neg(BN256_Fr *y, const BN256_Fr *x); BN256_DLL_API void BN256_Fr_neg(BN256_Fr *y, const BN256_Fr *x);
void BN256_Fr_inv(BN256_Fr *y, const BN256_Fr *x); BN256_DLL_API void BN256_Fr_inv(BN256_Fr *y, const BN256_Fr *x);
void BN256_Fr_add(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y); BN256_DLL_API void BN256_Fr_add(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y);
void BN256_Fr_sub(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y); BN256_DLL_API void BN256_Fr_sub(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y);
void BN256_Fr_mul(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y); BN256_DLL_API void BN256_Fr_mul(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y);
void BN256_Fr_div(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y); BN256_DLL_API void BN256_Fr_div(BN256_Fr *z, const BN256_Fr *x, const BN256_Fr *y);
//////////////////////////////////////////////// ////////////////////////////////////////////////
// set zero // set zero
void BN256_G1_clear(BN256_G1 *x); BN256_DLL_API void BN256_G1_clear(BN256_G1 *x);
void BN256_G1_copy(BN256_G1 *y, const BN256_G1 *x); BN256_DLL_API void BN256_G1_copy(BN256_G1 *y, const BN256_G1 *x);
// return 0 if success // return 0 if success
int BN256_G1_setStr(BN256_G1 *x, const char *str); BN256_DLL_API int BN256_G1_setStr(BN256_G1 *x, const char *str);
// return 1 if true and 0 otherwise // return 1 if true and 0 otherwise
int BN256_G1_isValid(const BN256_G1 *x); BN256_DLL_API int BN256_G1_isValid(const BN256_G1 *x);
int BN256_G1_isSame(const BN256_G1 *x, const BN256_G1 *y); BN256_DLL_API int BN256_G1_isSame(const BN256_G1 *x, const BN256_G1 *y);
int BN256_G1_isZero(const BN256_G1 *x); BN256_DLL_API int BN256_G1_isZero(const BN256_G1 *x);
int BN256_G1_hashAndMapTo(BN256_G1 *x, const char *str); BN256_DLL_API int BN256_G1_hashAndMapTo(BN256_G1 *x, const char *str);
// return 0 if success // return 0 if success
int BN256_G1_getStr(char *buf, size_t maxBufSize, const BN256_G1 *x); BN256_DLL_API int BN256_G1_getStr(char *buf, size_t maxBufSize, const BN256_G1 *x);
void BN256_G1_neg(BN256_G1 *y, const BN256_G1 *x); BN256_DLL_API void BN256_G1_neg(BN256_G1 *y, const BN256_G1 *x);
void BN256_G1_dbl(BN256_G1 *y, const BN256_G1 *x); BN256_DLL_API void BN256_G1_dbl(BN256_G1 *y, const BN256_G1 *x);
void BN256_G1_add(BN256_G1 *z, const BN256_G1 *x, const BN256_G1 *y); BN256_DLL_API void BN256_G1_add(BN256_G1 *z, const BN256_G1 *x, const BN256_G1 *y);
void BN256_G1_sub(BN256_G1 *z, const BN256_G1 *x, const BN256_G1 *y); BN256_DLL_API void BN256_G1_sub(BN256_G1 *z, const BN256_G1 *x, const BN256_G1 *y);
void BN256_G1_mul(BN256_G1 *z, const BN256_G1 *x, const BN256_Fr *y); BN256_DLL_API void BN256_G1_mul(BN256_G1 *z, const BN256_G1 *x, const BN256_Fr *y);
//////////////////////////////////////////////// ////////////////////////////////////////////////
// set zero // set zero
void BN256_G2_clear(BN256_G2 *x); BN256_DLL_API void BN256_G2_clear(BN256_G2 *x);
void BN256_G2_copy(BN256_G2 *y, const BN256_G2 *x); BN256_DLL_API void BN256_G2_copy(BN256_G2 *y, const BN256_G2 *x);
// return 0 if success // return 0 if success
int BN256_G2_setStr(BN256_G2 *x, const char *str); BN256_DLL_API int BN256_G2_setStr(BN256_G2 *x, const char *str);
// return 1 if true and 0 otherwise // return 1 if true and 0 otherwise
int BN256_G2_isValid(const BN256_G2 *x); BN256_DLL_API int BN256_G2_isValid(const BN256_G2 *x);
int BN256_G2_isSame(const BN256_G2 *x, const BN256_G2 *y); BN256_DLL_API int BN256_G2_isSame(const BN256_G2 *x, const BN256_G2 *y);
int BN256_G2_isZero(const BN256_G2 *x); BN256_DLL_API int BN256_G2_isZero(const BN256_G2 *x);
int BN256_G2_hashAndMapTo(BN256_G2 *x, const char *str); BN256_DLL_API int BN256_G2_hashAndMapTo(BN256_G2 *x, const char *str);
// return 0 if success // return 0 if success
int BN256_G2_getStr(char *buf, size_t maxBufSize, const BN256_G2 *x); BN256_DLL_API int BN256_G2_getStr(char *buf, size_t maxBufSize, const BN256_G2 *x);
void BN256_G2_neg(BN256_G2 *y, const BN256_G2 *x); BN256_DLL_API void BN256_G2_neg(BN256_G2 *y, const BN256_G2 *x);
void BN256_G2_dbl(BN256_G2 *y, const BN256_G2 *x); BN256_DLL_API void BN256_G2_dbl(BN256_G2 *y, const BN256_G2 *x);
void BN256_G2_add(BN256_G2 *z, const BN256_G2 *x, const BN256_G2 *y); BN256_DLL_API void BN256_G2_add(BN256_G2 *z, const BN256_G2 *x, const BN256_G2 *y);
void BN256_G2_sub(BN256_G2 *z, const BN256_G2 *x, const BN256_G2 *y); BN256_DLL_API void BN256_G2_sub(BN256_G2 *z, const BN256_G2 *x, const BN256_G2 *y);
void BN256_G2_mul(BN256_G2 *z, const BN256_G2 *x, const BN256_Fr *y); BN256_DLL_API void BN256_G2_mul(BN256_G2 *z, const BN256_G2 *x, const BN256_Fr *y);
//////////////////////////////////////////////// ////////////////////////////////////////////////
// set zero // set zero
void BN256_GT_clear(BN256_GT *x); BN256_DLL_API void BN256_GT_clear(BN256_GT *x);
void BN256_GT_copy(BN256_GT *y, const BN256_GT *x); BN256_DLL_API void BN256_GT_copy(BN256_GT *y, const BN256_GT *x);
// return 0 if success // return 0 if success
int BN256_GT_setStr(BN256_GT *x, const char *str); BN256_DLL_API int BN256_GT_setStr(BN256_GT *x, const char *str);
// return 1 if true and 0 otherwise // return 1 if true and 0 otherwise
int BN256_GT_isSame(const BN256_GT *x, const BN256_GT *y); BN256_DLL_API int BN256_GT_isSame(const BN256_GT *x, const BN256_GT *y);
int BN256_GT_isZero(const BN256_GT *x); BN256_DLL_API int BN256_GT_isZero(const BN256_GT *x);
int BN256_GT_isOne(const BN256_GT *x); BN256_DLL_API int BN256_GT_isOne(const BN256_GT *x);
// return 0 if success // return 0 if success
int BN256_GT_getStr(char *buf, size_t maxBufSize, const BN256_GT *x); BN256_DLL_API int BN256_GT_getStr(char *buf, size_t maxBufSize, const BN256_GT *x);
void BN256_GT_neg(BN256_GT *y, const BN256_GT *x); BN256_DLL_API void BN256_GT_neg(BN256_GT *y, const BN256_GT *x);
void BN256_GT_inv(BN256_GT *y, const BN256_GT *x); BN256_DLL_API void BN256_GT_inv(BN256_GT *y, const BN256_GT *x);
void BN256_GT_add(BN256_GT *z, const BN256_GT *x, const BN256_GT *y); BN256_DLL_API void BN256_GT_add(BN256_GT *z, const BN256_GT *x, const BN256_GT *y);
void BN256_GT_sub(BN256_GT *z, const BN256_GT *x, const BN256_GT *y); BN256_DLL_API void BN256_GT_sub(BN256_GT *z, const BN256_GT *x, const BN256_GT *y);
void BN256_GT_mul(BN256_GT *z, const BN256_GT *x, const BN256_GT *y); BN256_DLL_API void BN256_GT_mul(BN256_GT *z, const BN256_GT *x, const BN256_GT *y);
void BN256_GT_div(BN256_GT *z, const BN256_GT *x, const BN256_GT *y); BN256_DLL_API void BN256_GT_div(BN256_GT *z, const BN256_GT *x, const BN256_GT *y);
void BN256_GT_finalExp(BN256_GT *y, const BN256_GT *x); BN256_DLL_API void BN256_GT_finalExp(BN256_GT *y, const BN256_GT *x);
void BN256_GT_pow(BN256_GT *z, const BN256_GT *x, const BN256_Fr *y); BN256_DLL_API void BN256_GT_pow(BN256_GT *z, const BN256_GT *x, const BN256_Fr *y);
void BN256_pairing(BN256_GT *z, const BN256_G1 *x, const BN256_G2 *y); BN256_DLL_API void BN256_pairing(BN256_GT *z, const BN256_G1 *x, const BN256_G2 *y);
void BN256_millerLoop(BN256_GT *z, const BN256_G1 *x, const BN256_G2 *y); BN256_DLL_API void BN256_millerLoop(BN256_GT *z, const BN256_G1 *x, const BN256_G2 *y);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -1,2 +1,2 @@
@echo off @echo off
cl /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc -I ./include -I../xbyak -I../cybozulib/include -I../cybozulib_ext/include %1 %2 /link /LIBPATH:..\cybozulib_ext\lib /LIBPATH:.\lib cl /MT /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc -I ./include -I../xbyak -I../cybozulib/include -I../cybozulib_ext/include %1 %2 /link /LIBPATH:..\cybozulib_ext\lib /LIBPATH:.\lib

@ -1,7 +1,15 @@
@echo off @echo off
set CFLAGS=/MT /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc -I ./include -I../xbyak -I../cybozulib/include -I../cybozulib_ext/include
set LDFLAGS=/link /LIBPATH:..\cybozulib_ext\lib /LIBPATH:.\lib
rem nasm -f win64 -D_WIN64 src\asm\low_x86-64.asm rem nasm -f win64 -D_WIN64 src\asm\low_x86-64.asm
rem cl /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc /c -I ./include -I../xbyak -I../cybozulib/include -I../cybozulib_ext/include src\fp.cpp
rem lib /OUT:lib\mcl.lib /nodefaultlib fp.obj src\asm\low_x86-64.obj rem lib /OUT:lib\mcl.lib /nodefaultlib fp.obj src\asm\low_x86-64.obj
cl /DNOMINMAX /Ox /DNDEBUG /W4 /Zi /EHsc /c -I ./include -I../xbyak -I../cybozulib/include -I../cybozulib_ext/include src\fp.cpp echo cl /c %CFLAGS% src\fp.cpp
cl /c %CFLAGS% src\fp.cpp
echo lib /OUT:lib\mcl.lib /nodefaultlib fp.obj
lib /OUT:lib\mcl.lib /nodefaultlib fp.obj lib /OUT:lib\mcl.lib /nodefaultlib fp.obj
echo cl /c %CFLAGS% src\bn256_if.cpp
cl /c %CFLAGS% src\bn256_if.cpp
echo cl /LD /Febin\bn256_if.dll bn256_if.obj fp.obj %LDFLAGS%
cl /LD /Febin\bn256_if.dll bn256_if.obj fp.obj %LDFLAGS%

@ -1,4 +1,5 @@
#include <mcl/bn256.hpp> #include <mcl/bn256.hpp>
#define BN256_DLL_EXPORT
#define BN256_DEFINE_STRUCT #define BN256_DEFINE_STRUCT
#include <mcl/bn256_if.h> #include <mcl/bn256_if.h>
#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 #if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11

Loading…
Cancel
Save