From 9c4f135d66f1663de94167e3017c799844b9533c Mon Sep 17 00:00:00 2001 From: David Greven Date: Mon, 15 Nov 2021 09:12:10 +0100 Subject: [PATCH] Test MpSpdzIntegrationUtils constructor nullability (#12) * Use cs-common nullability testing Signed-off-by: David Greven Signed-off-by: Sebastian Becker --- .github/workflows/build-test-deploy.yaml | 20 +++++++++ .github/workflows/publish-and-release.yaml | 12 ++++- pom.xml | 45 +++++++++++++++---- .../integration/MpSpdzIntegrationUtils.java | 1 + .../MpSpdzIntegrationUtilsTest.java | 14 ++++++ 5 files changed, 82 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-test-deploy.yaml b/.github/workflows/build-test-deploy.yaml index bfc7888..8f9bd66 100644 --- a/.github/workflows/build-test-deploy.yaml +++ b/.github/workflows/build-test-deploy.yaml @@ -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: @@ -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 diff --git a/.github/workflows/publish-and-release.yaml b/.github/workflows/publish-and-release.yaml index 72aade8..0e20917 100644 --- a/.github/workflows/publish-and-release.yaml +++ b/.github/workflows/publish-and-release.yaml @@ -7,7 +7,7 @@ name: Publish and release on: workflow_run: - workflows: ["Artifacts"] + workflows: [ "Artifacts" ] branches: - master types: @@ -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 diff --git a/pom.xml b/pom.xml index eb31a0d..4a6797f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,27 +5,35 @@ ~ ~ SPDX-License-Identifier: Apache-2.0 --> - 4.0.0 + mp-spdz-integration io.carbynestack ${revision} Carbyne Stack MP-SPDZ Integration Utilities Integration utilities for MP-SPDZ MPC library + Apache-2.0 https://spdx.org/licenses/Apache-2.0.html - - scm:git:https://github.com/carbynestack/${project.artifactId}.git - scm:git:https://github.com/carbynestack/${project.artifactId}.git - https://github.com/carbynestack/${project.artifactId} - HEAD - + + + + github + Github Packages + https://maven.pkg.github.com/carbynestack/* + + true + + + + github @@ -33,11 +41,12 @@ https://maven.pkg.github.com/carbynestack/${project.artifactId} + UTF-8 UTF-8 - 0.1-SNAPSHOT + 0.2-SNAPSHOT false 1.8 @@ -50,18 +59,34 @@ 0.8.7 2.0.0 + + 0.1-SNAPSHOT-1452592126-1-135764e + 5.8.1 3.21.0 + + + io.carbynestack + common-testing + ${common.version} + test + org.junit.jupiter junit-jupiter-api ${junit.version} test + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + org.junit.jupiter junit-jupiter-engine @@ -75,6 +100,7 @@ test + @@ -163,6 +189,7 @@ + coverage diff --git a/src/main/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtils.java b/src/main/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtils.java index 0836fe7..75cf3f0 100644 --- a/src/main/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtils.java +++ b/src/main/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtils.java @@ -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; diff --git a/src/test/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtilsTest.java b/src/test/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtilsTest.java index 285722d..ede41b3 100644 --- a/src/test/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtilsTest.java +++ b/src/test/java/io/carbynestack/mpspdz/integration/MpSpdzIntegrationUtilsTest.java @@ -10,11 +10,14 @@ 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); @@ -22,6 +25,10 @@ public class MpSpdzIntegrationUtilsTest { 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 gfpTestData; @@ -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);