Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ac05245
- Added code from bn254 at wavesplatform/groth16verify;
vsuharnikov Sep 28, 2023
f5c8908
CI
vsuharnikov Sep 28, 2023
504f5cd
- New tests for groth16;
vsuharnikov Sep 29, 2023
d83c8c8
- Running Rust tests in build;
vsuharnikov Oct 2, 2023
a20f27e
Fix running Rust tests
vsuharnikov Oct 2, 2023
97c7a55
Fix running Rust tests (2)
vsuharnikov Oct 2, 2023
fd690b7
Run Java tests
vsuharnikov Oct 2, 2023
1662eaf
- Build for more platforms;
vsuharnikov Oct 2, 2023
9bdcb8f
Build fix
vsuharnikov Oct 2, 2023
8b635ee
Build fix (2)
vsuharnikov Oct 2, 2023
3ab7d13
Build fix (3)
vsuharnikov Oct 2, 2023
a33ba90
Build fix (4)
vsuharnikov Oct 2, 2023
6492664
Build fix (5)
vsuharnikov Oct 2, 2023
c749dda
Build fix (6)
vsuharnikov Oct 2, 2023
a8a422d
Build fix (7)
vsuharnikov Oct 2, 2023
28f88f0
Build fix (8)
vsuharnikov Oct 2, 2023
372d897
Build fix (9)
vsuharnikov Oct 2, 2023
191bae4
Build fix (10)
vsuharnikov Oct 2, 2023
5441e17
Build fix (11): extra packages
vsuharnikov Oct 2, 2023
549b87c
Build fix (12): extra packages
vsuharnikov Oct 2, 2023
fc70ccd
Build fix (13): windows build
vsuharnikov Oct 2, 2023
ad2d769
Build fix (14): windows build
vsuharnikov Oct 2, 2023
faa3d2b
Build fix (15): windows build
vsuharnikov Oct 2, 2023
12ec4e8
Build fix (16): windows build (x86)
vsuharnikov Oct 3, 2023
0f90103
Build fix (17): windows build (x86), msvc
vsuharnikov Oct 3, 2023
14e4148
Build fix (18): windows build, msvc
vsuharnikov Oct 3, 2023
f954ab3
Build fix (19): all platforms test
vsuharnikov Oct 3, 2023
ea3c71f
Build fix (20): fixed the native libraries directory structure
vsuharnikov Oct 3, 2023
2000724
Publishing (WIP)
vsuharnikov Oct 11, 2023
48079a6
Publishing (2)
vsuharnikov Oct 11, 2023
166cd0d
Publishing (3), snapshot publications work
vsuharnikov Oct 11, 2023
a4099ef
Publishing staging version test
vsuharnikov Oct 12, 2023
cafe871
Publishing staging version test (2)
vsuharnikov Oct 12, 2023
4b7d874
Publishing staging version test (3)
vsuharnikov Oct 12, 2023
dfea3df
Publishing staging version with io.github.gradle-nexus.publish-plugin…
vsuharnikov Oct 12, 2023
03028fe
Publishing staging version with io.github.gradle-nexus.publish-plugin…
vsuharnikov Oct 12, 2023
bb71b0a
wip
phearnot Oct 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
155 changes: 155 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Publish artifacts to Sonatype Repo

on:
push:
branches:
- master
- version-[0-9].[0-9]+.x
tags:
- v[0-9].[0-9]+.[0-9]+
pull_request:

env:
NATIVE_DIR: zwaves_jni/javalib/src/main/resources/META-INF/native
GRADLE_EXTRA_ARGS: --console=plain -Ppr=${{ github.event.number }} -PrefName=${{ github.head_ref }}
# GITHUB_CONTEXT: ${{ toJson(github) }} # For debugging purposes

jobs:
build-native:
name: ${{ matrix.platform }}/${{ matrix.arch }} library
runs-on: ${{ matrix.os }}
env:
# Where a library should be
target-path: ${{ matrix.jni-platform }}/${{ matrix.arch }}

# Rust build target
build-target: ${{ matrix.build-arch }}-${{ matrix.build-platform }}

# Rust target directory
TARGET_DIR: ./target

# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
# platform: [ linux, osx, windows ]
# arch: [ aarch64, amd64, x86 ]
platform: [ linux ]
arch: [ amd64 ]
exclude:
- platform: osx
arch: x86
- platform: windows
arch: aarch64

include:
- platform: linux
os: ubuntu-20.04
build-platform: unknown-linux-gnu
artifact: libzwaves_jni.so
jni-platform: linux64

# - platform: linux
# arch: aarch64
# extra-packages: gcc-aarch64-linux-gnu
#
# - platform: linux
# arch: x86
# extra-packages: gcc-multilib
# jni-platform: linux32
#
# - platform: osx
# os: macos-latest
# build-platform: apple-darwin
# artifact: libzwaves_jni.dylib
# jni-platform: osx64
#
# - platform: windows
# os: windows-2019
# build-platform: pc-windows-msvc # x86 and gcc lead to "undefined reference to _Unwind_Resume"
# artifact: zwaves_jni.dll
# jni-platform: windows64
#
# - platform: windows
# arch: x86
# jni-platform: windows32
#
# - arch: aarch64
# build-arch: aarch64

- arch: amd64
build-arch: x86_64

