2.1 KiB
JNI
Code that provides a JNI
for the library is included. Allows any JNI-using language to interact with
specific ed25519-zebra
calls and provides a minor analogue for some Rust
classes, allowing for things like basic sanity checks of certain values. Tests
written in Scala have also been included.
Compilation / Library Usage
To build the JNI code, there are several steps. The exact path forward depends on the user's preferred deployment method. No matter what, the following steps must be performed at the beginning.
- Run
cargo build
in the root directory. This generates the core Rust code. - Run
cargo build
in theed25519jni/rust
subdirectory. This generates the Rust glue code libraries (libed25519jni.a
andlibed25519jni.{so/dylib}
).
From here, there are two deployment methods: Direct library usage and JARs.
JAR
It's possible to generate a JAR that can be loaded into a project via SciJava's NativeLoader, along with the Java JNI interface file. There are two exta steps to perform after the mandatory compilation steps.
- Run
jni_jar_prereq.sh
from theed25519/scripts
subdirectory. This performs some JAR setup steps. - Run
sbt clean publishLocal
from theed25519jni/jvm
subdirectory. This generates the finaled25519jni.jar
file.
Direct library usage
(NOTE: Future work will better accommodate this option. For now, users will have to develop their own solutions.)
Use a preferred method to load the Rust core and JNI libraries directly as needed. If necessary, include the JNI Java files too.
Testing
Run sbt test
from the ed25519jni/jvm
directory. Note that, in order to run
the tests, the JAR compilation method must be executed first.
Capabilities
Among other things, the JNI code can perform the following actions.
- Generate a random 32 byte signing key seed.
- Generate a 32 byte verification key from a signing key seed.
- Sign arbitrary data with a signing key seed.
- Verify a signature for arbitrary data with verification key bytes (32 bytes).