Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 9 additions & 37 deletions .github/workflows/mvn-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,12 @@ on:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
- uses: actions/cache@v2
with:
key: ${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
- name: Prepare version
id: maven-version
run: |
mvn_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
git_ref=${GITHUB_REF##*/}
pr_number=${{ github.event.number }}
if [[ $git_ref =~ v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
if [[ v$mvn_version != $git_ref ]] ; then
echo Maven version $mvn_version does not match tag $git_ref
exit 1
fi
elif [[ $pr_number != "" && $mvn_version =~ -SNAPSHOT$ ]] ; then
pattern="s/(.+)-SNAPSHOT/\1-"$pr_number"-SNAPSHOT/g"
mvn_version=$(echo $mvn_version | sed -E $pattern)
mvn versions:set -DnewVersion=$mvn_version -DgenerateBackupPoms=false -q -DforceStdout
elif [[ ! $mvn_version =~ -SNAPSHOT$ ]] ; then
echo Refusing to publish non-snapshot version $mvn_version
echo '::set-output name=skip-publish::true'
fi
- uses: samuelmeuli/[email protected]
if:
${{ steps.maven-version.outputs.skip-publish != 'true' }}
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_KEY_ASCII }}
gpg_passphrase: ${{ secrets.OSSRH_GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_PASSWORD }}
uses: wavesplatform/protobuf-schemas/.github/workflows/mvn-publish.yml@5b4331ab892b44ad1fdd71862654421482dcd49c
with:
github-ref-name: ${{ github.ref_name }}
github-event-number: ${{ github.event.number }}
secrets:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_GPG_KEY: ${{ secrets.OSSRH_GPG_KEY }}
OSSRH_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }}
32 changes: 7 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,13 @@ on:

jobs:
run_tests:

runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Run tests
run: mvn -B test -Dmaven.test.failure.ignore=true

- name: Publish test report
uses: scacap/action-surefire-report@v1
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
java-version: 11
distribution: temurin
cache: maven
- run: mvn -B test -Dmaven.test.failure.ignore=true
- uses: scacap/action-surefire-report@v1
92 changes: 62 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.wavesplatform</groupId>
<artifactId>waves-crypto</artifactId>
<version>2.0.5</version>
<version>2.0.6-SNAPSHOT</version>

<name>Waves Crypto for Java</name>
<description>Tools to work with cryptographic primitives used in the Waves blockchain</description>
Expand Down Expand Up @@ -46,29 +46,48 @@
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.3</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.14.1</version>
<configuration>
<source>8</source>
<target>8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -81,7 +100,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.8</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -91,23 +110,16 @@
</goals>
</execution>
</executions>
<configuration>
<!-- Prevent `gpg` from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.5.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
Expand All @@ -126,44 +138,59 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.12.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<source>11</source>
<doclint>none</doclint>
</configuration>
</execution>
</executions>
<configuration>
<source>8</source>
<source>11</source>
<doclint>none</doclint>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<id>central</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

<repositories>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<name>Central Portal Snapshots</name>
<id>central-portal-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
</repositories>

<dependencies>
<!-- crypto -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.77</version>
<version>1.82</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.77</version>
<version>1.82</version>
</dependency>
<dependency>
<groupId>com.wavesplatform</groupId>
Expand All @@ -184,6 +211,11 @@
<version>3.20.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.wavesplatform</groupId>
<artifactId>blst-java</artifactId>
<version>0.3.15-SNAPSHOT</version>
</dependency>
</dependencies>

</project>
34 changes: 34 additions & 0 deletions src/main/java/com/wavesplatform/crypto/BlsUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.wavesplatform.crypto;

import supranational.blst.*;

public class BlsUtils {
private static final String DST = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_";

public static SecretKey mkBlsSecretKey(byte[] seed) {
SecretKey sk = new SecretKey();
sk.keygen(seed);
return sk;
}

public static byte[] mkBlsPublicKey(SecretKey sk) {
return new P1(sk).compress();
}

public static byte[] sign(SecretKey sk, byte[] message) {
return new P2()
.hash_to(message, DST)
.sign_with(sk)
.compress();
}

public static boolean verify(byte[] sigBytes, byte[] message, byte[] pkBytes) {
P2_Affine sig = new P2_Affine(sigBytes);
P1_Affine pk = new P1_Affine(pkBytes);

Pairing ctx = new Pairing(true, DST);
ctx.aggregate(pk, sig, message);
ctx.commit();
return ctx.finalverify();
}
}
1 change: 0 additions & 1 deletion src/main/java/com/wavesplatform/crypto/base/Base16.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* Base16 is used to represent byte arrays as a readable string.
*
* Not used in Waves blockchain, but can be used in Ride smart contracts.
*/
public abstract class Base16 {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/wavesplatform/crypto/rsa/RsaKeyPair.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

/**
* Pair of RSA private and public keys to encrypt/decrypt or signing data.
*
* RSA signatures are supported in Ride language.
*/
@SuppressWarnings("WeakerAccess")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/**
* RSA public key to encrypt data or verify that data is actually signed by the private key of the public key.
*
* RSA signatures are supported in Ride language.
*/
@SuppressWarnings("WeakerAccess")
Expand Down