diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-01-09 09:19:15 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-01-09 09:19:15 +0800 |
commit | 635a1d26596f1c3cdec423154eeb7a12c51c8a2d (patch) | |
tree | dd864418c24714f8fde39279b6a7d531db225268 | |
parent | 9c52ee0880d283aba981b0d8ba34510aae3c8bd2 (diff) | |
download | dexon-mcl-635a1d26596f1c3cdec423154eeb7a12c51c8a2d.tar.gz dexon-mcl-635a1d26596f1c3cdec423154eeb7a12c51c8a2d.tar.zst dexon-mcl-635a1d26596f1c3cdec423154eeb7a12c51c8a2d.zip |
rename MclElgamal to Elgamal
-rw-r--r-- | java/ElgamalTest.java (renamed from java/MclElgamalTest.java) | 18 | ||||
-rw-r--r-- | java/Makefile | 22 | ||||
-rw-r--r-- | java/com/herumi/mcl/CipherText.java | 16 | ||||
-rw-r--r-- | java/com/herumi/mcl/Elgamal.java (renamed from java/com/herumi/mcl/MclElgamal.java) | 14 | ||||
-rw-r--r-- | java/com/herumi/mcl/ElgamalJNI.java (renamed from java/com/herumi/mcl/MclElgamalJNI.java) | 2 | ||||
-rw-r--r-- | java/com/herumi/mcl/PrivateKey.java | 26 | ||||
-rw-r--r-- | java/com/herumi/mcl/PublicKey.java | 24 | ||||
-rw-r--r-- | java/elgamal.hpp (renamed from java/mcl_elgamal.hpp) | 0 | ||||
-rw-r--r-- | java/elgamal.i (renamed from java/mcl_elgamal.i) | 6 | ||||
-rwxr-xr-x | java/make_wrap.bat | 8 | ||||
-rwxr-xr-x | java/run-elgamal.bat | 8 | ||||
-rwxr-xr-x | java/run-mcl_elgamal.bat | 8 |
12 files changed, 75 insertions, 77 deletions
diff --git a/java/MclElgamalTest.java b/java/ElgamalTest.java index e055787..0cf49e1 100644 --- a/java/MclElgamalTest.java +++ b/java/ElgamalTest.java @@ -2,13 +2,13 @@ import java.io.*; import com.herumi.mcl.*; /* - MclElgamalTest [ecParam] + ElgamalTest [ecParam] ecParam = secp192k1, NIST_P224, ... hashParam = hash224, hash384, ... */ -public class MclElgamalTest { +public class ElgamalTest { static { - String lib = "mcl_elgamal_wrap"; + String lib = "mcl_elgamal"; String libName = System.mapLibraryName(lib); System.out.println("libName : " + libName); System.loadLibrary(lib); @@ -43,7 +43,7 @@ public class MclElgamalTest { } String param = ecStr + " " + hashStr; System.out.println("param=" + param); - MclElgamal.SystemInit(param); + Elgamal.SystemInit(param); String prvStr = ""; String pubStr = ""; @@ -124,19 +124,19 @@ public class MclElgamalTest { String m3 = "-2000000"; String m4 = "2001234"; CipherText c2 = new CipherText(); - SWIGTYPE_p_bool b = MclElgamal.new_p_bool(); + SWIGTYPE_p_bool b = Elgamal.new_p_bool(); pub.enc(c, m3); dec = prv.dec(c, b); - assertBool("expect dec fail", !MclElgamal.p_bool_value(b)); + assertBool("expect dec fail", !Elgamal.p_bool_value(b)); pub.enc(c2, m4); dec = prv.dec(c2, b); - assertBool("expect dec fail", !MclElgamal.p_bool_value(b)); + assertBool("expect dec fail", !Elgamal.p_bool_value(b)); c.add(c2); // m3 + m4 dec = prv.dec(c, b); assertEquals("int add", 1234, dec); - assertBool("expect dec success", MclElgamal.p_bool_value(b)); - MclElgamal.delete_p_bool(b); + assertBool("expect dec success", Elgamal.p_bool_value(b)); + Elgamal.delete_p_bool(b); } catch (RuntimeException e) { System.out.println("unknown exception :" + e); } diff --git a/java/Makefile b/java/Makefile index 78f657f..3295f82 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_elgamal_wrap.$(LIB_SUF) +TARGET=../bin/libmcl_elgamal.$(LIB_SUF) JAVA_EXE=cd ../bin && LD_LIBRARY_PATH=./:$(LD_LIBRARY_PATH) java -classpath ../java all: $(TARGET) -mcl_elgamal_wrap.cxx: mcl_elgamal.i mcl_elgamal.hpp +elgamal_wrap.cxx: elgamal.i elgamal.hpp $(MKDIR) $(PACKAGE_DIR) - swig -java -package $(PACKAGE_NAME) -outdir $(PACKAGE_DIR) -c++ -Wall mcl_elgamal.i + swig -java -package $(PACKAGE_NAME) -outdir $(PACKAGE_DIR) -c++ -Wall elgamal.i $(MCL_LIB): make -C .. -$(TARGET): mcl_elgamal_wrap.cxx $(MCL_LIB) +$(TARGET): elgamal_wrap.cxx $(MCL_LIB) $(PRE)$(CXX) $< -o $@ $(CFLAGS) $(LDFLAGS) $(MCL_LIB) -shared %.class: %.java javac $< -MclElgamalTest.class: MclElgamalTest.java $(TARGET) +ElgamalTest.class: ElgamalTest.java $(TARGET) jar: 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 +test_elgamal: ElgamalTest.class $(TARGET) + $(JAVA_EXE) ElgamalTest + $(JAVA_EXE) ElgamalTest -e NIST_P192 + $(JAVA_EXE) ElgamalTest -e NIST_P256 -h sha256 + $(JAVA_EXE) ElgamalTest -e NIST_P384 -h sha384 + $(JAVA_EXE) ElgamalTest -e NIST_P521 -h sha512 clean: rm -rf *.class $(TARGET) $(PACKAGE_DIR)/*.class diff --git a/java/com/herumi/mcl/CipherText.java b/java/com/herumi/mcl/CipherText.java index 6323ba9..4584755 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; - MclElgamalJNI.delete_CipherText(swigCPtr); + ElgamalJNI.delete_CipherText(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclElgamalJNI.CipherText_toStr(swigCPtr, this); + return ElgamalJNI.CipherText_toStr(swigCPtr, this); } public String toString() { - return MclElgamalJNI.CipherText_toString(swigCPtr, this); + return ElgamalJNI.CipherText_toString(swigCPtr, this); } public void fromStr(String str) { - MclElgamalJNI.CipherText_fromStr(swigCPtr, this, str); + ElgamalJNI.CipherText_fromStr(swigCPtr, this, str); } public void add(CipherText c) { - MclElgamalJNI.CipherText_add(swigCPtr, this, CipherText.getCPtr(c), c); + ElgamalJNI.CipherText_add(swigCPtr, this, CipherText.getCPtr(c), c); } public void mul(int m) { - MclElgamalJNI.CipherText_mul__SWIG_0(swigCPtr, this, m); + ElgamalJNI.CipherText_mul__SWIG_0(swigCPtr, this, m); } public void mul(String str) { - MclElgamalJNI.CipherText_mul__SWIG_1(swigCPtr, this, str); + ElgamalJNI.CipherText_mul__SWIG_1(swigCPtr, this, str); } public CipherText() { - this(MclElgamalJNI.new_CipherText(), true); + this(ElgamalJNI.new_CipherText(), true); } } diff --git a/java/com/herumi/mcl/MclElgamal.java b/java/com/herumi/mcl/Elgamal.java index 6a5bb8b..95beb30 100644 --- a/java/com/herumi/mcl/MclElgamal.java +++ b/java/com/herumi/mcl/Elgamal.java @@ -8,31 +8,31 @@ package com.herumi.mcl; -public class MclElgamal { +public class Elgamal { public static SWIGTYPE_p_bool new_p_bool() { - long cPtr = MclElgamalJNI.new_p_bool(); + long cPtr = ElgamalJNI.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 = MclElgamalJNI.copy_p_bool(value); + long cPtr = ElgamalJNI.copy_p_bool(value); return (cPtr == 0) ? null : new SWIGTYPE_p_bool(cPtr, false); } public static void delete_p_bool(SWIGTYPE_p_bool obj) { - MclElgamalJNI.delete_p_bool(SWIGTYPE_p_bool.getCPtr(obj)); + ElgamalJNI.delete_p_bool(SWIGTYPE_p_bool.getCPtr(obj)); } public static void p_bool_assign(SWIGTYPE_p_bool obj, boolean value) { - MclElgamalJNI.p_bool_assign(SWIGTYPE_p_bool.getCPtr(obj), value); + ElgamalJNI.p_bool_assign(SWIGTYPE_p_bool.getCPtr(obj), value); } public static boolean p_bool_value(SWIGTYPE_p_bool obj) { - return MclElgamalJNI.p_bool_value(SWIGTYPE_p_bool.getCPtr(obj)); + return ElgamalJNI.p_bool_value(SWIGTYPE_p_bool.getCPtr(obj)); } public static void SystemInit(String param) { - MclElgamalJNI.SystemInit(param); + ElgamalJNI.SystemInit(param); } } diff --git a/java/com/herumi/mcl/MclElgamalJNI.java b/java/com/herumi/mcl/ElgamalJNI.java index 57a4e5c..f2f09a9 100644 --- a/java/com/herumi/mcl/MclElgamalJNI.java +++ b/java/com/herumi/mcl/ElgamalJNI.java @@ -8,7 +8,7 @@ package com.herumi.mcl; -public class MclElgamalJNI { +public class ElgamalJNI { 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 fae42b9..10c01bd 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; - MclElgamalJNI.delete_PrivateKey(swigCPtr); + ElgamalJNI.delete_PrivateKey(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclElgamalJNI.PrivateKey_toStr(swigCPtr, this); + return ElgamalJNI.PrivateKey_toStr(swigCPtr, this); } public String toString() { - return MclElgamalJNI.PrivateKey_toString(swigCPtr, this); + return ElgamalJNI.PrivateKey_toString(swigCPtr, this); } public void fromStr(String str) { - MclElgamalJNI.PrivateKey_fromStr(swigCPtr, this, str); + ElgamalJNI.PrivateKey_fromStr(swigCPtr, this, str); } public void save(String fileName) { - MclElgamalJNI.PrivateKey_save(swigCPtr, this, fileName); + ElgamalJNI.PrivateKey_save(swigCPtr, this, fileName); } public void load(String fileName) { - MclElgamalJNI.PrivateKey_load(swigCPtr, this, fileName); + ElgamalJNI.PrivateKey_load(swigCPtr, this, fileName); } public void init() { - MclElgamalJNI.PrivateKey_init(swigCPtr, this); + ElgamalJNI.PrivateKey_init(swigCPtr, this); } public PublicKey getPublicKey() { - return new PublicKey(MclElgamalJNI.PrivateKey_getPublicKey(swigCPtr, this), true); + return new PublicKey(ElgamalJNI.PrivateKey_getPublicKey(swigCPtr, this), true); } public int dec(CipherText c, SWIGTYPE_p_bool b) { - return MclElgamalJNI.PrivateKey_dec__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, SWIGTYPE_p_bool.getCPtr(b)); + return ElgamalJNI.PrivateKey_dec__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, SWIGTYPE_p_bool.getCPtr(b)); } public int dec(CipherText c) { - return MclElgamalJNI.PrivateKey_dec__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c); + return ElgamalJNI.PrivateKey_dec__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c); } public void setCache(int rangeMin, int rangeMax) { - MclElgamalJNI.PrivateKey_setCache(swigCPtr, this, rangeMin, rangeMax); + ElgamalJNI.PrivateKey_setCache(swigCPtr, this, rangeMin, rangeMax); } public void clearCache() { - MclElgamalJNI.PrivateKey_clearCache(swigCPtr, this); + ElgamalJNI.PrivateKey_clearCache(swigCPtr, this); } public PrivateKey() { - this(MclElgamalJNI.new_PrivateKey(), true); + this(ElgamalJNI.new_PrivateKey(), true); } } diff --git a/java/com/herumi/mcl/PublicKey.java b/java/com/herumi/mcl/PublicKey.java index 4c76977..1e6c63f 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; - MclElgamalJNI.delete_PublicKey(swigCPtr); + ElgamalJNI.delete_PublicKey(swigCPtr); } swigCPtr = 0; } } public String toStr() { - return MclElgamalJNI.PublicKey_toStr(swigCPtr, this); + return ElgamalJNI.PublicKey_toStr(swigCPtr, this); } public String toString() { - return MclElgamalJNI.PublicKey_toString(swigCPtr, this); + return ElgamalJNI.PublicKey_toString(swigCPtr, this); } public void fromStr(String str) { - MclElgamalJNI.PublicKey_fromStr(swigCPtr, this, str); + ElgamalJNI.PublicKey_fromStr(swigCPtr, this, str); } public void save(String fileName) { - MclElgamalJNI.PublicKey_save(swigCPtr, this, fileName); + ElgamalJNI.PublicKey_save(swigCPtr, this, fileName); } public void load(String fileName) { - MclElgamalJNI.PublicKey_load(swigCPtr, this, fileName); + ElgamalJNI.PublicKey_load(swigCPtr, this, fileName); } public void enc(CipherText c, int m) { - MclElgamalJNI.PublicKey_enc__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); + ElgamalJNI.PublicKey_enc__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); } public void enc(CipherText c, String str) { - MclElgamalJNI.PublicKey_enc__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); + ElgamalJNI.PublicKey_enc__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); } public void rerandomize(CipherText c) { - MclElgamalJNI.PublicKey_rerandomize(swigCPtr, this, CipherText.getCPtr(c), c); + ElgamalJNI.PublicKey_rerandomize(swigCPtr, this, CipherText.getCPtr(c), c); } public void add(CipherText c, int m) { - MclElgamalJNI.PublicKey_add__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); + ElgamalJNI.PublicKey_add__SWIG_0(swigCPtr, this, CipherText.getCPtr(c), c, m); } public void add(CipherText c, String str) { - MclElgamalJNI.PublicKey_add__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); + ElgamalJNI.PublicKey_add__SWIG_1(swigCPtr, this, CipherText.getCPtr(c), c, str); } public PublicKey() { - this(MclElgamalJNI.new_PublicKey(), true); + this(ElgamalJNI.new_PublicKey(), true); } } diff --git a/java/mcl_elgamal.hpp b/java/elgamal.hpp index 034c7ad..034c7ad 100644 --- a/java/mcl_elgamal.hpp +++ b/java/elgamal.hpp diff --git a/java/mcl_elgamal.i b/java/elgamal.i index 9fc3c50..208a8ab 100644 --- a/java/mcl_elgamal.i +++ b/java/elgamal.i @@ -1,4 +1,4 @@ -%module MclElgamal +%module Elgamal %include "std_string.i" %include "std_except.i" @@ -20,9 +20,9 @@ static inline Param& getParam() } }; -#include "mcl_elgamal.hpp" +#include "elgamal.hpp" %} %include cpointer.i %pointer_functions(bool, p_bool); -%include "mcl_elgamal.hpp" +%include "elgamal.hpp" diff --git a/java/make_wrap.bat b/java/make_wrap.bat index 9a8af79..e658c33 100755 --- a/java/make_wrap.bat +++ b/java/make_wrap.bat @@ -7,13 +7,11 @@ set PACKAGE_DIR=%PACKAGE_NAME:.=\% echo [[run swig]] mkdir %PACKAGE_DIR% -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 +%SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall elgamal.i echo [[make 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 +cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc 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.dll -call run-mcl_elgamal.bat +call run-elgamal.bat echo [[make jar]] %JAVA_DIR%\bin\jar cvf mcl_elgamal.jar com
\ No newline at end of file diff --git a/java/run-elgamal.bat b/java/run-elgamal.bat new file mode 100755 index 0000000..0b57938 --- /dev/null +++ b/java/run-elgamal.bat @@ -0,0 +1,8 @@ +@echo off +echo [[compile ElgamalTest.java]] +%JAVA_DIR%\bin\javac ElgamalTest.java + +echo [[run ElgamalTest]] +pushd ..\bin +%JAVA_DIR%\bin\java -classpath ..\java ElgamalTest %1 %2 %3 %4 %5 %6 +popd diff --git a/java/run-mcl_elgamal.bat b/java/run-mcl_elgamal.bat deleted file mode 100755 index 507e215..0000000 --- a/java/run-mcl_elgamal.bat +++ /dev/null @@ -1,8 +0,0 @@ -@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 |