-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NODE-2604 Add code from wavesplatform/groth16verify (#23)
- Loading branch information
1 parent
ab9a8fe
commit 9c424ed
Showing
37 changed files
with
1,039 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.aarch64-unknown-linux-gnu] | ||
linker = "aarch64-linux-gnu-gcc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
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 ] | ||
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: Print debug information | ||
run: | | ||
cd ./zwaves_jni/javalib | ||
# About -q: https://github.com/gradle/gradle/issues/5098#issuecomment-1084652709 | ||
VERSION=$(./gradlew -q $GRADLE_EXTRA_ARGS printVersion) | ||
PUBLISHING_TYPE=$(./gradlew -q $GRADLE_EXTRA_ARGS publishingType) | ||
# echo "$GITHUB_CONTEXT" # For debugging purposes | ||
echo "Gradle extra arguments: ${GRADLE_EXTRA_ARGS}" | ||
echo "Building ${VERSION}, publishing type: ${PUBLISHING_TYPE}" | ||
# Make environment variables available in the next step | ||
echo "PUBLISHING_TYPE=${PUBLISHING_TYPE}" >> $GITHUB_ENV | ||
- name: Run tests | ||
run: | | ||
cd zwaves_jni/javalib | ||
./gradlew ${GRADLE_EXTRA_ARGS} test | ||
- name: Publish snapshot version | ||
if: ${{ env.PUBLISHING_TYPE == 'snapshot' }} | ||
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 }}' | ||
- name: Publish staging version | ||
if: ${{ env.PUBLISHING_TYPE == 'staging' }} | ||
run: | | ||
cd zwaves_jni/javalib | ||
./gradlew ${GRADLE_EXTRA_ARGS} publishToSonatype closeAndReleaseSonatypeStagingRepository \ | ||
-PsonatypeUsername='${{ secrets.OSSRH_USERNAME }}' \ | ||
-PsonatypePassword='${{ secrets.OSSRH_PASSWORD }}' \ | ||
-PgpgKey='${{ secrets.OSSRH_GPG_KEY_ASCII }}' \ | ||
-PgpgPassphrase='${{ secrets.OSSRH_GPG_PASSPHRASE }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ bin/ | |
pkg/ | ||
wasm-pack.log | ||
.vscode | ||
.idea | ||
!zwaves_jni/src/bn256/bin | ||
!zwaves_setup/src/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>"] | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,86 @@ | ||
/* | ||
* 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" | ||
} | ||
|
||
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' | ||
def pr() { project.findProperty('pr').toString() ?: "" } | ||
|
||
// This dependency is used internally, and not exposed to consumers on their own compile classpath. | ||
implementation 'com.google.guava:guava:27.0.1-jre' | ||
def refName() { project.findProperty('refName').toString() ?: "" } | ||
|
||
// Use JUnit test framework | ||
testImplementation 'junit:junit:4.12' | ||
ext { | ||
baseVersion = "0.1.7" | ||
|
||
publishingType = { | ||
if (pr()?.isNumber()) "snapshot" else if (refName() == "v${baseVersion}") "staging" else "prohibited" | ||
} | ||
|
||
artifactVersion = { | ||
if (pr()?.isNumber()) "${baseVersion}-${pr()}-SNAPSHOT" else baseVersion | ||
} | ||
} | ||
|
||
group = "com.wavesplatform" | ||
archivesBaseName = "zwaves" | ||
version = artifactVersion() | ||
|
||
dependencies { | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
|
||
test { | ||
useJUnit() | ||
|
||
maxHeapSize = '1G' | ||
} | ||
|
||
tasks.register('printVersion') { | ||
doLast { | ||
println version | ||
} | ||
} | ||
|
||
tasks.register('publishingType') { | ||
doLast { | ||
println publishingType() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
|
||
pom { | ||
packaging = 'jar' | ||
url = 'https://github.com/wavesplatform/zwaves' | ||
licenses { | ||
license { | ||
name.set("MIT License") | ||
url.set("LICENSE") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:git://github.com/wavesplatform/zwaves.git") | ||
developerConnection.set("scm:git:[email protected]:wavesplatform/zwaves.git") | ||
url.set("https://github.com/wavesplatform/zwaves") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys(gpgKey, gpgPassphrase) | ||
sign configurations.archives | ||
} | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sonatypeRepo= | ||
sonatypeUsername= | ||
sonatypePassword= | ||
gpgKey= | ||
gpgPassphrase= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.