Skip to content

Commit

Permalink
Test MpSpdzIntegrationUtils constructor nullability (#12)
Browse files Browse the repository at this point in the history
* Use cs-common nullability testing

Signed-off-by: David Greven <[email protected]>
Signed-off-by: Sebastian Becker <[email protected]>
  • Loading branch information
grevend-bosch authored Nov 15, 2021
1 parent 409a7a6 commit 9c4f135
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build-test-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ jobs:
java-version: ${{ matrix.jdk.version }}
distribution: ${{ matrix.jdk.distribution }}
cache: 'maven'
- name: Setting up Github Package Repository as Maven Repository
uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[{
"id": "github",
"username": "${{ secrets.GHPR_USERNAME }}",
"password": "${{ secrets.GHPR_TOKEN }}"
}]
- name: Build with Maven
run: mvn install -Dskip.tests --batch-mode --update-snapshots --no-transfer-progress
test:
Expand All @@ -43,6 +53,16 @@ jobs:
java-version: ${{ matrix.jdk.version }}
distribution: ${{ matrix.jdk.distribution }}
cache: 'maven'
- name: Setting up Github Package Repository as Maven Repository
uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[{
"id": "github",
"username": "${{ secrets.GHPR_USERNAME }}",
"password": "${{ secrets.GHPR_TOKEN }}"
}]
- name: Run Tests
run: mvn verify --activate-profiles coverage --batch-mode --no-transfer-progress
- name: Collect Jacoco reports
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/publish-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name: Publish and release
on:
workflow_run:
workflows: ["Artifacts"]
workflows: [ "Artifacts" ]
branches:
- master
types:
Expand Down Expand Up @@ -63,6 +63,16 @@ jobs:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Setting up Github Package Repository as Maven Repository
uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[{
"id": "github",
"username": "${{ secrets.GHPR_USERNAME }}",
"password": "${{ secrets.GHPR_TOKEN }}"
}]
- name: Update Maven project version
run: mvn versions:set -DnewVersion=${{ env.VERSION }} -DprocessAllModules -DgenerateBackupPoms=false
- name: Publish version to GitHub Packages
Expand Down
45 changes: 36 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,48 @@
~
~ SPDX-License-Identifier: Apache-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>mp-spdz-integration</artifactId>
<groupId>io.carbynestack</groupId>
<version>${revision}</version>
<name>Carbyne Stack MP-SPDZ Integration Utilities</name>
<description>Integration utilities for MP-SPDZ MPC library</description>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://spdx.org/licenses/Apache-2.0.html</url>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/carbynestack/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://github.com/carbynestack/${project.artifactId}.git</developerConnection>
<url>https://github.com/carbynestack/${project.artifactId}</url>
<tag>HEAD</tag>
</scm>

<repositories>
<repository>
<id>github</id>
<name>Github Packages</name>
<url>https://maven.pkg.github.com/carbynestack/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/carbynestack/${project.artifactId}</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<revision>0.1-SNAPSHOT</revision>
<revision>0.2-SNAPSHOT</revision>
<skip.tests>false</skip.tests>
<java.version>1.8</java.version>

Expand All @@ -50,18 +59,34 @@
<maven-jacoco-plugin.version>0.8.7</maven-jacoco-plugin.version>
<maven-license-plugin.version>2.0.0</maven-license-plugin.version>

<!-- Carbyne Stack dependency versions -->
<common.version>0.1-SNAPSHOT-1452592126-1-135764e</common.version>

<!-- Test dependency versions -->
<junit.version>5.8.1</junit.version>
<assertj.version>3.21.0</assertj.version>
</properties>

<dependencies>
<!--Test dependencies-->
<dependency>
<groupId>io.carbynestack</groupId>
<artifactId>common-testing</artifactId>
<version>${common.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand All @@ -75,6 +100,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
Expand Down Expand Up @@ -163,6 +189,7 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>coverage</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class MpSpdzIntegrationUtils {
/** The size of a word in the MP-SPDZ runtime. */
public static final int WORD_WIDTH = 2 * LIMB_WIDTH;
/** The size of a share (value, MAC) in the MP-SPDZ runtime. Equals two times the word width. */
@SuppressWarnings("unused")
public static final int SHARE_WIDTH = 2 * WORD_WIDTH;
/** Modulus N as used by the MP-SPDZ implementation */
private final BigInteger prime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import io.carbynestack.testing.nullable.NullableParamSource;
import java.math.BigInteger;
import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;

public class MpSpdzIntegrationUtilsTest {
private static final Random RANDOM = new Random(42);
private static final int REPETITIONS = 100000;
private static final BigInteger PRIME = new BigInteger("198766463529478683931867765928436695041");
private static final BigInteger R = new BigInteger("141515903391459779531506841503331516415");
private static final BigInteger R_INV = new BigInteger("133854242216446749056083838363708373830");

@SuppressWarnings("unused")
private static final Arguments OF = Arguments.of(PRIME, R, R_INV);

private final MpSpdzIntegrationUtils mpSpdzIntegrationUtils =
MpSpdzIntegrationUtils.of(PRIME, R, R_INV);
private List<TestTriple> gfpTestData;
Expand All @@ -32,6 +39,13 @@ public void loadGfpData() throws Exception {
loadFromResources("/GfpTestData", "/BigIntTestData", mpSpdzIntegrationUtils.getPrime());
}

@ParameterizedTest
@NullableParamSource("OF")
void givenNullValuesWhenInvokingOfThenThrowNullPointerException(
BigInteger prime, BigInteger r, BigInteger rInv) {
assertThatThrownBy(() -> MpSpdzIntegrationUtils.of(prime, r, rInv));
}

@Test
public void givenConfiguredUtils_whenGettingParameters_thenReturnExpectedValues() {
assertThat(mpSpdzIntegrationUtils.getPrime()).isEqualTo(PRIME);
Expand Down

0 comments on commit 9c4f135

Please sign in to comment.