ed25519-zebra/ed25519jni/scripts/jni_jar_prereq.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

Add JNI code for ed25519-zebra (#37) * Add JNI code for ed25519-zebra Add some code allowing other languages, via JNI, to interact with ed25519-zebra. The initial commit: - Allows users to obtain a random 32 byte signing key seed. - Allows users to obtain a 32 byte verification key from a signing key seed. - Allows users to sign arbitrary data. - Allows users to verify an Ed25519 signature. - Includes a Java file that can be used. - Includes some Scala-based JNI tests. * Review fixups - Minor Rust code optimizations. - Rust build optimizations. - Tweak the JNI JAR prereq script to match the new outputs. * Significant cleanup - More build system tidying. The primary goal is to try to firewall the JNI code from everything else. - README tidying. * Grab bag of improvements - Clean up the wrapper classes (streamlining, make constructors private, more mutability safety). - private -> public for a static variable intended for public usage. - Minor comment & build system cleanup. * Bump JNI version to 0.0.4-DEV Decided to bump the version to reflect earlier changes. * Hard-code the ed25519-zebra version for ed25519jni to use * Unify ed25519 JNI version Also add "-JNI" to assist with tagging and otherwise distinguish the JNI code from the main library version/code. * Add code to make VerificationKeyBytes comparison easier Also add a test suite for VerificationKeyBytes. * VerificationKeyBytes cleanup - Fix hashCode() override. - Add a test. - Remove unneecessary semicolons. * Add Signature to JNI Mirror the Signature struct from Rust and add some basic tests. Also do a bit of Scala test cleanup.
2021-02-26 14:58:38 -08:00
#!/usr/bin/env bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
if ${trace:-false}
then
set -x
fi
script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ed25519jni_jvm_dir="${script_dir}/../jvm"
ed25519jni_rust_dir="${script_dir}/../rust"
# Script to run in order to compile a JAR with the Ed25519 JNI libraries from Rust.
# Assumes SciJava's NativeLoader will be used.
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
nativeDir="${ed25519jni_jvm_dir}/natives/linux_64"
nativeSuffix="so"
elif [[ "$OSTYPE" == "darwin"* ]]; then
nativeDir="${ed25519jni_jvm_dir}/natives/osx_64"
nativeSuffix="dylib"
else
echo "JNI is unsupported on this OS. Exiting."
exit 1
fi
useDebug="0"
while getopts ":d" opt; do
case $opt in
d)
useDebug="1"
;;
esac
done
# Give priority to release directory, unless a debug flag was passed in.
mkdir -p ${nativeDir}
if [ ${useDebug} -eq "1" ]; then
mode=debug
else
mode=release
fi
if [[ -d ${ed25519jni_rust_dir}/target/${mode} ]] ; then
cp -f ${ed25519jni_rust_dir}/target/${mode}/libed25519jni.a ${nativeDir}
cp -f ${ed25519jni_rust_dir}/target/${mode}/libed25519jni.${nativeSuffix} ${nativeDir}
else
echo "Unable to obtain required libed25519jni ${mode} libraries. Exiting."
exit 1
fi