Add Fr.setHash() to JNI

update-fork
Johannes Gallmann 4 years ago
parent 1b8b3fcf92
commit 7fb2ee5bb7
  1. 5
      ffi/java/MclTest.java
  2. 4
      ffi/java/com/herumi/mcl/Fr.java
  3. 1
      ffi/java/com/herumi/mcl/MclJNI.java
  4. 10
      ffi/java/mcl_impl.hpp
  5. 31
      ffi/java/mcl_wrap.cxx

@ -53,6 +53,11 @@ public class MclTest {
assertBool("serialize", x.equals(t));
t.setLittleEndianMod(b);
assertBool("setLittleEndianMod", x.equals(t));
t.setHashOf(b);
assertBool("setHashOf", !x.equals(t));
Fr u = new Fr();
u.setHashOf(new byte[]{1,2,3});
assertBool("setHashOf - different", !u.equals(t));
}
G1 P = new G1();
System.out.println("P=" + P);

@ -100,6 +100,10 @@ public class Fr {
MclJNI.Fr_setLittleEndianMod(swigCPtr, this, cbuf);
}
public void setHashOf(byte[] cbuf) {
MclJNI.Fr_setHashOf(swigCPtr, this, cbuf);
}
public byte[] serialize() { return MclJNI.Fr_serialize(swigCPtr, this); }
}

@ -34,6 +34,7 @@ public class MclJNI {
public final static native String Fr_toString__SWIG_1(long jarg1, Fr jarg1_);
public final static native void Fr_deserialize(long jarg1, Fr jarg1_, byte[] jarg2);
public final static native void Fr_setLittleEndianMod(long jarg1, Fr jarg1_, byte[] jarg2);
public final static native void Fr_setHashOf(long jarg1, Fr jarg1_, byte[] jarg2);
public final static native byte[] Fr_serialize(long jarg1, Fr jarg1_);
public final static native void delete_Fr(long jarg1);
public final static native void neg__SWIG_1(long jarg1, Fp jarg1_, long jarg2, Fp jarg2_);

@ -34,6 +34,12 @@ void setLittleEndianModT(T& x, const char *cbuf, size_t bufSize)
x.setLittleEndianMod(cbuf, bufSize);
}
template<class T>
void setHashOfT(T& x, const char *cbuf, size_t bufSize)
{
x.setHashOf(cbuf, bufSize);
}
template<class T>
void serializeT(std::string& out, const T& x)
{
@ -98,6 +104,10 @@ public:
{
setLittleEndianModT(self_, cbuf, bufSize);
}
void setHashOf(const char *cbuf, size_t bufSize) throw(std::exception)
{
setHashOfT(self_, cbuf, bufSize);
}
void serialize(std::string& out) const throw(std::exception)
{
serializeT(out, self_);

@ -820,6 +820,37 @@ SWIGEXPORT void JNICALL Java_com_herumi_mcl_MclJNI_Fr_1setLittleEndianMod(JNIEnv
}
SWIGEXPORT void JNICALL Java_com_herumi_mcl_MclJNI_Fr_1setHashOf(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jbyteArray jarg2) {
Fr *arg1 = (Fr *) 0 ;
char *arg2 = (char *) 0 ;
size_t arg3 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(Fr **)&jarg1;
{
if (jarg2) {
arg2 = (char *) jenv->GetByteArrayElements(jarg2, 0);
arg3 = (size_t) jenv->GetArrayLength(jarg2);
} else {
arg2 = 0;
arg3 = 0;
}
}
try {
(arg1)->setHashOf((char const *)arg2,arg3);
} catch(std::exception &_e) {
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, (&_e)->what());
return ;
}
{
if (jarg2) jenv->ReleaseByteArrayElements(jarg2, (jbyte *)arg2, 0);
}
}
SWIGEXPORT jbyteArray JNICALL Java_com_herumi_mcl_MclJNI_Fr_1serialize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jbyteArray jresult = 0 ;
Fr *arg1 = (Fr *) 0 ;

Loading…
Cancel
Save