diff --git a/.github/workflows/library_interop_test_vectors.yml b/.github/workflows/library_interop_test_vectors.yml index 9b0a73e59..dc89e61a3 100644 --- a/.github/workflows/library_interop_test_vectors.yml +++ b/.github/workflows/library_interop_test_vectors.yml @@ -91,6 +91,7 @@ jobs: CORES=$(node -e 'console.log(os.cpus().length)') make transpile_net make write_correct_main_net + - name: Setup gradle if: matrix.language == 'java' uses: gradle/gradle-build-action@v2 @@ -103,7 +104,7 @@ jobs: with: aws-region: us-west-2 role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2 - role-session-name: NetTests + role-session-name: InterOpTests - name: Create Manifests working-directory: ./${{ matrix.library }} @@ -111,4 +112,109 @@ jobs: - name: Create Encrypt Manifests working-directory: ./${{ matrix.library }} - run: make test_encrypt_vectors_${{ matrix.language }} \ No newline at end of file + run: make test_encrypt_vectors_${{ matrix.language }} + + - name: Upload Encrypt Manifest and keys.json files + uses: actions/upload-artifact@v4 + with: + name: ${{matrix.os}}_vector_artifact_${{matrix.language}} + path: | + ./${{matrix.library}}/runtimes/${{matrix.language}}/*.json + ./${{matrix.library}}/runtimes/${{matrix.language}}/plaintexts + ./${{matrix.library}}/runtimes/${{matrix.language}}/ciphertexts + + testInteroperablity: + needs: generateEncryptVectors + strategy: + matrix: + library: [TestVectors] + os: [ + # https://taskei.amazon.dev/tasks/CrypTool-5283 + # windows-latest, + ubuntu-latest, + macos-12, + ] + language: [java, net] + # https://taskei.amazon.dev/tasks/CrypTool-5284 + dotnet-version: ["6.0.x"] + runs-on: ${{ matrix.os }} + permissions: + id-token: write + contents: read + + steps: + - name: Support longpaths on Git checkout + run: | + git config --global core.longpaths true + # TestVectors will call KMS + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: us-west-2 + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2 + role-session-name: InterOpTests + + - uses: actions/checkout@v3 + # Not all submodules are needed. + # We manually pull the submodule we DO need. + - run: git submodule update --init libraries + - run: git submodule update --init --recursive mpl + + # Set up runtimes + - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} + if: matrix.decrypting_language == 'net' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ matrix.dotnet-version }} + + - name: Setup Java 17 + if: matrix.decrypting_language == 'java' + uses: actions/setup-java@v3 + with: + distribution: "corretto" + java-version: 17 + + - name: Setup Dafny + uses: dafny-lang/setup-dafny-action@v1.6.1 + with: + dafny-version: ${{ inputs.dafny }} + + - name: Regenerate code using smithy-dafny if necessary + if: ${{ inputs.regenerate-code }} + uses: ./.github/actions/polymorph_codegen + with: + dafny: ${{ inputs.dafny }} + library: ${{ matrix.library }} + diff-generated-code: false + + # Build implementation for each runtime + - name: Build ${{ matrix.library }} implementation in Java + if: matrix.language == 'java' + shell: bash + working-directory: ./${{ matrix.library }} + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make build_java CORES=$CORES + make write_correct_main_java + + - name: Build ${{ matrix.library }} implementation in .NET + if: matrix.language == 'net' + shell: bash + working-directory: ./${{ matrix.library }} + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_net + make write_correct_main_net + + - name: Download Encrypt Manifest Artifact + uses: actions/download-artifact@v4 + with: + name: ${{matrix.os}}_vector_artifact_${{matrix.encrypting_language}} + path: ./${{matrix.library}}/runtimes/${{matrix.decrypting_language}} + + - name: Decrypt Encrypt Manifest + working-directory: ./${{ matrix.library }} + run: make test_decrypt_encrypt_vectors_${{matrix.decrypting_language}} + diff --git a/TestVectors/.gitignore b/TestVectors/.gitignore index ad4090a73..4db3e5410 100644 --- a/TestVectors/.gitignore +++ b/TestVectors/.gitignore @@ -5,8 +5,13 @@ ImplementationFromDafny-cs.dtr TestsFromDafny-cs.dtr **/bin **/obj -/runtimes/java/dafny -/runtimes/java/encrypt-manifest.json +runtimes/java/dafny +runtimes/**/encrypt-manifest.json +runtimes/**/decrypt-manifest.json +runtimes/**/keys.json +runtimes/**/ciphertexts/ +runtimes/**/plaintexts/ + dafny/TestVectors/test/ciphertexts dafny/TestVectors/test/plaintexts dafny/TestVectors/test/test.json diff --git a/TestVectors/runtimes/java/build.gradle.kts b/TestVectors/runtimes/java/build.gradle.kts index 1bad4290e..449254ba5 100644 --- a/TestVectors/runtimes/java/build.gradle.kts +++ b/TestVectors/runtimes/java/build.gradle.kts @@ -55,7 +55,7 @@ tasks.register("copyKeysJSON") { } tasks.register("copyKeysJSONCurr") { - from(layout.projectDirectory.file("../../dafny/ESDK/TestVectors/keys.json")) + from(layout.projectDirectory.file("../../dafny/TestVectors/test/keys.json")) into(layout.projectDirectory.dir(".")) }