# - arch: x86
# build-arch: i686
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Print debug information
run: |
echo "Build target: ${{ env.build-target }}"
echo "Target path: ${{ env.target-path }}"

- name: Install build tools
if: ${{ matrix.extra-packages }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.extra-packages }}

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ env.build-target }}

- name: Enable Rust dependencies caching
uses: Swatinem/rust-cache@v2

- name: Run Rust tests
# Architecture is always x86-64: https://stackoverflow.com/a/71220337
if: matrix.arch == 'amd64'
run: |
cd zwaves_jni
cargo test --lib --target ${{ env.build-target }}

- name: Build native libraries
run: |
cd zwaves_jni
cargo build --release --target ${{ env.build-target }}
cd ..

cp target/${{ env.build-target }}/release/${{ matrix.artifact }} ${{ env.NATIVE_DIR }}/${{ env.target-path }}

- name: Upload result
uses: actions/upload-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}/**/*

build-jni:
name: Build JNI library
runs-on: ubuntu-20.04
needs: build-native
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
cache: gradle

- uses: actions/download-artifact@v3
with:
name: native-libraries
path: ${{ env.NATIVE_DIR }}

- name: Publish version
run: |
cd zwaves_jni/javalib
./gradlew ${GRADLE_EXTRA_ARGS} publishToSonatype \
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \
-PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ bin/
pkg/
wasm-pack.log
.vscode
.idea
!zwaves_jni/src/bn256/bin
!zwaves_setup/src/bin
7 changes: 7 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
edition = "2018"

max_width = 120
hard_tabs = false
newline_style = "Unix"

imports_granularity = "Crate"
13 changes: 0 additions & 13 deletions zwaves_jni/.cargo/config

This file was deleted.

18 changes: 16 additions & 2 deletions zwaves_jni/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
[package]
name = "zwaves_jni"
version = "0.1.0"
version = "0.2.0"
authors = ["Igor Gulamov <igor.gulamov@gmail.com>"]
edition = "2018"

[lib]
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]
name = "zwaves_jni"

[[bin]]
path = "src/bn256/bin/show_test_vectors.rs"
name="show_test_vectors"

[dependencies]
bellman = { version = "0.1.0" }
zwaves_primitives = { path = "../zwaves_primitives"}
sapling-crypto = { path = "../sapling-crypto" }
pairing = "0.14"
pairing_ce = "0.18" # for bn256
num = "0.2"
serde = { version = "1.0", features = ["derive"] }
base64 = "0.11.0"
jni = "0.14.0"
byteorder = "1"
rand = "0.4"

# for bn256
[dependencies.ff]
version = "=0.7"
features = ["derive"]
package = "ff_ce"

[dev-dependencies]
test-case = "3.2.1"
9 changes: 0 additions & 9 deletions zwaves_jni/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
if [ ! -d "osxcross" ]; then
git clone https://github.com/tpoechtrager/osxcross
pushd osxcross
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz
mv MacOSX10.10.sdk.tar.xz tarballs/
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
popd
fi

cargo build --target=i686-unknown-linux-gnu --release
cp ../target/i686-unknown-linux-gnu/release/libzwaves_jni.so javalib/src/main/resources/META-INF/native/linux32

Expand Down
62 changes: 40 additions & 22 deletions zwaves_jni/javalib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.4.1/userguide/java_library_plugin.html
*/

plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id "java-library"
id "maven-publish"
id "signing"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}

group = "com.wavesplatform"
version = "0.2.0"

repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}

dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:27.0.1-jre'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}


test {
useJUnit()

maxHeapSize = '1G'
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
licenses {
license {
name.set("MIT License")
url.set("LICENSE")
}
}
scm {
connection.set("scm:git:git://github.com/wavesplatform/zwaves.git")
developerConnection.set("scm:git:git@github.com:wavesplatform/zwaves.git")
url.set("https://github.com/wavesplatform/zwaves")
}
}
}
}
}

signing {
useInMemoryPgpKeys(gpgKey, gpgPassphrase)
sign configurations.archives
}

nexusPublishing {
repositories {
sonatype()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified zwaves_jni/javalib/gradlew
100644 → 100755
Empty file.
9 changes: 0 additions & 9 deletions zwaves_jni/javalib/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/5.4.1/userguide/multi_project_builds.html
*/

rootProject.name = 'zwaves'
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package com.wavesplatform.zwaves.bls12;
package com.wavesplatform.zwaves;

import java.io.*;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -538,4 +538,4 @@ private boolean loadLibrary(ArrayList<Throwable> errors, String lib) {
return false;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.wavesplatform.zwaves;

public class ZWavesJNILibrary {
static {
new JNILibrary("zwaves_jni", ZWavesJNILibrary.class).load();
}

public static void init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class Groth16 {
public static native boolean verify(byte[] vk, byte[] proof, byte[] inputs);

static {
new JNILibrary("zwaves_jni", Groth16.class).load();
com.wavesplatform.zwaves.ZWavesJNILibrary.init();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.wavesplatform.zwaves.bn256;

public class Groth16 {
public static native boolean verify(byte[] vk, byte[] proof, byte[] inputs);

static {
com.wavesplatform.zwaves.ZWavesJNILibrary.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
place here libzwaves_jni.so file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
place here libzwaves_jni.dylib for Apple ARM file

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
place here zwaves_jni.dll file

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
place here zwaves_jni.dll file
Loading