fix encoding bitSize of Elgamal::PublicKey for Java

dev
MITSUNARI Shigeo 7 years ago
parent ea84028d95
commit 1e39f8caa4
  1. 3
      Makefile
  2. 11
      ffi/java/bn256_wrap.cxx
  3. 1129
      ffi/java/elgamal_wrap.cxx
  4. 5
      ffi/java/make_wrap.bat
  5. 5
      ffi/java/run-bn256.bat
  6. 5
      ffi/java/run-elgamal.bat
  7. 10
      include/mcl/elgamal.hpp

@ -195,6 +195,9 @@ test_go:
$(MAKE) test_go256
$(MAKE) test_go384
test_java:
$(MAKE) -C ffi/java test
##################################################################
VPATH=test sample src

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.8
* Version 3.0.12
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@ -105,9 +105,11 @@ template <typename T> T SwigValueInit() {
#endif
/* exporting methods */
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
#if defined(__GNUC__)
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif
# endif
#endif
@ -231,6 +233,7 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC
#include <string>
#include <typeinfo>
#include <stdexcept>

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
@echo off
call set-java-path.bat
set JAVA_INCLUDE=%JAVA_DIR%\include
set SWIG=..\..\..\p\swig\swig.exe
set SWIG=..\..\..\..\p\swig\swig.exe
set PACKAGE_NAME=com.herumi.mcl
set PACKAGE_DIR=%PACKAGE_NAME:.=\%
if /i "%1"=="" (
@ -12,9 +12,10 @@ if /i "%1"=="" (
echo [[run swig]]
mkdir %PACKAGE_DIR%
set TOP_DIR=../..
%SWIG% -java -package %PACKAGE_NAME% -outdir %PACKAGE_DIR% -c++ -Wall %NAME%.i
echo [[make dll]]
cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc %NAME%_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_%NAME%.dll
cl /MT /DNOMINMAX /LD /Ox /DNDEBUG /EHsc %NAME%_wrap.cxx %TOP_DIR%/src/fp.cpp -DMCL_NO_AUTOLINK -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win32 -I%TOP_DIR%/include -I%TOP_DIR%/../cybozulib/include -I%TOP_DIR%/../cybozulib_ext/include -I%TOP_DIR%/../xbyak /link /LIBPATH:%TOP_DIR%/../cybozulib_ext/lib /OUT:%TOP_DIR%/bin/mcl_%NAME%.dll
call run-%NAME%.bat

@ -3,6 +3,7 @@ echo [[compile Bn256Test.java]]
%JAVA_DIR%\bin\javac Bn256Test.java
echo [[run Bn256Test]]
pushd ..\bin
%JAVA_DIR%\bin\java -classpath ..\java Bn256Test %1 %2 %3 %4 %5 %6
set TOP_DIR=..\..
pushd %TOP_DIR%\bin
%JAVA_DIR%\bin\java -classpath ../ffi/java Bn256Test %1 %2 %3 %4 %5 %6
popd

@ -3,6 +3,7 @@ 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
set TOP_DIR=..\..
pushd %TOP_DIR%\bin
%JAVA_DIR%\bin\java -classpath ../ffi/java ElgamalTest %1 %2 %3 %4 %5 %6
popd

@ -222,6 +222,7 @@ struct ElgamalT {
this->g = g;
this->h = h;
enableWindowMethod_ = false;
enableWindowMethod();
}
/*
encode message
@ -362,7 +363,9 @@ struct ElgamalT {
template<class InputStream>
void load(InputStream& is, int ioMode = IoSerialize)
{
cybozu::load(bitSize, is);
std::string s;
mcl::fp::local::loadWord(s, is);
bitSize = cybozu::atoi(s);
f.load(is, ioMode);
g.load(is, ioMode);
h.load(is, ioMode);
@ -371,8 +374,11 @@ struct ElgamalT {
template<class OutputStream>
void save(OutputStream& os, int ioMode = IoSerialize) const
{
std::string s = cybozu::itoa(bitSize);
cybozu::write(os, s.c_str(), s.size());
cybozu::writeChar(os, ' ');
const char sep = *fp::getIoSeparator(ioMode);
cybozu::save(os, bitSize);
f.save(os, ioMode);
if (sep) cybozu::writeChar(os, sep);
g.save(os, ioMode);

Loading…
Cancel
Save