diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-01-09 06:30:16 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-01-09 06:30:16 +0800 |
commit | 9c52ee0880d283aba981b0d8ba34510aae3c8bd2 (patch) | |
tree | 7d153d7616f2ba521dedacc72929f5c18a9feef2 | |
parent | ec46946b4a1e597fec85ca2ad491387797aeb6dd (diff) | |
download | dexon-mcl-9c52ee0880d283aba981b0d8ba34510aae3c8bd2.tar.gz dexon-mcl-9c52ee0880d283aba981b0d8ba34510aae3c8bd2.tar.zst dexon-mcl-9c52ee0880d283aba981b0d8ba34510aae3c8bd2.zip |
rename Mcl to MclElgamal of Java
-rw-r--r-- | java/Makefile | 26 | ||||
-rw-r--r-- | java/MclElgamalTest.java (renamed from java/MclTest.java) | 18 | ||||
-rw-r--r-- | java/com/herumi/mcl/CipherText.java | 16 | ||||
-rw-r--r-- | java/com/herumi/mcl/MclElgamal.java (renamed from java/com/herumi/mcl/Mcl.java) | 14 | ||||
-rw-r--r-- | java/com/herumi/mcl/MclElgamalJNI.java (renamed from java/com/herumi/mcl/MclJNI.java) | 2 | ||||
-rw-r--r-- | java/com/herumi/mcl/PrivateKey.java | 26 | ||||
-rw-r--r-- | java/com/herumi/mcl/PublicKey.java | 24 | ||||
-rwxr-xr-x | java/make_wrap.bat | 12 | ||||
-rw-r--r-- | java/mcl_elgamal.hpp (renamed from java/mcl_if.hpp) | 0 | ||||
-rw-r--r-- | java/mcl_elgamal.i (renamed from java/mcl_if.i) | 6 | ||||
-rwxr-xr-x | java/run-mcl.bat | 8 | ||||
-rwxr-xr-x | java/run-mcl_elgamal.bat | 8 |
12 files changed, 80 insertions, 80 deletions
diff --git a/java/Makefile b/java/Makefile index fcbd285..78f657f 100644 --- a/java/Makefile +++ b/java/Makefile @@ -15,35 +15,35 @@ MCL_LIB=../lib/libmcl.a PACKAGE_NAME=com.herumi.mcl PACKAGE_DIR=$(subst .,/,$(PACKAGE_NAME)) -TARGET=../bin/libmcl_if_wrap.$(LIB_SUF) +TARGET=../bin/libmcl_elgamal_wrap.$(LIB_SUF) JAVA_EXE=cd ../bin && LD_LIBRARY_PATH=./:$(LD_LIBRARY_PATH) java -classpath ../java all: $(TARGET) -mcl_if_wrap.cxx: mcl_if.i mcl_if.hpp +mcl_elgamal_wrap.cxx: mcl_elgamal.i mcl_elgamal.hpp $(MKDIR) $(PACKAGE_DIR) - swig -java -package $(PACKAGE_NAME) -outdir $(PACKAGE_DIR) -c++ -Wall mcl_if.i + swig -java -package $(PACKAGE_NAME) -outdir $(PACKAGE_DIR) -c++ -Wall mcl_elgamal.i $(MCL_LIB): make -C .. -$(TARGET): mcl_if_wrap.cxx $(MCL_LIB) +$(TARGET): mcl_elgamal_wrap.cxx $(MCL_LIB) $(PRE)$(CXX) $< -o $@ $(CFLAGS) $(LDFLAGS) $(MCL_LIB) -shared %.class: %.java javac $< -MclTest.class: MclTest.java $(TARGET) +MclElgamalTest.class: MclElgamalTest.java $(TARGET) jar: - jar cvf mcl.jar com - -test: MclTest.class $(TARGET) - $(JAVA_EXE) MclTest - $(JAVA_EXE) MclTest -e NIST_P192 - $(JAVA_EXE) MclTest -e NIST_P256 -h sha256 - $(JAVA_EXE) MclTest -e NIST_P384 -h sha384 - $(JAVA_EXE) MclTest -e NIST_P521 -h sha512 + jar cvf mcl_elgamal.jar com + +test_elgamal: MclElgamalTest.class $(TARGET) + $(JAVA_EXE) MclElgamalTest + $(JAVA_EXE) MclElgamalTest -e NIST_P192 + $(JAVA_EXE) MclElgamalTest -e NIST_P256 -h sha256 + $(JAVA_EXE) MclElgamalTest -e NIST_P384 -h sha384 + $(JAVA_EXE) MclElgamalTest -e NIST_P521 -h sha512 clean: rm -rf *.class $(TARGET) $(PACKAGE_DIR)/*.class diff --git a/java/MclTest.java b/java/MclElgamalTest.java index 8e22f86..e055787 100644 --- a/java/MclTest.java +++ b/java/MclElgamalTest.java @@ -2,13 +2,13 @@ import java.io.*; import com.herumi.mcl.*; /* - MclTest [ecParam] + MclElgamalTest [ecParam] ecParam = secp192k1, NIST_P224, ... hashParam = hash224, hash384, ... */ -public class MclTest { +public class MclElgamalTest { static { - String lib = "mcl_if_wrap"; + String lib = "mcl_elgamal_wrap"; String libName = System.mapLibraryName(lib); System.out.println("libName : " + libName); System.loadLibrary(lib); @@ -43,7 +43,7 @@ public class MclTest { } String param = ecStr + " " + hashStr; System.out.println("param=" + param); - Mcl.SystemInit(param); + MclElgamal.SystemInit(param); String prvStr = ""; String pubStr = ""; @@ -124,19 +124,19 @@ public class MclTest { String m3 = "-2000000"; String m4 = "2001234"; CipherText c2 = new CipherText(); - SWIGTYPE_p_bool b = Mcl.new_p_bool(); + SWIGTYPE_p_bool b = MclElgamal.new_p_bool(); pub.enc(c, m3); dec = prv.dec(c, b); - assertBool("expect dec fail", !Mcl.p_bool_value(b)); + assertBool("expect dec fail", !MclElgamal.p_bool_value(b)); pub.enc(c2, m4); dec = prv.dec(c2, b); - assertBool("expect dec fail", !Mcl.p_bool_value(b)); + assertBool("expect dec fail", !MclElgamal.p_bool_value(b)); c.add(c2); // m3 + m4 dec = prv.dec(c, b); assertEquals("int add", 1234, dec); - assertBool("expect dec success", Mcl.p_bool_value(b)); - Mcl.delete_p_bool(b); + assertBool("expect dec success", MclElgamal.p_bool_value(b)); + MclElgamal.delete_p_bool(b); } catch (RuntimeException e) { System.out.println("unknown exception :" + e); } diff --git a/java/com/herumi/mcl/CipherText.java b/java/com/herumi/mcl/CipherText.java index e91c7e8..6323ba9 100644 --- a/java/com/herumi/mcl/CipherText.java +++ b/java/com/herumi/mcl/CipherText.java @@ -29,38 +29,38 @@ public class CipherText { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; - MclJNI.delete_CipherText(swigCPtr); + MclElgamalJNI.delete_CipherText(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclJNI.CipherText_toStr(swigCPtr, this); + return MclElgamalJNI.CipherText_toStr(swigCPtr, this); } public String toString() { - return MclJNI.CipherText_toString(swigCPtr, this); + return MclElgamalJNI.CipherText_toString(swigCPtr, this); } public void fromStr(String str) { - MclJNI.CipherText_fromStr(swigCPtr, this, str); + MclElgamalJNI.CipherText_fromStr(swigCPtr, this, str); } public void add(CipherText c) { - MclJNI.CipherText_add(swigCPtr, this, CipherText.getCPtr(c), c); + MclElgamalJNI.CipherText_add(swigCPtr, this, CipherText.getCPtr(c), c); } public void mul(int m) { - MclJNI.CipherText_mul__SWIG_0(swigCPtr, this, m); + MclElgamalJNI.CipherText_mul__SWIG_0(swigCPtr, this, m); } public void mul(String str) { - MclJNI.CipherText_mul__SWIG_1(swigCPtr, this, str); + MclElgamalJNI.CipherText_mul__SWIG_1(swigCPtr, this, str); } public CipherText() { - this(MclJNI.new_CipherText(), true); + this(MclElgamalJNI.new_CipherText(), true); } } diff --git a/java/com/herumi/mcl/Mcl.java b/java/com/herumi/mcl/MclElgamal.java index b7b5206..6a5bb8b 100644 --- a/java/com/herumi/mcl/Mcl.java +++ b/java/com/herumi/mcl/MclElgamal.java @@ -8,31 +8,31 @@ package com.herumi.mcl; -public class Mcl { +public class MclElgamal { public static SWIGTYPE_p_bool new_p_bool() { - long cPtr = MclJNI.new_p_bool(); + long cPtr = MclElgamalJNI.new_p_bool(); return (cPtr == 0) ? null : new SWIGTYPE_p_bool(cPtr, false); } public static SWIGTYPE_p_bool copy_p_bool(boolean value) { - long cPtr = MclJNI.copy_p_bool(value); + long cPtr = MclElgamalJNI.copy_p_bool(value); return (cPtr == 0) ? null : new SWIGTYPE_p_bool(cPtr, false); } public static void delete_p_bool(SWIGTYPE_p_bool obj) { - MclJNI.delete_p_bool(SWIGTYPE_p_bool.getCPtr(obj)); + MclElgamalJNI.delete_p_bool(SWIGTYPE_p_bool.getCPtr(obj)); } public static void p_bool_assign(SWIGTYPE_p_bool obj, boolean value) { - MclJNI.p_bool_assign(SWIGTYPE_p_bool.getCPtr(obj), value); + MclElgamalJNI.p_bool_assign(SWIGTYPE_p_bool.getCPtr(obj), value); } public static boolean p_bool_value(SWIGTYPE_p_bool obj) { - return MclJNI.p_bool_value(SWIGTYPE_p_bool.getCPtr(obj)); + return MclElgamalJNI.p_bool_value(SWIGTYPE_p_bool.getCPtr(obj)); } public static void SystemInit(String param) { - MclJNI.SystemInit(param); + MclElgamalJNI.SystemInit(param); } } diff --git a/java/com/herumi/mcl/MclJNI.java b/java/com/herumi/mcl/MclElgamalJNI.java index f2af0ef..57a4e5c 100644 --- a/java/com/herumi/mcl/MclJNI.java +++ b/java/com/herumi/mcl/MclElgamalJNI.java @@ -8,7 +8,7 @@ package com.herumi.mcl; -public class MclJNI { +public class MclElgamalJNI { public final static native long new_p_bool(); public final static native long copy_p_bool(boolean jarg1); public final static native void delete_p_bool(long jarg1); diff --git a/java/com/herumi/mcl/PrivateKey.java b/java/com/herumi/mcl/PrivateKey.java index 212fc0b..fae42b9 100644 --- a/java/com/herumi/mcl/PrivateKey.java +++ b/java/com/herumi/mcl/PrivateKey.java @@ -29,58 +29,58 @@ public class PrivateKey { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; - MclJNI.delete_PrivateKey(swigCPtr); + MclElgamalJNI.delete_PrivateKey(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclJNI.PrivateKey_toStr(swigCPtr, this); + return MclElgamalJNI.PrivateKey_toStr(swigCPtr, this); } public String toString() { - return MclJNI.PrivateKey_toString(swigCPtr, this); + return MclElgamalJNI.PrivateKey_toString(swigCPtr, this); } public void fromStr(String str) { - MclJNI.PrivateKey_fromStr(swigCPtr, this, str); + MclElgamalJNI.PrivateKey_fromStr(swigCPtr, this, str); } public void save(String fileName) { - MclJNI.PrivateKey_save(swigCPtr, this, fileName); + MclElgamalJNI.PrivateKey_save(swigCPtr, this, fileName); } public void load(String fileName) { - MclJNI.PrivateKey_load(swigCPtr, this, fileName); + MclElgamalJNI.PrivateKey_load(swigCPtr, this, fileName); } public void init() { - MclJNI.PrivateKey_init(swigCPtr, this); + MclElgamalJNI.PrivateKey_init(swigCPtr, this); } public PublicKey getPublicKey() { - return new PublicKey(MclJNI.PrivateKey_getPublicKey(swigCPtr, this), true); + return new PublicKey(MclElgamalJNI.PrivateKey_getPublicKey(swigCPtr, this), true); } public int dec(CipherText c, SWIGTYPE_p_bool b) { - return MclJNI.PrivateKey_dec__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, SWIGTYPE_p_bool.getCPtr(b)); + return MclElgamalJNI.PrivateKey_dec__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, SWIGTYPE_p_bool.getCPtr(b)); } public int dec(CipherText c) { - return MclJNI.PrivateKey_dec__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c); + return MclElgamalJNI.PrivateKey_dec__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c); } public void setCache(int rangeMin, int rangeMax) { - MclJNI.PrivateKey_setCache(swigCPtr, this, rangeMin, rangeMax); + MclElgamalJNI.PrivateKey_setCache(swigCPtr, this, rangeMin, rangeMax); } public void clearCache() { - MclJNI.PrivateKey_clearCache(swigCPtr, this); + MclElgamalJNI.PrivateKey_clearCache(swigCPtr, this); } public PrivateKey() { - this(MclJNI.new_PrivateKey(), true); + this(MclElgamalJNI.new_PrivateKey(), true); } } diff --git a/java/com/herumi/mcl/PublicKey.java b/java/com/herumi/mcl/PublicKey.java index a2367bb..4c76977 100644 --- a/java/com/herumi/mcl/PublicKey.java +++ b/java/com/herumi/mcl/PublicKey.java @@ -29,54 +29,54 @@ public class PublicKey { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; - MclJNI.delete_PublicKey(swigCPtr); + MclElgamalJNI.delete_PublicKey(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclJNI.PublicKey_toStr(swigCPtr, this); + return MclElgamalJNI.PublicKey_toStr(swigCPtr, this); } public String toString() { - return MclJNI.PublicKey_toString(swigCPtr, this); + return MclElgamalJNI.PublicKey_toString(swigCPtr, this); } public void fromStr(String str) { - MclJNI.PublicKey_fromStr(swigCPtr, this, str); + MclElgamalJNI.PublicKey_fromStr(swigCPtr, this, str); } public void save(String fileName) { - MclJNI.PublicKey_save(swigCPtr, this, fileName); + MclElgamalJNI.PublicKey_save(swigCPtr, this, fileName); } public void load(String fileName) { - MclJNI.PublicKey_load(swigCPtr, this, fileName); + MclElgamalJNI.PublicKey_load(swigCPtr, this, fileName); } public void enc(CipherText c, int m) { - MclJNI.PublicKey_enc__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); + MclElgamalJNI.PublicKey_enc__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); } public void enc(CipherText c, String str) { - MclJNI.PublicKey_enc__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); + MclElgamalJNI.PublicKey_enc__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); } public void rerandomize(CipherText c) { - MclJNI.PublicKey_rerandomize(swigCPtr, this, CipherText.getCPtr(c), c); + MclElgamalJNI.PublicKey_rerandomize(swigCPtr, this, CipherText.getCPtr(c), c); } public void add(CipherText c, int m) { - MclJNI.PublicKey_add__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); + MclElgamalJNI.PublicKey_add__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); } public void add(CipherText c, String str) { - MclJNI.PublicKey_add__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); + MclElgamalJNI.PublicKey_add__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); } public PublicKey() { - this(MclJNI.new_PublicKey(), true); + this(MclElgamalJNI.new_PublicKey(), true); } } diff --git a/java/make_wrap.bat b/java/make_wrap.bat index 2843970..9a8af79 100755 --- a/java/make_wrap.bat +++ b/java/make_wrap.bat @@ -7,13 +7,13 @@ set PACKAGE_DIR=%PACKAGE_NAME:.=\% echo [[run swig]] mkdir %PACKAGE_DIR% -echo %SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall mcl_if.i -%SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall mcl_if.i +echo %SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall mcl_elgamal.i +%SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall mcl_elgamal.i echo [[make dll]] -rem cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc mcl_if_wrap.cxx -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -I../include -I../../cybozulib/include -I../../cybozulib_ext/include -I../../xbyak /link /LIBPATH:../../cybozulib_ext/lib /LIBPATH:../lib /OUT:../bin/mcl_if_wrap.dll -cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc mcl_if_wrap.cxx ../src/fp.cpp -DMCL_NO_AUTOLINK -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -I../include -I../../cybozulib/include -I../../cybozulib_ext/include -I../../xbyak /link /LIBPATH:../../cybozulib_ext/lib /OUT:../bin/mcl_if_wrap.dll +rem cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc mcl_elgamal_wrap.cxx -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -I../include -I../../cybozulib/include -I../../cybozulib_ext/include -I../../xbyak /link /LIBPATH:../../cybozulib_ext/lib /LIBPATH:../lib /OUT:../bin/mcl_elgamal_wrap.dll +cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc mcl_elgamal_wrap.cxx ../src/fp.cpp -DMCL_NO_AUTOLINK -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -I../include -I../../cybozulib/include -I../../cybozulib_ext/include -I../../xbyak /link /LIBPATH:../../cybozulib_ext/lib /OUT:../bin/mcl_elgamal_wrap.dll -call run-mcl.bat +call run-mcl_elgamal.bat echo [[make jar]] -%JAVA_DIR%\bin\jar cvf mcl.jar com
\ No newline at end of file +%JAVA_DIR%\bin\jar cvf mcl_elgamal.jar com
\ No newline at end of file diff --git a/java/mcl_if.hpp b/java/mcl_elgamal.hpp index 034c7ad..034c7ad 100644 --- a/java/mcl_if.hpp +++ b/java/mcl_elgamal.hpp diff --git a/java/mcl_if.i b/java/mcl_elgamal.i index f14445b..9fc3c50 100644 --- a/java/mcl_if.i +++ b/java/mcl_elgamal.i @@ -1,4 +1,4 @@ -%module Mcl +%module MclElgamal %include "std_string.i" %include "std_except.i" @@ -20,9 +20,9 @@ static inline Param& getParam() } }; -#include "mcl_if.hpp" +#include "mcl_elgamal.hpp" %} %include cpointer.i %pointer_functions(bool, p_bool); -%include "mcl_if.hpp" +%include "mcl_elgamal.hpp" diff --git a/java/run-mcl.bat b/java/run-mcl.bat deleted file mode 100755 index f0d89b8..0000000 --- a/java/run-mcl.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -echo [[compile MclTest.java]] -%JAVA_DIR%\bin\javac MclTest.java - -echo [[run MclTest]] -pushd ..\bin -%JAVA_DIR%\bin\java -classpath ..\java MclTest %1 %2 %3 %4 %5 %6 -popd diff --git a/java/run-mcl_elgamal.bat b/java/run-mcl_elgamal.bat new file mode 100755 index 0000000..507e215 --- /dev/null +++ b/java/run-mcl_elgamal.bat @@ -0,0 +1,8 @@ +@echo off +echo [[compile MclElGamalTest.java]] +%JAVA_DIR%\bin\javac MclElGamalTest.java + +echo [[run MclElGamalTest]] +pushd ..\bin +%JAVA_DIR%\bin\java -classpath ..\java MclElGamalTest %1 %2 %3 %4 %5 %6 +popd |