From 4eb4b2bd36699889a3c5a3b5af7e856d359de9a2 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 10 Mar 2021 16:32:45 +0900 Subject: [PATCH 1/3] [python] add makefile --- ffi/python/Makefile | 9 +++++++++ ffi/python/readme.md | 7 +++++++ ffi/python/she.py | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 ffi/python/Makefile create mode 100644 ffi/python/readme.md diff --git a/ffi/python/Makefile b/ffi/python/Makefile new file mode 100644 index 0000000..1b4846f --- /dev/null +++ b/ffi/python/Makefile @@ -0,0 +1,9 @@ +include ../../common.mk + +SHE384_256_SLIB=libmclshe384_256.$(LIB_SUF) + +she_test: ../../lib/$(SHE384_256_SLIB) + env LD_LIBRARY_PATH=../../lib python3 she.py + +../../lib/$(SHE384_256_SLIB): + make -C ../../ lib/$(SHE384_256_SLIB) diff --git a/ffi/python/readme.md b/ffi/python/readme.md new file mode 100644 index 0000000..48479d1 --- /dev/null +++ b/ffi/python/readme.md @@ -0,0 +1,7 @@ +# sample for Python + +## SHE + +``` +make test_she +``` diff --git a/ffi/python/she.py b/ffi/python/she.py index 4234a67..538515f 100644 --- a/ffi/python/she.py +++ b/ffi/python/she.py @@ -1,6 +1,7 @@ import os import platform from ctypes import * +#from ctypes.util import find_library BN254 = 0 BLS12_381 = 5 @@ -34,6 +35,7 @@ def init(curveType=BN254): libName = 'mclshe384_256.dll' else: raise RuntimeError("not support yet", name) +# lib = cdll.LoadLibrary(find_library(libName)) lib = cdll.LoadLibrary(libName) ret = lib.sheInit(curveType, MCLBN_COMPILED_TIME_VAR) if ret != 0: From 317934bdfb885265f9de1a9b829ecc2e016d250a Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 10 Mar 2021 16:39:02 +0900 Subject: [PATCH 2/3] fix test --- ffi/python/Makefile | 2 +- ffi/python/readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ffi/python/Makefile b/ffi/python/Makefile index 1b4846f..9d46068 100644 --- a/ffi/python/Makefile +++ b/ffi/python/Makefile @@ -3,7 +3,7 @@ include ../../common.mk SHE384_256_SLIB=libmclshe384_256.$(LIB_SUF) she_test: ../../lib/$(SHE384_256_SLIB) - env LD_LIBRARY_PATH=../../lib python3 she.py + cd ../../lib && python3 ../ffi/python/she.py ../../lib/$(SHE384_256_SLIB): make -C ../../ lib/$(SHE384_256_SLIB) diff --git a/ffi/python/readme.md b/ffi/python/readme.md index 48479d1..7f102bd 100644 --- a/ffi/python/readme.md +++ b/ffi/python/readme.md @@ -3,5 +3,5 @@ ## SHE ``` -make test_she +make she_test ``` From e6cc4025e1908bf75fcd469f3dbd95d6db289fc3 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 10 Mar 2021 16:43:09 +0900 Subject: [PATCH 3/3] [python] LD_LIBRARY_PATH is necessary for linux --- ffi/python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffi/python/Makefile b/ffi/python/Makefile index 9d46068..85d4797 100644 --- a/ffi/python/Makefile +++ b/ffi/python/Makefile @@ -3,7 +3,7 @@ include ../../common.mk SHE384_256_SLIB=libmclshe384_256.$(LIB_SUF) she_test: ../../lib/$(SHE384_256_SLIB) - cd ../../lib && python3 ../ffi/python/she.py + cd ../../lib && env LD_LIBRARY_PATH=./ python3 ../ffi/python/she.py ../../lib/$(SHE384_256_SLIB): make -C ../../ lib/$(SHE384_256_SLIB)