From 3efad1cd9fda8590a3609534068d1117b0c26446 Mon Sep 17 00:00:00 2001 From: goncalo-frade-iohk <87179681+goncalo-frade-iohk@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:47:35 +0000 Subject: [PATCH] build: reorganise apollo and remove unused modules --- aes/README.md | 59 ---- aes/aes.podspec | 43 --- aes/karma.config.d/karma.config.js | 9 - aes/src/androidMain/AndroidManifest.xml | 2 - .../io/iohk/atala/prism/apollo/aes/AES.kt | 65 ----- .../atala/prism/apollo/aes/KAESAlgorithm.kt | 11 - .../atala/prism/apollo/aes/KAESBlockMode.kt | 27 -- .../atala/prism/apollo/aes/KAESPadding.kt | 17 -- .../io/iohk/atala/prism/apollo/aes/AES.kt | 23 -- .../atala/prism/apollo/aes/AESDecryptor.kt | 5 - .../atala/prism/apollo/aes/AESEncryptor.kt | 5 - .../prism/apollo/aes/AESKeyGeneration.kt | 12 - .../atala/prism/apollo/aes/KAESAlgorithm.kt | 22 -- .../atala/prism/apollo/aes/KAESBlockMode.kt | 23 -- .../atala/prism/apollo/aes/KAESPadding.kt | 9 - .../iohk/atala/prism/apollo/aes/AESTests.kt | 59 ---- .../io/iohk/atala/prism/apollo/aes/AES.kt | 64 ---- .../atala/prism/apollo/aes/KAESAlgorithm.kt | 20 -- .../atala/prism/apollo/aes/KAESBlockMode.kt | 35 --- .../atala/prism/apollo/aes/KAESPadding.kt | 20 -- .../io/iohk/atala/prism/apollo/aes/AES.kt | 119 -------- .../atala/prism/apollo/aes/KAESAlgorithm.kt | 19 -- .../atala/prism/apollo/aes/KAESBlockMode.kt | 29 -- .../atala/prism/apollo/aes/KAESPadding.kt | 19 -- .../io/iohk/atala/prism/apollo/aes/AES.kt | 65 ----- .../atala/prism/apollo/aes/KAESAlgorithm.kt | 11 - .../atala/prism/apollo/aes/KAESBlockMode.kt | 27 -- .../atala/prism/apollo/aes/KAESPadding.kt | 17 -- aes/webpack.config.d/polyfill.js | 6 - apollo/build.gradle.kts | 107 ++++++- base-symmetric-encryption/build.gradle.kts | 194 ------------ .../src/androidMain/AndroidManifest.xml | 2 - .../prism/apollo/utils/KMMSymmetricKey.kt | 20 -- .../prism/apollo/utils/SymmetricKeyType.kt | 5 - .../prism/apollo/utils/IVBase64Export.kt | 14 - .../prism/apollo/utils/IVBase64Import.kt | 14 - .../atala/prism/apollo/utils/IVGeneration.kt | 12 - .../prism/apollo/utils/KMMSymmetricKey.kt | 5 - .../apollo/utils/SymmetricKeyBase64Export.kt | 8 - .../apollo/utils/SymmetricKeyBase64Import.kt | 11 - .../prism/apollo/utils/SymmetricKeyType.kt | 5 - .../apollo/utils/KMMSymmetricKeyTests.kt | 11 - .../prism/apollo/utils/KMMSymmetricKey.kt | 17 -- .../prism/apollo/utils/SymmetricKeyType.kt | 5 - .../prism/apollo/utils/KMMSymmetricKey.kt | 18 -- .../prism/apollo/utils/SymmetricKeyType.kt | 7 - .../prism/apollo/utils/KMMSymmetricKey.kt | 20 -- .../prism/apollo/utils/SymmetricKeyType.kt | 5 - build.gradle.kts | 5 +- .../build.gradle.kts | 45 +-- .../src/androidMain/AndroidManifest.xml | 0 .../atala/prism/apollo/derivation/Mnemonic.kt | 0 .../prism/apollo/derivation/MnemonicCode.kt | 0 .../prism/apollo/secp256k1/Secp256k1Lib.kt | 0 .../atala/prism/apollo/utils/KMMEdKeyPair.kt | 0 .../prism/apollo/utils/KMMEdPrivateKey.kt | 0 .../prism/apollo/utils/KMMEdPublicKey.kt | 0 .../atala/prism/apollo/utils/KMMRSAKeyPair.kt | 0 .../prism/apollo/utils/KMMRSAPrivateKey.kt | 0 .../prism/apollo/utils/KMMRSAPublicKey.kt | 0 .../prism/apollo/utils/KMMX25519KeyPair.kt | 0 .../prism/apollo/utils/KMMX25519PrivateKey.kt | 0 .../prism/apollo/utils/KMMX25519PublicKey.kt | 0 .../apollo/utils/RSAAsymmetricAlgorithm.kt | 0 .../apollo/utils/RSAKeyPairGeneration.kt | 0 .../prism/apollo/derivation/DerivationAxis.kt | 0 .../prism/apollo/derivation/DerivationPath.kt | 0 .../atala/prism/apollo/derivation/HDKey.kt | 0 .../prism/apollo/derivation/HDKeyOptions.kt | 0 .../apollo/derivation/MnemonicCodeEnglish.kt | 0 .../apollo/derivation/MnemonicException.kt | 0 .../prism/apollo/derivation/MnemonicHelper.kt | 0 .../prism/apollo/secp256k1/Secp256k1Lib.kt | 0 .../iohk/atala/prism/apollo/utils/ECConfig.kt | 0 .../prism/apollo/utils/ECKeyExceptions.kt | 0 .../apollo/utils/Ed25519KeyPairGeneration.kt | 0 .../atala/prism/apollo/utils/Encodable.kt | 0 .../atala/prism/apollo/utils/KMMECPoint.kt | 0 .../apollo/utils/KMMECSecp256k1PrivateKey.kt | 0 .../apollo/utils/KMMECSecp256k1PublicKey.kt | 0 .../atala/prism/apollo/utils/KMMEdKeyPair.kt | 0 .../prism/apollo/utils/KMMEdPrivateKey.kt | 0 .../prism/apollo/utils/KMMEdPublicKey.kt | 0 .../prism/apollo/utils/KMMEllipticCurve.kt | 0 .../atala/prism/apollo/utils/KMMRSAKeyPair.kt | 0 .../prism/apollo/utils/KMMRSAPrivateKey.kt | 0 .../prism/apollo/utils/KMMRSAPublicKey.kt | 0 .../prism/apollo/utils/KMMX25519KeyPair.kt | 0 .../prism/apollo/utils/KMMX25519PrivateKey.kt | 0 .../prism/apollo/utils/KMMX25519PublicKey.kt | 0 .../apollo/utils/RSAAsymmetricAlgorithm.kt | 0 .../apollo/utils/RSAKeyPairGeneration.kt | 0 .../apollo/utils/X25519KeyPairGeneration.kt | 0 .../apollo/utils/bip39/MnemonicException.kt | 0 .../bip39/wordlists/MnemonicCodeCzech.kt | 0 .../bip39/wordlists/MnemonicCodeEnglish.kt | 0 .../bip39/wordlists/MnemonicCodeFrench.kt | 0 .../bip39/wordlists/MnemonicCodeItalian.kt | 0 .../bip39/wordlists/MnemonicCodeJapanese.kt | 0 .../bip39/wordlists/MnemonicCodeKorean.kt | 0 .../MnemonicCodeSimplifiedChinese.kt | 0 .../bip39/wordlists/MnemonicCodeSpanish.kt | 0 .../MnemonicCodeTraditionalChinese.kt | 0 .../prism/apollo/derivation/HDKeyTest.kt | 0 .../apollo/utils/KMMECSecp256k1KeysTests.kt | 0 .../apollo/utils/KMMEdKeyPairTestsIgnored.kt | 0 .../apollo/utils/KMMX25519KeyPairTests.kt | 0 .../atala/prism/apollo/utils/MnemonicTests.kt | 0 .../prism/apollo/utils/Secp256k1LibTests.kt | 0 .../apollo/utils/Secp256k1TestVectors.kt | 0 .../atala/prism/apollo/derivation/Mnemonic.kt | 0 .../prism/apollo/derivation/MnemonicCode.kt | 0 .../iohk/atala/prism/apollo/secp256k1/ECDH.kt | 0 .../atala/prism/apollo/secp256k1/ECDSA.kt | 0 .../iohk/atala/prism/apollo/secp256k1/Hex.kt | 0 .../atala/prism/apollo/secp256k1/Schnorr.kt | 0 .../atala/prism/apollo/secp256k1/Secp256k1.kt | 0 .../apollo/secp256k1/Secp256k1Exception.kt | 0 .../prism/apollo/secp256k1/Secp256k1Lib.kt | 0 .../atala/prism/apollo/utils/KMMEdKeyPair.kt | 0 .../prism/apollo/utils/KMMEdPrivateKey.kt | 0 .../prism/apollo/utils/KMMEdPublicKey.kt | 0 .../atala/prism/apollo/utils/KMMRSAKeyPair.kt | 0 .../prism/apollo/utils/KMMRSAPrivateKey.kt | 0 .../prism/apollo/utils/KMMRSAPublicKey.kt | 0 .../prism/apollo/utils/KMMX25519KeyPair.kt | 0 .../prism/apollo/utils/KMMX25519PrivateKey.kt | 0 .../prism/apollo/utils/KMMX25519PublicKey.kt | 0 .../apollo/utils/RSAAsymmetricAlgorithm.kt | 0 .../apollo/utils/RSAKeyPairGeneration.kt | 0 .../prism/apollo/secp256k1/Secp256k1Tests.kt | 0 .../atala/prism/apollo/derivation/Mnemonic.kt | 0 .../prism/apollo/derivation/MnemonicCode.kt | 0 .../prism/apollo/secp256k1/Secp256k1Lib.kt | 0 .../prism/apollo/utils/Curve25519Parser.kt | 0 .../atala/prism/apollo/utils/JsHashType.kt | 0 .../atala/prism/apollo/utils/KMMECPointJS.kt | 0 .../atala/prism/apollo/utils/KMMEdKeyPair.kt | 0 .../prism/apollo/utils/KMMEdPrivateKey.kt | 0 .../prism/apollo/utils/KMMEdPublicKey.kt | 0 .../atala/prism/apollo/utils/KMMRSAKeyPair.kt | 0 .../prism/apollo/utils/KMMRSAPrivateKey.kt | 0 .../prism/apollo/utils/KMMRSAPublicKey.kt | 0 .../prism/apollo/utils/KMMX25519KeyPair.kt | 0 .../prism/apollo/utils/KMMX25519PrivateKey.kt | 0 .../prism/apollo/utils/KMMX25519PublicKey.kt | 0 .../apollo/utils/RSAAsymmetricAlgorithm.kt | 0 .../apollo/utils/RSAKeyPairGeneration.kt | 0 .../prism/apollo/utils/external/BIP32.kt | 0 .../prism/apollo/utils/external/BIP39.kt | 0 .../atala/prism/apollo/utils/external/BNjs.kt | 0 .../prism/apollo/utils/external/Curve.kt | 0 .../prism/apollo/utils/external/Ellipticjs.kt | 0 .../apollo/utils/external/PresetCurve.kt | 0 .../prism/apollo/utils/external/Stabelib.kt | 0 .../utils/external/secp256k1/secp256k1js.kt | 0 .../prism/apollo/utils/KMMEdKeyPairTests.kt | 0 .../prism/apollo/utils/KMMX25519Tests.kt | 0 .../atala/prism/apollo/derivation/Mnemonic.kt | 0 .../prism/apollo/derivation/MnemonicCode.kt | 0 .../prism/apollo/secp256k1/Secp256k1Lib.kt | 0 .../atala/prism/apollo/utils/KMMEdKeyPair.kt | 0 .../prism/apollo/utils/KMMEdPrivateKey.kt | 0 .../prism/apollo/utils/KMMEdPublicKey.kt | 0 .../atala/prism/apollo/utils/KMMRSAKeyPair.kt | 0 .../prism/apollo/utils/KMMRSAPrivateKey.kt | 0 .../prism/apollo/utils/KMMRSAPublicKey.kt | 0 .../prism/apollo/utils/KMMX25519KeyPair.kt | 0 .../prism/apollo/utils/KMMX25519PrivateKey.kt | 0 .../prism/apollo/utils/KMMX25519PublicKey.kt | 0 .../apollo/utils/RSAAsymmetricAlgorithm.kt | 0 .../apollo/utils/RSAKeyPairGeneration.kt | 0 .../nativeInterop/cinterop/IOHKCryptoKit.def | 0 .../cinterop/IOHKSecureRandomGeneration.def | 0 .../nativeInterop/cinterop/SwiftCryptoKit.def | 0 .../webpack.config.d/polyfill.js | 0 ecdsa/build.gradle.kts | 275 ------------------ ecdsa/ecdsa.podspec | 43 --- ecdsa/src/androidMain/AndroidManifest.xml | 2 - .../iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt | 43 --- .../atala/prism/apollo/ecdsa/ECDSAType.kt | 7 - .../iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt | 6 - .../atala/prism/apollo/ecdsa/KMMECDSATests.kt | 141 --------- .../iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt | 115 -------- .../iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt | 47 --- .../iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt | 43 --- jose/build.gradle.kts | 219 -------------- jose/jose.podspec | 42 --- jose/src/androidMain/AndroidManifest.xml | 2 - .../io/iohk/atala/prism/apollo/jose/JOSE.kt | 199 ------------- .../io/iohk/atala/prism/apollo/jose/JOSE.kt | 199 ------------- rsa/README.md | 41 --- rsa/rsa.podspec | 42 --- .../androidAndroidTest/AndroidManifest.xml | 2 - .../iohk/atala/prism/apollo/rsa/RSATests.kt | 31 -- rsa/src/androidMain/AndroidManifest.xml | 2 - .../io/iohk/atala/prism/apollo/rsa/RSA.kt | 29 -- .../prism/apollo/rsa/RSASignatureType.kt | 25 -- .../iohk/atala/prism/apollo/rsa/RSATests.kt | 31 -- .../io/iohk/atala/prism/apollo/rsa/RSA.kt | 3 - .../prism/apollo/rsa/RSASignatureType.kt | 14 - .../iohk/atala/prism/apollo/rsa/RSASigner.kt | 15 - .../atala/prism/apollo/rsa/RSAVerifier.kt | 15 - .../iohk/atala/prism/apollo/rsa/RSATests.kt | 10 - .../io/iohk/atala/prism/apollo/rsa/RSA.kt | 26 -- .../prism/apollo/rsa/RSASignatureType.kt | 32 -- .../iohk/atala/prism/apollo/rsa/RSATests.kt | 31 -- .../io/iohk/atala/prism/apollo/rsa/RSA.kt | 67 ----- .../prism/apollo/rsa/RSASignatureType.kt | 25 -- .../iohk/atala/prism/apollo/rsa/RSATests.kt | 32 -- .../io/iohk/atala/prism/apollo/rsa/RSA.kt | 29 -- .../prism/apollo/rsa/RSASignatureType.kt | 25 -- .../iohk/atala/prism/apollo/rsa/RSATests.kt | 31 -- settings.gradle.kts | 4 +- 214 files changed, 98 insertions(+), 3219 deletions(-) delete mode 100644 aes/README.md delete mode 100644 aes/aes.podspec delete mode 100644 aes/karma.config.d/karma.config.js delete mode 100644 aes/src/androidMain/AndroidManifest.xml delete mode 100644 aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt delete mode 100644 aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt delete mode 100644 aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt delete mode 100644 aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESDecryptor.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESEncryptor.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESKeyGeneration.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt delete mode 100644 aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt delete mode 100644 aes/src/commonTest/kotlin/io/iohk/atala/prism/apollo/aes/AESTests.kt delete mode 100644 aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt delete mode 100644 aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt delete mode 100644 aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt delete mode 100644 aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt delete mode 100644 aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt delete mode 100644 aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt delete mode 100644 aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt delete mode 100644 aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt delete mode 100644 aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt delete mode 100644 aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt delete mode 100644 aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt delete mode 100644 aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt delete mode 100644 aes/webpack.config.d/polyfill.js delete mode 100644 base-symmetric-encryption/build.gradle.kts delete mode 100644 base-symmetric-encryption/src/androidMain/AndroidManifest.xml delete mode 100644 base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt delete mode 100644 base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Export.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Import.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVGeneration.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Export.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Import.kt delete mode 100644 base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt delete mode 100644 base-symmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKeyTests.kt delete mode 100644 base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt delete mode 100644 base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt delete mode 100644 base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt delete mode 100644 base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt delete mode 100644 base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt delete mode 100644 base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt rename {base-asymmetric-encryption => cryptography}/build.gradle.kts (87%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/AndroidManifest.xml (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationAxis.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationPath.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyOptions.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCodeEnglish.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicException.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicHelper.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECConfig.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECKeyExceptions.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Ed25519KeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Encodable.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPoint.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEllipticCurve.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/X25519KeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/MnemonicException.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeCzech.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeEnglish.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeFrench.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeItalian.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeJapanese.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeKorean.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSimplifiedChinese.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSpanish.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeTraditionalChinese.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1KeysTests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTestsIgnored.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPairTests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/MnemonicTests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1TestVectors.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDH.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDSA.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Hex.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Schnorr.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Exception.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/iosTest/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Tests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/Curve25519Parser.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/JsHashType.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPointJS.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP32.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP39.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BNjs.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Curve.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Ellipticjs.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/PresetCurve.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Stabelib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/secp256k1/secp256k1js.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519Tests.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt (100%) rename {base-asymmetric-encryption => cryptography}/src/nativeInterop/cinterop/IOHKCryptoKit.def (100%) rename {base-asymmetric-encryption => cryptography}/src/nativeInterop/cinterop/IOHKSecureRandomGeneration.def (100%) rename {base-asymmetric-encryption => cryptography}/src/nativeInterop/cinterop/SwiftCryptoKit.def (100%) rename {base-asymmetric-encryption => cryptography}/webpack.config.d/polyfill.js (100%) delete mode 100644 ecdsa/build.gradle.kts delete mode 100644 ecdsa/ecdsa.podspec delete mode 100644 ecdsa/src/androidMain/AndroidManifest.xml delete mode 100644 ecdsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt delete mode 100644 ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/ECDSAType.kt delete mode 100644 ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt delete mode 100644 ecdsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSATests.kt delete mode 100644 ecdsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt delete mode 100644 ecdsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt delete mode 100644 ecdsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt delete mode 100644 jose/build.gradle.kts delete mode 100644 jose/jose.podspec delete mode 100644 jose/src/androidMain/AndroidManifest.xml delete mode 100644 jose/src/androidMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt delete mode 100644 jose/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt delete mode 100644 rsa/README.md delete mode 100644 rsa/rsa.podspec delete mode 100644 rsa/src/androidAndroidTest/AndroidManifest.xml delete mode 100644 rsa/src/androidAndroidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt delete mode 100644 rsa/src/androidMain/AndroidManifest.xml delete mode 100644 rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt delete mode 100644 rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt delete mode 100644 rsa/src/androidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt delete mode 100644 rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt delete mode 100644 rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt delete mode 100644 rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASigner.kt delete mode 100644 rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSAVerifier.kt delete mode 100644 rsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt delete mode 100644 rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt delete mode 100644 rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt delete mode 100644 rsa/src/iosTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt delete mode 100644 rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt delete mode 100644 rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt delete mode 100644 rsa/src/jsTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt delete mode 100644 rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt delete mode 100644 rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt delete mode 100644 rsa/src/jvmTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt diff --git a/aes/README.md b/aes/README.md deleted file mode 100644 index aae882433..000000000 --- a/aes/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Apollo - AES - -[![Kotlin](https://img.shields.io/badge/kotlin-1.7.21-blue.svg?logo=kotlin)](http://kotlinlang.org) - -![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) -![apple-silicon](https://camo.githubusercontent.com/a92c841ffd377756a144d5723ff04ecec886953d40ac03baa738590514714921/687474703a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d2535424170706c6553696c69636f6e2535442d3433424246462e7376673f7374796c653d666c6174) -![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174) -![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) -![js](https://camo.githubusercontent.com/3e0a143e39915184b54b60a2ecedec75e801f396d34b5b366c94ec3604f7e6bd/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a732d4638444235442e7376673f7374796c653d666c6174) -![getNode-js](https://camo.githubusercontent.com/d08fda729ceebcae0f23c83499ca8f06105350f037661ac9a4cc7f58edfdbca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6e6f64656a732d3638613036332e7376673f7374796c653d666c6174) -![macos](https://camo.githubusercontent.com/1b8313498db244646b38a4480186ae2b25464e5e8d71a1920c52b2be5212b909/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6d61636f732d3131313131312e7376673f7374796c653d666c6174) -![tvos](https://camo.githubusercontent.com/4ac08d7fb1bcb8ef26388cd2bf53b49626e1ab7cbda581162a946dd43e6a2726/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d74766f732d3830383038302e7376673f7374796c653d666c6174) -![watchos](https://camo.githubusercontent.com/135dbadae40f9cabe7a3a040f9380fb485cff36c90909f3c1ae36b81c304426b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d77617463686f732d4330433043302e7376673f7374796c653d666c6174) - -Apollo AES is Kotlin Multiplatform library for AES encryption & decryption with the following supports. - -## Supported Key Size - -- 128 -- 192 -- 256 - -## Supported Block Mode - -- ECB -- CBC -- CFB -- CFB8 -- CTR -- GCM -- OFB -- RC4 - -## Supported Padding - -- No Padding -- PKCS5 -- PKCS7 - -## Usage - -```kotlin -val text = "Welcome to IOG!" -val algo = KAESAlgorithm.AES_256 -val key = AES.createRandomAESKey(algo) -val aes = AES( - algo, - KAESBlockMode.GCM, - KAESPadding.No_Padding, - key, - KMMSymmetricKey.createRandomIV(16) -) -val encryptedBytes = aes.encrypt(text.encodeToByteArray()) -val decryptedBytes = aes.decrypt(encryptedBytes) -``` - -## TODO - -* Update supported Block Mode to the only ones supported per platform. \ No newline at end of file diff --git a/aes/aes.podspec b/aes/aes.podspec deleted file mode 100644 index 6a8a5aa59..000000000 --- a/aes/aes.podspec +++ /dev/null @@ -1,43 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'aes' - spec.version = '1.7.0-alpha' - spec.homepage = '' - spec.source = { :http=> ''} - spec.authors = 'IOG' - spec.license = '' - spec.summary = 'ApolloAES is an AES lib' - spec.vendored_frameworks = 'build/cocoapods/framework/ApolloAES.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '13.0' - spec.osx.deployment_target = '12.0' - spec.tvos.deployment_target = '13.0' - spec.watchos.deployment_target = '8.0' - spec.dependency 'IOHKAES', '1.0.0' - spec.dependency 'IOHKSecureRandomGeneration', '1.0.0' - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':aes', - 'PRODUCT_MODULE_NAME' => 'ApolloAES', - } - - spec.script_phases = [ - { - :name => 'Build aes', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/aes/karma.config.d/karma.config.js b/aes/karma.config.d/karma.config.js deleted file mode 100644 index e56914aa1..000000000 --- a/aes/karma.config.d/karma.config.js +++ /dev/null @@ -1,9 +0,0 @@ -config.set({ - browserDisconnectTimeout: 300000, - processKillTimeout: 300000, - client: { - mocha: { - timeout: 300000 - } - } -}); diff --git a/aes/src/androidMain/AndroidManifest.xml b/aes/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 232c3f49e..000000000 --- a/aes/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt b/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt deleted file mode 100644 index 476d6408d..000000000 --- a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt +++ /dev/null @@ -1,65 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey -import java.security.spec.AlgorithmParameterSpec -import javax.crypto.Cipher -import javax.crypto.KeyGenerator -import javax.crypto.spec.GCMParameterSpec -import javax.crypto.spec.IvParameterSpec - -actual typealias KAESAlgorithmNativeType = String -actual typealias KAESBlockModeNativeType = String -actual typealias KAESPaddingNativeType = String - -actual final class AES actual constructor( - actual val algorithm: KAESAlgorithm, - actual val blockMode: KAESBlockMode, - actual val padding: KAESPadding, - actual val key: KMMSymmetricKey, - actual val iv: ByteArray? -) : AESEncryptor, AESDecryptor { - - private val cipher: Cipher = Cipher.getInstance("${algorithm.nativeValue()}/${blockMode.nativeValue()}/${padding.nativeValue()}") - private val ivSpec: AlgorithmParameterSpec? = if (blockMode.needIV()) { - when (blockMode) { - KAESBlockMode.ECB -> IvParameterSpec(iv) - KAESBlockMode.CBC -> IvParameterSpec(iv) - KAESBlockMode.CFB -> IvParameterSpec(iv) - KAESBlockMode.CFB8 -> IvParameterSpec(iv) - KAESBlockMode.CTR -> IvParameterSpec(iv) - KAESBlockMode.GCM -> GCMParameterSpec(AUTH_TAG_SIZE, iv) - KAESBlockMode.OFB -> IvParameterSpec(iv) - KAESBlockMode.RC4 -> IvParameterSpec(iv) - } - } else { - null - } - - override suspend fun encrypt(data: ByteArray): ByteArray { - if (ivSpec == null) { - cipher.init(Cipher.ENCRYPT_MODE, key.nativeType) - } else { - cipher.init(Cipher.ENCRYPT_MODE, key.nativeType, ivSpec) - } - return cipher.doFinal(data) - } - - override suspend fun decrypt(data: ByteArray): ByteArray { - if (ivSpec == null) { - cipher.init(Cipher.DECRYPT_MODE, key.nativeType) - } else { - cipher.init(Cipher.DECRYPT_MODE, key.nativeType, ivSpec) - } - return cipher.doFinal(data) - } - - actual companion object : AESKeyGeneration { - private const val AUTH_TAG_SIZE = 128 - - override suspend fun createRandomAESKey(algorithm: KAESAlgorithm, blockMode: KAESBlockMode): KMMSymmetricKey { - val keygen = KeyGenerator.getInstance("AES") - keygen.init(algorithm.keySize()) - return KMMSymmetricKey(keygen.generateKey()) - } - } -} diff --git a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt b/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt deleted file mode 100644 index f68fa3ef6..000000000 --- a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESAlgorithm : NativeTypeInterface { - AES_128, - AES_192, - AES_256; - - override fun nativeValue() = "AES" -} diff --git a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt b/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt deleted file mode 100644 index 471df724e..000000000 --- a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt +++ /dev/null @@ -1,27 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESBlockMode : NativeTypeInterface { - ECB, - CBC, - CFB, - CFB8, - CTR, - GCM, - OFB, - RC4; - - override fun nativeValue(): KAESBlockModeNativeType { - return when (this) { - ECB -> "ECB" - CBC -> "CBC" - CFB -> "CFB" - CFB8 -> "CFB8" - CTR -> "CTR" - GCM -> "GCM" - OFB -> "OFB" - RC4 -> throw Exception("Not implemented in JVM") - } - } -} diff --git a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt b/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt deleted file mode 100644 index 9c7ee7237..000000000 --- a/aes/src/androidMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESPadding : NativeTypeInterface { - NO_PADDING, - PKCS5PADDING, - PKCS7PADDING; - - override fun nativeValue(): KAESPaddingNativeType { - return when (this) { - NO_PADDING -> "NoPadding" - PKCS5PADDING -> "PKCS5Padding" - PKCS7PADDING -> "PKCS5Padding" - } - } -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt deleted file mode 100644 index b3b058ac9..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey - -expect class KAESAlgorithmNativeType -expect class KAESBlockModeNativeType -expect class KAESPaddingNativeType - -expect final class AES( - algorithm: KAESAlgorithm, - blockMode: KAESBlockMode, - padding: KAESPadding, - key: KMMSymmetricKey, - iv: ByteArray? -) : AESEncryptor, AESDecryptor { - val algorithm: KAESAlgorithm - val blockMode: KAESBlockMode - val padding: KAESPadding - val key: KMMSymmetricKey - val iv: ByteArray? - - companion object : AESKeyGeneration -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESDecryptor.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESDecryptor.kt deleted file mode 100644 index 7d8d4a778..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESDecryptor.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -interface AESDecryptor { - suspend fun decrypt(data: ByteArray): ByteArray -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESEncryptor.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESEncryptor.kt deleted file mode 100644 index 3a8b8e983..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESEncryptor.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -interface AESEncryptor { - suspend fun encrypt(data: ByteArray): ByteArray -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESKeyGeneration.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESKeyGeneration.kt deleted file mode 100644 index dc849c085..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/AESKeyGeneration.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey - -interface AESKeyGeneration { - /** - * Generate random AES key - * - * @param algorithm AES Key algorithm - */ - suspend fun createRandomAESKey(algorithm: KAESAlgorithm, blockMode: KAESBlockMode = KAESBlockMode.GCM): KMMSymmetricKey -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt deleted file mode 100644 index 58ef1546a..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface -import kotlin.js.ExperimentalJsExport -import kotlin.js.JsExport - -expect enum class KAESAlgorithm : NativeTypeInterface { - AES_128, - AES_192, - AES_256 -} - -@OptIn(ExperimentalJsExport::class) -@JsExport -fun KAESAlgorithm.keySize(): Int { - return when (this) { - KAESAlgorithm.AES_128 -> 128 - KAESAlgorithm.AES_192 -> 192 - KAESAlgorithm.AES_256 -> 256 - else -> throw Exception("This line should never be reached") - } -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt deleted file mode 100644 index f2a98c7a2..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -expect enum class KAESBlockMode : NativeTypeInterface { - ECB, - CBC, - CFB, - CFB8, - CTR, - GCM, - OFB, - RC4 -} - -fun KAESBlockMode.needIV(): Boolean { - return when (this) { - KAESBlockMode.ECB -> false - KAESBlockMode.CBC, KAESBlockMode.CFB, KAESBlockMode.CFB8, KAESBlockMode.CTR, KAESBlockMode.GCM, - KAESBlockMode.OFB, KAESBlockMode.RC4 -> true - else -> throw IllegalStateException("Should never reach this line") - } -} diff --git a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt b/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt deleted file mode 100644 index 7184aa504..000000000 --- a/aes/src/commonMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt +++ /dev/null @@ -1,9 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -expect enum class KAESPadding : NativeTypeInterface { - NO_PADDING, - PKCS5PADDING, - PKCS7PADDING -} diff --git a/aes/src/commonTest/kotlin/io/iohk/atala/prism/apollo/aes/AESTests.kt b/aes/src/commonTest/kotlin/io/iohk/atala/prism/apollo/aes/AESTests.kt deleted file mode 100644 index 3bbd20e76..000000000 --- a/aes/src/commonTest/kotlin/io/iohk/atala/prism/apollo/aes/AESTests.kt +++ /dev/null @@ -1,59 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey -import io.iohk.atala.prism.apollo.utils.SymmetricKeyType -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertEquals - -class AESTests { - @OptIn(ExperimentalCoroutinesApi::class) - @Test - fun testAESGCM() = runTest { - val text = "Welcome to IOG!" - val algo = KAESAlgorithm.AES_256 - val key = AES.createRandomAESKey(algo) - val aes = AES( - algo, - KAESBlockMode.GCM, - KAESPadding.NO_PADDING, - key, - KMMSymmetricKey.createRandomIV(16) - ) - val encryptedBytes = aes.encrypt(text.encodeToByteArray()) - val decryptedBytes = aes.decrypt(encryptedBytes) - assertEquals(text, decryptedBytes.decodeToString()) - } - - @OptIn(ExperimentalCoroutinesApi::class) - @Test - fun testAESCBC() = runTest { - val text = "Welcome to IOG!" - val algo = KAESAlgorithm.AES_256 - val key = AES.createRandomAESKey(algo) - val aes = AES( - algo, - KAESBlockMode.CBC, - KAESPadding.PKCS5PADDING, - key, - KMMSymmetricKey.createRandomIV(16) - ) - val encryptedBytes = aes.encrypt(text.encodeToByteArray()) - val decryptedBytes = aes.decrypt(encryptedBytes) - assertEquals(text, decryptedBytes.decodeToString()) - } - - @OptIn(ExperimentalCoroutinesApi::class) - @Test - fun testAESKeyExportImport() = runTest { - val algo = KAESAlgorithm.AES_256 - val key = AES.createRandomAESKey(algo) - - val base64Key = key.exportToBase64() - - val importedKey = KMMSymmetricKey.createKeyFromBase64(base64Key, SymmetricKeyType.AES) - - assertEquals(base64Key, importedKey.exportToBase64()) - } -} diff --git a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt b/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt deleted file mode 100644 index e1dee0b53..000000000 --- a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt +++ /dev/null @@ -1,64 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import cocoapods.IOHKAES.AESOptionsNone -import cocoapods.IOHKAES.AESOptionsPkcs7Padding -import cocoapods.IOHKAES.IOHKAES -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey -import io.iohk.atala.prism.apollo.utils.toByteArray -import io.iohk.atala.prism.apollo.utils.toNSData -import kotlinx.cinterop.autoreleasepool -import platform.Foundation.NSData - -actual typealias KAESAlgorithmNativeType = Long -actual typealias KAESBlockModeNativeType = Int -actual typealias KAESPaddingNativeType = Long - -actual final class AES actual constructor( - actual val algorithm: KAESAlgorithm, - actual val blockMode: KAESBlockMode, - actual val padding: KAESPadding, - actual val key: KMMSymmetricKey, - actual val iv: ByteArray? -) : AESEncryptor, AESDecryptor { - override suspend fun encrypt(data: ByteArray): ByteArray { - autoreleasepool { - val encryptedData = IOHKAES.aesEncryptionWithAlgorithm( - algorithm.nativeValue(), - AESOptionsPkcs7Padding, - blockMode.nativeValue().toUInt(), - padding.nativeValue(), - data.toNSData(), - key.nativeValue, - iv?.toNSData() ?: NSData() - )?.toByteArray() - - return encryptedData ?: ByteArray(0) - } - } - - override suspend fun decrypt(data: ByteArray): ByteArray { - autoreleasepool { - val decryptedData = IOHKAES.aesDecryptionWithAlgorithm( - algorithm.nativeValue(), - AESOptionsNone, - blockMode.nativeValue().toUInt(), - padding.nativeValue(), - data.toNSData(), - key.nativeValue, - iv?.toNSData() ?: NSData() - )?.toByteArray() - - return decryptedData ?: ByteArray(0) - } - } - - actual companion object : AESKeyGeneration { - override suspend fun createRandomAESKey(algorithm: KAESAlgorithm, blockMode: KAESBlockMode): KMMSymmetricKey { - autoreleasepool { - return KMMSymmetricKey( - IOHKAES.generateAESKeyWithAlgorithm(algorithm.nativeValue()) - ) - } - } - } -} diff --git a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt b/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt deleted file mode 100644 index f6d2e2d01..000000000 --- a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import cocoapods.IOHKAES.AESAlgorithmAes128 -import cocoapods.IOHKAES.AESAlgorithmAes192 -import cocoapods.IOHKAES.AESAlgorithmAes256 -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESAlgorithm : NativeTypeInterface { - AES_128, - AES_192, - AES_256; - - override fun nativeValue(): KAESAlgorithmNativeType { - return when (this) { - AES_128 -> AESAlgorithmAes128 - AES_192 -> AESAlgorithmAes192 - AES_256 -> AESAlgorithmAes256 - } - } -} diff --git a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt b/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt deleted file mode 100644 index 06b1d21da..000000000 --- a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import cocoapods.IOHKAES.BlockModeCbc -import cocoapods.IOHKAES.BlockModeCfb -import cocoapods.IOHKAES.BlockModeCfb8 -import cocoapods.IOHKAES.BlockModeCtr -import cocoapods.IOHKAES.BlockModeEcb -import cocoapods.IOHKAES.BlockModeGcm -import cocoapods.IOHKAES.BlockModeOfb -import cocoapods.IOHKAES.BlockModeRc4 -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESBlockMode : NativeTypeInterface { - ECB, - CBC, - CFB, - CFB8, - CTR, - GCM, - OFB, - RC4; - - override fun nativeValue(): KAESBlockModeNativeType { - return when (this) { - ECB -> BlockModeEcb.toInt() - CBC -> BlockModeCbc.toInt() - CFB -> BlockModeCfb.toInt() - CFB8 -> BlockModeCfb8.toInt() - CTR -> BlockModeCtr.toInt() - GCM -> BlockModeGcm.toInt() - OFB -> BlockModeOfb.toInt() - RC4 -> BlockModeRc4.toInt() - } - } -} diff --git a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt b/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt deleted file mode 100644 index 37f023965..000000000 --- a/aes/src/iosMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import cocoapods.IOHKAES.PaddingNoPadding -import cocoapods.IOHKAES.PaddingPkcs7Padding -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESPadding : NativeTypeInterface { - NO_PADDING, - PKCS5PADDING, - PKCS7PADDING; - - override fun nativeValue(): KAESPaddingNativeType { - return when (this) { - NO_PADDING -> PaddingNoPadding - // PKCS#5 padding and PKCS#7 padding are practically the same => https://crypto.stackexchange.com/questions/9043/what-is-the-difference-between-pkcs5-padding-and-pkcs7-padding/9044#9044 - PKCS5PADDING -> PaddingPkcs7Padding - PKCS7PADDING -> PaddingPkcs7Padding - } - } -} diff --git a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt b/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt deleted file mode 100644 index 5707e845e..000000000 --- a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt +++ /dev/null @@ -1,119 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey -import io.iohk.atala.prism.apollo.utils.toArrayBuffer -import io.iohk.atala.prism.apollo.utils.toByteArray -import kotlinx.coroutines.MainScope -import kotlinx.coroutines.await -import kotlinx.coroutines.promise -import web.crypto.AesCbcParams -import web.crypto.AesGcmParams -import web.crypto.AesKeyAlgorithm -import web.crypto.AesKeyGenParams -import web.crypto.Algorithm -import web.crypto.KeyFormat -import web.crypto.KeyUsage -import web.crypto.crypto - -actual typealias KAESAlgorithmNativeType = String -actual typealias KAESBlockModeNativeType = String -actual typealias KAESPaddingNativeType = String - -actual final class AES actual constructor( - actual val algorithm: KAESAlgorithm, - actual val blockMode: KAESBlockMode, - actual val padding: KAESPadding, - actual val key: KMMSymmetricKey, - actual val iv: ByteArray? -) : AESEncryptor, AESDecryptor { - - private fun getAesKeyAlgorithm(): AesKeyAlgorithm { - val algorithmString = "${algorithm.nativeValue()}-${blockMode.nativeValue()}" - val length = this.algorithm.keySize() - return js("{name: algorithmString, length: length}").unsafeCast() - } - - private fun getAesParams(): Algorithm { - val algorithmString = "${algorithm.nativeValue()}-${blockMode.nativeValue()}" - return if (blockMode.needIV()) { - val jsIV = this.iv!!.toArrayBuffer() - when (blockMode) { - KAESBlockMode.GCM -> { - val tagSize = GCM_AUTH_TAG_SIZE - js("{name: algorithmString, iv: jsIV, tagLength: tagSize}").unsafeCast() - } - KAESBlockMode.CBC -> { - js("{name: algorithmString, iv: jsIV}").unsafeCast() - } - else -> { - throw NotImplementedError("Yet to be implemented") - } - } - } else { - js("{name: algorithmString}").unsafeCast() - } - } - - override suspend fun encrypt(data: ByteArray): ByteArray { - return MainScope().promise { - val nativeKey = key.nativeValue - - val cryptoKey = crypto.subtle.importKey( - KeyFormat.raw, - nativeKey.toArrayBuffer(), - getAesKeyAlgorithm(), - true, - arrayOf(KeyUsage.encrypt, KeyUsage.decrypt) - ).await() - - crypto.subtle.encrypt( - getAesParams(), - cryptoKey, - data.toArrayBuffer() - ).await().toByteArray() - }.await() - } - - override suspend fun decrypt(data: ByteArray): ByteArray { - return MainScope().promise { - val nativeKey = key.nativeValue - - val cryptoKey = crypto.subtle.importKey( - KeyFormat.raw, - nativeKey.toArrayBuffer(), - getAesKeyAlgorithm(), - true, - arrayOf(KeyUsage.encrypt, KeyUsage.decrypt) - ).await() - - crypto.subtle.decrypt( - getAesParams(), - cryptoKey, - data.toArrayBuffer() - ).await().toByteArray() - }.await() - } - - actual companion object : AESKeyGeneration { - // Because NITS recommends it to always be 128 or bigger https://csrc.nist.gov/publications/detail/sp/800-38d/final - private const val GCM_AUTH_TAG_SIZE = 128 - - private fun getAesKeyGenParams(algorithm: KAESAlgorithm, blockMode: KAESBlockMode): AesKeyGenParams { - val algorithmString = "${algorithm.nativeValue()}-${blockMode.nativeValue()}" - val keyLength = algorithm.keySize() - return js("{name: algorithmString, length: keyLength}").unsafeCast() - } - - override suspend fun createRandomAESKey(algorithm: KAESAlgorithm, blockMode: KAESBlockMode): KMMSymmetricKey { - return MainScope().promise { - val cryptoKey = crypto.subtle.generateKey( - getAesKeyGenParams(algorithm, blockMode), - true, - arrayOf(KeyUsage.encrypt, KeyUsage.decrypt) - ).await() - val key = crypto.subtle.exportKey(KeyFormat.raw, cryptoKey).await().toByteArray() - KMMSymmetricKey(key) - }.await() - } - } -} diff --git a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt b/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt deleted file mode 100644 index 40dfbd497..000000000 --- a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -@OptIn(ExperimentalJsExport::class) -@JsExport -actual enum class KAESAlgorithm : NativeTypeInterface { - AES_128, - AES_192, - AES_256; - - override fun nativeValue(): KAESAlgorithmNativeType { - return when (this) { - AES_128 -> "AES" - AES_192 -> "AES" - AES_256 -> "AES" - } - } -} diff --git a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt b/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt deleted file mode 100644 index 80c70ca37..000000000 --- a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -@OptIn(ExperimentalJsExport::class) -@JsExport -actual enum class KAESBlockMode : NativeTypeInterface { - ECB, - CBC, - CFB, - CFB8, - CTR, - GCM, - OFB, - RC4; - - override fun nativeValue(): KAESBlockModeNativeType { - return when (this) { - ECB -> throw NotImplementedError() - CBC -> "CBC" - CFB -> throw NotImplementedError() - CFB8 -> throw NotImplementedError() - CTR -> "CTR" - GCM -> "GCM" - OFB -> throw NotImplementedError() - RC4 -> throw NotImplementedError() - } - } -} diff --git a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt b/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt deleted file mode 100644 index 92ae3eaf5..000000000 --- a/aes/src/jsMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -@OptIn(ExperimentalJsExport::class) -@JsExport -actual enum class KAESPadding : NativeTypeInterface { - NO_PADDING, - PKCS5PADDING, - PKCS7PADDING; - - override fun nativeValue(): KAESPaddingNativeType { - return when (this) { - NO_PADDING -> "" - PKCS5PADDING -> "" - PKCS7PADDING -> "" - } - } -} diff --git a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt b/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt deleted file mode 100644 index 476d6408d..000000000 --- a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/AES.kt +++ /dev/null @@ -1,65 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.KMMSymmetricKey -import java.security.spec.AlgorithmParameterSpec -import javax.crypto.Cipher -import javax.crypto.KeyGenerator -import javax.crypto.spec.GCMParameterSpec -import javax.crypto.spec.IvParameterSpec - -actual typealias KAESAlgorithmNativeType = String -actual typealias KAESBlockModeNativeType = String -actual typealias KAESPaddingNativeType = String - -actual final class AES actual constructor( - actual val algorithm: KAESAlgorithm, - actual val blockMode: KAESBlockMode, - actual val padding: KAESPadding, - actual val key: KMMSymmetricKey, - actual val iv: ByteArray? -) : AESEncryptor, AESDecryptor { - - private val cipher: Cipher = Cipher.getInstance("${algorithm.nativeValue()}/${blockMode.nativeValue()}/${padding.nativeValue()}") - private val ivSpec: AlgorithmParameterSpec? = if (blockMode.needIV()) { - when (blockMode) { - KAESBlockMode.ECB -> IvParameterSpec(iv) - KAESBlockMode.CBC -> IvParameterSpec(iv) - KAESBlockMode.CFB -> IvParameterSpec(iv) - KAESBlockMode.CFB8 -> IvParameterSpec(iv) - KAESBlockMode.CTR -> IvParameterSpec(iv) - KAESBlockMode.GCM -> GCMParameterSpec(AUTH_TAG_SIZE, iv) - KAESBlockMode.OFB -> IvParameterSpec(iv) - KAESBlockMode.RC4 -> IvParameterSpec(iv) - } - } else { - null - } - - override suspend fun encrypt(data: ByteArray): ByteArray { - if (ivSpec == null) { - cipher.init(Cipher.ENCRYPT_MODE, key.nativeType) - } else { - cipher.init(Cipher.ENCRYPT_MODE, key.nativeType, ivSpec) - } - return cipher.doFinal(data) - } - - override suspend fun decrypt(data: ByteArray): ByteArray { - if (ivSpec == null) { - cipher.init(Cipher.DECRYPT_MODE, key.nativeType) - } else { - cipher.init(Cipher.DECRYPT_MODE, key.nativeType, ivSpec) - } - return cipher.doFinal(data) - } - - actual companion object : AESKeyGeneration { - private const val AUTH_TAG_SIZE = 128 - - override suspend fun createRandomAESKey(algorithm: KAESAlgorithm, blockMode: KAESBlockMode): KMMSymmetricKey { - val keygen = KeyGenerator.getInstance("AES") - keygen.init(algorithm.keySize()) - return KMMSymmetricKey(keygen.generateKey()) - } - } -} diff --git a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt b/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt deleted file mode 100644 index f68fa3ef6..000000000 --- a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESAlgorithm.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESAlgorithm : NativeTypeInterface { - AES_128, - AES_192, - AES_256; - - override fun nativeValue() = "AES" -} diff --git a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt b/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt deleted file mode 100644 index 471df724e..000000000 --- a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESBlockMode.kt +++ /dev/null @@ -1,27 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESBlockMode : NativeTypeInterface { - ECB, - CBC, - CFB, - CFB8, - CTR, - GCM, - OFB, - RC4; - - override fun nativeValue(): KAESBlockModeNativeType { - return when (this) { - ECB -> "ECB" - CBC -> "CBC" - CFB -> "CFB" - CFB8 -> "CFB8" - CTR -> "CTR" - GCM -> "GCM" - OFB -> "OFB" - RC4 -> throw Exception("Not implemented in JVM") - } - } -} diff --git a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt b/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt deleted file mode 100644 index 9c7ee7237..000000000 --- a/aes/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/aes/KAESPadding.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.iohk.atala.prism.apollo.aes - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual enum class KAESPadding : NativeTypeInterface { - NO_PADDING, - PKCS5PADDING, - PKCS7PADDING; - - override fun nativeValue(): KAESPaddingNativeType { - return when (this) { - NO_PADDING -> "NoPadding" - PKCS5PADDING -> "PKCS5Padding" - PKCS7PADDING -> "PKCS5Padding" - } - } -} diff --git a/aes/webpack.config.d/polyfill.js b/aes/webpack.config.d/polyfill.js deleted file mode 100644 index 26262794b..000000000 --- a/aes/webpack.config.d/polyfill.js +++ /dev/null @@ -1,6 +0,0 @@ -config.resolve = { - fallback: { - crypto: require.resolve('crypto-browserify'), - stream: require.resolve("stream-browserify") - } -}; diff --git a/apollo/build.gradle.kts b/apollo/build.gradle.kts index ca8136edf..3093adcc3 100644 --- a/apollo/build.gradle.kts +++ b/apollo/build.gradle.kts @@ -1,3 +1,4 @@ +import dev.petuska.npm.publish.extension.domain.NpmAccess import org.gradle.internal.os.OperatingSystem import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target @@ -7,8 +8,10 @@ val os: OperatingSystem = OperatingSystem.current() plugins { kotlin("multiplatform") + id("io.github.luca992.multiplatform-swiftpackage") version "2.0.5-arm64" id("com.android.library") id("org.jetbrains.dokka") + id("dev.petuska.npm.publish") version "3.4.1" } kotlin { @@ -25,11 +28,43 @@ kotlin { useJUnitPlatform() } } + if (os.isMacOsX) { - ios() - iosSimulatorArm64() - macosArm64() + ios { + binaries.framework { + export(project(":cryptography")) + export(project(":multibase")) + export(project(":base64")) + export(project(":base58")) + export(project(":base32")) + export(project(":utils")) + export(project(":hashing")) + } + } + iosSimulatorArm64() { + binaries.framework { + export(project(":cryptography")) + export(project(":multibase")) + export(project(":base64")) + export(project(":base58")) + export(project(":base32")) + export(project(":utils")) + export(project(":hashing")) + } + } + macosArm64() { + binaries.framework { + export(project(":cryptography")) + export(project(":multibase")) + export(project(":base64")) + export(project(":base58")) + export(project(":base32")) + export(project(":utils")) + export(project(":hashing")) + } + } } + js(IR) { this.moduleName = currentModuleName this.binaries.library() @@ -66,9 +101,24 @@ kotlin { } } + multiplatformSwiftPackage { + packageName("Apollo") + swiftToolsVersion("5.3") + targetPlatforms { + iOS { v("13") } + macOS { v("11") } + } + outputDirectory(File(rootDir, "base-asymmetric-encryption/build/packages/ApolloSwift")) + } + sourceSets { val commonMain by getting { dependencies { + api(project(":cryptography")) + api(project(":multibase")) + api(project(":base64")) + api(project(":base58")) + api(project(":base32")) api(project(":utils")) api(project(":hashing")) implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") @@ -93,19 +143,18 @@ kotlin { } val jsMain by getting val jsTest by getting - if (os.isMacOsX) { - val iosMain by getting - val iosTest by getting - val iosSimulatorArm64Main by getting { - this.dependsOn(iosMain) - } - val iosSimulatorArm64Test by getting { - this.dependsOn(iosTest) - } - val macosArm64Main by getting - val macosArm64Test by getting + val iosMain by getting + val iosTest by getting + + val iosSimulatorArm64Main by getting { + this.dependsOn(iosMain) + } + val iosSimulatorArm64Test by getting { + this.dependsOn(iosTest) } + val macosArm64Main by getting + val macosArm64Test by getting } if (os.isMacOsX) { @@ -156,3 +205,33 @@ tasks.withType { } } } + +npmPublish { + organization.set("input-output-hk") + version.set(project.version.toString()) + access.set(NpmAccess.PUBLIC) + packages { + access.set(NpmAccess.PUBLIC) + named("js") { + scope.set("input-output-hk") + packageName.set("apollo") + packageJson { + author { + name.set("IOG") + } + repository { + type.set("git") + url.set("https://github.com/input-output-hk/atala-prism-apollo.git") + } + } + } + } + registries { + access.set(NpmAccess.PUBLIC) + github { + uri.set("https://npm.pkg.github.com/") + access.set(NpmAccess.PUBLIC) + this.authToken.set(System.getenv("ATALA_GITHUB_TOKEN")) + } + } +} diff --git a/base-symmetric-encryption/build.gradle.kts b/base-symmetric-encryption/build.gradle.kts deleted file mode 100644 index 8644853da..000000000 --- a/base-symmetric-encryption/build.gradle.kts +++ /dev/null @@ -1,194 +0,0 @@ -import org.gradle.internal.os.OperatingSystem -import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target - -val currentModuleName = "ApolloBaseSymmetricEncryption" -val os: OperatingSystem = OperatingSystem.current() - -plugins { - kotlin("multiplatform") - id("com.android.library") - id("org.jetbrains.dokka") -} - -kotlin { - android { - publishAllLibraryVariants() - } - jvm { - compilations.all { - kotlinOptions { - jvmTarget = "11" - } - } - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } - } - if (os.isMacOsX) { - ios() -// tvos() -// watchos() - iosSimulatorArm64() -// tvosSimulatorArm64() -// watchosSimulatorArm64() - macosArm64() - } -// if (os.isWindows) { -// // mingwX86() // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// mingwX64() -// } - js(IR) { - this.moduleName = currentModuleName - this.binaries.library() - this.useCommonJs() - generateTypeScriptDefinitions() - this.compilations["main"].packageJson { - this.version = rootProject.version.toString() - } - this.compilations["test"].packageJson { - this.version = rootProject.version.toString() - } - browser { - this.webpackTask { - this.output.library = currentModuleName - this.output.libraryTarget = Target.VAR - } - this.commonWebpackConfig { - } - this.testTask { - if (os.isWindows) { - this.enabled = false - } - this.useKarma { - this.useChromeHeadless() - } - } - } - nodejs { - this.testTask { - if (os.isWindows) { - this.enabled = false - } - this.useKarma { - this.useChromeHeadless() - } - } - } - } - - sourceSets { - val commonMain by getting { - dependencies { - implementation(project(":secure-random")) - implementation(project(":base64")) - } - } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - val jvmMain by getting - val jvmTest by getting - val androidMain by getting - val androidTest by getting { - dependencies { - implementation("junit:junit:4.13.2") - } - } - val jsMain by getting { - dependencies { - implementation("org.jetbrains.kotlin-wrappers:kotlin-web:1.0.0-pre.461") - implementation("org.jetbrains.kotlin-wrappers:kotlin-node:18.11.13-pre.461") - } - } - val jsTest by getting - if (os.isMacOsX) { - val iosMain by getting - val iosTest by getting -// val tvosMain by getting -// val tvosTest by getting -// val watchosMain by getting -// val watchosTest by getting - val iosSimulatorArm64Main by getting { - this.dependsOn(iosMain) - } - val iosSimulatorArm64Test by getting { - this.dependsOn(iosTest) - } -// val tvosSimulatorArm64Main by getting { -// this.dependsOn(tvosMain) -// } -// val tvosSimulatorArm64Test by getting { -// this.dependsOn(tvosTest) -// } -// val watchosSimulatorArm64Main by getting { -// this.dependsOn(watchosMain) -// } -// val watchosSimulatorArm64Test by getting { -// this.dependsOn(watchosTest) -// } - val macosArm64Main by getting { - this.dependsOn(iosMain) - } - val macosArm64Test by getting { - this.dependsOn(iosTest) - } - } -// if (os.isWindows) { -// // val mingwX86Main by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// // val mingwX86Test by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// val mingwX64Main by getting -// val mingwX64Test by getting -// } - } - - if (os.isMacOsX) { - tasks.getByName("iosX64Test") { - device.set("iPhone 14 Plus") - } - tasks.getByName("iosSimulatorArm64Test") { - device.set("iPhone 14 Plus") - } - } -} - -android { - compileSdk = 32 - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = 21 - targetSdk = 32 - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - /** - * Because Software Components will not be created automatically for Maven publishing from - * Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android. - * disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new - * publishing DSL. - */ - publishing { - multipleVariants { - withSourcesJar() - withJavadocJar() - allVariants() - } - } -} - -// Dokka implementation -tasks.withType { - moduleName.set(project.name) - moduleVersion.set(rootProject.version.toString()) - description = "This is a Kotlin Multiplatform Library for Base Symmetric Encryption" - dokkaSourceSets { - // TODO: Figure out how to include files to the documentations - named("commonMain") { - includes.from("Module.md", "docs/Module.md") - } - } -} diff --git a/base-symmetric-encryption/src/androidMain/AndroidManifest.xml b/base-symmetric-encryption/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 1ddfad099..000000000 --- a/base-symmetric-encryption/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt b/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt deleted file mode 100644 index b8a637ba7..000000000 --- a/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadDecodedBytes -import io.iohk.atala.prism.apollo.base64.base64PadEncoded -import javax.crypto.SecretKey -import javax.crypto.spec.SecretKeySpec - -actual open class KMMSymmetricKey(val nativeType: SecretKey) : SymmetricKeyBase64Export { - override fun exportToBase64(): String { - return nativeType.encoded.base64PadEncoded - } - - actual companion object : SymmetricKeyBase64Import, IVBase64Import, IVBase64Export, IVGeneration { - override fun createKeyFromBase64(base64Encoded: String, algorithm: SymmetricKeyType): KMMSymmetricKey { - val decodedKey = base64Encoded.base64PadDecodedBytes - val originalKey: SecretKey = SecretKeySpec(decodedKey, 0, decodedKey.size, algorithm.value) - return KMMSymmetricKey(originalKey) - } - } -} diff --git a/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt b/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt deleted file mode 100644 index 9edaf17a9..000000000 --- a/base-symmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -actual enum class SymmetricKeyType(val value: String) { - AES("AES"); -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Export.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Export.kt deleted file mode 100644 index b917c91d3..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Export.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadEncoded - -interface IVBase64Export { - /** - * Export IV to Base64 standard with padding - * - * @param iv iv value to convert to Base64 standard with padding - */ - fun exportToBase64(iv: ByteArray): String { - return iv.base64PadEncoded - } -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Import.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Import.kt deleted file mode 100644 index ed237bec9..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVBase64Import.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadDecodedBytes - -interface IVBase64Import { - /** - * Create an IV from Base64 standard with padding - * - * @param base64Encoded Base64 standard with padding value to convert to IV - */ - fun createIVFromBase64(base64Encoded: String): ByteArray { - return base64Encoded.base64PadDecodedBytes - } -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVGeneration.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVGeneration.kt deleted file mode 100644 index 04ac31aee..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/IVGeneration.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.securerandom.SecureRandom - -interface IVGeneration { - /** - * Generate random data with specified size - * - * @param size the size of the random generated data - */ - fun createRandomIV(size: Int): ByteArray = SecureRandom().nextBytes(size) -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt deleted file mode 100644 index 730dd2d33..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -expect open class KMMSymmetricKey : SymmetricKeyBase64Export { - companion object : SymmetricKeyBase64Import, IVBase64Import, IVBase64Export, IVGeneration -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Export.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Export.kt deleted file mode 100644 index 998529672..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Export.kt +++ /dev/null @@ -1,8 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -public interface SymmetricKeyBase64Export { - /** - * export [KMMSymmetricKey] to Base64 standard with padding - */ - fun exportToBase64(): String -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Import.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Import.kt deleted file mode 100644 index a7a38964d..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyBase64Import.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -public interface SymmetricKeyBase64Import { - /** - * Create an instance of [KMMSymmetricKey] from a Base64 standard with padding encoded key - * - * @param base64Encoded a Base64 standard with padding encoded key value - * @param algorithm algorithm type supported - */ - fun createKeyFromBase64(base64Encoded: String, algorithm: SymmetricKeyType): KMMSymmetricKey -} diff --git a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt b/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt deleted file mode 100644 index bf30bff06..000000000 --- a/base-symmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -expect enum class SymmetricKeyType { - AES -} diff --git a/base-symmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKeyTests.kt b/base-symmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKeyTests.kt deleted file mode 100644 index edc19840b..000000000 --- a/base-symmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKeyTests.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import kotlin.test.Test -import kotlin.test.assertEquals - -class KMMSymmetricKeyTests { - @Test - fun test() { - assertEquals(1, 1) - } -} diff --git a/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt b/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt deleted file mode 100644 index 800149c9e..000000000 --- a/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadDecodedBytes -import io.iohk.atala.prism.apollo.base64.base64PadEncoded -import platform.Foundation.NSData - -actual open class KMMSymmetricKey(val nativeValue: NSData) : SymmetricKeyBase64Export { - override fun exportToBase64(): String { - return nativeValue.toByteArray().base64PadEncoded - } - - actual companion object : SymmetricKeyBase64Import, IVBase64Import, IVBase64Export, IVGeneration { - override fun createKeyFromBase64(base64Encoded: String, algorithm: SymmetricKeyType): KMMSymmetricKey { - return KMMSymmetricKey(base64Encoded.base64PadDecodedBytes.toNSData()) - } - } -} diff --git a/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt b/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt deleted file mode 100644 index ff0e79f15..000000000 --- a/base-symmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -actual enum class SymmetricKeyType { - AES -} diff --git a/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt b/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt deleted file mode 100644 index 588581a91..000000000 --- a/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadDecodedBytes -import io.iohk.atala.prism.apollo.base64.base64PadEncoded - -@OptIn(ExperimentalJsExport::class) -@JsExport -actual open class KMMSymmetricKey(val nativeValue: ByteArray) : SymmetricKeyBase64Export { - override fun exportToBase64(): String { - return nativeValue.base64PadEncoded - } - - actual companion object : SymmetricKeyBase64Import, IVBase64Import, IVBase64Export, IVGeneration { - override fun createKeyFromBase64(base64Encoded: String, algorithm: SymmetricKeyType): KMMSymmetricKey { - return KMMSymmetricKey(base64Encoded.base64PadDecodedBytes) - } - } -} diff --git a/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt b/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt deleted file mode 100644 index 88bf48f70..000000000 --- a/base-symmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -@OptIn(ExperimentalJsExport::class) -@JsExport -actual enum class SymmetricKeyType { - AES; -} diff --git a/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt b/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt deleted file mode 100644 index b8a637ba7..000000000 --- a/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMSymmetricKey.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -import io.iohk.atala.prism.apollo.base64.base64PadDecodedBytes -import io.iohk.atala.prism.apollo.base64.base64PadEncoded -import javax.crypto.SecretKey -import javax.crypto.spec.SecretKeySpec - -actual open class KMMSymmetricKey(val nativeType: SecretKey) : SymmetricKeyBase64Export { - override fun exportToBase64(): String { - return nativeType.encoded.base64PadEncoded - } - - actual companion object : SymmetricKeyBase64Import, IVBase64Import, IVBase64Export, IVGeneration { - override fun createKeyFromBase64(base64Encoded: String, algorithm: SymmetricKeyType): KMMSymmetricKey { - val decodedKey = base64Encoded.base64PadDecodedBytes - val originalKey: SecretKey = SecretKeySpec(decodedKey, 0, decodedKey.size, algorithm.value) - return KMMSymmetricKey(originalKey) - } - } -} diff --git a/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt b/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt deleted file mode 100644 index 9edaf17a9..000000000 --- a/base-symmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/SymmetricKeyType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.iohk.atala.prism.apollo.utils - -actual enum class SymmetricKeyType(val value: String) { - AES("AES"); -} diff --git a/build.gradle.kts b/build.gradle.kts index bcce562a9..0ea94035b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,11 +34,10 @@ dependencies { kover(project(":base64")) kover(project(":multibase")) kover(project(":utils")) - kover(project(":base-symmetric-encryption")) + kover(project(":cryptography")) kover(project(":secure-random")) // kover(project(":aes")) - kover(project(":base-asymmetric-encryption")) -// kover(project(":rsa")) + // kover(project(":rsa")) // kover(project(":ecdsa")) kover(project(":varint")) // kover(project(":jose")) diff --git a/base-asymmetric-encryption/build.gradle.kts b/cryptography/build.gradle.kts similarity index 87% rename from base-asymmetric-encryption/build.gradle.kts rename to cryptography/build.gradle.kts index a23967f46..284b59ae6 100644 --- a/base-asymmetric-encryption/build.gradle.kts +++ b/cryptography/build.gradle.kts @@ -1,17 +1,14 @@ -import dev.petuska.npm.publish.extension.domain.NpmAccess import org.gradle.internal.os.OperatingSystem import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target -val currentModuleName = "ApolloBaseAsymmetricEncryption" +val currentModuleName = "Cryptography" val os: OperatingSystem = OperatingSystem.current() plugins { kotlin("multiplatform") - id("io.github.luca992.multiplatform-swiftpackage") version "2.0.5-arm64" id("com.android.library") id("org.jetbrains.dokka") - id("dev.petuska.npm.publish") version "3.4.1" } kotlin { @@ -116,16 +113,6 @@ kotlin { } } - multiplatformSwiftPackage { - packageName("Apollo") - swiftToolsVersion("5.3") - targetPlatforms { - iOS { v("13") } - macOS { v("11") } - } - outputDirectory(File(rootDir, "base-asymmetric-encryption/build/packages/ApolloSwift")) - } - sourceSets { val commonMain by getting { dependencies { @@ -287,33 +274,3 @@ ktlint { exclude { projectDir.toURI().relativize(it.file.toURI()).path.contains("/external/") } } } - -npmPublish { - organization.set("input-output-hk") - version.set(project.version.toString()) - access.set(NpmAccess.PUBLIC) - packages { - access.set(NpmAccess.PUBLIC) - named("js") { - scope.set("input-output-hk") - packageName.set("apollo") - packageJson { - author { - name.set("IOG") - } - repository { - type.set("git") - url.set("https://github.com/input-output-hk/atala-prism-apollo.git") - } - } - } - } - registries { - access.set(NpmAccess.PUBLIC) - github { - uri.set("https://npm.pkg.github.com/") - access.set(NpmAccess.PUBLIC) - this.authToken.set(System.getenv("ATALA_GITHUB_TOKEN")) - } - } -} diff --git a/base-asymmetric-encryption/src/androidMain/AndroidManifest.xml b/cryptography/src/androidMain/AndroidManifest.xml similarity index 100% rename from base-asymmetric-encryption/src/androidMain/AndroidManifest.xml rename to cryptography/src/androidMain/AndroidManifest.xml diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt diff --git a/base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt b/cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt rename to cryptography/src/androidMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationAxis.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationAxis.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationAxis.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationAxis.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationPath.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationPath.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationPath.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/DerivationPath.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyOptions.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyOptions.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyOptions.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyOptions.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCodeEnglish.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCodeEnglish.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCodeEnglish.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCodeEnglish.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicException.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicException.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicException.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicException.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicHelper.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicHelper.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicHelper.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicHelper.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECConfig.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECConfig.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECConfig.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECConfig.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECKeyExceptions.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECKeyExceptions.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECKeyExceptions.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/ECKeyExceptions.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Ed25519KeyPairGeneration.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Ed25519KeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Ed25519KeyPairGeneration.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Ed25519KeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Encodable.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Encodable.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Encodable.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/Encodable.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPoint.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPoint.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPoint.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPoint.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PrivateKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PrivateKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PrivateKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PublicKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PublicKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1PublicKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEllipticCurve.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEllipticCurve.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEllipticCurve.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEllipticCurve.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/X25519KeyPairGeneration.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/X25519KeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/X25519KeyPairGeneration.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/X25519KeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/MnemonicException.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/MnemonicException.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/MnemonicException.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/MnemonicException.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeCzech.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeCzech.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeCzech.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeCzech.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeEnglish.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeEnglish.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeEnglish.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeEnglish.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeFrench.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeFrench.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeFrench.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeFrench.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeItalian.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeItalian.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeItalian.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeItalian.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeJapanese.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeJapanese.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeJapanese.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeJapanese.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeKorean.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeKorean.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeKorean.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeKorean.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSimplifiedChinese.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSimplifiedChinese.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSimplifiedChinese.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSimplifiedChinese.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSpanish.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSpanish.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSpanish.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeSpanish.kt diff --git a/base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeTraditionalChinese.kt b/cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeTraditionalChinese.kt similarity index 100% rename from base-asymmetric-encryption/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeTraditionalChinese.kt rename to cryptography/src/commonMain/kotlin/io/iohk/atala/prism/apollo/utils/bip39/wordlists/MnemonicCodeTraditionalChinese.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/derivation/HDKeyTest.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1KeysTests.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1KeysTests.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1KeysTests.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMECSecp256k1KeysTests.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTestsIgnored.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTestsIgnored.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTestsIgnored.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTestsIgnored.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPairTests.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPairTests.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPairTests.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPairTests.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/MnemonicTests.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/MnemonicTests.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/MnemonicTests.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/MnemonicTests.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTests.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTests.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTests.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1LibTests.kt diff --git a/base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1TestVectors.kt b/cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1TestVectors.kt similarity index 100% rename from base-asymmetric-encryption/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1TestVectors.kt rename to cryptography/src/commonTest/kotlin/io/iohk/atala/prism/apollo/utils/Secp256k1TestVectors.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDH.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDH.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDH.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDH.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDSA.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDSA.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDSA.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/ECDSA.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Hex.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Hex.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Hex.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Hex.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Schnorr.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Schnorr.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Schnorr.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Schnorr.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Exception.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Exception.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Exception.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Exception.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt diff --git a/base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt b/cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt rename to cryptography/src/iosMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/iosTest/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Tests.kt b/cryptography/src/iosTest/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Tests.kt similarity index 100% rename from base-asymmetric-encryption/src/iosTest/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Tests.kt rename to cryptography/src/iosTest/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Tests.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/Curve25519Parser.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/Curve25519Parser.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/Curve25519Parser.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/Curve25519Parser.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/JsHashType.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/JsHashType.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/JsHashType.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/JsHashType.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPointJS.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPointJS.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPointJS.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMECPointJS.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP32.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP32.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP32.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP32.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP39.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP39.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP39.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BIP39.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BNjs.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BNjs.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BNjs.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/BNjs.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Curve.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Curve.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Curve.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Curve.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Ellipticjs.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Ellipticjs.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Ellipticjs.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Ellipticjs.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/PresetCurve.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/PresetCurve.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/PresetCurve.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/PresetCurve.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Stabelib.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Stabelib.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Stabelib.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/Stabelib.kt diff --git a/base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/secp256k1/secp256k1js.kt b/cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/secp256k1/secp256k1js.kt similarity index 100% rename from base-asymmetric-encryption/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/secp256k1/secp256k1js.kt rename to cryptography/src/jsMain/kotlin/io/iohk/atala/prism/apollo/utils/external/secp256k1/secp256k1js.kt diff --git a/base-asymmetric-encryption/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTests.kt b/cryptography/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTests.kt similarity index 100% rename from base-asymmetric-encryption/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTests.kt rename to cryptography/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPairTests.kt diff --git a/base-asymmetric-encryption/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519Tests.kt b/cryptography/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519Tests.kt similarity index 100% rename from base-asymmetric-encryption/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519Tests.kt rename to cryptography/src/jsTest/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519Tests.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/Mnemonic.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/derivation/MnemonicCode.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/secp256k1/Secp256k1Lib.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdKeyPair.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPrivateKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMEdPublicKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAKeyPair.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPrivateKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMRSAPublicKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519KeyPair.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PrivateKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/KMMX25519PublicKey.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAAsymmetricAlgorithm.kt diff --git a/base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt b/cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt similarity index 100% rename from base-asymmetric-encryption/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt rename to cryptography/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/utils/RSAKeyPairGeneration.kt diff --git a/base-asymmetric-encryption/src/nativeInterop/cinterop/IOHKCryptoKit.def b/cryptography/src/nativeInterop/cinterop/IOHKCryptoKit.def similarity index 100% rename from base-asymmetric-encryption/src/nativeInterop/cinterop/IOHKCryptoKit.def rename to cryptography/src/nativeInterop/cinterop/IOHKCryptoKit.def diff --git a/base-asymmetric-encryption/src/nativeInterop/cinterop/IOHKSecureRandomGeneration.def b/cryptography/src/nativeInterop/cinterop/IOHKSecureRandomGeneration.def similarity index 100% rename from base-asymmetric-encryption/src/nativeInterop/cinterop/IOHKSecureRandomGeneration.def rename to cryptography/src/nativeInterop/cinterop/IOHKSecureRandomGeneration.def diff --git a/base-asymmetric-encryption/src/nativeInterop/cinterop/SwiftCryptoKit.def b/cryptography/src/nativeInterop/cinterop/SwiftCryptoKit.def similarity index 100% rename from base-asymmetric-encryption/src/nativeInterop/cinterop/SwiftCryptoKit.def rename to cryptography/src/nativeInterop/cinterop/SwiftCryptoKit.def diff --git a/base-asymmetric-encryption/webpack.config.d/polyfill.js b/cryptography/webpack.config.d/polyfill.js similarity index 100% rename from base-asymmetric-encryption/webpack.config.d/polyfill.js rename to cryptography/webpack.config.d/polyfill.js diff --git a/ecdsa/build.gradle.kts b/ecdsa/build.gradle.kts deleted file mode 100644 index 7c438150f..000000000 --- a/ecdsa/build.gradle.kts +++ /dev/null @@ -1,275 +0,0 @@ -import org.gradle.internal.os.OperatingSystem -import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target - -val currentModuleName = "ApolloECDSA" -val os: OperatingSystem = OperatingSystem.current() - -plugins { - kotlin("multiplatform") - kotlin("native.cocoapods") - id("com.android.library") - id("org.jetbrains.dokka") -} - -kotlin { - android { - publishAllLibraryVariants() - } - jvm { - compilations.all { - kotlinOptions { - jvmTarget = "11" - } - } - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } - } - if (os.isMacOsX) { - ios() -// tvos() -// watchos() -// macosX64() -// if (System.getProperty("os.arch") != "x86_64") { // M1Chip -// iosSimulatorArm64() -// tvosSimulatorArm64() -// watchosSimulatorArm64() -// macosArm64() -// } - } -// if (os.isWindows) { -// // mingwX86() // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// mingwX64() -// } - js(IR) { - this.moduleName = currentModuleName - this.binaries.library() - this.useCommonJs() - this.compilations["main"].packageJson { - this.version = rootProject.version.toString() - } - this.compilations["test"].packageJson { - this.version = rootProject.version.toString() - } - browser { - this.webpackTask { - this.output.library = currentModuleName - this.output.libraryTarget = Target.VAR - } - this.commonWebpackConfig { - this.cssSupport { - this.enabled = true - } - } - this.testTask { - if (os.isWindows) { - this.enabled = false - } - this.useKarma { - this.useChromeHeadless() - } - } - } - nodejs { - this.testTask { - if (os.isWindows) { - this.enabled = false - } - this.useKarma { - this.useChromeHeadless() - } - } - } - } - - if (os.isMacOsX) { - cocoapods { - this.summary = "ApolloECDSA is ECDSA" - this.version = rootProject.version.toString() - this.authors = "IOG" - this.ios.deploymentTarget = "13.0" - this.osx.deploymentTarget = "12.0" - this.tvos.deploymentTarget = "13.0" - this.watchos.deploymentTarget = "8.0" - framework { - this.baseName = currentModuleName - } - - pod("IOHKRSA") { - version = "1.0.0" - packageName = "IOHKRSA1" - source = path(project.file("../iOSLibs/IOHKRSA")) - } - - pod("IOHKSecureRandomGeneration") { - version = "1.0.0" - packageName = "IOHKSecureRandomGeneration2" - source = path(project.file("../iOSLibs/IOHKSecureRandomGeneration")) - } - } - } - - sourceSets { - val commonMain by getting { - dependencies { - implementation(project(":utils")) - implementation(project(":base-asymmetric-encryption")) - implementation(project(":hashing")) - } - } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - val jvmMain by getting { - dependencies { - implementation("org.bouncycastle:bcprov-jdk15on:1.68") - } - } - val jvmTest by getting - val androidMain by getting { - dependencies { - implementation("org.bouncycastle:bcprov-jdk15on:1.68") - } - } - val androidTest by getting { - dependencies { - implementation("junit:junit:4.13.2") - } - } - val jsMain by getting { - dependencies { - implementation(npm("elliptic", "6.5.4")) - implementation(npm("@types/elliptic", "6.4.14")) - - // Polyfill dependencies - implementation(npm("stream-browserify", "3.0.0")) - implementation(npm("buffer", "6.0.3")) - - implementation("org.jetbrains.kotlin-wrappers:kotlin-web:1.0.0-pre.461") - implementation("org.jetbrains.kotlin-wrappers:kotlin-node:18.11.13-pre.461") - } - } - val jsTest by getting - if (os.isMacOsX) { - val iosMain by getting - val iosTest by getting -// val tvosMain by getting -// val tvosTest by getting -// val watchosMain by getting -// val watchosTest by getting -// val macosX64Main by getting -// val macosX64Test by getting -// if (System.getProperty("os.arch") != "x86_64") { // M1Chip -// val iosSimulatorArm64Main by getting { -// this.dependsOn(iosMain) -// } -// val iosSimulatorArm64Test by getting { -// this.dependsOn(iosTest) -// } -// val tvosSimulatorArm64Main by getting { -// this.dependsOn(tvosMain) -// } -// val tvosSimulatorArm64Test by getting { -// this.dependsOn(tvosTest) -// } -// val watchosSimulatorArm64Main by getting { -// this.dependsOn(watchosMain) -// } -// val watchosSimulatorArm64Test by getting { -// this.dependsOn(watchosTest) -// } -// val macosArm64Main by getting { -// this.dependsOn(macosX64Main) -// } -// val macosArm64Test by getting { -// this.dependsOn(macosX64Test) -// } -// } - } -// if (os.isWindows) { -// // val mingwX86Main by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// // val mingwX86Test by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// val mingwX64Main by getting -// val mingwX64Test by getting -// } - } -} - -android { - compileSdk = 32 - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = 21 - targetSdk = 32 - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - /** - * Because Software Components will not be created automatically for Maven publishing from - * Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android. - * disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new - * publishing DSL. - */ - publishing { - multipleVariants { - withSourcesJar() - withJavadocJar() - allVariants() - } - } -} - -// Dokka implementation -tasks.withType { - moduleName.set(project.name) - moduleVersion.set(rootProject.version.toString()) - description = """ - This is a Kotlin Multiplatform Library for ECDSA - """.trimIndent() - dokkaSourceSets { - // TODO: Figure out how to include files to the documentations - named("commonMain") { - includes.from("Module.md", "docs/Module.md") - } - } -} - -// afterEvaluate { -// tasks.withType { -// testLogging { -// events("passed", "skipped", "failed", "standard_out", "standard_error") -// showExceptions = true -// showStackTraces = true -// } -// } -// } - -// TODO(Investigate why the below tasks fails) -tasks.matching { - fun String.isOneOf(values: List): Boolean { - for (value in values) { - if (this == value) { - return true - } - } - return false - } - - it.name.isOneOf( - listOf( - "linkPodReleaseFrameworkIosFat", - ":linkPodReleaseFrameworkIosFat", - ":base-asymmetric-encryption:linkPodReleaseFrameworkIosFat", - "linkPodDebugFrameworkIosFat", - ":linkPodDebugFrameworkIosFat", - ":base-asymmetric-encryption:linkPodDebugFrameworkIosFat" - ) - ) -}.all { - this.enabled = false -} diff --git a/ecdsa/ecdsa.podspec b/ecdsa/ecdsa.podspec deleted file mode 100644 index 663c8fdc7..000000000 --- a/ecdsa/ecdsa.podspec +++ /dev/null @@ -1,43 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'ecdsa' - spec.version = '1.7.0-alpha' - spec.homepage = '' - spec.source = { :http=> ''} - spec.authors = 'IOG' - spec.license = '' - spec.summary = 'ApolloECDSA is ECDSA' - spec.vendored_frameworks = 'build/cocoapods/framework/ApolloECDSA.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '13.0' - spec.osx.deployment_target = '12.0' - spec.tvos.deployment_target = '13.0' - spec.watchos.deployment_target = '8.0' - spec.dependency 'IOHKRSA', '1.0.0' - spec.dependency 'IOHKSecureRandomGeneration', '1.0.0' - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':ecdsa', - 'PRODUCT_MODULE_NAME' => 'ApolloECDSA', - } - - spec.script_phases = [ - { - :name => 'Build ecdsa', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/ecdsa/src/androidMain/AndroidManifest.xml b/ecdsa/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 3ee55cfd8..000000000 --- a/ecdsa/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/ecdsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt b/ecdsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt deleted file mode 100644 index 8fa645d39..000000000 --- a/ecdsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt +++ /dev/null @@ -1,43 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -import io.iohk.atala.prism.apollo.utils.KMMECPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMECPublicKey -import org.bouncycastle.jce.provider.BouncyCastleProvider -import java.security.Signature - -actual object KMMECDSA { - private val provider = BouncyCastleProvider() - - actual fun sign( - type: ECDSAType, - data: ByteArray, - privateKey: KMMECPrivateKey - ): ByteArray { - val signatureAlgorithm = when (type) { - ECDSAType.ECDSA_SHA256 -> "SHA256withECDSA" - ECDSAType.ECDSA_SHA384 -> "SHA384withECDSA" - ECDSAType.ECDSA_SHA512 -> "SHA512withECDSA" - } - val signer = Signature.getInstance(signatureAlgorithm, provider) - signer.initSign(privateKey.nativeValue) - signer.update(data) - return signer.sign() - } - - actual fun verify( - type: ECDSAType, - data: ByteArray, - publicKey: KMMECPublicKey, - signature: ByteArray - ): Boolean { - val signatureAlgorithm = when (type) { - ECDSAType.ECDSA_SHA256 -> "SHA256withECDSA" - ECDSAType.ECDSA_SHA384 -> "SHA384withECDSA" - ECDSAType.ECDSA_SHA512 -> "SHA512withECDSA" - } - val verifier = Signature.getInstance(signatureAlgorithm, provider) - verifier.initVerify(publicKey.nativeValue) - verifier.update(data) - return verifier.verify(signature) - } -} diff --git a/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/ECDSAType.kt b/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/ECDSAType.kt deleted file mode 100644 index 95139ad2b..000000000 --- a/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/ECDSAType.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -enum class ECDSAType { - ECDSA_SHA256, - ECDSA_SHA384, - ECDSA_SHA512 -} diff --git a/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt b/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt deleted file mode 100644 index dfd349d29..000000000 --- a/ecdsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt +++ /dev/null @@ -1,6 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -expect object KMMECDSA { - fun sign(type: ECDSAType, data: ByteArray, privateKey: KMMECPrivateKey): ByteArray - fun verify(type: ECDSAType, data: ByteArray, publicKey: KMMECPublicKey, signature: ByteArray): Boolean -} diff --git a/ecdsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSATests.kt b/ecdsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSATests.kt deleted file mode 100644 index 13d81d896..000000000 --- a/ecdsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSATests.kt +++ /dev/null @@ -1,141 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -import io.iohk.atala.prism.apollo.utils.KMMECSecp256k1KeyPair -import io.iohk.atala.prism.apollo.utils.KMMECSecp256k1PrivateKey -import io.iohk.atala.prism.apollo.utils.decodeHex -import kotlin.test.Ignore -import kotlin.test.Test -import kotlin.test.assertFalse -import kotlin.test.assertTrue - -class KMMECDSATests { - - @Test - fun testECDSA() { - val textToSign = "Hello IOG!" - val keyPair = KMMECSecp256k1KeyPair.generateSecp256k1KeyPair() - - val signature = KMMECDSA.sign( - ECDSAType.ECDSA_SHA256, - textToSign.encodeToByteArray(), - keyPair.privateKey - ) - - assertTrue( - KMMECDSA.verify( - ECDSAType.ECDSA_SHA256, - textToSign.encodeToByteArray(), - keyPair.publicKey, - signature - ) - ) - } - - @Test - fun testSignAndVerifyText() { - val keyPair = KMMECSecp256k1KeyPair.generateSecp256k1KeyPair() - val text = "The quick brown fox jumps over the lazy dog" - - val signature = KMMECDSA.sign( - type = ECDSAType.ECDSA_SHA256, - privateKey = keyPair.privateKey, - data = text.encodeToByteArray() - ) - - assertTrue( - KMMECDSA.verify( - type = ECDSAType.ECDSA_SHA256, - data = text.encodeToByteArray(), - publicKey = keyPair.publicKey, - signature = signature - ) - ) - } - - @Test - fun testSignAndVerifyData() { - val testData = byteArrayOf(-107, 101, 68, 118, 27, 74, 29, 50, -32, 72, 47, -127, -49, 3, -8, -55, -63, -66, 46, 125) - val keyPair = KMMECSecp256k1KeyPair.generateSecp256k1KeyPair() - - val signature = KMMECDSA.sign( - type = ECDSAType.ECDSA_SHA256, - privateKey = keyPair.privateKey, - data = testData - ) - - assertTrue( - KMMECDSA.verify( - type = ECDSAType.ECDSA_SHA256, - data = testData, - publicKey = keyPair.publicKey, - signature = signature - ) - ) - } - - @Test - fun testNotVerifyWrongInput() { - val type = ECDSAType.ECDSA_SHA256 - val keyPair = KMMECSecp256k1KeyPair.generateSecp256k1KeyPair() - val wrongKeyPair = KMMECSecp256k1KeyPair.generateSecp256k1KeyPair() - - val text = "The quick brown fox jumps over the lazy dog" - val wrongText = "Wrong text" - - val signature = KMMECDSA.sign( - type = type, - privateKey = keyPair.privateKey, - data = text.encodeToByteArray() - ) - val wrongSignature = KMMECDSA.sign( - type = type, - privateKey = keyPair.privateKey, - data = wrongText.encodeToByteArray() - ) - - assertFalse( - KMMECDSA.verify( - type = type, - data = wrongText.encodeToByteArray(), - publicKey = keyPair.publicKey, - signature = signature - ) - ) - assertFalse( - KMMECDSA.verify( - type = type, - data = text.encodeToByteArray(), - publicKey = wrongKeyPair.publicKey, - signature = signature - ) - ) - assertFalse( - KMMECDSA.verify( - type = type, - data = text.encodeToByteArray(), - publicKey = keyPair.publicKey, - signature = wrongSignature - ) - ) - } - - @Test - @Ignore // Not working for JS - fun testVerifySameSignatureInAllImplementations() { - val testData = byteArrayOf(-107, 101, 68, 118, 27, 74, 29, 50, -32, 72, 47, -127, -49, 3, -8, -55, -63, -66, 46, 125) - val hexEncodedPrivateKey = "0123fbf1050c3fc060b709fdcf240e766a41190c40afc5ac7a702961df8313c0" - val hexEncodedSignature = - "30450221008a78c557dfc18275b5c800281ef8d26d2b40572b9c1442d708c610f50f797bd302207e44e340f787df7ab1299dabfc988e4c02fcaca0f68dbe813050f4b8641fa739" - val privateKey = KMMECSecp256k1PrivateKey.secp256k1FromBytes(hexEncodedPrivateKey.decodeHex()) - val signature = hexEncodedSignature.decodeHex() - - assertTrue( - KMMECDSA.verify( - type = ECDSAType.ECDSA_SHA256, - data = testData, - publicKey = privateKey.getPublicKey(), - signature = signature - ) - ) - } -} diff --git a/ecdsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt b/ecdsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt deleted file mode 100644 index ddb1bd336..000000000 --- a/ecdsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt +++ /dev/null @@ -1,115 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -/* ktlint-disable */ -import io.iohk.atala.prism.apollo.hashing.SHA256 -import io.iohk.atala.prism.apollo.hashing.SHA384 -import io.iohk.atala.prism.apollo.hashing.SHA512 -import io.iohk.atala.prism.apollo.secp256k1.Secp256k1Exception -import io.iohk.atala.prism.apollo.utils.KMMECPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMECPublicKey -import io.iohk.atala.prism.apollo.utils.toHex -import kotlinx.cinterop.UByteVar -import kotlinx.cinterop.addressOf -import kotlinx.cinterop.alloc -import kotlinx.cinterop.allocArray -import kotlinx.cinterop.convert -import kotlinx.cinterop.memScoped -import kotlinx.cinterop.pin -import kotlinx.cinterop.ptr -import kotlinx.cinterop.readBytes -import secp256k1.* -/* ktlint-disable */ - -actual object KMMECDSA { - @OptIn(ExperimentalUnsignedTypes::class) - actual fun sign( - type: ECDSAType, - data: ByteArray, - privateKey: KMMECPrivateKey - ): ByteArray { - val hashedData = when (type) { - ECDSAType.ECDSA_SHA256 -> SHA256().digest(data) - ECDSAType.ECDSA_SHA384 -> SHA384().digest(data) - ECDSAType.ECDSA_SHA512 -> SHA512().digest(data) - } - memScoped { - // Context - val context = secp256k1_context_create((SECP256K1_CONTEXT_SIGN or SECP256K1_CONTEXT_VERIFY).convert()) - - val privateKeyPinned = privateKey.nativeValue.pin() - val nPrivateKey = privateKeyPinned.addressOf(0) - - val messagePinned = hashedData.toUByteArray().pin() - val nMessage = messagePinned.addressOf(0) - - val nSig = alloc() - if (secp256k1_ecdsa_sign(context, nSig.ptr, nMessage, nPrivateKey, null, null) != 1) { - throw Secp256k1Exception("secp256k1_ecdsa_sign() failed") - } - val natOutput = allocArray(64) - - if(secp256k1_ecdsa_signature_serialize_compact(context, natOutput, nSig.ptr) != 1) { - throw Secp256k1Exception("secp256k1_ecdsa_signature_serialize_compact() failed") - } - - this.defer { - secp256k1_context_destroy(context) - privateKeyPinned.unpin() - messagePinned.unpin() - } - return natOutput.readBytes(64) - } - } - - @OptIn(ExperimentalUnsignedTypes::class) - actual fun verify( - type: ECDSAType, - data: ByteArray, - publicKey: KMMECPublicKey, - signature: ByteArray - ): Boolean { - val hashedData = when (type) { - ECDSAType.ECDSA_SHA256 -> SHA256().digest(data) - ECDSAType.ECDSA_SHA384 -> SHA384().digest(data) - ECDSAType.ECDSA_SHA512 -> SHA512().digest(data) - } - memScoped { - // Context - val context = secp256k1_context_create((SECP256K1_CONTEXT_SIGN or SECP256K1_CONTEXT_VERIFY).convert()) - - // Public Key Alloc - val publicKeyPinned = publicKey.getEncoded().asUByteArray().pin() - val natPub = publicKeyPinned.addressOf(0) - val nPublicKey = alloc() - - if (secp256k1_ec_pubkey_parse(context, nPublicKey.ptr, natPub, publicKey.nativeValue.size.convert()) != 1) { - throw Secp256k1Exception("secp256k1_ec_pubkey_parse() failed") - } - - // Message - val messagePinned = hashedData.toUByteArray().pin() - val nMessage = messagePinned.addressOf(0) - - // Signature - val sig = alloc() - val sigPinned = signature.toUByteArray().pin() - val nativeBytes = sigPinned.addressOf(0) - val result = when { - signature.size == 64 -> secp256k1_ecdsa_signature_parse_compact(context, sig.ptr, nativeBytes) - signature.size < 64 -> throw Secp256k1Exception("Unknown signature format") - else -> secp256k1_ecdsa_signature_parse_der(context, sig.ptr, nativeBytes, signature.size.convert()) - } - if (result != 1) { - throw Secp256k1Exception("cannot parse signature (size = ${signature.size} sig = ${signature.toHex()}") - } - - this.defer { - secp256k1_context_destroy(context) - publicKeyPinned.unpin() - messagePinned.unpin() - sigPinned.unpin() - } - return secp256k1_ecdsa_verify(context, sig.ptr, nMessage, nPublicKey.ptr) == 1 - } - } -} diff --git a/ecdsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt b/ecdsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt deleted file mode 100644 index 0928f4cfe..000000000 --- a/ecdsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt +++ /dev/null @@ -1,47 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -import io.iohk.atala.prism.apollo.hashing.internal.toHexString -import io.iohk.atala.prism.apollo.utils.ECConfig -import io.iohk.atala.prism.apollo.utils.KMMECPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMECPublicKey -import io.iohk.atala.prism.apollo.utils.decodeHex -import io.iohk.atala.prism.apollo.utils.external.ec - -actual object KMMECDSA { - actual fun sign( - type: ECDSAType, - data: ByteArray, - privateKey: KMMECPrivateKey - ): ByteArray { - when (type) { - ECDSAType.ECDSA_SHA256 -> {} - ECDSAType.ECDSA_SHA384, ECDSAType.ECDSA_SHA512 -> { - throw NotImplementedError("Only ECDSA with SHA256 is supported") - } - } - val byteList = privateKey.nativeValue.toArray().map { it.toByte() } - val padding = ByteArray(ECConfig.PRIVATE_KEY_BYTE_SIZE - byteList.size) { 0 } - val privateKeyBytes = (padding + byteList).toHexString() - - val ecjs = ec("secp256k1") - val signature = ecjs.sign(data.toHexString(), privateKeyBytes, enc = "hex") - val value = signature.toDER(enc = "hex").unsafeCast() - return value.decodeHex() - } - - actual fun verify( - type: ECDSAType, - data: ByteArray, - publicKey: KMMECPublicKey, - signature: ByteArray - ): Boolean { - when (type) { - ECDSAType.ECDSA_SHA256 -> {} - ECDSAType.ECDSA_SHA384, ECDSAType.ECDSA_SHA512 -> { - throw NotImplementedError("Only ECDSA with SHA256 is supported") - } - } - val ecjs = ec("secp256k1") - return ecjs.verify(data.toHexString(), signature.toHexString(), publicKey.getEncoded().toHexString(), enc = "hex") - } -} diff --git a/ecdsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt b/ecdsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt deleted file mode 100644 index 8fa645d39..000000000 --- a/ecdsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/ecdsa/KMMECDSA.kt +++ /dev/null @@ -1,43 +0,0 @@ -package io.iohk.atala.prism.apollo.ecdsa - -import io.iohk.atala.prism.apollo.utils.KMMECPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMECPublicKey -import org.bouncycastle.jce.provider.BouncyCastleProvider -import java.security.Signature - -actual object KMMECDSA { - private val provider = BouncyCastleProvider() - - actual fun sign( - type: ECDSAType, - data: ByteArray, - privateKey: KMMECPrivateKey - ): ByteArray { - val signatureAlgorithm = when (type) { - ECDSAType.ECDSA_SHA256 -> "SHA256withECDSA" - ECDSAType.ECDSA_SHA384 -> "SHA384withECDSA" - ECDSAType.ECDSA_SHA512 -> "SHA512withECDSA" - } - val signer = Signature.getInstance(signatureAlgorithm, provider) - signer.initSign(privateKey.nativeValue) - signer.update(data) - return signer.sign() - } - - actual fun verify( - type: ECDSAType, - data: ByteArray, - publicKey: KMMECPublicKey, - signature: ByteArray - ): Boolean { - val signatureAlgorithm = when (type) { - ECDSAType.ECDSA_SHA256 -> "SHA256withECDSA" - ECDSAType.ECDSA_SHA384 -> "SHA384withECDSA" - ECDSAType.ECDSA_SHA512 -> "SHA512withECDSA" - } - val verifier = Signature.getInstance(signatureAlgorithm, provider) - verifier.initVerify(publicKey.nativeValue) - verifier.update(data) - return verifier.verify(signature) - } -} diff --git a/jose/build.gradle.kts b/jose/build.gradle.kts deleted file mode 100644 index ac7d0a97e..000000000 --- a/jose/build.gradle.kts +++ /dev/null @@ -1,219 +0,0 @@ -import org.gradle.internal.os.OperatingSystem -import org.jetbrains.dokka.gradle.DokkaTask - -val currentModuleName = "JOSE" -val os: OperatingSystem = OperatingSystem.current() - -plugins { - kotlin("multiplatform") - kotlin("native.cocoapods") - id("com.android.library") - id("org.jetbrains.dokka") -} - -kotlin { - android { - publishAllLibraryVariants() - } - jvm { - compilations.all { - kotlinOptions { - jvmTarget = "11" - } - } - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } - } - if (os.isMacOsX) { - // ios() -// tvos() -// watchos() -// macosX64() -// if (System.getProperty("os.arch") != "x86_64") { // M1Chip -// iosSimulatorArm64() -// tvosSimulatorArm64() -// watchosSimulatorArm64() -// macosArm64() -// } - } -// if (os.isWindows) { -// // mingwX86() // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// mingwX64() -// } -// js(IR) { -// this.moduleName = currentModuleName -// this.binaries.library() -// this.useCommonJs() -// this.compilations["main"].packageJson { -// this.version = rootProject.version.toString() -// } -// this.compilations["test"].packageJson { -// this.version = rootProject.version.toString() -// } -// browser { -// this.webpackTask { -// this.output.library = currentModuleName -// this.output.libraryTarget = Target.VAR -// } -// this.commonWebpackConfig { -// this.cssSupport { -// this.enabled = true -// } -// } -// this.testTask { -// if (os.isWindows) { -// this.enabled = false -// } -// this.useKarma { -// this.useChromeHeadless() -// } -// } -// } -// nodejs { -// this.testTask { -// if (os.isWindows) { -// this.enabled = false -// } -// this.useKarma { -// this.useChromeHeadless() -// } -// } -// } -// } - - if (os.isMacOsX) { - cocoapods { - this.summary = "JOSE is JSON Object Signing and Encryption" - this.version = rootProject.version.toString() - this.authors = "IOG" - this.ios.deploymentTarget = "13.0" - this.osx.deploymentTarget = "12.0" - this.tvos.deploymentTarget = "13.0" - this.watchos.deploymentTarget = "8.0" - framework { - this.baseName = currentModuleName - } - } - } - - sourceSets { - val commonMain by getting - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - val jvmMain by getting { - dependencies { - implementation("com.nimbusds:nimbus-jose-jwt:9.31") - } - } - val jvmTest by getting - val androidMain by getting { - dependencies { - implementation("com.nimbusds:nimbus-jose-jwt:9.31") - } - } - val androidTest by getting { - dependencies { - implementation("junit:junit:4.13.2") - } - } -// val jsMain by getting -// val jsTest by getting - if (os.isMacOsX) { -// val iosMain by getting -// val iosTest by getting -// val tvosMain by getting -// val tvosTest by getting -// val watchosMain by getting -// val watchosTest by getting -// val macosX64Main by getting -// val macosX64Test by getting - if (System.getProperty("os.arch") != "x86_64") { // M1Chip -// val iosSimulatorArm64Main by getting { -// this.dependsOn(iosMain) -// } -// val iosSimulatorArm64Test by getting { -// this.dependsOn(iosTest) -// } -// val tvosSimulatorArm64Main by getting { -// this.dependsOn(tvosMain) -// } -// val tvosSimulatorArm64Test by getting { -// this.dependsOn(tvosTest) -// } -// val watchosSimulatorArm64Main by getting { -// this.dependsOn(watchosMain) -// } -// val watchosSimulatorArm64Test by getting { -// this.dependsOn(watchosTest) -// } -// val macosArm64Main by getting { -// this.dependsOn(macosX64Main) -// } -// val macosArm64Test by getting { -// this.dependsOn(macosX64Test) -// } - } - } -// if (os.isWindows) { -// // val mingwX86Main by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// // val mingwX86Test by getting // it depend on kotlinx-datetime lib to support this platform before we can support it as well -// val mingwX64Main by getting -// val mingwX64Test by getting -// } - } -} - -android { - compileSdk = 32 - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = 21 - targetSdk = 32 - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - /** - * Because Software Components will not be created automatically for Maven publishing from - * Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android. - * disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new - * publishing DSL. - */ - publishing { - multipleVariants { - withSourcesJar() - withJavadocJar() - allVariants() - } - } -} - -// Dokka implementation -tasks.withType { - moduleName.set(project.name) - moduleVersion.set(rootProject.version.toString()) - description = """ - This is a Kotlin Multiplatform Library for JOSE - JSON Object Signing and Encryption - """.trimIndent() - dokkaSourceSets { - // TODO: Figure out how to include files to the documentations - named("commonMain") { - includes.from("Module.md", "docs/Module.md") - } - } -} - -// afterEvaluate { -// tasks.withType { -// testLogging { -// events("passed", "skipped", "failed", "standard_out", "standard_error") -// showExceptions = true -// showStackTraces = true -// } -// } -// } diff --git a/jose/jose.podspec b/jose/jose.podspec deleted file mode 100644 index 02a6fa529..000000000 --- a/jose/jose.podspec +++ /dev/null @@ -1,42 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'jose' - spec.version = '1.7.0-alpha' - spec.homepage = '' - spec.source = { :http=> ''} - spec.authors = 'IOG' - spec.license = '' - spec.summary = 'JOSE is JSON Object Signing and Encryption' - spec.vendored_frameworks = 'build/cocoapods/framework/jose.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '13.0' - spec.osx.deployment_target = '12.0' - spec.tvos.deployment_target = '13.0' - spec.watchos.deployment_target = '8.0' - - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':jose', - 'PRODUCT_MODULE_NAME' => 'jose', - } - - spec.script_phases = [ - { - :name => 'Build jose', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/jose/src/androidMain/AndroidManifest.xml b/jose/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 09bb0c772..000000000 --- a/jose/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/jose/src/androidMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt b/jose/src/androidMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt deleted file mode 100644 index ac7648732..000000000 --- a/jose/src/androidMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt +++ /dev/null @@ -1,199 +0,0 @@ -package io.iohk.atala.prism.apollo.jose - -import com.nimbusds.jose.JOSEException -import com.nimbusds.jose.JOSEObjectType -import com.nimbusds.jose.JWSAlgorithm -import com.nimbusds.jose.JWSHeader -import com.nimbusds.jose.JWSObject -import com.nimbusds.jose.JWSObjectJSON -import com.nimbusds.jose.Payload -import com.nimbusds.jose.UnprotectedHeader -import com.nimbusds.jose.crypto.ECDSASigner -import com.nimbusds.jose.crypto.ECDSAVerifier -import com.nimbusds.jose.crypto.Ed25519Signer -import com.nimbusds.jose.crypto.Ed25519Verifier -import com.nimbusds.jose.jwk.Curve -import com.nimbusds.jose.jwk.ECKey -import com.nimbusds.jose.jwk.JWK -import com.nimbusds.jose.jwk.OctetKeyPair -import com.nimbusds.jose.util.Base64URL -import com.nimbusds.jwt.JWTClaimsSet -import com.nimbusds.jwt.SignedJWT -import java.security.SignatureException - -sealed interface Key { - val id: String - val jwk: JWK - val curve: Curve -} - -enum class Typ(val typ: String) { - Encrypted("application/didcomm-encrypted+json"), - Signed("application/didcomm-signed+json"), - Plaintext("application/didcomm-plain+json"); - - companion object { - fun parse(str: String): Typ = when (str) { - "application/didcomm-encrypted+json" -> Encrypted - "application/didcomm-signed+json" -> Signed - "application/didcomm-plain+json" -> Plaintext - else -> throw IllegalArgumentException("Unsupported message typ") - } - } -} - -enum class SignAlg { - /** - * Elliptic curve digital signature with edwards curves Ed25519 and SHA-512 - */ - ED25519, - - /** - * Elliptic curve digital signature with NIST p-256 curve and SHA-256 - */ - ES256, - - /** - * Elliptic curve digital signature with Secp256k1 keys - */ - ES256K -} - -inline fun JWK.asKey(): Key { - if (this !is Key) throw IllegalArgumentException("Can not cast JWK to ${Key::class.java.name}") - return this -} - -object JWS { - fun sign(payload: String, key: Key): String { - val jwk = key.jwk - val alg = getJWSAlgorithm(jwk) - - val signer = try { - when (alg) { - JWSAlgorithm.ES256 -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.ES256K -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.EdDSA -> Ed25519Signer(jwk.asKey()) - else -> throw NotImplementedError(alg.name) - } - } catch (e: JOSEException) { - throw NotImplementedError(alg.name) - } - - val jwsProtectedHeader = JWSHeader.Builder(alg) - .type(JOSEObjectType(Typ.Signed.typ)) - .build() - - val jwsUnprotectedHeader = UnprotectedHeader.Builder().keyID(key.id).build() - return JWSObjectJSON(Payload(Base64URL.encode(payload))) - .apply { - try { - sign(jwsProtectedHeader, jwsUnprotectedHeader, signer) - } catch (e: JOSEException) { - // this can be thrown if the signature type is not supported - // example: curve256k1 is not supported in JDK >= 15 - if (e.cause is SignatureException) { - throw NotImplementedError("Unsupported signature algorithm ${e.cause}") - } - throw NotImplementedError("JWS cannot be signed $e") - } - } - .serializeGeneral() - } - - fun verify(signature: JWSObjectJSON.Signature, signAlg: SignAlg, key: Key) { - val jwk = key.jwk - - val verifier = try { - when (signAlg) { - SignAlg.ES256 -> ECDSAVerifier(jwk.asKey()) - SignAlg.ES256K -> ECDSAVerifier(jwk.asKey()) - SignAlg.ED25519 -> Ed25519Verifier(jwk.asKey()) - } - } catch (e: JOSEException) { - throw NotImplementedError(signAlg.name) - } - - try { - if (!signature.verify(verifier)) { - throw NotImplementedError("Invalid signature") - } - } catch (e: JOSEException) { - // this can be thrown if the signature type is not supported - // example: curve256k1 is not supported in JDK >= 15 - if (e.cause is SignatureException) { - throw NotImplementedError("Unsupported signature algorithm ${e.cause}") - } - throw NotImplementedError("JWS signature cannot be verified $e") - } - } -} - -object JWT { - fun sign(jwtClaimsSet: JWTClaimsSet, key: Key): String { - val jwk = key.jwk - val alg = getJWSAlgorithm(jwk) - - val signer = try { - when (alg) { - JWSAlgorithm.ES256 -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.ES256K -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.EdDSA -> Ed25519Signer(jwk.asKey()) - else -> throw NotImplementedError(alg.name) - } - } catch (e: JOSEException) { - throw NotImplementedError(alg.name) - } - - val jwsHeader = JWSHeader.Builder(alg) - .keyID(key.id) - .build() - - return SignedJWT(jwsHeader, jwtClaimsSet).apply { - try { - sign(signer) - } catch (e: JOSEException) { - throw NotImplementedError("JWT cannot be signed $e") - } - }.serialize() - } -} - -private fun getCryptoAlg(signature: JWSObjectJSON.Signature): SignAlg { - return when (val alg = signature.header.algorithm) { - JWSAlgorithm.ES256 -> SignAlg.ES256 - JWSAlgorithm.ES256K -> SignAlg.ES256K - JWSAlgorithm.EdDSA -> SignAlg.ED25519 - else -> throw NotImplementedError("UnsupportedCurveException ${alg.name}") - } -} - -private fun getJWSAlgorithm(jwk: JWK): JWSAlgorithm { - return when (jwk) { - is ECKey -> { - when (jwk.curve) { - Curve.P_256 -> JWSAlgorithm.ES256 - Curve.SECP256K1 -> JWSAlgorithm.ES256K - else -> { - throw NotImplementedError("UnsupportedCurveException ${jwk.curve}") - } - } - } - is OctetKeyPair -> { - when (jwk.curve) { - Curve.Ed25519 -> JWSAlgorithm.EdDSA - else -> throw NotImplementedError("UnsupportedCurveException ${jwk.curve.name}") - } - } - else -> throw NotImplementedError("UnsupportedCurveException ${jwk.javaClass.name}") - } -} - -private fun getCryptoAlg(jws: JWSObject): SignAlg { - return when (val alg = jws.header.algorithm) { - JWSAlgorithm.ES256 -> SignAlg.ES256 - JWSAlgorithm.ES256K -> SignAlg.ES256K - JWSAlgorithm.EdDSA -> SignAlg.ED25519 - else -> throw NotImplementedError(alg.name) - } -} diff --git a/jose/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt b/jose/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt deleted file mode 100644 index ac7648732..000000000 --- a/jose/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/jose/JOSE.kt +++ /dev/null @@ -1,199 +0,0 @@ -package io.iohk.atala.prism.apollo.jose - -import com.nimbusds.jose.JOSEException -import com.nimbusds.jose.JOSEObjectType -import com.nimbusds.jose.JWSAlgorithm -import com.nimbusds.jose.JWSHeader -import com.nimbusds.jose.JWSObject -import com.nimbusds.jose.JWSObjectJSON -import com.nimbusds.jose.Payload -import com.nimbusds.jose.UnprotectedHeader -import com.nimbusds.jose.crypto.ECDSASigner -import com.nimbusds.jose.crypto.ECDSAVerifier -import com.nimbusds.jose.crypto.Ed25519Signer -import com.nimbusds.jose.crypto.Ed25519Verifier -import com.nimbusds.jose.jwk.Curve -import com.nimbusds.jose.jwk.ECKey -import com.nimbusds.jose.jwk.JWK -import com.nimbusds.jose.jwk.OctetKeyPair -import com.nimbusds.jose.util.Base64URL -import com.nimbusds.jwt.JWTClaimsSet -import com.nimbusds.jwt.SignedJWT -import java.security.SignatureException - -sealed interface Key { - val id: String - val jwk: JWK - val curve: Curve -} - -enum class Typ(val typ: String) { - Encrypted("application/didcomm-encrypted+json"), - Signed("application/didcomm-signed+json"), - Plaintext("application/didcomm-plain+json"); - - companion object { - fun parse(str: String): Typ = when (str) { - "application/didcomm-encrypted+json" -> Encrypted - "application/didcomm-signed+json" -> Signed - "application/didcomm-plain+json" -> Plaintext - else -> throw IllegalArgumentException("Unsupported message typ") - } - } -} - -enum class SignAlg { - /** - * Elliptic curve digital signature with edwards curves Ed25519 and SHA-512 - */ - ED25519, - - /** - * Elliptic curve digital signature with NIST p-256 curve and SHA-256 - */ - ES256, - - /** - * Elliptic curve digital signature with Secp256k1 keys - */ - ES256K -} - -inline fun JWK.asKey(): Key { - if (this !is Key) throw IllegalArgumentException("Can not cast JWK to ${Key::class.java.name}") - return this -} - -object JWS { - fun sign(payload: String, key: Key): String { - val jwk = key.jwk - val alg = getJWSAlgorithm(jwk) - - val signer = try { - when (alg) { - JWSAlgorithm.ES256 -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.ES256K -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.EdDSA -> Ed25519Signer(jwk.asKey()) - else -> throw NotImplementedError(alg.name) - } - } catch (e: JOSEException) { - throw NotImplementedError(alg.name) - } - - val jwsProtectedHeader = JWSHeader.Builder(alg) - .type(JOSEObjectType(Typ.Signed.typ)) - .build() - - val jwsUnprotectedHeader = UnprotectedHeader.Builder().keyID(key.id).build() - return JWSObjectJSON(Payload(Base64URL.encode(payload))) - .apply { - try { - sign(jwsProtectedHeader, jwsUnprotectedHeader, signer) - } catch (e: JOSEException) { - // this can be thrown if the signature type is not supported - // example: curve256k1 is not supported in JDK >= 15 - if (e.cause is SignatureException) { - throw NotImplementedError("Unsupported signature algorithm ${e.cause}") - } - throw NotImplementedError("JWS cannot be signed $e") - } - } - .serializeGeneral() - } - - fun verify(signature: JWSObjectJSON.Signature, signAlg: SignAlg, key: Key) { - val jwk = key.jwk - - val verifier = try { - when (signAlg) { - SignAlg.ES256 -> ECDSAVerifier(jwk.asKey()) - SignAlg.ES256K -> ECDSAVerifier(jwk.asKey()) - SignAlg.ED25519 -> Ed25519Verifier(jwk.asKey()) - } - } catch (e: JOSEException) { - throw NotImplementedError(signAlg.name) - } - - try { - if (!signature.verify(verifier)) { - throw NotImplementedError("Invalid signature") - } - } catch (e: JOSEException) { - // this can be thrown if the signature type is not supported - // example: curve256k1 is not supported in JDK >= 15 - if (e.cause is SignatureException) { - throw NotImplementedError("Unsupported signature algorithm ${e.cause}") - } - throw NotImplementedError("JWS signature cannot be verified $e") - } - } -} - -object JWT { - fun sign(jwtClaimsSet: JWTClaimsSet, key: Key): String { - val jwk = key.jwk - val alg = getJWSAlgorithm(jwk) - - val signer = try { - when (alg) { - JWSAlgorithm.ES256 -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.ES256K -> ECDSASigner(jwk.asKey()) - JWSAlgorithm.EdDSA -> Ed25519Signer(jwk.asKey()) - else -> throw NotImplementedError(alg.name) - } - } catch (e: JOSEException) { - throw NotImplementedError(alg.name) - } - - val jwsHeader = JWSHeader.Builder(alg) - .keyID(key.id) - .build() - - return SignedJWT(jwsHeader, jwtClaimsSet).apply { - try { - sign(signer) - } catch (e: JOSEException) { - throw NotImplementedError("JWT cannot be signed $e") - } - }.serialize() - } -} - -private fun getCryptoAlg(signature: JWSObjectJSON.Signature): SignAlg { - return when (val alg = signature.header.algorithm) { - JWSAlgorithm.ES256 -> SignAlg.ES256 - JWSAlgorithm.ES256K -> SignAlg.ES256K - JWSAlgorithm.EdDSA -> SignAlg.ED25519 - else -> throw NotImplementedError("UnsupportedCurveException ${alg.name}") - } -} - -private fun getJWSAlgorithm(jwk: JWK): JWSAlgorithm { - return when (jwk) { - is ECKey -> { - when (jwk.curve) { - Curve.P_256 -> JWSAlgorithm.ES256 - Curve.SECP256K1 -> JWSAlgorithm.ES256K - else -> { - throw NotImplementedError("UnsupportedCurveException ${jwk.curve}") - } - } - } - is OctetKeyPair -> { - when (jwk.curve) { - Curve.Ed25519 -> JWSAlgorithm.EdDSA - else -> throw NotImplementedError("UnsupportedCurveException ${jwk.curve.name}") - } - } - else -> throw NotImplementedError("UnsupportedCurveException ${jwk.javaClass.name}") - } -} - -private fun getCryptoAlg(jws: JWSObject): SignAlg { - return when (val alg = jws.header.algorithm) { - JWSAlgorithm.ES256 -> SignAlg.ES256 - JWSAlgorithm.ES256K -> SignAlg.ES256K - JWSAlgorithm.EdDSA -> SignAlg.ED25519 - else -> throw NotImplementedError(alg.name) - } -} diff --git a/rsa/README.md b/rsa/README.md deleted file mode 100644 index c77fce15f..000000000 --- a/rsa/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Apollo - AES - -[![Kotlin](https://img.shields.io/badge/kotlin-1.7.21-blue.svg?logo=kotlin)](http://kotlinlang.org) - -![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) -![apple-silicon](https://camo.githubusercontent.com/a92c841ffd377756a144d5723ff04ecec886953d40ac03baa738590514714921/687474703a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742d2535424170706c6553696c69636f6e2535442d3433424246462e7376673f7374796c653d666c6174) -![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174) -![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) -![js](https://camo.githubusercontent.com/3e0a143e39915184b54b60a2ecedec75e801f396d34b5b366c94ec3604f7e6bd/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a732d4638444235442e7376673f7374796c653d666c6174) -![getNode-js](https://camo.githubusercontent.com/d08fda729ceebcae0f23c83499ca8f06105350f037661ac9a4cc7f58edfdbca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6e6f64656a732d3638613036332e7376673f7374796c653d666c6174) -![macos](https://camo.githubusercontent.com/1b8313498db244646b38a4480186ae2b25464e5e8d71a1920c52b2be5212b909/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6d61636f732d3131313131312e7376673f7374796c653d666c6174) -![tvos](https://camo.githubusercontent.com/4ac08d7fb1bcb8ef26388cd2bf53b49626e1ab7cbda581162a946dd43e6a2726/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d74766f732d3830383038302e7376673f7374796c653d666c6174) -![watchos](https://camo.githubusercontent.com/135dbadae40f9cabe7a3a040f9380fb485cff36c90909f3c1ae36b81c304426b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d77617463686f732d4330433043302e7376673f7374796c653d666c6174) - -Apollo RSA is Kotlin Multiplatform library for RSA & RSA/PSS signature. - -## Supported Key Size - -- 1024 -- 2048 -- 3072 -- 4096 - -## Supported Signature - -- RSA -- RSA/PSS - -## Usage - -Example of key pair generation, signing and verifying RSA/PSS with SHA256 -```kotlin -val keyPair = KMMKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) -val rsa = RSA() -val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) -val verify = rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256) -``` - -## TODO - -* Make support for key size depend on the logic of multiable of 1024 instead of the current limited value selection diff --git a/rsa/rsa.podspec b/rsa/rsa.podspec deleted file mode 100644 index 804b15835..000000000 --- a/rsa/rsa.podspec +++ /dev/null @@ -1,42 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'rsa' - spec.version = '1.7.0-alpha' - spec.homepage = '' - spec.source = { :http=> ''} - spec.authors = 'IOG' - spec.license = '' - spec.summary = 'ApolloRSA is an RSA lib' - spec.vendored_frameworks = 'build/cocoapods/framework/ApolloRSA.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '13.0' - spec.osx.deployment_target = '12.0' - spec.tvos.deployment_target = '13.0' - spec.watchos.deployment_target = '8.0' - spec.dependency 'IOHKRSA', '1.0.0' - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':rsa', - 'PRODUCT_MODULE_NAME' => 'ApolloRSA', - } - - spec.script_phases = [ - { - :name => 'Build rsa', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/rsa/src/androidAndroidTest/AndroidManifest.xml b/rsa/src/androidAndroidTest/AndroidManifest.xml deleted file mode 100644 index 71a1eb3ee..000000000 --- a/rsa/src/androidAndroidTest/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/rsa/src/androidAndroidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/androidAndroidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index ce115cb04..000000000 --- a/rsa/src/androidAndroidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAKeyPair -import io.iohk.atala.prism.apollo.utils.RSAAsymmetricAlgorithm -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.Test -import kotlin.test.assertTrue - -@OptIn(ExperimentalCoroutinesApi::class) -actual class RSATests { - @Test - actual fun testRSA() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSA, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSASHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSASHA256)) - } - - @Test - actual fun testRSAPSS() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } -} diff --git a/rsa/src/androidMain/AndroidManifest.xml b/rsa/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 71a1eb3ee..000000000 --- a/rsa/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt b/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt deleted file mode 100644 index f17909c96..000000000 --- a/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMRSAPublicKey -import org.bouncycastle.jce.provider.BouncyCastleProvider -import java.security.Security -import java.security.Signature - -actual final class RSA : RSASigner, RSAVerifier { - - init { - Security.removeProvider("BC") - Security.addProvider(BouncyCastleProvider()) - } - - override suspend fun sign(privateKey: KMMRSAPrivateKey, data: ByteArray, type: RSASignatureType): ByteArray { - val signature = Signature.getInstance(type.nativeValue()) - signature.initSign(privateKey.nativeType) - signature.update(data) - return signature.sign() - } - - override suspend fun verify(publicKey: KMMRSAPublicKey, data: ByteArray, signedData: ByteArray, type: RSASignatureType): Boolean { - val signature = Signature.getInstance(type.nativeValue()) - signature.initVerify(publicKey.nativeType) - signature.update(data) - return signature.verify(signedData) - } -} diff --git a/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt b/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt deleted file mode 100644 index f0f01128c..000000000 --- a/rsa/src/androidMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual typealias RSASignatureTypeNativeType = String - -actual final enum class RSASignatureType : NativeTypeInterface { - RSASHA256, - RSASHA384, - RSASHA512, - RSAPSSSHA256, - RSAPSSSHA384, - RSAPSSSHA512; - - override fun nativeValue(): String { - return when (this) { - RSASHA256 -> "SHA256withRSA" - RSASHA384 -> "SHA384withRSA" - RSASHA512 -> "SHA512withRSA" - RSAPSSSHA256 -> "SHA256withRSA/PSS" - RSAPSSSHA384 -> "SHA384withRSA/PSS" - RSAPSSSHA512 -> "SHA512withRSA/PSS" - } - } -} diff --git a/rsa/src/androidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/androidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index ce115cb04..000000000 --- a/rsa/src/androidTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAKeyPair -import io.iohk.atala.prism.apollo.utils.RSAAsymmetricAlgorithm -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.Test -import kotlin.test.assertTrue - -@OptIn(ExperimentalCoroutinesApi::class) -actual class RSATests { - @Test - actual fun testRSA() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSA, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSASHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSASHA256)) - } - - @Test - actual fun testRSAPSS() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } -} diff --git a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt b/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt deleted file mode 100644 index 708cd98d6..000000000 --- a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -expect final class RSA : RSASigner, RSAVerifier diff --git a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt b/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt deleted file mode 100644 index 67f270bfb..000000000 --- a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -expect class RSASignatureTypeNativeType - -expect final enum class RSASignatureType : NativeTypeInterface { - RSASHA256, - RSASHA384, - RSASHA512, - RSAPSSSHA256, - RSAPSSSHA384, - RSAPSSSHA512; -} diff --git a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASigner.kt b/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASigner.kt deleted file mode 100644 index 9a12b53c3..000000000 --- a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASigner.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAPrivateKey - -interface RSASigner { - /** - * Returns the signature bytes of all the data updated. The format of the signature depends on the underlying - * signature scheme. - * - * @param privateKey private key in PKCS#8 pem format - * @param data the data to sign - * @return the signature bytes of the signing operation's result. - */ - suspend fun sign(privateKey: KMMRSAPrivateKey, data: ByteArray, type: RSASignatureType): ByteArray -} diff --git a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSAVerifier.kt b/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSAVerifier.kt deleted file mode 100644 index 363266a0d..000000000 --- a/rsa/src/commonMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSAVerifier.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAPublicKey - -interface RSAVerifier { - /** - * Verifies the passed-in signature. - * - * @param publicKey public key in PKCS#8 pem format - * @param data data that we need to sign - * @param signedData data that has already been signed - * @return boolean value representing if the verifying was correct or not - */ - suspend fun verify(publicKey: KMMRSAPublicKey, data: ByteArray, signedData: ByteArray, type: RSASignatureType): Boolean -} diff --git a/rsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index 83fecaa0b..000000000 --- a/rsa/src/commonTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,10 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestResult - -@OptIn(ExperimentalCoroutinesApi::class) -expect class RSATests { - fun testRSA(): TestResult - fun testRSAPSS(): TestResult -} diff --git a/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt b/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt deleted file mode 100644 index cca55373d..000000000 --- a/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import cocoapods.IOHKRSA.IOHKRSA -import io.iohk.atala.prism.apollo.utils.KMMRSAPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMRSAPublicKey -import io.iohk.atala.prism.apollo.utils.toByteArray -import io.iohk.atala.prism.apollo.utils.toNSData - -actual final class RSA : RSASigner, RSAVerifier { - override suspend fun sign(privateKey: KMMRSAPrivateKey, data: ByteArray, type: RSASignatureType): ByteArray { - return IOHKRSA.signRSAWithKey( - privateKey.nativeType, - type.nativeValue(), - data.toNSData() - )!!.toByteArray() - } - - override suspend fun verify(publicKey: KMMRSAPublicKey, data: ByteArray, signedData: ByteArray, type: RSASignatureType): Boolean { - return IOHKRSA.verifyRSAWithKey( - publicKey.nativeType, - type.nativeValue(), - data.toNSData(), - signedData.toNSData() - ) - } -} diff --git a/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt b/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt deleted file mode 100644 index b2652656f..000000000 --- a/rsa/src/iosMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt +++ /dev/null @@ -1,32 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import cocoapods.IOHKRSA.RSASignatureMessageType -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaPSSSHA256 -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaPSSSHA384 -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaPSSSHA512 -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaSHA256 -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaSHA384 -import cocoapods.IOHKRSA.RSASignatureMessageTypeRsaSHA512 -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual typealias RSASignatureTypeNativeType = Long - -actual final enum class RSASignatureType : NativeTypeInterface { - RSASHA256, - RSASHA384, - RSASHA512, - RSAPSSSHA256, - RSAPSSSHA384, - RSAPSSSHA512; - - override fun nativeValue(): RSASignatureMessageType { - return when (this) { - RSASHA256 -> RSASignatureMessageTypeRsaSHA256 - RSASHA384 -> RSASignatureMessageTypeRsaSHA384 - RSASHA512 -> RSASignatureMessageTypeRsaSHA512 - RSAPSSSHA256 -> RSASignatureMessageTypeRsaPSSSHA256 - RSAPSSSHA384 -> RSASignatureMessageTypeRsaPSSSHA384 - RSAPSSSHA512 -> RSASignatureMessageTypeRsaPSSSHA512 - } - } -} diff --git a/rsa/src/iosTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/iosTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index ecadb4656..000000000 --- a/rsa/src/iosTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAKeyPair -import io.iohk.atala.prism.apollo.utils.RSAAsymmetricAlgorithm -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertTrue - -@OptIn(ExperimentalCoroutinesApi::class) -actual class RSATests { - @Test - actual fun testRSA() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } - - @Test - actual fun testRSAPSS() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } -} diff --git a/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt b/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt deleted file mode 100644 index d2bff71cf..000000000 --- a/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt +++ /dev/null @@ -1,67 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMRSAPublicKey -import io.iohk.atala.prism.apollo.utils.toArrayBuffer -import io.iohk.atala.prism.apollo.utils.toByteArray -import kotlinx.coroutines.MainScope -import kotlinx.coroutines.await -import kotlinx.coroutines.promise -import web.crypto.RsaPssParams -import web.crypto.crypto - -actual final class RSA : RSASigner, RSAVerifier { - - private fun getRsaPssParams(): RsaPssParams { - val algorithm = "RSA-PSS" - return js("{name: algorithm, saltLength: 32}") as RsaPssParams - } - - override suspend fun sign(privateKey: KMMRSAPrivateKey, data: ByteArray, type: RSASignatureType): ByteArray { - return when (type) { - RSASignatureType.RSASHA256, RSASignatureType.RSASHA384, RSASignatureType.RSASHA512 -> { - MainScope().promise { - crypto.subtle.sign( - privateKey.nativeType.algorithm.name, - privateKey.nativeType, - data.toArrayBuffer() - ).await().toByteArray() - }.await() - } - RSASignatureType.RSAPSSSHA256, RSASignatureType.RSAPSSSHA384, RSASignatureType.RSAPSSSHA512 -> { - MainScope().promise { - crypto.subtle.sign( - getRsaPssParams(), - privateKey.nativeType, - data.toArrayBuffer() - ).await().toByteArray() - }.await() - } - } - } - - override suspend fun verify(publicKey: KMMRSAPublicKey, data: ByteArray, signedData: ByteArray, type: RSASignatureType): Boolean { - return when (type) { - RSASignatureType.RSASHA256, RSASignatureType.RSASHA384, RSASignatureType.RSASHA512 -> { - MainScope().promise { - crypto.subtle.verify( - publicKey.nativeType.algorithm.name, - publicKey.nativeType, - signedData.toArrayBuffer(), - data.toArrayBuffer() - ).await() - }.await() - } - RSASignatureType.RSAPSSSHA256, RSASignatureType.RSAPSSSHA384, RSASignatureType.RSAPSSSHA512 -> { - MainScope().promise { - crypto.subtle.verify( - getRsaPssParams(), - publicKey.nativeType, - signedData.toArrayBuffer(), - data.toArrayBuffer() - ).await() - }.await() - } - } - } -} diff --git a/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt b/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt deleted file mode 100644 index 95278d688..000000000 --- a/rsa/src/jsMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual typealias RSASignatureTypeNativeType = String - -actual final enum class RSASignatureType : NativeTypeInterface { - RSASHA256, - RSASHA384, - RSASHA512, - RSAPSSSHA256, - RSAPSSSHA384, - RSAPSSSHA512; - - override fun nativeValue(): RSASignatureTypeNativeType { - return when (this) { - RSASHA256 -> "RSA-PSS" - RSASHA384 -> "RSA-PSS" - RSASHA512 -> "RSA-PSS" - RSAPSSSHA256 -> "RSASSA-PKCS1-v1_5" - RSAPSSSHA384 -> "RSASSA-PKCS1-v1_5" - RSAPSSSHA512 -> "RSASSA-PKCS1-v1_5" - } - } -} diff --git a/rsa/src/jsTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/jsTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index 736631f19..000000000 --- a/rsa/src/jsTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,32 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.JsHashType -import io.iohk.atala.prism.apollo.utils.KMMRSAKeyPair -import io.iohk.atala.prism.apollo.utils.RSAAsymmetricAlgorithm -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertTrue - -@OptIn(ExperimentalCoroutinesApi::class) -actual class RSATests { - @Test - actual fun testRSA() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, JsHashType.SHA256, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } - - @Test - actual fun testRSAPSS() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, JsHashType.SHA256, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } -} diff --git a/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt b/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt deleted file mode 100644 index f17909c96..000000000 --- a/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSA.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAPrivateKey -import io.iohk.atala.prism.apollo.utils.KMMRSAPublicKey -import org.bouncycastle.jce.provider.BouncyCastleProvider -import java.security.Security -import java.security.Signature - -actual final class RSA : RSASigner, RSAVerifier { - - init { - Security.removeProvider("BC") - Security.addProvider(BouncyCastleProvider()) - } - - override suspend fun sign(privateKey: KMMRSAPrivateKey, data: ByteArray, type: RSASignatureType): ByteArray { - val signature = Signature.getInstance(type.nativeValue()) - signature.initSign(privateKey.nativeType) - signature.update(data) - return signature.sign() - } - - override suspend fun verify(publicKey: KMMRSAPublicKey, data: ByteArray, signedData: ByteArray, type: RSASignatureType): Boolean { - val signature = Signature.getInstance(type.nativeValue()) - signature.initVerify(publicKey.nativeType) - signature.update(data) - return signature.verify(signedData) - } -} diff --git a/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt b/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt deleted file mode 100644 index f0f01128c..000000000 --- a/rsa/src/jvmMain/kotlin/io/iohk/atala/prism/apollo/rsa/RSASignatureType.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.NativeTypeInterface - -actual typealias RSASignatureTypeNativeType = String - -actual final enum class RSASignatureType : NativeTypeInterface { - RSASHA256, - RSASHA384, - RSASHA512, - RSAPSSSHA256, - RSAPSSSHA384, - RSAPSSSHA512; - - override fun nativeValue(): String { - return when (this) { - RSASHA256 -> "SHA256withRSA" - RSASHA384 -> "SHA384withRSA" - RSASHA512 -> "SHA512withRSA" - RSAPSSSHA256 -> "SHA256withRSA/PSS" - RSAPSSSHA384 -> "SHA384withRSA/PSS" - RSAPSSSHA512 -> "SHA512withRSA/PSS" - } - } -} diff --git a/rsa/src/jvmTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt b/rsa/src/jvmTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt deleted file mode 100644 index 1c7ffa0e9..000000000 --- a/rsa/src/jvmTest/kotlin/io/iohk/atala/prism/apollo/rsa/RSATests.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.iohk.atala.prism.apollo.rsa - -import io.iohk.atala.prism.apollo.utils.KMMRSAKeyPair -import io.iohk.atala.prism.apollo.utils.RSAAsymmetricAlgorithm -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.Test -import kotlin.test.assertTrue - -@OptIn(ExperimentalCoroutinesApi::class) -actual class RSATests { - @Test - actual fun testRSA() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSA, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSASHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSASHA256)) - } - - @Test - actual fun testRSAPSS() = runTest { - val msgToSign = "Hello IOG!" - val keyPair = KMMRSAKeyPair.generateRSAKeyPair(RSAAsymmetricAlgorithm.RSAPSS, 2048) - val rsa = RSA() - val signature = rsa.sign(keyPair.privateKey, msgToSign.encodeToByteArray(), RSASignatureType.RSAPSSSHA256) - - assertTrue(rsa.verify(keyPair.publicKey, msgToSign.encodeToByteArray(), signature, RSASignatureType.RSAPSSSHA256)) - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index d33d8d0d2..7a40c78f2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,10 +29,10 @@ include(":base58") include(":base64") include(":multibase") include(":utils") -include(":base-symmetric-encryption") +include(":cryptography") include(":secure-random") // include(":aes") -include(":base-asymmetric-encryption") +include(":cryptography") include(":iOSLibs") // include(":rsa") // include(":ecdsa")