herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

Feature Request: Allow seed to be specified via JNI #103

Closed stewartie4 closed 3 years ago

stewartie4 commented 3 years ago

Fp holds an instance of RandGen: a wrapper for a random generator. In C++, this random function can be overridden, for example in the case where a seed has previously been generated mcl::fp::RandGen::setRandFunc(self, readFunc);

Indeed, most of the libraries that use this library (bls-go, bls-js etc.) have a "setRand" binding which maps to the above code. However, the instance of RandGen is inaccessible from the swig generated JNI and therefore the java bindings do not have the ability to specify a seed like you can in C.

I have spent hours trying adding the boiler plate to get the following binding to work in Java: Mcl.setRandData(byte[] seed); which would do the above under the hood but to no avail.

stewartie4 commented 3 years ago

Closing as I have resolved this on fork. Will open a PR shortly.